def step_impl(context):
    winclient = Windows_Client(RUNNER_CONFIG.get('OEM_CLIENT', "mozypro"))
    import time
    time.sleep(10)
    winclient.gui.restore_panel.select_restore_by_date(
        ConfigAdapter.get_output_path())
    winclient.gui.restore_panel.startrestore()
    winclient.gui.restore_panel.apply()
def stem_impl(context, output_dir):
    root_path = ConfigAdapter.get_installer_path(product='linux')
    output_path = os.path.join(ConfigAdapter.get_output_path(product='linux'),
                               output_dir)
    for mzd_file in FileHelper.find_file(root_path, "*.mzd"):
        LogHelper.info('restore mzd file %s to %s' % (mzd_file, output_path))
        FileHelper.create_directory(output_path)
        LinuxGUIClient.download_cmd.download(mzd=mzd_file,
                                             output=output_path,
                                             overwrite=None)
Exemplo n.º 3
0
def decrypt_files(context, source, dest):
    source_root = ConfigAdapter.get_installer_path('LINUX')
    source_full_path = os.path.join(source_root, source)
    LogHelper.info("Decrypt src {source}".format(source=source_full_path))
    dest_root = ConfigAdapter.get_output_path('LINUX')
    dest_full_path = os.path.join(dest_root, dest)
    FileHelper.create_directory(dest_full_path, True)
    output = LinuxGUIClient.decrypt_cmd.decrypt(source_full_path,
                                                dest_full_path)
    LogHelper.info("Decrypt output {output}".format(output=output))
def step_impl(context, raw_path, raw_output):
    LogHelper.info("start to download %s to %s" % (raw_path, raw_output))
    root_path = ConfigAdapter.get_testdata_path()
    path = os.path.join(root_path, raw_path)
    root_output = ConfigAdapter.get_output_path()
    output = os.path.join(root_output, raw_output)
    LogHelper.info("start to download %s to %s" % (path, output))
    if FileHelper.dir_exist(output):
        FileHelper.delete_directory(output)
    FileHelper.create_directory(output)
    result = LinuxGUIClient.download_cmd.download(path=path,
                                                  output=output,
                                                  overwrite=None)
    LogHelper.info(result)
def step_impl(context, location):
    if location == 'backup':
        LogHelper.info("start to clean backup folder")
        testdata_root = ConfigAdapter.get_testdata_path()
        testdata_dir = testdata_root
        FileHelper.delete_directory(testdata_dir)
    elif location == 'restore':
        LogHelper.info("start to clean restore folder")
        testdata_root = ConfigAdapter.get_restore_path()
        testdata_dir = testdata_root
        FileHelper.delete_directory(testdata_dir)
    elif location == 'output':
        testdata_root = ConfigAdapter.get_output_path()
        testdata_dir = testdata_root
        LogHelper.info("start to clean output folder: %s" % testdata_dir)
        FileHelper.delete_directory(testdata_dir)
Exemplo n.º 6
0
def decrypt_tar(context, dest):
    source_root = ConfigAdapter.get_installer_path('LINUX')
    source_full_path = source_root
    #    for file in os.listdir(source_root):
    #	print(file)
    #        if re.match(r'.*\.tar$', file):
    #             source_full_path = os.path.join(source_root, file)
    tars = FileHelper.find_file(source_root, "*.tar")
    LogHelper.info(tars[-1])
    for file in tars:
        LogHelper.info(file)
        source_full_path = os.path.join(source_root, file)

#    source_full_path = os.path.join(source_root,source)
    LogHelper.info("Decrypt src: {source}".format(source=source_full_path))
    dest_root = ConfigAdapter.get_output_path('LINUX')
    dest_full_path = os.path.join(dest_root, dest)
    FileHelper.create_directory(dest_full_path, True)
    output = LinuxGUIClient.decrypt_cmd.decrypt(source_full_path,
                                                dest_full_path)
    LogHelper.info("Decrypt output {output}".format(output=output))
def step_impl(context, restore_dir, backup_dir):
    testdata_root = ConfigAdapter.get_testdata_path()
    output_root = ConfigAdapter.get_output_path()
    restore_file_path = os.path.join(output_root, restore_dir)
    backup_file_path = os.path.join(testdata_root, backup_dir)
    LogHelper.info('restore_file_path is {0}'.format(restore_file_path))
    LogHelper.info('backup_file_path is {0}'.format(backup_file_path))
    if PlatformHelper.is_mac():
        result = FileHelper.is_dir_same(restore_file_path,
                                        backup_file_path,
                                        exclude_pattern='.DS_Store')
    else:
        result = FileHelper.is_dir_same(restore_file_path, backup_file_path)

    if result:
        for diff in result:
            LogHelper.error("diff files found {path}".format(path=diff))
    try:
        len(result).should.equal(0)
    except AssertionError as e:
        LogHelper.error(e.message)
        raise e
    def run_mzd_restore(cls, dest, personal_key=None, index=-1):
        """
        select mzd reuqest to restore files
        :param dest:  restore file destination, dertermine to root config and dest
        :param personal_key: personal key, if not None, input personal key during restore process
        :param index: mzd list
        :return: Boolean. if restore complete, true. otherwise false
        """

        output_path = ConfigAdapter.get_output_path()
        output_path = os.path.join(output_path, dest)
        if FileHelper.dir_exist(output_path):
            FileHelper.delete_directory(output_path)
        FileHelper.create_directory(output_path)
        cmd = MacFryR_Controller.prefix_for_sudo() + 'sudo -S chmod -R 777 "{path}"'.format(path=output_path)
        CmdHelper.run(cmd)

        LogHelper.info('Select %s to generate mzd request' % output_path)

        try:
            LogHelper.info("Multiple restore jobs found, automation will select the latest job to do the restore.")
            MacFryrElement({'AXRole': 'AXRow'}, index, 10).left_click()
            MacFryrElement({'AXRole': 'AXButton', 'AXIdentifier': '_NS:29'}).click()
        except:
            LogHelper.info("Only one restore job found, automation will do restore with the default job.")

        MacFryrElement({'AXRole': 'AXRadioButton', 'AXDescription': 'selectNewLocationRadio'}, wait_time=5).click()
        time.sleep(2)
        root = MacUIUtils.get_root_volume_name()
        pop_menu = MacFryrElement({'AXRole': 'AXPopUpButton'}, 0, 10).element

        app = pop_menu.getApplication()

        MacUIUtils.click_popmenu_item_by_value(pop_menu, root)
        browser_window = MacUIUtils.wait_element(app, AXRole='AXWindow', AXTitle='Open')
        browser_handle = MacUIUtils.wait_element(browser_window, AXRole='AXBrowser')
        MacUIUtils.select_nodes(browser_handle, output_path, node_matcher='AXTextField')
        # MacFryrElement({'AXTitle': 'New Folder'}).click()
        # MacFryrElement({'AXIdentifier': '_NS:43'}, 0, 5).send_keys(dest)
        # MacFryrElement({'AXIdentifier': '_NS:53'}).click()
        btn_open = MacUIUtils.wait_element(browser_window, AXRole='AXButton', AXTitle='Open')
        MacUIUtils.click_button(btn_open)
        MacFryrElement({'AXRole': 'AXButton', 'AXIdentifier': '_NS:29'}).click()

        if personal_key:
            LogHelper.info('input personal key %s' % personal_key)
            el = MacUIUtils.wait_element(app, timeout=120, AXRole='AXTextField', AXDescription='privateKeyField')
            MacUIUtils.input_text(el, personal_key)
            LogHelper.info('click next button')
            btn_next = MacFryrElement({'AXRole': 'AXButton', 'AXTitle': 'Next'})
            btn_next.click()

        MacFryrElement({'AXRole': 'AXButton', 'AXIdentifier': '_NS:29'}).click()
        time.sleep(3)

        from apps.mac.mac_gui_installer.mac_gui_installer import AppUIElement
        try:
            textbox_psd = AppUIElement.from_bundle('com.apple.SecurityAgent',
                                               {'AXRole': 'AXTextField', 'AXSubrole': 'AXSecureTextField'}, 0, 10)
        except ValueError:
            LogHelper.info("Security Agent is not found")
            textbox_psd = None

        if textbox_psd and textbox_psd.element:
            password = MAC_CONFIG.get("LOCAL_ADMIN_PASSWORD")
            textbox_psd.send_keys(password)
            time.sleep(1)
            btn_ok = AppUIElement.from_bundle('com.apple.SecurityAgent', {'AXRole': 'AXButton', 'AXTitle': 'OK'})
            btn_ok.left_click()
            time.sleep(1)

        cls.wait_restore_finished()