def test(personlist,information): import root while 1:#if don't enter 'exit' print "What can i do for you?my host" name=raw_input("Please enter a name:") if name=='exit': break #personlist=config.PERSON_FILE#design by config #information=config.PERSON_INFORMATION#design by config people=root.person_object(name,information) peoples=people.file_handle(personlist,'r') commander=raw_input("Please enter your commander(insert,update,delete,search,exit):") if commander == "insert" or commander== "update": if commander == "insert": people.insert() else: update_str=''; update_str=raw_input("Please enter the information_key you want to update,like:phone,email:") update_information_keys=[]; update_information_keys=update_str.split(',') #print update_information_keys; people.update(update_information_keys,peoples) people.file_handle(personlist,'w') elif commander == "delete" or commander == "search": if commander == "delete": people.delete(peoples) people.file_handle(personlist,'w') else: people.search(peoples) elif commander=='exit': break else: print 'Error Commander' continue
def shell_test(status,config_object): import root print "What can i do for you?my host" name=raw_input("Please enter a name:") moudle=raw_input("please enter the moudle you want to call on:") status_right=config_object.STATUS_RIGHT[status] #退出命令行 personlist=config_object.PERSON_FILE#design by config information=config_object.PERSON_INFORMATION#design by config people=root.person_object(name,information) peoples=people.file_handle(personlist,'r') if status_right^config_object.RIGHT_RAND[0]: right=0#作为search函数的参数 pwd=raw_input("Please enter your password:"******"Please enter your commander(insert,update,delete,search,exit):") if peoples: #search 和 update的参数 # str=''; if commander == "insert" and status_right&config_object.HANDLE_RIGHT['insert']: people.insert() elif commander=='update' and pwd == peoples[name]['password']: for i in peoples[name]: print i,':',peoples[name][i] str=raw_input("Please enter the information_key you want to update or search,like:phone,email:") update_information_keys=[]; update_information_keys=str.split(',') people.update(update_information_keys,peoples) elif commander == "delete" and status_right&config_object.HANDLE_RIGHT['delete']: people.delete(peoples) elif commander=='search' and status_right&config_object.HANDLE_RIGHT['search']: people.search(peoples,right) elif commander=='exit': break else: print 'you do not have permission to perform the operation or enter false commander' else: if commander == "insert" and status_right&config_object.HANDLE_RIGHT['insert']: people.insert() elif commander=='exit': break elif status_right&config_object.HANDLE_RIGHT['insert']: print 'There are not anything,you should insert the information' else: print 'you can not do anything,please contact root' break #将信息写入保存文件 people.file_handle(personlist,'w')
def test(status, config_object): import root while 1: # if don't enter 'exit' print "What can i do for you?my host" name = raw_input("Please enter a name:") status_right = config_object.STATUS_RIGHT[status] if name == "exit": break personlist = config_object.PERSON_FILE # design by config information = config_object.PERSON_INFORMATION # design by config people = root.person_object(name, information) peoples = people.file_handle(personlist, "r") if status_right ^ config_object.RIGHT_RAND[0]: right = 0 # 作为search函数的参数 pwd = raw_input("Please enter your password:"******"Please enter your commander(insert,update,delete,search,exit):") if peoples: # search 和 update的参数 str = "" str = raw_input("Please enter the information_key you want to update or search,like:phone,email:") update_information_keys = [] update_information_keys = str.split(",") search_information_keys = update_information_keys if commander == "insert" and status_right & config_object.HANDLE_RIGHT["insert"]: people.insert() elif commander == "update" and pwd == peoples[name]["password"]: # print peoples[name] # print update_information_keys; people.update(update_information_keys, peoples) # else: # print 'you do not have permission to perform this insert or update(maybe your password is false)' # people.file_handle(personlist,'w') # elif commander == "delete" or commander == "search": elif commander == "delete" and status_right & config_object.HANDLE_RIGHT["delete"]: people.delete(peoples) elif commander == "search" and status_right & config_object.HANDLE_RIGHT["search"]: people.search(search_information_keys, peoples, right) elif commander == "exit": break else: print "you do not have permission to perform the operation or enter false commander" else: if commander == "insert" and status_right & config_object.HANDLE_RIGHT["insert"]: people.insert() elif commander == "exit": break elif status_right & config_object.HANDLE_RIGHT["insert"]: print "There are not anything,you should insert the information" else: print "you can not do anything,please contact root" break # elif commander=='exit': # break # else: # print 'Error Commander' # continue people.file_handle(personlist, "w")