Beispiel #1
0
 def edit(self, ssid, edit_value_dict):
     """
         edit_value_dict like : {"ssid": "R1-TC_5G_n", "password": "******", ...  ,
         "static_ip": [ip, subnet_mask, gateway]}
     """
     log.info("edit '{}' wireless profile".format(ssid))
     icon = wait_element(self.pic("_move_mouse"), offset=(0, 10))[0]
     tool.click(icon[0], icon[1], num=2)
     if wait_element(self.pic("_{}".format(ssid))):
         pyautogui.click(wait_element(self.pic("_{}".format(ssid)))[0],
                         interval=2)
         pyautogui.click(wait_element(self.pic("_edit"))[0], interval=2)
     else:
         down_menu = wait_element(self.pic("_down_menu"))[0]
         if down_menu:
             tool.click(down_menu[0], down_menu[1], num=10)
             if wait_element(self.pic("_{}".format(ssid))):
                 pyautogui.click(wait_element(self.pic(
                     "_{}".format(ssid)))[0],
                                 interval=2)
                 pyautogui.click(wait_element(self.pic("_edit"))[0],
                                 interval=2)
             else:
                 log.info('{} wireless not exists'.format(ssid))
                 return False
         else:
             log.info('{} wireless not exists'.format(ssid))
             return False
     self.set_wireless_profile(edit_value_dict)
     if "static_ip" in edit_value_dict.keys():
         self.set_ipv4_static(ip=edit_value_dict["static_ip"][0],
                              subnet_mask=edit_value_dict["static_ip"][1],
                              gateway=edit_value_dict["static_ip"][2])
     self.apply_and_ok()
def click_icon(lis):
    log.info('check icon and click')
    path = os.path.join(common_function.get_current_dir(), 'Test_Data',
                        'td_power_manager', 'verify_s3_work')
    for i in lis:
        power_icon = picture_operator.wait_element(os.path.join(path, i),
                                                   offset=(20, 10))
        tool.click(power_icon[0][0], power_icon[0][1], 1)
def sw_user(p):
    path = os.path.join(common_function.get_current_dir(), 'Test_Data',
                        'td_power_manager', 'verify_domain_users',
                        '{}'.format(p))
    power_icon = picture_operator.wait_element(path, offset=(10, 10))
    print(power_icon)
    if power_icon:
        tool.click(power_icon[0][0], power_icon[0][1], 3)
def lock_screen():
    log.info('lock the screen')
    SwitchThinProMode(switch_to='user')
    time.sleep(2)
    pyautogui.hotkey('ctrl', 'alt', 'l')
    time.sleep(2)
    size = common_function.screen_resolution()
    tool.click(int(size[0] / 2), int(size[1] / 2), 1)
    return True
def set_user_password_callback(res):
    loc, offset = res
    loc_x, loc_y = loc[0] + offset[0], loc[1] + offset[1]
    click(loc_x, loc_y)
    time.sleep(1)
    tap_key("1", 1)
    tap_key("Tab", 1)
    tap_key("1", 1)
    tap_key(keyboard.enter_key, 2)
    close_control_pannel()
    return
Beispiel #6
0
 def clear_text(self, name):
     log.info('clear {} proxy info'.format(name))
     icon_location = wait_element(self.dns_pic(name), offset=(200, 10))
     if icon_location:
         tool.click(icon_location[0][0], icon_location[0][1], 3)
     else:
         return
     time.sleep(1)
     pyautogui.press('backspace')
     time.sleep(0.5)
     return True
Beispiel #7
0
 def __set_value(self, name, text):
     icon_location = wait_element(self.dns_pic(name), offset=(200, 10))
     if icon_location:
         tool.click(icon_location[0][0], icon_location[0][1], 3)
         time.sleep(0.5)
         pyautogui.press('backspace')
     else:
         log.info('not find position {}'.format(self.dns_pic(name)))
         return
     time.sleep(1)
     pyautogui.typewrite(text)
     return True
Beispiel #8
0
 def open_dns(self):
     log.info('Open NetWork DNS from Control Panel')
     for i in range(2):
         self.open_network()
         time.sleep(5)
         icon_location = wait_element(self.dns_pic("dns"), offset=(10, 10))
         if not icon_location:
             log.info('not find position {}'.format(self.dns_pic("dns")))
             continue
         tool.click(icon_location[0][0], icon_location[0][1], 1)
         break
     return True
Beispiel #9
0
def step2(*args, **kwargs):
    case_name = kwargs.get("case_name")
    yml_path = kwargs.get("yml_path")
    click(150, 200)
    event_dict = {
        "event_method": wait_and_check_screen_saver,
        "error_msg": {'actual': 'screen saver launch fail'},
        "call_back": resume,
        "do_call_back_while_fail": True,
        "case_name": case_name,
        "yml_path": yml_path
    }
    return event(**event_dict)
def select_system_image():
    log.info(
        'select custom screensaver image image file diretory to the system image mode'
    )
    path = os.path.join(common_function.get_current_dir(), 'Test_Data',
                        'td_power_manager',
                        'verify_screensaver_works_in_system_image_mode',
                        'open')
    pic_list = common_function.get_folder_items(path, file_only=True)
    for i in pic_list:
        time.sleep(1)
        icon_location = wait_element(os.path.join(path, i))
        if icon_location:
            tool.click(icon_location[0][0], icon_location[0][1], 1)
def set_user_password(**kwargs):
    current_path = common_function.get_current_dir("Test_Data")
    temp_path = current_path + "/temp.png"
    user = current_path + "/td_power_manager/user_icon"
    enabled = user + "/enabled"
    change_path = user + "/change"
    SwitchThinProMode("admin")
    time.sleep(1)
    log.info("Open security desktop")
    os.popen("hptc-control-panel --config-panel /etc/hptc-control-panel/applications/hptc-security.desktop")
    time.sleep(2)
    res = picture_operator.wait_element(user)
    if res:
        location, shape = res
        loc_x, loc_y = location
        offset_x, offset_y = 0, -20
        loc = {"left": loc_x + offset_x, "top": loc_y + offset_y, "width": 500, "height": 40}
        picture_operator.capture_screen_by_loc(temp_path, loc)
        enabled_list = common_function.get_folder_items(enabled, file_only=True)
        change_path_list = common_function.get_folder_items(change_path, file_only=True)
        flag = True
        for i in enabled_list:
            if picture_operator.compare_pic_similarity(enabled + "/{}".format(i), temp_path):
                break
        else:
            flag = False
        for i in change_path_list:
            change_res = picture_operator.compare_pic_similarity(change_path + "/{}".format(i), temp_path)
            if change_res:
                break
        else:
            change_res = False
        if flag and change_res:
            change_loc, change_shape = change_res
            offset = (change_loc[0] + int(change_shape[1] / 2), change_loc[1] + int(change_shape[0] / 2))
            res = (loc_x + offset_x, loc_y + offset_y), offset
            loc, offset = res
            loc_x, loc_y = loc[0] + offset[0], loc[1] + offset[1]
            tool.click(loc_x, loc_y)
            time.sleep(1)
            tool.tap_key("1", 1)
            tool.tap_key("Tab", 1)
            tool.tap_key("1", 1)
            tool.tap_key(tool.keyboard.enter_key, 2)
            os.popen("hptc-control-panel --term")
def click_icon(name, **kwargs):
    try:
        n = ''
        count = kwargs.get('count', n)
        path = os.path.join(common_function.get_current_dir(), 'Test_Data',
                            'td_power_manager', 'verify_screen_lock_dialog',
                            '{}'.format(name))
        if count:
            icon_location = picture_operator.wait_element(path, offset=(8, 10))
            print(icon_location)
            if icon_location:
                tool.click(icon_location[0][0], icon_location[0][1], count)
            print('click icon')
        else:
            return picture_operator.wait_element(path)
    except:
        log.warning(traceback.format_exc())
        pass
Beispiel #13
0
 def delete(self, ssid=""):
     icon = wait_element(self.pic("_move_mouse"), offset=(0, 10))[0]
     tool.click(icon[0], icon[1], num=2)
     if ssid:
         log.info("delete '{}' wireless ".format(ssid))
         if wait_element(self.pic("_{}".format(ssid))):
             pyautogui.click(wait_element(self.pic("_{}".format(ssid)))[0],
                             interval=2)
             pyautogui.press(keys='tab', presses=3)
             pyautogui.press(keys='space')
             pyautogui.press(keys='space')
         else:
             down_menu = wait_element(self.pic("_down_menu"))
             if down_menu:
                 tool.click(down_menu[0][0], down_menu[0][1], num=10)
                 if wait_element(self.pic("_{}".format(ssid))):
                     pyautogui.click(wait_element(
                         self.pic("_{}".format(ssid)))[0],
                                     interval=2)
                     pyautogui.press(keys='tab', presses=3)
                     pyautogui.press(keys='space')
                     pyautogui.press(keys='space')
                 else:
                     log.info('{} wireless not exists'.format(ssid))
                     return False
             else:
                 log.info('{} wireless not exists'.format(ssid))
                 return False
     else:
         log.info("delete the first wireless ".format(ssid))
         ssid_title = wait_element(self.pic("_ssid_title".format(ssid)),
                                   offset=(20, 30))[0]
         tool.click(ssid_title[0], ssid_title[1])
         pyautogui.click(wait_element(self.pic("_delete"))[0], interval=2)
         pyautogui.click(wait_element(self.pic("_yes"))[0], interval=2)
 def open_power_manager_from_tray():
     log().info("start open power manager from tray")
     platform = common_function.get_platform()
     if 'MT' not in platform.upper():
         log().error("dtc can't open power manager from tray")
         return False
     os.system("wmctrl -c 'Control Panel'")
     x, y = common_function.screen_resolution()
     power_setting_word = os.path.join(get_current_dir(), "Test_Data", "td_power_manager", "systray_icon",
                                       "_pm_adjust_power_settings")
     x, y = int(x), int(y)
     icon_info = os.popen('xwininfo -name hptc-battery-systray').read()
     print(icon_info)
     res = re.findall(r"Absolute upper-left X:.*?(\d{3,4}).{0,100}Absolute upper-left Y:.*?(\d{3,4})"
                      r".{0,100}Width:.*?(\d{2}).{0,100}Height:.*?(\d{2})", icon_info, re.S)
     print(res)
     log().info('current screen size is : {} x {}'.format(x, y))
     ts = precheck_function.thinpro_or_smartzero()
     if ts == "thinpro":          # ThinPro mode
         if not res:
             log().error("can't get battery size and loc")
             return False
         res = res[0]
         x, y, w, h = int(res[0]), int(res[1]), int(res[2]), int(res[3])
         log().info('battery loc: {} x {}, battery icon size: {} x {}'.format(x, y, w, h))
         right_click(int(x + w/2), int(y + h/2))
         time.sleep(1)
         rs = wait_element(power_setting_word, cycle=1, offset=(0, 0))
         if rs:
             moveto(rs[0][0], rs[0][1]+5)
             click(rs[0][0], rs[0][1]+5)
             time.sleep(2)
             window = subprocess.getoutput("wmctrl -lx | grep -i 'control panel'")
             if window:
                 log().info("open power manager from tray success")
                 return True
             else:
                 log().error("open power manager from tray fail")
                 return False
         else:
             log().error("open power manager from tray fail")
             return False
     else:                                   # smart zero mode
         k = int(y/2)
         moveto(x-1, k)
         time.sleep(1)
         for j in range(0, 8):
             moveto(x - 1, k)
             click(x - 10, k + 226 - (50 * j))
             time.sleep(0.2)
             right_click(x - 10, k + 226 - (50 * j))
             time.sleep(1)
             os.system("wmctrl -c 'HP Virtual Keyboard'")
             rs = wait_element(power_setting_word, cycle=1, offset=(0, 0))
             if rs:
                 moveto(rs[0][0], rs[0][1] + 5)
                 click(rs[0][0], rs[0][1] + 5)
                 time.sleep(2)
                 window = subprocess.getoutput("wmctrl -lx | grep -i 'control panel'")
                 if window:
                     log().info("open power manager from tray success")
                     return True
                 else:
                     log().error("open power manager from tray fail")
                     return False
         else:
             log().error("open power manager from tray fail")
             return False