Ejemplo n.º 1
0
def download_assets():
    all_assets = asset.get_all_assets()
    if all_assets:
        logging.info("Available download assets:")
        logging.info("")
        for asset_info in all_assets:
            asset_keys = asset_info.keys()
            logging.info("%d - %s" % (all_assets.index(asset_info) + 1,
                         asset_info['title']))
            asset_keys.pop(asset_keys.index('title'))
            asset_keys.sort()
            for k in asset_keys:
                logging.info("    %s = %s" % (k, asset_info[k]))
            logging.info("")
    indexes = raw_input("%s INFO | Type the index for the assets you want to "
                        "download (comma separated, Ctrl+C to abort): " %
                        time.strftime("%H:%M:%S", time.localtime()))

    index_list = []

    for idx in indexes.split(","):
        try:
            index = int(idx) - 1
            index_list.append(index)
            all_assets[index]
        except (ValueError, IndexError):
            logging.error("Invalid index(es), aborting...")
            sys.exit(1)

    for idx in index_list:
        asset_info = all_assets[idx]
        asset.download_file(asset_info, interactive=True)
Ejemplo n.º 2
0
def download_assets():
    all_assets = asset.get_all_assets()
    if all_assets:
        logging.info("Available download assets:")
        logging.info("")
        for asset_info in all_assets:
            asset_keys = asset_info.keys()
            logging.info(
                "%d - %s" %
                (all_assets.index(asset_info) + 1, asset_info['title']))
            asset_keys.pop(asset_keys.index('title'))
            asset_keys.sort()
            for k in asset_keys:
                logging.info("    %s = %s" % (k, asset_info[k]))
            logging.info("")
    indexes = raw_input("%s INFO | Type the index for the assets you want to "
                        "download (comma separated, Ctrl+C to abort): " %
                        time.strftime("%H:%M:%S", time.localtime()))

    index_list = []

    for idx in indexes.split(","):
        try:
            index = int(idx) - 1
            index_list.append(index)
            all_assets[index]
        except (ValueError, IndexError):
            logging.error("Invalid index(es), aborting...")
            sys.exit(1)

    for idx in index_list:
        asset_info = all_assets[idx]
        asset.download_file(asset_info, interactive=True)
Ejemplo n.º 3
0
def download_assets():
    view = output.View()
    all_assets = asset.get_all_assets()
    if all_assets:
        view.notify(msg="Available download assets:")
        view.notify(msg="")
        for asset_info in all_assets:
            asset_keys = asset_info.keys()
            view.notify(event='minor', msg="%d - %s" % (all_assets.index(asset_info) + 1,
                                                        asset_info['title']))
            asset_keys.pop(asset_keys.index('title'))
            asset_keys.sort()
            for k in asset_keys:
                view.notify(event='minor', msg="    %s = %s" % (k, asset_info[k]))
            view.notify(msg="")
    indexes = raw_input("Type the index for the assets you want to "
                        "download (comma separated, leave empty to abort): ")

    index_list = []

    for idx in indexes.split(","):
        try:
            index = int(idx) - 1
            index_list.append(index)
            all_assets[index]
        except (ValueError, IndexError):
            logging.error("Invalid index(es), aborting...")
            sys.exit(1)

    for idx in index_list:
        asset_info = all_assets[idx]
        asset.download_file(asset_info, interactive=True)
Ejemplo n.º 4
0
def download_assets():
    view = output.View()
    all_assets = asset.get_all_assets()
    if all_assets:
        view.notify(msg="Available download assets:")
        view.notify(msg="")
        for asset_info in all_assets:
            asset_keys = asset_info.keys()
            view.notify(
                event='minor',
                msg="%d - %s" %
                (all_assets.index(asset_info) + 1, asset_info['title']))
            asset_keys.pop(asset_keys.index('title'))
            asset_keys.sort()
            for k in asset_keys:
                view.notify(event='minor',
                            msg="    %s = %s" % (k, asset_info[k]))
            view.notify(msg="")
    indexes = raw_input("Type the index for the assets you want to "
                        "download (comma separated, leave empty to abort): ")

    index_list = []

    for idx in indexes.split(","):
        try:
            index = int(idx) - 1
            index_list.append(index)
            all_assets[index]
        except (ValueError, IndexError):
            logging.error("Invalid index(es), aborting...")
            sys.exit(1)

    for idx in index_list:
        asset_info = all_assets[idx]
        asset.download_file(asset_info, interactive=True)
Ejemplo n.º 5
0
def download_assets():
    all_assets = asset.get_all_assets()
    all_assets_sorted = []
    if all_assets:
        view.notify(msg="Available download assets:")
        view.notify(msg="")
        title_list = [a['title'] for a in all_assets]
        for index, title in enumerate(sorted(title_list)):
            asset_info = [a for a in all_assets if a['title'] == title][0]
            all_assets_sorted.append(asset_info)
            asset_present_str = output.term_support.partial_str('Missing')
            if asset_info['asset_exists']:
                asset_present_str = output.term_support.healthy_str('Present')
            asset_msg = ("%s - [%s] %s (%s)" %
                         (index + 1,
                          asset_present_str,
                          output.term_support.header_str(asset_info['title']),
                          asset_info['destination']))
            view.notify(event='minor', msg=asset_msg)
    indexes = raw_input("Type the index for the assets you want to "
                        "download (comma separated, leave empty to abort): ")

    index_list = []

    for idx in indexes.split(","):
        try:
            assert int(idx) > 0
            index = int(idx) - 1
            index_list.append(index)
            all_assets_sorted[index]
        except (ValueError, IndexError, AssertionError):
            view.notify(event='error', msg="Invalid index(es), aborting...")
            sys.exit(1)

    for idx in index_list:
        asset_info = all_assets_sorted[idx]
        try:
            asset.download_file(asset_info, interactive=True)
        except urllib2.HTTPError, http_error:
            view.notify(event='error', msg='HTTP Error %s: URL %s' %
                                           (http_error.code,
                                            asset_info['url']))
            os.remove(asset_info['destination'])