def set_secret_key(plain_text_key):
    encoded_key = False
    # Checks the length of the plain text secret key
    if not len(plain_text_key) == 16:
        print_error("The secret key needs to be exactly 16 characters in length"
                    ". {0} is {1} characters in length."
                    .format(plain_text_key, len(plain_text_key)))
        status = False
    else:
        # Gets base 64 encoding for the plain text secret key
        encoded_key = base64.b64encode(plain_text_key)

        # Gets path to Tools
        path = Tools.__path__[0]

        # creates admin directory if that does not exist
        path = file_Utils.createDir(path, "admin")

        # creates secret.key file if it does not exists. Writes the base 64
        # encoded key to it.
        path = os.path.join(path, "secret.key")
        with open(path, 'w') as f:
            f.write(encoded_key)

        status = True
    return status, encoded_key
 def create_tmp_dir(self):
     """
         Create a temp directory for parallel execution test
     """
     path = file_Utils.createDir(file_Utils.getDirName(self.logsdir), "tmp")
     return True, {
         "parallel_exec_tmp_dir":
         os.path.join(file_Utils.getDirName(self.logsdir), "tmp")
     } if path else False
 def compute_system_resultfile(self, kw_resultfile_list, resultsdir,
                               system_name):
     """Takes a list of steps as input and executes them in sequential
     order by sending them to test case steps execution driver
     """
     system_results_dir = file_Utils.createDir(resultsdir, 'System_Results')
     system_resultfile = file_Utils.getCustomLogFile(
         'system', system_results_dir, system_name, '.xml')
     testcase_Utils.append_result_files(system_resultfile,
                                        kw_resultfile_list,
                                        dst_root='System')
     return system_resultfile
def set_secret_key(plain_text_key):
    """
    Function that saves base64 encoded
    format of  secret key, passed to this
    function and saved to secret.key file

    Args:
        plain_text_key - Plain text key, that is is used for encryption

    Return:
        status - True if key is base64 encoded and saved
                 False if not saved
        key - base64 endoced key
    """
    encoded_key = False
    # Checks the length of the plain text secret key
    if not len(plain_text_key) == 16:
        print_error("The secret key needs to be exactly 16 characters in length"
                    ". {0} is {1} characters in length."
                    .format(plain_text_key, len(plain_text_key)))
        status = False
    else:
        # Gets base 64 encoding for the plain text secret key
        encoded_key = base64.b64encode(plain_text_key)

        # Gets path to Tools
        path = Tools.__path__[0]

        # creates admin directory if that does not exist
        path = file_Utils.createDir(path, "admin")

        # creates secret.key file if it does not exists. Writes the base 64
        # encoded key to it.
        path = os.path.join(path, "secret.key")
        with open(path, 'w') as f:
            f.write(encoded_key)

        status = True
    return status, encoded_key