def traverse_menu( previous_menu, menu_str, system, attempt=0, ): if not f2.is_system_open(tries=25): login.sign_in_toronto(login.username, login.password, system) window_data = VERIFICATION['system'][system] if not f2.verify(window_data, attempts=50): login.sign_in_toronto(login.username, login.password, system) if attempt > 2: return False if previous_menu(system): window_data = VERIFICATION['screens'][menu_str] cmd = VERIFICATION['navigation'][menu_str] print(cmd) if '{' in cmd: keyboard.write_mix(cmd) else: keyboard.write_text(cmd) keyboard.enter(1) if not f2.verify(window_data, 50): return traverse_menu(previous_menu, menu_str, system, attempt=attempt + 1) return True return False
def sign_in_toronto(username, password, system, attempts=0): print(f"starting login attempt: {attempts}") if attempts > 5: return False login(username, password) if not f2.is_system_open(100): print(f"system is not open attempt{attempts}") return sign_in_toronto(username, password, attempts + 1) else: print("system has opened") # sign into f2 Canada window_data_size_1 = VERIFICATION['screens']['text_login_menu_1'] print('verifying window') if not f2.verify_contains(window_data_size_1, attempts=500): print("attempting to varify") return sign_in_toronto(username, password, attempts + 1) keyboard.write_text( VERIFICATION['system_options']['f2_canada_menu_number']) # sign into live system window_data_size_1 = VERIFICATION['screens']['text_login_menu_2'] if not f2.verify_contains(window_data_size_1, attempts=500): print(f'sign in attempt {attempts}') return sign_in_toronto(username, password, attempts + 1) # choose syste, if system == 'f2_canada_real': keyboard.write_text( VERIFICATION['system_options']['f2_canada_real_system_number']) window_data = VERIFICATION['system']['f2_canada_real'] elif system == 'f2_canada_test': keyboard.write_text( VERIFICATION['system_options']['f2_canada_test_system_number']) window_data = VERIFICATION['system']['f2_canada_test'] else: return False if not f2.verify(window_data, attempts=500): return sign_in_toronto(username, password, attempts + 1) window_data = VERIFICATION['screens']['main_menu'] if not f2.verify(window_data, attempts=500): return sign_in_toronto(username, password, attempts + 1) print('signed in') return True
def stock_per_location_location(system, from_date, to_date, location, attempt=0, virtual=False): if attempt > 10: return False if location in get_actual_stock_locations(system, from_date, to_date, virtual=virtual): keyword = 'stock_per_location-flowers-location' keyboard.write_text(location) keyboard.enter(2) window_data = copy.deepcopy(VERIFICATION['screens'][keyword]) swaps = { '{location}': location, } for w in window_data: w['target'] = swap_values(swaps, w['target']) print(f"location is {location}: {window_data}") if not f2.verify(window_data, 100): return stock_per_location_location(system, from_date, to_date, location, attempt + 1, virtual=virtual) return True return False
def main_menu_stock_stock_per_location_edit_stock_date_flowers( system, from_date, to_date, attempt=0, virtual=False): if attempt > 10: return False if type(from_date) == datetime.datetime: from_date = dates.get_menu_date(from_date) if type(to_date) == datetime.datetime: to_date = dates.get_menu_date(to_date) if main_menu_stock_stock_per_location_edit_stock_date(system, from_date, to_date, attempt=0, virtual=virtual): keyword = "main_menu-stock-stock_per_location-edit_stock-date-flowers" window_data = VERIFICATION['screens'][keyword] cmd = VERIFICATION['navigation'][keyword] keyboard.write_mix(cmd) keyboard.enter(1) if not f2.verify(window_data, 50): return main_menu_stock_stock_per_location_edit_stock_date_flowers( system, from_date, to_date, attempt + 1) else: return True return False
def main_menu(system): window_data = VERIFICATION['system'][system] if not f2.is_system_open(tries=25): login.sign_in_toronto(login.username, login.password, system) if not f2.verify(window_data, attempts=500): login.sign_in_toronto(login.username, login.password, system) main_menu_call() main_menu_call() return main_menu_call()
def price_item(price): points = VERIFICATION['pricing']['f8-pricing'] if True or f2.verify(points, attempts=10): keyboard.home() keyboard.enter() keyboard.paste_write(pricing.make_price_str(price)) keyboard.f11() keyboard.f12() else: return False
def verify_per_location(location): keyword = 'stock_per_location-flowers-location' window_data = copy.deepcopy(VERIFICATION['screens'][keyword]) swaps = { '{location}': location, } for w in window_data: w['target'] = swap_values(swaps, w['target']) return f2.verify(window_data, 50)
def count_items_in_category(count=0, oldcreen=''): points = VERIFICATION['pricing']['in_group-pricing'] if f2.verify(points, attempts=10): if f2.is_new_screen(oldcreen): uscreen = window.get_window() count += parse.count_category(uscreen) keyboard.pgdn() time.sleep(.1) return count_items_in_category(count, uscreen) return count return None
def main_menu_maintainance_data(system, attempt=0): if attempt > 10: return False if main_menu(system): window_data = VERIFICATION['screens']['main_menu-maintenance_data'] cmd = VERIFICATION['navigation']['main_menu-maintenance_data'] keyboard.write_text(cmd) keyboard.enter(1) if not f2.verify(window_data, 50): return main_menu_maintainance_data(attempt + 1) return True return False
def main_menu_call(attempt=0): window_data = VERIFICATION['screens']['main_menu'] if attempt > 20: return False if not f2.verify(window_data, 2): keyboard.f12(7) keyboard.write_text('n') keyboard.home(3) time.sleep(.01) return main_menu_call(attempt + 1) else: keyboard.home(3) return True
def verify_lot_info(lot_number, virtual=False): if virtual: screen = 'virtual_lot_info' else: screen = 'lot_info' window_data = copy.deepcopy(VERIFICATION['screens'][screen]) swaps = { '{lot_number}': lot_number, } for w in window_data: w['target'] = swap_values(swaps, w['target']) return f2.verify(window_data, 10)
def main_menu_maintainance_data_pricelists_edit_pricelist_flowers_select( price_list, date, system, attempt=0): menu_str = 'main_menu-maintenance_data-pricelists-edit_pricelist-flowers' f = main_menu_maintainance_data_pricelists_edit_pricelist if traverse_menu(f, menu_str, system, attempt=0): if date: keyboard.command(('shift', '3')) keyboard.write_text(date) keyboard.enter() keyboard.write_text(price_list) price_list_name = VERIFICATION['price_list'][price_list]['name'] window_data = VERIFICATION['screens'][ 'main_menu-maintenance_data-pricelists-edit_pricelist-flowers-select'] window_data[1]['target'] = price_list_name if not f2.verify(window_data, 50): return False else: return True return False
def main_menu_stock_stock_per_location_edit_stock_date(system, from_date, to_date, attempt=0, virtual=False): if attempt > 10: return False if type(from_date) == datetime.datetime: from_date = dates.get_menu_date(from_date) if type(to_date) == datetime.datetime: to_date = dates.get_menu_date(to_date) if virtual: menu = main_menu_stock_virtual_stock_location_edit_stock else: menu = main_menu_stock_stock_per_location_edit_stock if menu(system, attempt=0): keyboard.write_text(from_date) keyboard.enter() keyboard.write_text(to_date) keyboard.enter() window_data = copy.deepcopy( VERIFICATION['screens'] ['main_menu-stock-stock_per_location-edit_stock-date']) swaps = { '{from_date}': from_date, '{to_date}': to_date, } for w in window_data: w['target'] = swap_values(swaps, w['target']) # print(window_data) if not f2.verify(window_data, 50): return main_menu_stock_stock_per_location_edit_stock_date( system, from_date, to_date, attempt + 1) else: return True return False
def verify_per_location_price_level(location, level, attempt=0): if attempt > 50: return False level = str(level) if level == '0': row = parse.process_scene(window.get_window())[4][55:-5].strip() print('row', row) if row == '' or row == 'Pricegroup : 0': print("TRUE") return True else: return verify_per_location_price_level(location, level, attempt + 1) keyword = "stock_per_location-flowers-location-price_level" window_data = VERIFICATION['screens'][keyword] swaps = { '{level}': level, } for w in window_data: w['target'] = swap_values(swaps, w['target']) return verify_per_location(location) and f2.verify(window_data, 50)
for w in window_data: w['target'] = swap_values(swaps, w['target']) return f2.verify(window_data, 10) def swap_values(swaps, text): for s in swaps: if s in text: return text.replace(s, swaps[s]) return text if __name__ == '__main__': location = 'ec' level = '2' # cmd = verify_per_location_price_level(location, level) # print(cmd) # print(verify_lot_info('641921')) # print(verify_lot_info('641913')) a = f2.verify([{ 'target': 'Intern partijnummer : 647801', 'location': (17, 97) }], 10) # b = f2.verify([{'target': 'Intern partijnummer : 647801', 'location': (18, 97)}], 10) print(a) # [{'target': 'Inkooporder', 'location': (19, 97)}, {'target': 'Art. info', 'location': (5, 98)}, {'target': 'VBN', 'location': (8, 97)}, {'target': 'Intern partijnummer : 639545', 'location': (18, 97)}]