def _display_emulator_binaries(self):
        emulator_binaries = dict()

        emulator_dir = clean_path(
            add_ending_slash(str(GlobalConfig.SDK_DIR)) + "emulator/")
        try:
            for the_file in list_files_in_dir(emulator_dir):
                file_path = os.path.join(emulator_dir, the_file)
                if os.path.isfile(file_path) and "emulator" in file_path:
                    binary_name = re.findall("emulator\/(emulator*.+)",
                                             file_path)

                    if binary_name:
                        emulator_binaries[str(binary_name[0])] = file_path
        finally:
            if len(emulator_binaries) == 0:
                message = "Unable to find emulator binary files in direction '{}' of Android SDK."
                message = message.format(str(emulator_dir))
                raise LauncherFlowInterruptedException(self.TAG, message)

            else:
                Printer.system_message(
                    self.TAG,
                    "Emulator related binary files found in Android SDK:")
                for path in emulator_binaries.values():
                    Printer.system_message(
                        self.TAG, "  * " + Color.GREEN + path + Color.BLUE)

        return emulator_binaries
    def _find_latest_build_tools(self):
        build_tools = list_files_in_dir(
            clean_path(add_ending_slash(GlobalConfig.SDK_DIR) + "build-tools"))
        build_tools = [
            build_tool for build_tool in build_tools
            if build_tool[0].isdigit()
        ]
        build_tools_folder_with_highest_ver = None
        Printer.system_message(
            self.TAG,
            "Available Android SDK Build-Tools versions: " + str(build_tools))
        for build_tools_folder in build_tools:
            if build_tools_folder_with_highest_ver is None:
                build_tools_folder_with_highest_ver = build_tools_folder
                continue

            ver = int(re.sub("[^0-9]", "", build_tools_folder))
            highest_ver = int(
                re.sub("[^0-9]", "", build_tools_folder_with_highest_ver))

            if ver > highest_ver:
                build_tools_folder_with_highest_ver = build_tools_folder
        if build_tools_folder_with_highest_ver is None:
            message = "Android SDK Build-Tools not found. Launcher will quit."
            raise LauncherFlowInterruptedException(self.TAG, message)

        else:
            Printer.system_message(
                self.TAG,
                "Android SDK Build-Tools with latest version were selected: " +
                Color.GREEN + str(build_tools_folder_with_highest_ver) +
                Color.BLUE + ".")
        return build_tools_folder_with_highest_ver
 def __init__(self):
     build_tools = self._find_latest_build_tools()
     self.aapt_bin = clean_path(
         add_ending_slash(GlobalConfig.SDK_DIR) + "build-tools/" +
         build_tools + "/aapt")
     self._assert_bin_directory_exists()
     self.aapt_command_assembler = AaptCommandAssembler()
    def apply_config_to_avd(self, avd_schema):
        config_ini_to_apply_filepath = clean_path(
            avd_schema.create_avd_hardware_config_filepath)

        real_config_ini_file_path = clean_path(
            add_ending_slash(GlobalConfig.AVD_DIR) + add_ending_slash("avd") +
            add_ending_slash(avd_schema.avd_name + ".avd") + "config.ini")

        real_config_ini_file = None
        config_ini_to_apply_file = None
        try:
            if os.path.isfile(config_ini_to_apply_filepath):
                config_ini_to_apply_file = open(config_ini_to_apply_filepath,
                                                "r")
                real_config_ini_file = open(real_config_ini_file_path, "w")
                real_config_ini_file.seek(0)
                real_config_ini_file.truncate()

                for config_line in config_ini_to_apply_file.readlines():
                    temp_lane = config_line
                    if "AvdId=" in config_line:
                        temp_lane = ("AvdId=" + str(avd_schema.avd_name) +
                                     "\n")
                    if "avd.ini.displayname=" in config_line:
                        temp_lane = ("avd.ini.displayname=" +
                                     str(avd_schema.avd_name) + "\n")
                    real_config_ini_file.write(temp_lane)
            else:
                message = "Filepath '" + config_ini_to_apply_filepath + "' not found!"
                raise LauncherFlowInterruptedException(self.TAG, message)
        finally:
            if real_config_ini_file is not None:
                real_config_ini_file.close()
            if config_ini_to_apply_file is not None:
                config_ini_to_apply_file.close()

        return "Config.ini successfully applied"
import argparse
import os

from system.file.FileUtils import (clean_path, get_project_root, load_json,
                                   add_ending_slash)

TAG = "ArgLoader:"

CONFIG_FILES_DIR_DEFAULT_DIR = clean_path(
    add_ending_slash(get_project_root()) + "config_files_dir.json")

LAUNCH_MANIFEST_DIR_KEY = "launch_manifest_path"
TEST_MANIFEST_DIR_KEY = "test_manifest_path"
AVD_MANIFEST_DIR_KEY = "avd_manifest_path"
PATH_MANIFEST_DIR_KEY = "path_manifest_path"

config_files_dir = load_json(CONFIG_FILES_DIR_DEFAULT_DIR)


def get_manifest_dir(key):
    if config_files_dir is None:
        return None
    else:
        return config_files_dir[key]


LAUNCH_PLAN_DEFAULT = "default"
TEST_SET_DEFAULT = "default"
AVD_SET_DEFAULT = "default"
PATH_SET_DEFAULT = "default"
示例#6
0
import argparse
import os

from system.file.FileUtils import (
    clean_path,
    get_project_root,
    load_json,
    add_ending_slash
)

TAG = "ArgLoader:"

CONFIG_FILES_DIR_DEFAULT_DIR = clean_path(add_ending_slash(get_project_root()) + "config_files_dir.json")

LAUNCH_MANIFEST_DIR_KEY = "launch_manifest_path"
TEST_MANIFEST_DIR_KEY = "test_manifest_path"
AVD_MANIFEST_DIR_KEY = "avd_manifest_path"
PATH_MANIFEST_DIR_KEY = "path_manifest_path"

config_files_dir = load_json(CONFIG_FILES_DIR_DEFAULT_DIR)


def get_manifest_dir(key):
    if config_files_dir is None:
        return None
    else:
        return config_files_dir[key]


LAUNCH_PLAN_DEFAULT = "default"
TEST_SET_DEFAULT = "default"
 def __init__(self):
     self.adb_bin = clean_path(
         add_ending_slash(GlobalConfig.SDK_DIR) + "platform-tools/adb")
     self._assert_bin_directory_exists()
     self.adb_command_assembler = AdbCommandAssembler()
 def __init__(self):
     self.adb_bin = clean_path(
         add_ending_slash(GlobalConfig.SDK_DIR) + "platform-tools/adb")
     self._assert_bin_directory_exists()
     self.instrumentation_runner_command_assembler = InstrumentationRunnerCommandAssembler(
     )
 def __init__(self):
     self.avdmanager_bin = clean_path(
         add_ending_slash(GlobalConfig.SDK_DIR) + "tools/bin/avdmanager")
     self._assert_bin_directory_exists()
     self.avdmanager_command_assembler = AvdManagerCommandAssembler()