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 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_purchase_default_purchase_distribute_flowers_purchase( system, purchase_date, attempts=0): if type(purchase_date) == datetime.datetime: purchase_date = dates.get_menu_date(purchase_date) if main_menu_purchase_default_purchase_distribute_flowers(system): keyboard.write_text(purchase_date) keyboard.enter() keyboard.f11()
def main_menu_purchase_default_input_purchases_flowers_date( system, purchase_date, attempts=0): if type(purchase_date) in (datetime.datetime, datetime.date): purchase_date = dates.get_menu_date(purchase_date) if main_menu_purchase_default_input_purchases_flowers(system): keyboard.write_text(purchase_date) keyboard.enter() keyboard.shift_f11() keyboard.home(3) return True
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 go_to_lot(system, location, lot, attempt=0): if f2_page.verify_per_location(location) and f2.verify_system(system): time.sleep(attempt * .05) keyboard.command('F7') keyboard.write_text(lot) keyboard.enter(2) keyboard.command(('shift', 'F10')) found = f2_page.verify_lot_info(lot) keyboard.command('f12') if not found and attempt < 5: found = go_to_lot(system, location, lot, attempt=attempt + 1) return found
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 go_to_pricing(): screen = window.get_window() if not screen: time.sleep(.1) screen = window.get_window() if 'Pricegroup:' in screen: keyboard.command('f1') keyboard.write_text('0') keyboard.enter() keyboard.command('f2') keyboard.shift_f11() keyboard.home(3) return lot_verify.pricing_screen()
def make_list_from_file(system, filename, po_id): variety = '' order_date = get_data.get_virtual_purchase_order(po_id)[2] week = dates.get_week(order_date) year = dates.get_year(order_date) df = import_ecuador_prices(filename) for index, row in df.iterrows(): if not pd.isnull(row['$ fob']): if row['Variety'].strip() != variety: variety = row['Variety'].strip() window.drag_window() keyboard.write_text(variety) print_row_ecuador(row) answer = input("next") if answer == '': try: assortment = add_article() except: assortment = lots.get_lot_info_assortment() keyboard.f12() keyboard.command('down') insert_data.insert_virtual_purchase( assortment_code=assortment['assortment_code'], quantity=15, packing=row['St/bx'], fob="%0.2f" % row['$ fob'], landed="%0.2f" % row['$ fob'], virtual_purchase_order_id=po_id, entered=False) try: insert_data.insert_weekly_price( system, week, year, assortment['assortment_code'], row['selling']) except: update_data.update_weekly_price( system, year, week, assortment['assortment_code'], row['selling']) elif 'q' in answer: break elif 'n' in answer: pass return df
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 login(username, password): closef2.close() paths = [{ 'dir': r'c:/Program Files (x86)/Connect Internet/', 'filename': 'Connect.exe' }, { 'dir': r'c:/Program Files (x86)/Connect2000_Internet/', 'filename': 'Connect2000.exe' }] for path in paths: try: os.chdir(path['dir']) os.system(path['filename']) break except: print("not found") print(path) while not is_login_dialogue_open(): time.sleep(.1) keyboard.write_text(password) pyautogui.hotkey('shift', 'tab') keyboard.write_text(username) keyboard.enter()
def get_lot_data(lot, system): lot_number = lot[0] purchase_date = lot[1] window.drag_window() keyboard.command("f7") keyboard.write_text(lot_number) keyboard.enter() for i in range(5): try: lot_main = parse.get_input_purchase_lots(system, purchase_date) break except: lot_main = False time.sleep(.1) if not lot_main or lot_number not in lot_main: return False lot_main = lot_main[lot_number] supplier_code = lot_main['supplier_code'] if not supplier_code or supplier_code[0] in ( 'M', '1') and 'f2_canada' in system: return False data = lots.get_lot_info_purchase(lot_number, purchase_date, supplier_code) keyboard.f12() return data
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 enter_purchase_normal(code, fob, landed, quantity, packing, supplier): keyboard.command('f10') keyboard.write_text(code) keyboard.enter() keyboard.write_text(fob) keyboard.enter() keyboard.write_text(landed) keyboard.enter() keyboard.write_text(quantity) keyboard.enter() keyboard.write_text(packing) keyboard.enter() keyboard.write_text(supplier) keyboard.f11(2)
def change_price_level(system, location, price_level): if f2_page.verify_per_location(location) and f2.verify_system(system): keyboard.command('F1') keyboard.write_text(str(price_level)) keyboard.enter() return f2_page.verify_per_location_price_level(location, price_level)
def set_availability_dates(from_date, to_date, cut_off_start_date, cut_off_start_time, cut_off_date, cut_off_time): time.sleep(1) window.drag_window() if not verify((('Available', 22, 54), ('Visible', 25, 56))): time.sleep(1) if not verify((('Available', 22, 54), ('Visible', 25, 56))): print("sent") keyboard.command("INSERT") keyboard.command("F6") for d in (from_date, to_date): keyboard.write_text(d) keyboard.command("enter") keyboard.write_text('0000') keyboard.command("enter") keyboard.write_text(cut_off_start_date) keyboard.command("enter") keyboard.write_text(cut_off_start_time) keyboard.command("enter") keyboard.write_text(cut_off_date) keyboard.command("enter") keyboard.write_text(cut_off_time) keyboard.command("enter") keyboard.command("enter") keyboard.f11()
def go_to_lot(lot_number): window.get_window() keyboard.command('f7') keyboard.write_text(lot_number) keyboard.enter(n=2) return lot_verify.verify_lot(lot_number)
def main_menu_purchase_default_insert_virtual_purchase_flowers_date( system, purchase_date, attempts=0): if main_menu_purchase_default_insert_virtual_purchase_flowers(system): keyboard.write_text(purchase_date) keyboard.enter()
def underline_item(date_str, b): w = window.get_window() if (date_str in w) == b: keyboard.write_text(' ') keyboard.command('down') return w