Ejemplo n.º 1
0
def get_asset_info(asset):
    asset_path = os.path.join(data_dir.get_download_dir(), '%s.ini' % asset)
    asset_cfg = ConfigParser.ConfigParser()
    asset_cfg.read(asset_path)

    url = asset_cfg.get(asset, 'url')
    sha1_url = asset_cfg.get(asset, 'sha1_url')
    title = asset_cfg.get(asset, 'title')
    destination = asset_cfg.get(asset, 'destination')
    if not os.path.isabs(destination):
        destination = os.path.join(data_dir.get_data_dir(), destination)
    asset_exists = os.path.isfile(destination)

    # Optional fields
    try:
        destination_uncompressed = asset_cfg.get(asset,
                                                 'destination_uncompressed')
        if not os.path.isabs(destination_uncompressed):
            destination_uncompressed = os.path.join(data_dir.get_data_dir(),
                                                    destination)
        uncompress_cmd = asset_cfg.get(asset, 'uncompress_cmd')
    except:
        destination_uncompressed = None
        uncompress_cmd = None


    return {'url': url, 'sha1_url': sha1_url, 'destination': destination,
            'destination_uncompressed': destination_uncompressed,
            'uncompress_cmd': uncompress_cmd, 'shortname': asset,
            'title': title,
            'downloaded': asset_exists}
Ejemplo n.º 2
0
def get_all_assets():
    asset_data_list = []
    download_dir = data_dir.get_download_dir()
    for asset in glob.glob(os.path.join(download_dir, '*.ini')):
        asset_name = os.path.basename(asset).split('.')[0]
        asset_data_list.append(get_asset_info(asset_name))
    return asset_data_list
Ejemplo n.º 3
0
def get_all_assets():
    asset_data_list = []
    download_dir = data_dir.get_download_dir()
    for asset in glob.glob(os.path.join(download_dir, '*.ini')):
        asset_name = os.path.basename(asset).split('.')[0]
        asset_data_list.append(get_asset_info(asset_name))
    return asset_data_list
Ejemplo n.º 4
0
    def __init__(self, address, netperf_path, md5sum="", local_path="",
                 client="ssh", port="22", username="******", password="******",
                 check_command=None):
        """
        Class NetperfPackage just represent the netperf package
        Init NetperfPackage class.

        :param address: Remote host or guest address
        :param netperf_path: Remote netperf path
        :param me5sum: Local netperf package me5sum
        :param local_path: Local netperf (path or link) path
        :param client: The client to use ('ssh', 'telnet' or 'nc')
        :param port: Port to connect to
        :param username: Username (if required)
        :param password: Password (if required)
        """
        super(NetperfPackage, self).__init__(address, client, username,
                                             password, port, netperf_path)

        self.local_netperf = local_path
        self.pack_suffix = ""
        if client == "nc":
            self.prompt = r"^\w:\\.*>\s*$"
            self.linesep = "\r\n"
        else:
            self.prompt = "^\[.*\][\#\$]\s*$"
            self.linesep = "\n"
            if self.remote_path.endswith("tar.bz2"):
                self.pack_suffix = ".tar.bz2"
                self.decomp_cmd = "tar jxvf"
            elif self.remote_path.endswith("tar.gz"):
                self.pack_suffix = ".tar.gz"
                self.decomp_cmd = "tar zxvf"

            self.netperf_dir = self.remote_path.rstrip(self.pack_suffix)
            self.netperf_base_dir = os.path.dirname(self.remote_path)
            self.netperf_exec = os.path.basename(self.remote_path)

        logging.debug("Create remote session")
        self.session = remote.remote_login(self.client, self.address,
                                           self.port, self.username,
                                           self.password, self.prompt,
                                           self.linesep, timeout=360)

        self.build_tool = True
        if check_command:
            netperf_status = self.session.cmd_status("which %s" %
                                                     check_command)
            if netperf_status == 0:
                self.build_tool = False

        if self.build_tool:
            if utils.is_url(local_path):
                logging.debug("Download URL file to local path")
                tmp_dir = data_dir.get_download_dir()
                self.local_netperf = utils.unmap_url_cache(tmp_dir, local_path,
                                                           md5sum)
            self.push_file(self.local_netperf)
Ejemplo n.º 5
0
    def pull_file(self, netperf_source=None):
        """
        Copy file from remote to local.
        """

        if utils.is_url(netperf_source):
            logging.debug("Download URL file to local path")
            tmp_dir = data_dir.get_download_dir()
            self.netperf_source = utils.unmap_url_cache(tmp_dir, netperf_source,
                                                        self.md5sum)
        else:
            self.netperf_source = netperf_source
        return self.netperf_source
Ejemplo n.º 6
0
    def pull_file(self, netperf_source=None):
        """
        Copy file from remote to local.
        """

        if utils.is_url(netperf_source):
            logging.debug("Download URL file to local path")
            tmp_dir = data_dir.get_download_dir()
            self.netperf_source = utils.unmap_url_cache(
                tmp_dir, netperf_source, self.md5sum)
        else:
            self.netperf_source = netperf_source
        return self.netperf_source
Ejemplo n.º 7
0
    def __init__(self, address, netperf_path, md5sum="", local_path="",
                 client="ssh", port="22", username="******", password="******"):
        """
        Class NetperfPackage just represent the netperf package
        Init NetperfPackage class.

        :param address: Remote host or guest address
        :param netperf_path: Remote netperf path
        :param me5sum: Local netperf package me5sum
        :param local_path: Local netperf (path or link) path
        :param client: The client to use ('ssh', 'telnet' or 'nc')
        :param port: Port to connect to
        :param username: Username (if required)
        :param password: Password (if required)
        """
        super(NetperfPackage, self).__init__(address, client, username,
                                             password, port, netperf_path)

        self.local_netperf = local_path
        self.pack_suffix = ""
        if client == "nc":
            self.prompt = r"^\w:\\.*>\s*$"
            self.linesep = "\r\n"
        else:
            self.prompt = "^\[.*\][\#\$]\s*$"
            self.linesep = "\n"
            if self.remote_path.endswith("tar.bz2"):
                self.pack_suffix = ".tar.bz2"
                self.decomp_cmd = "tar jxvf"
            elif self.remote_path.endswith("tar.gz"):
                self.pack_suffix = ".tar.gz"
                self.decomp_cmd = "tar zxvf"

            self.netperf_dir = self.remote_path.rstrip(self.pack_suffix)
            self.netperf_base_dir = os.path.dirname(self.remote_path)
            self.netperf_exec = os.path.basename(self.remote_path)

        if utils.is_url(local_path):
            logging.debug("Download URL file to local path")
            tmp_dir = data_dir.get_download_dir()
            self.local_netperf = utils.unmap_url_cache(tmp_dir, local_path,
                                                       md5sum)
        self.push_file(self.local_netperf)

        logging.debug("Create remote session")
        self.session = remote.remote_login(self.client, self.address,
                                           self.port, self.username,
                                           self.password, self.prompt,
                                           self.linesep, timeout=360)
Ejemplo n.º 8
0
def get_asset_info(asset):
    asset_path = os.path.join(data_dir.get_download_dir(), '%s.ini' % asset)
    asset_cfg = ConfigParser.ConfigParser()
    asset_cfg.read(asset_path)

    url = asset_cfg.get(asset, 'url')
    try:
        sha1_url = asset_cfg.get(asset, 'sha1_url')
    except ConfigParser.NoOptionError:
        sha1_url = None
    title = asset_cfg.get(asset, 'title')
    destination = asset_cfg.get(asset, 'destination')
    if not os.path.isabs(destination):
        destination = os.path.join(data_dir.get_data_dir(), destination)
    asset_exists = os.path.isfile(destination)

    # Optional fields
    try:
        destination_uncompressed = asset_cfg.get(asset,
                                                 'destination_uncompressed')
        if not os.path.isabs(destination_uncompressed):
            destination_uncompressed = os.path.join(data_dir.get_data_dir(),
                                                    destination_uncompressed)
    except:
        destination_uncompressed = None

    try:
        uncompress_cmd = asset_cfg.get(asset, 'uncompress_cmd')
    except:
        uncompress_cmd = None

    return {
        'url': url,
        'sha1_url': sha1_url,
        'destination': destination,
        'destination_uncompressed': destination_uncompressed,
        'uncompress_cmd': uncompress_cmd,
        'shortname': asset,
        'title': title,
        'downloaded': asset_exists
    }
Ejemplo n.º 9
0
def get_asset_info(asset):
    asset_info = {}
    asset_path = os.path.join(data_dir.get_download_dir(), '%s.ini' % asset)
    asset_cfg = test_config.config_loader(asset_path)

    asset_info['url'] = asset_cfg.get(asset, 'url')
    asset_info['sha1_url'] = asset_cfg.get(asset, 'sha1_url')
    asset_info['title'] = asset_cfg.get(asset, 'title')
    destination = asset_cfg.get(asset, 'destination')
    if not os.path.isabs(destination):
        destination = os.path.join(data_dir.get_data_dir(), destination)
    asset_info['destination'] = destination
    asset_info['asset_exists'] = os.path.isfile(destination)

    # Optional fields
    d_uncompressed = asset_cfg.get(asset, 'destination_uncompressed')
    if d_uncompressed is not None and not os.path.isabs(d_uncompressed):
        d_uncompressed = os.path.join(data_dir.get_data_dir(), d_uncompressed)
    asset_info['destination_uncompressed'] = d_uncompressed
    asset_info['uncompress_cmd'] = asset_cfg.get(asset, 'uncompress_cmd')

    return asset_info
Ejemplo n.º 10
0
def get_asset_info(asset):
    asset_info = {}
    asset_path = os.path.join(data_dir.get_download_dir(), "%s.ini" % asset)
    asset_cfg = test_config.config_loader(asset_path)

    asset_info["url"] = asset_cfg.get(asset, "url")
    asset_info["sha1_url"] = asset_cfg.get(asset, "sha1_url")
    asset_info["title"] = asset_cfg.get(asset, "title")
    destination = asset_cfg.get(asset, "destination")
    if not os.path.isabs(destination):
        destination = os.path.join(data_dir.get_data_dir(), destination)
    asset_info["destination"] = destination
    asset_info["asset_exists"] = os.path.isfile(destination)

    # Optional fields
    d_uncompressed = asset_cfg.get(asset, "destination_uncompressed")
    if d_uncompressed is not None and not os.path.isabs(d_uncompressed):
        d_uncompressed = os.path.join(data_dir.get_data_dir(), d_uncompressed)
    asset_info["destination_uncompressed"] = d_uncompressed
    asset_info["uncompress_cmd"] = asset_cfg.get(asset, "uncompress_cmd")

    return asset_info
Ejemplo n.º 11
0
def get_asset_info(asset):
    asset_info = {}
    asset_path = os.path.join(data_dir.get_download_dir(), '%s.ini' % asset)
    asset_cfg = test_config.config_loader(asset_path)

    asset_info['url'] = asset_cfg.get(asset, 'url')
    asset_info['sha1_url'] = asset_cfg.get(asset, 'sha1_url')
    asset_info['title'] = asset_cfg.get(asset, 'title')
    destination = asset_cfg.get(asset, 'destination')
    if not os.path.isabs(destination):
        destination = os.path.join(data_dir.get_data_dir(), destination)
    asset_info['destination'] = destination
    asset_info['asset_exists'] = os.path.isfile(destination)

    # Optional fields
    d_uncompressed = asset_cfg.get(asset, 'destination_uncompressed')
    if d_uncompressed is not None and not os.path.isabs(d_uncompressed):
        d_uncompressed = os.path.join(data_dir.get_data_dir(),
                                      d_uncompressed)
    asset_info['destination_uncompressed'] = d_uncompressed
    asset_info['uncompress_cmd'] = asset_cfg.get(asset, 'uncompress_cmd')

    return asset_info
Ejemplo n.º 12
0
def get_asset_info(asset):
    asset_path = os.path.join(data_dir.get_download_dir(), "%s.ini" % asset)
    asset_cfg = ConfigParser.ConfigParser()
    asset_cfg.read(asset_path)

    url = asset_cfg.get(asset, "url")
    try:
        sha1_url = asset_cfg.get(asset, "sha1_url")
    except ConfigParser.NoOptionError:
        sha1_url = None
    title = asset_cfg.get(asset, "title")
    destination = asset_cfg.get(asset, "destination")
    if not os.path.isabs(destination):
        destination = os.path.join(data_dir.get_data_dir(), destination)
    asset_exists = os.path.isfile(destination)

    # Optional fields
    try:
        destination_uncompressed = asset_cfg.get(asset, "destination_uncompressed")
        if not os.path.isabs(destination_uncompressed):
            destination_uncompressed = os.path.join(data_dir.get_data_dir(), destination)
        uncompress_cmd = asset_cfg.get(asset, "uncompress_cmd")
    except:
        destination_uncompressed = None
        uncompress_cmd = None

    return {
        "url": url,
        "sha1_url": sha1_url,
        "destination": destination,
        "destination_uncompressed": destination_uncompressed,
        "uncompress_cmd": uncompress_cmd,
        "shortname": asset,
        "title": title,
        "downloaded": asset_exists,
    }