Opened 15 years ago

Closed 15 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


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")
-    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")

Attachments (0)

Change History (1)

comment:1 Changed 15 years ago by John Hampton

Resolution: fixed
Status: newclosed

(In [3826])

  • Accepted patch to create a main() function that is easily callable from other python modules. Thanks to alberto Closes #3148
  • Accepted patch to check for presence of arguments before checking value. Closes #3138

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain John Hampton.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.