Modify ↓
Opened 17 years ago
Closed 16 years ago
#3138 closed defect (fixed)
Check db arguments given before checking contents
Reported by: | anonymous | Owned by: | John Hampton |
---|---|---|---|
Priority: | normal | Component: | SqliteToPgScript |
Severity: | minor | Keywords: | |
Cc: | Trac Release: | 0.10 |
Description
If you don't specify a postgres uri, then the program will fail with:
Traceback (most recent call last): File "./sqlite2pg", line 330, in ? opts = doArgs() File "./sqlite2pg", line 305, in doArgs if not options.pg_uri.startswith('postgres://'): AttributeError: 'NoneType' object has no attribute 'startswith'
The fix is to check for none before calling startswith. Patch is
Index: sqlite2pg =================================================================== --- sqlite2pg (revision 3795) +++ sqlite2pg (working copy) @@ -302,12 +302,12 @@ options.project = args[0] options.tracenv = os.path.join(options.tracbase, args[0]) - if not options.pg_uri.startswith('postgres://'): + if not options.pg_uri or not options.pg_uri.startswith('postgres://'): print ("You must specify a valid URI for the PostgreSQL database.") print (" eg. postgres://user:password@localhost/dbname") sys.exit(1) - if not options.sqlite_uri.startswith('sqlite:'): + if not options.sqlite_uri or not options.sqlite_uri.startswith('sqlite:'): print ("You must specify a valid URI for the SQLite database.") print (" eg. sqlite:db/trac.db") sys.exit(1)
Attachments (0)
Note: See
TracTickets for help on using
tickets.
(In [3826])