def getdatabase(): q = "Select database to connect to:\n\n\t1 - Production (Petra5)\n\t2 - Test (Petra5_Test)\n\nDatabase: " regex = "^1|2$" error = "Invalid entry. Expecting a 1 or 2" dbase = getresponse(q, regex, error) try: po.database = 'Petra5' if int(dbase) == 1 else 'Petra5_Test' po.testconnection() except: print "\nError: Cannot connect to database" getdatabase() return int(dbase)
def getdatabase(): q = "Select database to connect to:\n\n\t1 - Production (Petra5)\n\t2 - Test (Petra5_Test)\n\nDatabase: " regex = "^1|2$" error = "Invalid entry. Expecting a 1 or 2" dbase = getresponse(q,regex,error) try: po.database = 'Petra5' if int(dbase)==1 else 'Petra5_Test' po.testconnection() except: print "\nError: Cannot connect to database" getdatabase() return int(dbase)