Example #1
0
def step_impl(context):
    result = MacGUIInstaller.is_setup_assistant_launched(120)
    result.should.equal(True)

    env = RUNNER_CONFIG.get('ENVIRONMENT')
    MacController.setup_qa_env(env)
    MacController.kill_system_preference()
Example #2
0
def step_impl(context):
    result = MacInstaller.install_from_volumes()
    result.should.equal(True)

    env = RUNNER_CONFIG.get('ENVIRONMENT')
    MacController.setup_qa_env(env)

    MacInstaller.eject_images('Mozy')
Example #3
0
def step_impl(context):
    if MacController().is_installed():
        MacInstaller.uninstall_package()

    result = MacController().is_installed()
    result.should.equal(False)

    if MacController.check_process_by_name('System Preferences'):
        MacController.kill_system_preference()
Example #4
0
def step_impl(context):
    brand = RUNNER_CONFIG.get('OEM_CLIENT')
    normalize_brand = MacController.normalize_brand_name(brand)

    result = MacController.check_process_by_name(normalize_brand + 'Backup')
    result.should.equal(True)

    result = MacController.check_process_by_name(normalize_brand + ' Status')
    result.should.equal(True)
    def download_and_install(cls, build=-1, job='', pattern=r''):
        if build == 0:
            # keep current build
            return True

        if not pattern:
            pattern = cls.default_pattern

        if not job:
            job = cls.default_job

        version = MacController().get_version()
        LogHelper.info('Current build number is {}'.format(version))

        if version == 0:  # not installed
            package = cls.download_package(job=job,
                                           build=build,
                                           pattern=pattern)
            result = cls.install_package(package[0])
        elif build == -1 or version != build:
            cls.uninstall_package()
            package = cls.download_package(job=job,
                                           build=build,
                                           pattern=pattern)
            result = cls.install_package(package[0])

        else:
            # not install happen
            result = True
        return result
    def __get_downloaded_image(cls):
        result = None

        import glob
        installer_path = ConfigAdapter.get_installer_path(product='MAC')
        build = RUNNER_CONFIG.get("BUILD")
        images = glob.glob(installer_path +
                           '/*{build}*.dmg'.format(build=build))

        if len(images) != 0:  # == 0:
            # raise StandardError('Package was not downloaded successfully')
            result = images[0]
        else:
            job = RUNNER_CONFIG.get("JOB")
            if job is None or job == 'null':
                job = cls.default_job

            brand = RUNNER_CONFIG.get("OEM_CLIENT")
            if brand is None or brand == 'null':
                pattern = cls.default_pattern
            else:
                pattern = ".*" + MacController.normalize_brand_name(
                    brand) + ".*"

            packages = cls.download_package(job, build, pattern)
            if len(packages) != 0:
                result = packages[0]

        return result
Example #7
0
def step_impl(context):
    result = True
    matcher = {'AXRole': 'AXSheet'}
    sheet_history = AppUIElement.from_bundle(MacController().spbundleid,
                                             matcher)
    if sheet_history is None:
        result = False
    result.should.equal(True)

    matcher = {'AXRole': 'AXRow', 'AXSubrole': 'AXTableRow'}
    first_entry = sheet_history.find_child(matcher)
    first_entry.left_click()
    time.sleep(1)
    matcher = {'AXRole': 'AXStaticText', 'AXValue': '1 / 1'}
    text_file_sent = sheet_history.find_child(matcher)
    if text_file_sent is None:
        result = False
    matcher = {'AXRole': 'AXStaticText', 'AXValue': 'Success'}
    text_result = sheet_history.find_child(matcher)
    if text_result is None:
        result = False
    result.should.equal(True)

    matcher = {'AXRole': 'AXButton', 'AXTitle': 'Done'}
    btn_done = sheet_history.find_child(matcher)
    btn_done.click()
Example #8
0
def step_impl(context, text):
    result = True
    time.sleep(2)
    # btn_text = MacGUIClient().summary_tab.get_title_btn_backup()
    # btn_text.should.equal(text)
    matcher = {'AXRole': 'AXButton'}
    matcher['AXTitle'] = text
    btn_backup = AppUIElement.from_bundle(MacController().spbundleid, matcher)
    if btn_backup is None:
        result = False
    result.should.equal(True)
    def mount_image_and_launch_installer(cls):
        if MacController.check_process_by_name('Installer'):
            cmd = MacController.prefix_for_sudo() + "sudo -S killall Installer"
            CmdHelper.run(cmd)

        cls.eject_images('Mozy')
        image_path = cls.__get_downloaded_image()
        if image_path is None:
            raise StandardError('Package was not downloaded successfully')

        volume = cls.__mount_image(image_path=image_path)
        pkg_path = os.path.join(volume, 'Mozy.pkg')

        LogHelper.info("Launch GUI installer")
        launch_cmd = 'open "{pkg}"'.format(pkg=pkg_path)
        CmdHelper.run(launch_cmd)

        if not MacController.check_process_by_name('Installer'):
            raise StandardError('Installer was not launched successfully')

        return True
def step_impl(context, menuname):
    brand = RUNNER_CONFIG.get('OEM_CLIENT')
    status_app_name = MacController.normalize_brand_name(brand) + " Status"
    status_menu = StatusMenu(status_app_name)
    context.status_menu = status_menu

    status_menu.expand()
    time.sleep(1)
    status_menu.click_menu_item(menuname)
    status_menu.collapse()

    if menuname == 'Pause Backup':
        time.sleep(10)
Example #11
0
    def is_setup_assistant_launched(wait_time=60):
        result = False
        spbundleid = MacController().spbundleid
        app = None
        wait_t = wait_time
        while app is None and wait_t > 0:
            time.sleep(1)
            app = atomac.getAppRefByBundleId(spbundleid)
            wait_t -= 1

        window = None
        if app is not None:
            window = AppUIElement(app, {'AXRole': 'AXWindow'}, 0, wait_time)

        if window is not None:
            brand = RUNNER_CONFIG.get('OEM_CLIENT')
            window_name = MacController.normalize_brand_name(brand)
            title = window.get_title()
            if title == window_name:
                result = True

        return result
 def __kill_security_agent():
     is_sa_exist = False
     find_cmd = 'lsappinfo find name=SecurityAgent'
     output = CmdHelper.run(find_cmd).replace('\n','')
     wait_time = 0
     while (not output) and wait_time<60:
         time.sleep(5)
         wait_time += 5
         output = CmdHelper.run(find_cmd)
     if wait_time>=60:
         print 'timeout'
     if output:
         cmd = MacController.prefix_for_sudo() + 'sudo -S killall -9 "SecurityAgent"'
         CmdHelper.run(cmd)
Example #13
0
def step_impl(context, text):
    result = True
    matcher = {'AXRole': 'AXWindow', 'AXSubrole': 'AXDialog'}
    dialog = AppUIElement.from_bundle(MacController().spbundleid, matcher, 0,
                                      30)
    if dialog.element is None:
        result = False
    result.should.equal(True)
    context.dialog = dialog

    matcher = {'AXRole': 'AXStaticText'}
    matcher['AXValue'] = text
    message = dialog.find_child(matcher)
    message.exists().should.equal(True)
Example #14
0
def step_impl(context, number):
    brand = RUNNER_CONFIG.get('OEM_CLIENT')
    status_app_name = MacController.normalize_brand_name(brand) + " Status"
    status_menu = StatusMenu(status_app_name)
    status_menu.expand()
    title = status_menu.get_menu_text_by_index(0)
    str_number = format(int(number), ',')
    str_backedup = 'Backed Up: {number} files'.format(number=str_number)
    result = title.startswith(str_backedup)
    result.should.equal(True)

    if title.find('--') != -1:
        result = False
    result.should.equal(True)
    status_menu.collapse()
    def start_app():
        #check that where mozy is installed
        if MacController().is_installed():
            current_wait_second = 0
            result = MacGUIClient.launch_mozy_application()
            while (not result) and current_wait_second < 120:
                sleep_time = 5
                time.sleep(sleep_time)
                result = MacGUIClient.launch_mozy_application()
                current_wait_second += sleep_time

            return result
        else:
            # mac client is not installed
            raise Exception('Mac Client is not installed')
    def __silent_install(cls, pkg_path):
        LogHelper.info("start to install")
        install_cmd = MacController.prefix_for_sudo(
        ) + "sudo -S /usr/sbin/installer -pkg \"{path}\" -target {dest}".format(
            path=pkg_path, dest="/")
        output = CmdHelper.run(install_cmd)

        LogHelper.debug(output)
        if output.find('successful') > 0:
            LogHelper.debug("Install successfully")
            result = True
        else:
            LogHelper.error("Install failed")
            result = False

        return result
def before_tag(context, tag):
    if tag == "cleanup":
        testdata = ConfigAdapter.get_testdata_path()
        output = ConfigAdapter.get_output_path()
        installer_path = ConfigAdapter.get_installer_path()
        FileHelper.delete_directory(testdata)
        FileHelper.delete_directory(output)
        FileHelper.delete_directory(installer_path)

    if tag == "cleandownload":
        downloadpath = ConfigAdapter.get_output_path()
        FileHelper.delete_directory(downloadpath)

    if tag == "mac_setup":
        MacCliClient().rule_cmd.remove_all_rules()
        MacController().restart_mozypro_pid()
Example #18
0
    def is_installer_launched():
        # print MacController.check_process_by_name("Installer")
        result = False
        if not MacController.check_process_by_name("Installer"):
            return result

        str_oem = RUNNER_CONFIG.get('OEM_CLIENT').lower()
        installer_win = AppUIElement.from_bundle('com.apple.installer',
                                                 {'AXRole': 'AXWindow'}, 0, 10)

        if installer_win is not None:
            str_title = installer_win.get_title().lower()
            if str_title.find(str_oem) != -1:
                result = True

        return result
    def uninstall_package(cls, removeconfig=True):
        """
        :return:
        """
        result = False
        uninstall_cmd = MacController.prefix_for_sudo(
        ) + "sudo -S MozyProBackup uninstall"

        if removeconfig:
            uninstall_cmd += " --removeconfig"

        output = CmdHelper.run(uninstall_cmd)
        if output.find('Uninstall thread done') > 0:
            result = True
            LogHelper.debug("Uninstall mozypro successfully")
        else:
            LogHelper.error("something went wrong with uninstall")

        return result
Example #20
0
def step_impl(context, backup_set_name):
    step_str = 'When I visit "Files & Folders" tab'
    context.execute_steps(unicode(step_str))
    # MacCliClient().rule_cmd.remove_all_rules()
    files_folder_tab = MacGUIClient().files_folder_tab
    files_folder_tab.click_advance_button()
    files_folder_tab.show_suggested_backup_sets()

    matcher = {'AXRole': 'AXTextField'}
    matcher['AXValue'] = backup_set_name + "*"
    tr_text_doc = AppUIElement.from_bundle(MacController().spbundleid, matcher)
    matcher = {'AXRole': 'AXCheckBox'}
    tr_checkbox_doc = AppUIElement(tr_text_doc.get_native_parent(), matcher)
    tr_checkbox_doc.left_click()
    matcher = {'AXRole': 'AXButton', 'AXTitle': 'OK'}
    btn_ok = AppUIElement(tr_text_doc.get_native_ancestor(level=4), matcher)
    btn_ok.click()

    time.sleep(5)
    files_folder_tab.click_OK_button()
    def launch_mozy_application():
        """
        launch app
        :return:
        """
        bundleId = MacController().spbundleid
        WindowName = 'MozyPro'
        try:
            atomac.launchAppByBundleId(bundleId)
        except RuntimeError as e:
            print e.message
        mozy_window = None

        app = atomac.getAppRefByBundleId(bundleId)
        window = MacUIUtils.wait_element(app, AXRole='AXWindow')
        app.activate()
        btn_showall = MacUIUtils.wait_element(window,
                                              AXRole='AXButton',
                                              AXTitle='Show All')
        MacUIUtils.click_button(btn_showall)
        window = MacUIUtils.wait_element(app, AXRole='AXWindow')

        title = window.AXTitle
        if title == 'MozyPro':  # it is already mozy window
            mozy_window = window
        elif title == "System Preferences":
            btn_mozypro = MacUIUtils.wait_element(app,
                                                  AXRole='AXButton',
                                                  AXTitle=WindowName)
            btn_mozypro.Press()
            mozy_window = MacUIUtils.wait_element(app,
                                                  AXRole='AXWindow',
                                                  AXTitle=WindowName)
        else:
            raise Exception('Not implemented yet')

        if mozy_window.AXRole:
            MacMozyUIBase.mozy_window = mozy_window
            return mozy_window
        else:
            return False
    def __mount_image(cls, image_path):
        LogHelper.debug("check that package is existed")
        if not FileHelper.file_exist(image_path):
            raise StandardError(
                'file {package} is not existed'.format(package=image_path))

        LogHelper.debug("mount dmg")
        mount_cmd = MacController.prefix_for_sudo(
        ) + 'sudo -S hdiutil attach {package}'.format(package=image_path)
        output = CmdHelper.run(mount_cmd)
        LogHelper.debug("mount result is {output}".format(output=output))

        mounted_volumes = cls.__find_mounted_volume(pattern='.*MozyPro.*')

        if len(mounted_volumes) > 1:
            LogHelper.error(
                "More than one volume deteched, something went wrong")

        mounted_volume = mounted_volumes[-1]

        return mounted_volume
def step_impl(context):
    brand = RUNNER_CONFIG.get('OEM_CLIENT')
    status_app_name = MacController.normalize_brand_name(brand) + " Status"
    status_menu = StatusMenu(status_app_name)
    context.status_menu = status_menu
    status_menu.right_click()
Example #24
0
def step_impl(context):
    result = MacController().is_client_running()
    result.should.equal(True)
Example #25
0
def step_impl(context):
    if not MacController.check_process_by_name("System Preferences"):
        MacGUIClient().start_app()
    username = MacGUIClient().summary_tab.get_current_username()
    username.should.equal(context.username)
Example #26
0
def step_impl(context):
    #MacController().clean_db()
    MacController().clean_all()
    env = RUNNER_CONFIG.get('ENVIRONMENT') or "QA12"
    MacController.setup_qa_env(env)
Example #27
0
def step_impl(context):
    brand = RUNNER_CONFIG.get('OEM_CLIENT')
    normalize_brand = MacController.normalize_brand_name(brand)

    result = MacInstaller.files_installed(normalize_brand)
    result.should.equal(True)
Example #28
0
 def __init__(self, oem="mozypro"):
     self._controller = MacController()
     self._installer = MacInstaller()
     #Add oem support
     self._cli = MacGUIClient()
     self._gui = MacCliClient()