def check_test_result(test_name, test_index, response, test_data): global test_passed, test_failed author = get_author_name(test_index,test_data) if response is None: print blue(test_name+" ("+str(test_index)+")") + fail(": Test failed ") + ("" if len(author) == 0 else blue(" contact test author: "+author+"")) print "response is None" test_failed += 1 return if response.status_code != 200: print blue(test_name+" ("+str(test_index)+")") + fail(": Test failed ") + ("" if len(author) == 0 else blue(" contact test author: "+author+"")) print "HTTP status code = "+ str(response.status_code) test_failed += 1 return message_filler = get_message_filler(test_index,test_data) ignore_whitespace = get_ignore_whitespace(test_index,test_data) expected_response = replace_with_global_data(get_expected_response(test_index,test_data)) if((not ignore_whitespace and response_match(response.text.strip(),expected_response, message_filler)) or ( ignore_whitespace and response_match(clean_whitespace(response.text) ,clean_whitespace(expected_response),message_filler))): print blue(test_name+" ("+str(test_index)+")") + green(": Test passed") test_passed += 1 else: print blue(test_name+" ("+str(test_index)+")") + fail(": Test failed ") + ("" if len(author) == 0 else blue(" contact test author: "+author+"")) print warn("EXPECTED")+": \n"+ expected_response + "\n\n"+warn("ACTUAL")+":\n" + response.text test_failed += 1
def Tagger(files, discogs): if discogs is None: TaggerWriteNone(files) return print( style.blue(discogs['json'].get('artists_sort') + ' - ' + discogs['json'].get('title'))) print(style.blue(discogs['url'])) print() TaggerWriteData(files, discogs) return
def Folder(paths): results = [] for path in paths: for root, dirs, files in os.walk(path, topdown=False): for dir in dirs: if dir != '.AppleDouble': results.append(os.path.join(root, dir)) results.sort() print(style.yellow('\n---\n')) print(style.blue(str(len(results)) + ' folders found.')) print(style.yellow('\n---\n')) return results
if(not dir.endswith('/')): dir = dir+'/' test_file_names = filter ( lambda x : x.endswith(TEST_FILE_EXTENSION), os.listdir(dir)) test_file_names = map( lambda x : dir+x , test_file_names) #Start executing test/s in each file test_file_names.sort() print header(u'Running Community API Tester!') for test_file_name in test_file_names: test_file = open(test_file_name,'r') test_data = json.load(test_file) if(not is_list_of_dicts(test_data)): print blue(test_file_name) + warn(": Invalid file format") test_not_executed += 1 continue if(not test_data[0].has_key(GLOBAL_STORE)): test_data[0][GLOBAL_STORE] = [] test_count += (len(test_data) - 1); #first element is list is configuration and not a test for test_index in range(1,len(test_data)): if(not min_required_data_present_in(test_index,test_data)): print blue(test_name) + warn(": Insuffecient data to run test") test_not_executed += 1 continue test_name = replace_with_global_data(get_test_name(test_index,test_data,test_file_name))
def display_computer_detail(self, computer_id): computer = API.getComputer( computer_id) ##Demander l'id de l'ordi à l'utilisateur clear() print("Ordinateur : " + str(computer['name']) + "\n") print(Separator()) print(style.bold("\nSpécifications techniques :")) #Computer print(style.blue("\nProcesseur :")) print( style.light_cyan("\t" + "Architecture : ") + str(computer["specs"]["processor"]["plateform"]) + " bits") print( style.light_cyan("\t" + "Marque : ") + str(computer["specs"]["processor"]["brand"])) print( style.light_cyan("\t" + "Vitesse : ") + str(computer["specs"]["processor"]["speed"])) print( style.light_cyan("\t" + "Cache : ") + str(computer["specs"]["processor"]["size_cache"])) print( style.light_cyan("\t" + "Modèle : ") + str(computer["specs"]["processor"]["model"])) #RAM print(style.blue("\nRAM :")) print( style.light_cyan("\t" + "Nombre de barette : ") + str(computer["specs"]["RAM"]["number"])) print( style.light_cyan("\t" + "Taille : ") + str(computer["specs"]["RAM"]["total_size"])) #Graphic card print(style.blue("\nCarte graphique :")) print( style.light_cyan("\t" + "Marque : ") + str(computer["specs"]["graphic_card"]["brand"])) print( style.light_cyan("\t" + "Mémoire : ") + str(computer["specs"]["graphic_card"]["memory"])) print( style.light_cyan("\t" + "Modèle : ") + str(computer["specs"]["graphic_card"]["model"])) #Video port print(style.blue("\nPorts vidéo :")) print( style.light_cyan("\t" + "Ports vidéo : ") + ', '.join(computer["specs"]["video_port"])) #Screen print(style.blue("\nEcran :")) print( style.light_cyan("\t" + "Résolution : ") + str(computer["specs"]["screen"]['screen_res'])) print( style.light_cyan("\t" + "Taille : ") + str(computer["specs"]["screen"]['screen_size']).strip( '[]').replace(', ', 'x') + "px") #Connectors print(style.blue("\nConnectique :")) print( style.light_cyan("\t" + "Lecteur CD : ") + ("Oui" if computer["specs"]["CD_player"] else "Non")) print( style.light_cyan("\t" + "Ports USB : ") + str(computer["specs"]["nb_USB_port"])) #Stockage print(style.blue("\nStockage :")) n_storage = 1 for storage in computer["specs"]['storage']: print(style.light_cyan("\tStockage " + str(n_storage) + " :")) print(style.magenta("\t\tType : ") + str(storage["type"])) print(style.magenta("\t\tPort : ") + str(storage["port"])) print(style.magenta("\t\tTaille : ") + str(storage["size"])) n_storage += 1 #Network card print(style.blue("\nCarte réseau :")) print( style.light_cyan("\t" + "Vitesse : ") + str(computer["specs"]["network_card"]['speed'])) print( style.light_cyan("\t" + "Marque : ") + str(computer["specs"]["network_card"]['brand'])) #User print(style.blue("\nUtilisateur :")) print( style.light_cyan("\t" + "Nom : ") + str(computer["user"]['name'])) print( style.light_cyan("\t" + "Nom d'utilisation : ") + str(computer["user"]['username'])) #Other print(style.blue("\nAutre :")) print( style.light_cyan("\t" + "WiFi : ") + ("Oui" if computer["specs"]["wifi"] else "Non")) print( style.light_cyan("\t" + "Bluetooth : ") + ("Oui" if computer["specs"]["bluetooth"] else "Non")) print( style.light_cyan("\t" + "Fabriquant : ") + str(computer["specs"]["maker"])) print( style.light_cyan("\t" + "Fournisseur : ") + str(computer["specs"]["provider"])) print( style.light_cyan("\t" + "Date d'achat : ") + datetime.fromtimestamp(computer["specs"]["purchase_date_timestamp"] ).strftime("%d/%m/%Y")) print("\n") print(Separator()) print(style.bold("\nLocalisation :\n")) print(style.blue("Salle :")) if API.getRoom(computer["localisation"]) != None: print( style.light_cyan("\t" + "Nom : ") + API.getRoom(computer["localisation"])["room_name"]) print( style.light_cyan("\t" + "Batiment : ") + API.getRoom(computer["localisation"])["building_name"]) print("\n") print(Separator()) print("\n") options = [ { 'type': 'list', 'name': 'menu_computer_detail', 'message': 'Selectionner un des menus avec les flèches du clavier.', 'choices': [ "Editer", "Logiciels installés", "Ajouter une salle à cet ordinateur", Separator(), "Retour" ] }, ] res = prompt(options) ##On affiche le formulaire try: res_index = options[0]['choices'].index( res["menu_computer_detail"]) if res_index == 0: ##Formulaire d'edition de l'ordinateur self.edit_computer_detail(computer_id) elif res_index == 1: ##Formulaire des logiciels clear() self.display_installed_software(computer_id) elif res_index == 2: clear() self.display_rooms() self.ask_for_room(computer_id) elif res_index == 4: ##Retour clear() if not self.computer_id: self.display_options() else: pass except: self.display_computer_detail(computer_id)