﻿id	summary	reporter	owner	description	type	status	priority	component	severity	resolution	keywords	cc	release
3138	Check db arguments given before checking contents	anonymous	pacopablo	"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)
}}}"	defect	closed	normal	SqliteToPgScript	minor	fixed			0.10
