def type_csv(): selection = 1 confirmation = 0 while confirmation == 0: csvfile = input( '\n\nEnter the full path location to the CSV file to be used for importing devices: ' ) if selection == 1 and confirmation == 0: print('\n\nFile selected for importing: ' + csvfile) confirmation = int( input( '\n\nPress enter to confirm correct, press ctrl-c to abort...' ) or 1) clear() if confirmation == 1: csv_import = brander.CsvProc(csvfile, 'Serial') serials = csv_import.read_input() return serials elif confirmation >= 1: selection = 1 confirmation = 0 print(errors.SELECTION_ERROR) else: print(errors.SELECTION_ERROR) break
def input_type(): selection = False while selection is False: try: clear() selection = int( input( '\n\nCurrent list of accepted input types, refer to documentation for further detail on each input type.\n1. CSV\n2. Serial Numbers\n3. Order Numbers\n\nSelect Input: ' )) if selection == 1: selection = 'type_csv' return selection if selection == 2: selection = 'type_serial' return selection if selection == 3: selection = 'type_order' return selection elif selection >= 4 or selection <= 0: selection = False print(errors.SELECTION_ERROR) continue else: print(errors.GENERAL_ERROR) break except ValueError: print(errors.SELECTION_ERROR)
def claim_identify(serials): devices = [] identified = False for serial in serials: response = dashboard.organizations.getOrganizationInventoryDevice( org_id, serial) added_device = response['model'] devices.append(added_device) clear() print('\nConfirm all the models of hardware that will be imported.\n') print('\nDevice Models to be added:', devices) while identified == False: try: identified = str( input( '\n\nPress enter to confirm correct, press ctrl-c to abort.' ) or 'y').lower() clear() if identified in ('y', 'yes'): identified = True return identified else: print(errors.SELECTION_ERROR) claimed = False return claimed except ValueError: print(errors.GENERAL_ERROR)
def input_checker(serials): print( '\nPlease confirm the following list of serial numbers are correct for the devices you wish to create the site with.' ) print('\nSerial Numbers: ', serials) checked = str( input('\nPress enter to confirm correct, press ctrl-c to abort.') or 'y') clear() return checked
def country_selector( brand ): #This selected needs to be refind to obtain a list of the countries available to that brand rather than displaying all possible countries clear() country_selection = int( input( (brand) + ' is in the following countries.\n1. COUNTRY1 \n2. COUNTRY 2\n3. COUNTRY3\n4. COUNTRY4\n' + (COUNTRY))) if country_selection == 1: country = 'C1' return country elif country_selection == 2: country = 'C2' return country elif country_selection == 3: country = 'C3' return country elif country_selection == 4: country = 'C4' return country else: print(SELECTION_ERROR)
def text_menu(): def selector(): selection = int(input(STANDARD_ENTER) or "1") return selection def country_selector( brand ): #This selected needs to be refind to obtain a list of the countries available to that brand rather than displaying all possible countries clear() country_selection = int( input( (brand) + ' is in the following countries.\n1. COUNTRY1 \n2. COUNTRY 2\n3. COUNTRY3\n4. COUNTRY4\n' + (COUNTRY))) if country_selection == 1: country = 'C1' return country elif country_selection == 2: country = 'C2' return country elif country_selection == 3: country = 'C3' return country elif country_selection == 4: country = 'C4' return country else: print(SELECTION_ERROR) l1_selected = False while l1_selected == False: clear() print(TOP_TEXT) print(TOP_SELECT_TEXT) selection = selector() clear() if selection == 1: serials = importer() l1_selected = True l2_selected = False while l2_selected == False: print(CREATE_SITE_TEXT) brands_list = site_creator.brander.CsvProc(brandscsv, 'Brand') brands_list.read() brand = int(input(BRAND)) if brand == 1: l2_selected = True complete = False brand = 'B1' country = 'C1' clear() site = input(SITE_NAME).upper() while complete == False: name = site_creator.namer.SiteName( brand, country, site) site_name = name.create() confirm = int(input(SITE_NAME_CONFIRM) or 1) if confirm == 1: create_site = site_creator.network.orgNetwork( site_name, serials) create_site.create() device_name = device.deviceNamer( site_name, serials) device_name.get() complete = True clear() print(COMPLETE) return complete elif confirm != 1: print(RESTART) else: break elif brand == 2: l2_selected = True complete = False brand = 'B2' country = 'C1' clear() site = input(SITE_NAME).upper() while complete == False: name = site_creator.namer.SiteName( brand, country, site) site_name = name.create() confirm = int(input(SITE_NAME_CONFIRM) or 1) if confirm == 1: create_site = site_creator.network.orgNetwork( site_name, serials) create_site.create() device_name = device.deviceNamer( site_name, serials) device_name.get() complete = True clear() print(COMPLETE) return complete elif confirm != 1: print(RESTART) else: break elif brand == 3: l2_selected = True complete = False brand = 'B3' site = input(SITE_NAME).upper() while complete == False: country = country_selector(brand) clear() name = site_creator.namer.SiteName( brand, country, site) site_name = name.create() confirm = int(input(SITE_NAME_CONFIRM) or 1) if confirm == 1: create_site = site_creator.network.orgNetwork( site_name, serials) create_site.create() device_name = device.deviceNamer( site_name, serials) device_name.get() clear() print(COMPLETE) complete = True return complete elif confirm != 1: print(RESTART) else: break else: break