Example #1
0
def get_log_filename(filename):
    """
    Return full path of log file name

    :param filename: Log file name
    :return: str. The full path of the log file
    """
    if aurl.is_url(filename):
        return filename
    return os.path.realpath(
        os.path.abspath(utils_path.get_path(_log_file_dir, filename)))
Example #2
0
def _get_file(src, dst, permissions=None):
    if src == dst:
        return

    if aurl.is_url(src):
        url_download(src, dst)
    else:
        shutil.copyfile(src, dst)

    if permissions:
        os.chmod(dst, permissions)
    return dst
Example #3
0
def get_path(base_path, user_path):
    """
    Translate a user specified path to a real path.
    If user_path is relative, append it to base_path.
    If user_path is absolute, return it as is.

    :param base_path: The base path of relative user specified paths.
    :param user_path: The user specified path.
    """
    if os.path.isabs(user_path) or aurl.is_url(user_path):
        return user_path
    else:
        return os.path.join(base_path, user_path)
Example #4
0
def get_path(base_path, user_path):
    """
    Translate a user specified path to a real path.
    If user_path is relative, append it to base_path.
    If user_path is absolute, return it as is.

    :param base_path: The base path of relative user specified paths.
    :param user_path: The user specified path.
    """
    if os.path.isabs(user_path) or aurl.is_url(user_path):
        return user_path
    else:
        return os.path.join(base_path, user_path)
Example #5
0
    def pull_file(self, netperf_source=None):
        """
        Copy file from remote to local.
        """

        if aurl.is_url(netperf_source):
            LOG.debug("Download URL file to local path")
            tmp_dir = data_dir.get_download_dir()
            dst = os.path.join(tmp_dir, os.path.basename(netperf_source))
            self.netperf_source = download.get_file(src=netperf_source,
                                                    dst=dst,
                                                    hash_expected=self.md5sum)
        else:
            self.netperf_source = netperf_source
        return self.netperf_source
Example #6
0
    def pull_file(self, netperf_source=None):
        """
        Copy file from remote to local.
        """

        if aurl.is_url(netperf_source):
            logging.debug("Download URL file to local path")
            tmp_dir = data_dir.get_download_dir()
            dst = os.path.join(tmp_dir, os.path.basename(netperf_source))
            self.netperf_source = download.get_file(src=netperf_source,
                                                    dst=dst,
                                                    hash_expected=self.md5sum)
        else:
            self.netperf_source = netperf_source
        return self.netperf_source
Example #7
0
def get_file(src, dst, permissions=None):
    """
    Get a file from src and put it in dest, returning dest path.

    :param src: source path or URL. May be local or a remote file.
    :param dst: destination path.
    :param permissions: (optional) set access permissions.
    :return: destination path.
    """
    if src == dst:
        return

    if aurl.is_url(src):
        url_download(src, dst)
    else:
        shutil.copyfile(src, dst)

    if permissions:
        os.chmod(dst, permissions)
    return dst
Example #8
0
 def _copy_file_to_test_dir(file_path):
     if aurl.is_url(file_path):
         return file_path
     file_abs_path = os.path.join(test.bindir, file_path)
     dest = os.path.join(sub_test_path, os.path.basename(file_abs_path))
     return os.path.basename(download.get_file(file_path, dest))
Example #9
0
 def _copy_file_to_test_dir(file_path):
     if aurl.is_url(file_path):
         return file_path
     file_abs_path = os.path.join(test.bindir, file_path)
     dest = os.path.join(sub_test_path, os.path.basename(file_abs_path))
     return os.path.basename(download.get_file(file_path, dest))