def get_archive_name(): download_path = ConfigAdapter.get_installer_path() for file in FileHelper.find_file(download_path, '*'): file = os.path.basename(file) pattern = r'restore_(.+?).zip' if re.match(pattern, file): return file
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
def download(job, build, pattern): jh = JenkinsHelper(GLOBAL_CONFIG["JENKINS"]["URL"], GLOBAL_CONFIG["JENKINS"]["USERNAME"], GLOBAL_CONFIG["JENKINS"]["KEY"]) dest = ConfigAdapter.get_installer_path(product='LINUX') return jh.download_packages(jh.get_packages(job, build, pattern), dest=dest)
def download_and_install(cls, build, job): volume_name = cls.get_subdir() if volume_name is not None: CmdHelper.run("diskutil eject '" + volume_name + "'") LogHelper.info( "Prepare download Mozy Restore Manager from jenkins, build number is " + job) jh = JenkinsHelper(GLOBAL_CONFIG["JENKINS"]["URL"], GLOBAL_CONFIG["JENKINS"]["USERNAME"], GLOBAL_CONFIG["JENKINS"]["KEY"]) dest = ConfigAdapter.get_installer_path('MACFRYR') LogHelper.info('Clean up existing files') for file in FileHelper.find_file(dest, '*'): LogHelper.debug('Delete file %s' % file) FileHelper.delete_file(file) pattern = 'mozy-fryr' packages = jh.download_packages(jh.get_packages(job, build, pattern), dest=dest) TARGET_APP = '/Applications/Mozy Restore Manager.app' if os.path.exists(TARGET_APP): shutil.rmtree(TARGET_APP) image_path = packages[0] mount_cmd = 'sudo hdiutil attach {package}'.format(package=image_path) CmdHelper.run(mount_cmd) volume_name = cls.get_subdir() ORIGIN_APP = '/Volumes/' + volume_name + '/Mozy Restore Manager.app' shutil.copytree(ORIGIN_APP, TARGET_APP)
def download_from_mozy(pattern): dl = Download_Helper(GLOBAL_CONFIG["MOZY.COM"]["URL2"]) dest = ConfigAdapter.get_installer_path(product='LINUX') packages = [] packages.append( dl.download_package(dl.get_download_url(pattern), dest=dest)) return packages
def get_mzd_path(): download_path = ConfigAdapter.get_installer_path().replace( "\\\\", "\\") for file in os.listdir(download_path): if re.match(r'restore_.*\.mzd$', file): file = os.path.join(download_path, file) LogHelper.info("Get mzd target path: " + file) return file
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)
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 clear_download_folder(): directory = ConfigAdapter.get_installer_path('MACFRYR') if platform.system() == "Windows": directory = "C:/" + ConfigAdapter.get_testdata_path( 'WINFRYR').split('\\\\')[1] for file in FileHelper.find_file(directory, '*'): LogHelper.debug('Delete file %s' % file) os.remove(file) for folder in FileHelper.find_dir(directory, '*'): LogHelper.debug('Delete folder %s' % folder) try: shutil.rmtree(folder) except: pass
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()
def download_fb( cls, product=None, dry_run=False, ): current_platform = PlatformHelper.get_system() fb_site = "https://artifacts.elastic.co/downloads/beats/filebeat/" package_name = "" if current_platform == "Linux" and PlatformHelper.get_arch( ) == "deb-64": package_name = 'filebeat-5.2.0-amd64.deb' if current_platform == "Linux" and PlatformHelper.get_arch( ) == "deb-32": package_name = 'filebeat-5.2.0-i386.deb' if current_platform == "Windows": package_name = 'filebeat-5.2.0-windows-x86_64.zip' if current_platform == "Darwin": package_name = 'filebeat-5.2.0-darwin-x86_64.tar.gz' installer_dir = ConfigAdapter.get_installer_path(product) cls.package_name = package_name installer_path = os.path.join(installer_dir, package_name) url = fb_site + package_name LogHelper.info("installer_path is " + installer_path) LogHelper.info("package url is " + url) if not FileHelper.dir_exist(installer_dir): FileHelper.create_directory(installer_dir) if FileHelper.file_exist(installer_path): FileHelper.delete_file(installer_path) if not dry_run: downloaded_package = urllib2.urlopen(url) LogHelper.info("download result is %s" % downloaded_package) with open(installer_path, 'wb') as output: output.write(downloaded_package.read()) return installer_path
def download_package(cls, job, build, pattern): """ :return: """ jh = JenkinsHelper(GLOBAL_CONFIG["JENKINS"]["URL"], GLOBAL_CONFIG["JENKINS"]["USERNAME"], GLOBAL_CONFIG["JENKINS"]["KEY"]) dest = ConfigAdapter.get_installer_path(product='MAC') # Delete existing images before downloading import glob images = glob.glob(dest + '/*.dmg') for path in images: FileHelper.delete_file(path) package = jh.get_packages(job, build, pattern) return jh.download_packages(package, dest=dest)
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 download_and_install(cls, build, job): # pass WinFryR_Installer.uninstall(False) LogHelper.info( "Prepare download Mozy Restore Manager from jenkins, build number is " + job) jh = JenkinsHelper(GLOBAL_CONFIG["JENKINS"]["URL"], GLOBAL_CONFIG["JENKINS"]["USERNAME"], GLOBAL_CONFIG["JENKINS"]["KEY"]) dest = ConfigAdapter.get_installer_path('WINFRYR') LogHelper.info('Clean up existing files') for file in FileHelper.find_file(dest, '*'): LogHelper.debug('Delete file %s' % file) FileHelper.delete_file(file) pattern = 'mozy-fryr' packages = jh.download_packages(jh.get_packages(job, build, pattern), dest=dest) for package in packages: if str(package).endswith('setup.exe'): LogHelper.info("Prepare to install Mozy Restore Manager.") install_cmd = "%s" % (package) CmdHelper.run(install_cmd) break
def download_and_install(build, job): jh = JenkinsHelper(GLOBAL_CONFIG["JENKINS"]["URL"], GLOBAL_CONFIG["JENKINS"]["USERNAME"], GLOBAL_CONFIG["JENKINS"]["KEY"]) dest = ConfigAdapter.get_installer_path('ANDROID') jh.download_packages(jh.get_packages(job, build), dest=dest)
def clear_installer_folder(product_name): directory = ConfigAdapter.get_installer_path(product_name) for file in FileHelper.find_file(directory, '*'): LogHelper.debug('Delete file %s' % file) FileHelper.delete_file(file)
def public_restore_flow(encrypt_type='default', encrypt_key=None): # If multiple restore jobs found, then automation will select the latest job to do the restore. # Below try catch is to process the multi-restore job scenarios try: MacFryrElement({'AXRole': 'AXRow'}, -1, 10).left_click() LogHelper.info("Multiple restore jobs found, automation will select the latest job to do the restore.") 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'}).click() MacFryrElement({'AXValue': 'Documents'}).left_click() MacFryrElement({'AXIdentifier': '_NS:64'}).mouse_click({'AXValue': 'auto_restore'}) MacFryrElement({'AXRole': 'AXButton', 'AXIdentifier': '_NS:97'}).click() MacFryrElement({'AXRole': 'AXButton', 'AXIdentifier': '_NS:29'}).click() if encrypt_type == 'pkey': MacFryrElement({'AXRole': 'AXTextField', 'AXIdentifier': '_NS:502'}).force_send(encrypt_key) MacFryrElement({'AXRole': 'AXButton', 'AXIdentifier': '_NS:29'}).click() elif encrypt_type == 'ckey' or encrypt_type == 'rkey': command = 'cp ' + os.path.dirname(os.path.dirname(__file__)) + '/' + encrypt_key + ' ' + ConfigAdapter.get_installer_path() CmdHelper.run(command) MacFryrElement({'AXRole': 'AXButton', 'AXIdentifier': '_NS:495'}).click() MacFryrElement({'AXIdentifier': '_NS:81'}).click() MacFryrElement({'AXTitle': 'Macintosh HD'}).click() MacFryrElement({'AXIdentifier': '_NS:64'}).mouse_click({'AXValue': 'fryr_installer'}) MacFryrElement({'AXRole': 'AXButton', 'AXIdentifier': '_NS:97'}).click() MacFryrElement({'AXIdentifier': '_NS:64'}).mouse_click({'AXValue': encrypt_key}) MacFryrElement({'AXRole': 'AXButton', 'AXIdentifier': '_NS:97'}).click() MacFryrElement({'AXRole': 'AXButton', 'AXIdentifier': '_NS:29'}).click() MacFryrElement({'AXRole': 'AXButton', 'AXIdentifier': '_NS:29'}).click()