Exemple #1
0
 def _create_apk_dir_if_not_exists(self):
     if FileUtils.dir_exists(GlobalConfig.APK_DIR):
         Printer.system_message(
             self.TAG, "Directory " + Color.GREEN + GlobalConfig.APK_DIR +
             Color.BLUE + " was found.")
     else:
         Printer.system_message(
             self.TAG, "Directory " + Color.GREEN + GlobalConfig.APK_DIR +
             Color.BLUE + " not found. Creating...")
         FileUtils.create_dir(GlobalConfig.APK_DIR)
Exemple #2
0
def _create_logcats():
    logcat_html_path = GlobalConfig.OUTPUT_LOGCAT_HTML_DIR
    if not os.path.isdir(logcat_html_path):
        FileUtils.create_dir(logcat_html_path)

    logcats = load_logcats(GlobalConfig.OUTPUT_TEST_LOGCAT_DIR)
    for logcat_dict in logcats:
        file_dir = logcat_html_path
        file_name = logcat_dict["test_name"]
        file_extension = "html"
        file = "{}{}.{}".format(file_dir, file_name, file_extension)

        with open(file, "w", encoding="utf-8") as html_file:
            html_content = _generate_logcat_html(logcat_dict)
            html_file.write(html_content)
Exemple #3
0
    def prepare_output_directories(self):
        if FileUtils.dir_exists(GlobalConfig.OUTPUT_DIR):
            Printer.system_message(
                self.TAG, "Directory " + Color.GREEN +
                GlobalConfig.OUTPUT_DIR + Color.BLUE +
                " found!. Only session related directories and files will be cleaned."
            )
        else:
            Printer.system_message(
                self.TAG,
                "Directory " + Color.GREEN + GlobalConfig.OUTPUT_DIR +
                Color.BLUE + " not found. Creating...")

        for directory in [
                GlobalConfig.OUTPUT_SUMMARY_LOG_DIR,
                GlobalConfig.OUTPUT_AVD_LOG_DIR,
                GlobalConfig.OUTPUT_TEST_LOG_DIR,
                GlobalConfig.OUTPUT_TEST_LOGCAT_DIR,
                GlobalConfig.OUTPUT_STYLES_FOLDER_DIR,
                GlobalConfig.OUTPUT_LOGCAT_HTML_DIR,
                GlobalConfig.OUTPUT_TEST_RECORDINGS_DIR
        ]:

            if FileUtils.dir_exists(directory):
                files_num = 0 if FileUtils.list_files_in_dir(
                    directory) is None else len(
                        FileUtils.list_files_in_dir(directory))
                Printer.system_message(
                    self.TAG, "Directory " + Color.GREEN + directory +
                    Color.BLUE + " was found. Removing (" + Color.GREEN +
                    str(files_num) + " files" + Color.BLUE + ").")
                FileUtils.clear_dir(directory)
            else:
                Printer.system_message(
                    self.TAG, "Directory " + Color.GREEN + directory +
                    Color.BLUE + " not found. Creating...")
                FileUtils.create_dir(directory)

        if FileUtils.file_exists(GlobalConfig.OUTPUT_INDEX_HTML_DIR):
            Printer.system_message(
                self.TAG, "Removing " + Color.GREEN +
                GlobalConfig.OUTPUT_INDEX_HTML_DIR + Color.BLUE +
                " file from previous session.")