def flow(self): # doc = docmnt con = True while con == True: command = raw_input('>>> ') if command[0] == 'i': if command[1:len('CellVal')+1].lower() == 'CellVal'.lower(): val = command[command.find('(')+1:command.find(')')] val = val.split(';') try: self.updateCell(val) except : with open("editlog.txt","a") as log : log.write("\nInserting of Values into cell was Unsuccessful") else : with open("editlog.txt","a") as log : log.write("\nInserting of Values into cell was Successful") elif command[1:len('RowVal')+1].lower() == 'RowVal'.lower(): val = command[command.find('(')+1:command.find(')')] val = val.split(';') try: self.updateRow(val) except : with open("editlog.txt","a") as log : log.write("\nInserting of Values into rows was Unsuccessful") else : with open("editlog.txt","a") as log : log.write("\nInserting of Values into rows was Successful") elif command[1:len('ColVal')+1].lower() == 'ColVal'.lower(): val = command[command.find('(')+1:command.find(')')] val = val.split(';') try: self.updateCol(val) except : with open("editlog.txt","a") as log : log.write("\nInserting of Values into columns was Unsuccessful") else : with open("editlog.txt","a") as log : log.write("\nInserting of Values into columns was Successful") else: print 'Cannot find command: '+command elif command[0] == 'd': if command[1:len('CellVal')+1].lower() == 'CellVal'.lower(): val = command[command.find('(')+1:command.find(')')] val = val.split(';') try: self.deleteCellValue(val) except : with open("editlog.txt","a") as log : log.write("\nDeleting of Values in Cells was Unsuccessful") else : with open("editlog.txt","a") as log : log.write("\nDeleting of Values in Cells was Successful") elif command[1:len('RowVal')+1].lower() == 'RowVal'.lower(): val = command[command.find('(')+1:command.find(')')] val = val.split(';') try: self.deleteRowValues(val) except : with open("editlog.txt","a") as log : log.write("\nDeleting of Values in Rows was Unsuccessful") else : with open("editlog.txt","a") as log : log.write("\nDeleting of Values in Rows was Successful") elif command[1:len('ColVal')+1].lower() == 'ColVal'.lower(): #val = command[command.find('(')+1:command.find(')')] #val = val.split(';') #self.deleteColValues(docmnt, val) pass elif command[1:len('Row')+1].lower() == 'Row'.lower(): val = command[command.find('(')+1:command.find(')')] val = val.split(';') try: self.deleteRecord(val) except : with open("editlog.txt","a") as log : log.write("\nDeleting of Record was Unsuccessful") else : with open("editlog.txt","a") as log : log.write("\nDeleting of Record was Successful") elif command[1:len('WS')+1].lower() == 'WS'.lower(): val = command[command.find('(')+1:command.find(')')] val = val.split(';') try: self.deleteWorksheet(val) except : with open("editlog.txt","a") as log : log.write("\nDeleting of Worksheet was Unsuccessful") else : with open("editlog.txt","a") as log : log.write("\nDeleting of Worksheet was Successful") elif command[1:len('SS')+1].lower() == 'SS'.lower(): val = command[command.find('(')+1:command.find(')')] val = val.split(';') try: self.deleteSpreadsheet(val) except : with open("editlog.txt","a") as log : log.write("\nDeleting of Spreadsheet was Unsuccessful") else : with open("editlog.txt","a") as log : log.write("\nDeleting of Spreadsheet was Successful") else: print 'Cannot find command: '+command elif command[0] == 'c': if command[1:len('WS')+1].lower() == 'WS'.lower(): val = command[command.find('(')+1:command.find(')')].strip() #val = val.split(';') client.wksht_id = client.getWorksheetIdByName(val) elif command[1:len('SS')+1].lower() == 'SS'.lower(): val = command[command.find('(')+1:command.find(')')].strip() #val = val.split(';') client.sheet_key = client.getSpreadsheetKey(val) client.exit_if_no_key() elif command[0:len('clear')+1].lower() == 'clear'.lower(): os.system("clear") else: print 'Cannot find command: '+command elif command[0] =='n': if command[1:len('WS')+1].lower() == 'WS'.lower(): val = command[command.find('(')+1:command.find(')')].strip() val = val.split(',') try: if len(val) == 3: self.addWorksheet(val[0], val[1], val[2]) else: self.addWorksheet(val[0]) except : with open("editlog.txt","a") as log : log.write("\nCreation of new worksheet was Unsuccessful") else : with open("editlog.txt","a") as log : log.write("\nCreation of new worksheet was Successful") elif command[1:len('SS')+1].lower() == 'SS'.lower(): val = command[command.find('(')+1:command.find(')')].strip() try: self.createSpreadsheet(val) except : with open("editlog.txt","a") as log : log.write("\nCreation of new spreadsheet was Unsuccessful") else : with open("editlog.txt","a") as log : log.write("\nCreation of new spreadsheet was Successful") else: print 'Cannot find command: '+command else: if command[0:len('print')+1].lower() == 'print'.lower(): self.printData() elif command[0:len('help')+1].lower() == 'help'.lower(): self.getHelp() elif command[0:len('exit')+1].lower() == 'exit'.lower(): #self.sendMail() sys.exit(2) else: print 'Cannot find command: '+command
client = SpreadsheetScript(userVal, pwdVal, docNameVal, src=srcVal) log = open("editlog.txt","a+") if nSS == True: client.createSpreadsheet(nSSVal) #client.exit_if_no_key() if nWS == True: nWSVal = nWSVal.split(',') try: if len(nWSVal) == 3: client.addWorksheet(nWSVal[0], nWSVal[1], nWSVal[2]) else: client.addWorksheet(nWSVal[0]) # assign id of worksheet created to client.wksht_id client.wksht_id = client.getWorksheetIdByName(nWSVal) except : log.write("\nCreation of new worksheet was Unsuccessful") else : log.write("\nCreation of new worksheet was Successful") #if worksheet == True : #client.wksht_id = client.getWorksheetIdByName(worksheetVal) #elif nWS == True: #client.wksht_id = client.getWorksheetIdByName(nWSVal) #else: #pass if insert == True and docName == True: row = str(client.getRowNumber(client.today)) set_of_values = insertVal.split(";")