22
33import os , sys , re , datetime , argparse , traceback , tempfile
44
5+ # args
6+ parser = argparse .ArgumentParser (
7+ description = """Perform a test crawl of the project. For each found URL, the HTTP
8+ response status is printed. If it's not OK/redirect, FAIL is
9+ printed - in case of errors, a stacktrace is also included.""" )
10+ parser .add_argument ('urls' , metavar = 'URL' , nargs = '*' ,
11+ help = 'One or more URLs to start the crawl from' )
12+ parser .add_argument ('--urls' , '-u' , dest = 'url_file' ,
13+ help = 'file with URLs to start the crawl from' )
14+ parser .add_argument ('--slow' , dest = 'slow_threshold' , type = float , default = 1.0 ,
15+ help = 'responses taking longer than this (in seconds) results in SLOW being printed' )
16+ parser .add_argument ('--settings' , dest = 'settings' , help = 'custom settings file' )
17+
18+ args = parser .parse_args ()
19+
520# boilerplate
621basedir = os .path .abspath (os .path .join (os .path .dirname (__file__ ), "../" ))
722sys .path = [ basedir ] + sys .path
8- os .environ .setdefault ("DJANGO_SETTINGS_MODULE" , "ietf.settings" )
23+
24+ settings_module = args .settings or "ietf.settings"
25+
26+ os .environ .setdefault ("DJANGO_SETTINGS_MODULE" , settings_module )
927
1028import django .test
11- from django .conf import settings
1229
1330# prevent memory from leaking when settings.DEBUG=True
1431from django .db import connection
@@ -19,20 +36,6 @@ connection.queries = DontSaveQueries()
1936
2037MAX_URL_LENGTH = 500
2138
22- # args
23- parser = argparse .ArgumentParser (
24- description = """Perform a test crawl of the project. For each found URL, the HTTP
25- response status is printed. If it's not OK/redirect, FAIL is
26- printed - in case of errors, a stacktrace is also included.""" )
27- parser .add_argument ('urls' , metavar = 'URL' , nargs = '*' ,
28- help = 'One or more URLs to start the crawl from' )
29- parser .add_argument ('--urls' , '-u' , dest = 'url_file' ,
30- help = 'file with URLs to start the crawl from' )
31- parser .add_argument ('--slow' , dest = 'slow_threshold' , type = float , default = 1.0 ,
32- help = 'responses taking longer than this (in seconds) results in SLOW being printed' )
33-
34- args = parser .parse_args ()
35-
3639slow_threshold = args .slow_threshold
3740
3841initial_urls = []
0 commit comments