def test_api_result_2(self): """Test a result with errors=[{"id": INVALID_CHARS, "msg": "some error"}], and no status field""" result = { "foo": "bar", "errors": [{ "id": INVALID_CHARS, "msg": "some error" }] } self.assertEqual(handle_api_result(result, show_json=False), (1, False)) self.assertTrue(handle_api_result(result, show_json=False)[0] == 1)
def sources_info(socket_path, api_version, args, show_json=False): """Output info on a list of projects :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool sources info <source-name> """ if len(args) == 0: log.error("sources info is missing the name of the source") return 1 if show_json: api_route = client.api_url(api_version, "/projects/source/info/%s" % ",".join(args)) result = client.get_url_json(socket_path, api_route) rc = handle_api_result(result, show_json)[0] else: api_route = client.api_url(api_version, "/projects/source/info/%s?format=toml" % ",".join(args)) try: result = client.get_url_raw(socket_path, api_route) print(result) rc = 0 except RuntimeError as e: print(str(e)) rc = 1 return rc
def sources_add(socket_path, api_version, args, show_json=False): """Add or change a source :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool sources add <source.toml> """ api_route = client.api_url(api_version, "/projects/source/new") rval = 0 for source in argify(args): if not os.path.exists(source): log.error("Missing source file: %s", source) continue source_toml = open(source, "r").read() result = client.post_url_toml(socket_path, api_route, source_toml) if handle_api_result(result, show_json): rval = 1 return rval
def blueprints_changes(socket_path, api_version, args, show_json=False): """Display the changes for each of the blueprints :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool blueprints changes <blueprint,...> Display the changes for each blueprint. """ api_route = client.api_url( api_version, "/blueprints/changes/%s" % (",".join(argify(args)))) result = client.get_url_json(socket_path, api_route) (rc, exit_now) = handle_api_result(result, show_json) if exit_now: return rc for blueprint in result["blueprints"]: print(blueprint["name"]) for change in blueprint["changes"]: prettyCommitDetails(change) return rc
def modules_cmd(opts): """Process modules commands :param opts: Cmdline arguments :type opts: argparse.Namespace :returns: Value to return from sys.exit() :rtype: int """ if opts.args[1] == "help" or opts.args[1] == "--help": print(modules_help) return 0 elif opts.args[1] != "list": log.error("Unknown modules command: %s", opts.args[1]) return 1 api_route = client.api_url(opts.api_version, "/modules/list") result = client.get_url_json_unlimited(opts.socket, api_route) (rc, exit_now) = handle_api_result(result, opts.json) if exit_now: return rc # "list" should output a plain list of identifiers, one per line. print("\n".join(r["name"] for r in result["modules"])) return rc
def projects_list(socket_path, api_version, args, show_json=False): """Output the list of available projects :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool projects list """ api_route = client.api_url(api_version, "/projects/list") result = client.get_url_json(socket_path, api_route) (rc, exit_now) = handle_api_result(result, show_json) if exit_now: return rc for proj in result["projects"]: for k in [ field for field in ("name", "summary", "homepage", "description") if proj[field] ]: print("%s: %s" % (k.title(), textwrap.fill(proj[k], subsequent_indent=" " * (len(k) + 2)))) print("\n\n") return rc
def compose_cancel(socket_path, api_version, args, show_json=False, testmode=0): """Cancel a running compose :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool :param testmode: unused in this function :type testmode: int compose cancel <uuid> This will cancel a running compose. It does nothing if the compose has finished. """ if len(args) == 0: log.error("cancel is missing the compose build id") return 1 api_route = client.api_url(api_version, "/compose/cancel/%s" % args[0]) result = client.delete_url_json(socket_path, api_route) return handle_api_result(result, show_json)
def upload_log(socket_path, api_version, args, show_json=False, testmode=0): """Return the upload log :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool :param testmode: unused in this function :type testmode: int upload log <build-uuid> """ if len(args) == 0: log.error("log is missing the upload uuid") return 1 api_route = client.api_url(api_version, "/upload/log/%s" % args[0]) result = client.get_url_json(socket_path, api_route) (rc, exit_now) = handle_api_result(result, show_json) if exit_now: return rc print("Upload log for %s:\n" % result["upload_id"]) print(result["log"]) return 0
def providers_push(socket_path, api_version, args, show_json=False, testmode=0): """Add a new provider profile or overwrite an existing one :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool :param testmode: unused in this function :type testmode: int providers push <profile.toml> """ if len(args) == 0: log.error("push is missing the profile TOML file") return 1 if not os.path.exists(args[0]): log.error("Missing profile TOML file: %s", args[0]) return 1 api_route = client.api_url(api_version, "/upload/providers/save") profile = toml.load(args[0]) result = client.post_url_json(socket_path, api_route, json.dumps(profile)) return handle_api_result(result, show_json)[0]
def providers_delete(socket_path, api_version, args, show_json=False, testmode=0): """Delete a profile from a provider :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool :param testmode: unused in this function :type testmode: int providers delete <provider> <profile> """ if len(args) == 0: log.error("delete is missing the provider name") return 1 if len(args) == 1: log.error("delete is missing the profile name") return 1 api_route = client.api_url(api_version, "/upload/providers/delete/%s/%s" % (args[0], args[1])) result = client.delete_url_json(socket_path, api_route) return handle_api_result(result, show_json)[0]
def blueprints_depsolve(socket_path, api_version, args, show_json=False): """Display the packages needed to install the blueprint :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool blueprints depsolve <blueprint,...> Display the packages needed to install the blueprint. """ api_route = client.api_url(api_version, "/blueprints/depsolve/%s" % (",".join(argify(args)))) result = client.get_url_json(socket_path, api_route) (rc, exit_now) = handle_api_result(result, show_json) if exit_now: return rc for blueprint in result["blueprints"]: if blueprint["blueprint"].get("version", ""): print("blueprint: %s v%s" % (blueprint["blueprint"]["name"], blueprint["blueprint"]["version"])) else: print("blueprint: %s" % (blueprint["blueprint"]["name"])) for dep in blueprint["dependencies"]: print(" " + packageNEVRA(dep)) return rc
def blueprints_workspace(socket_path, api_version, args, show_json=False): """Push the blueprint TOML to the temporary workspace storage :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool blueprints workspace <blueprint> Push the blueprint TOML to the temporary workspace storage. """ api_route = client.api_url(api_version, "/blueprints/workspace") rval = 0 for blueprint in argify(args): if not os.path.exists(blueprint): log.error("Missing blueprint file: %s", blueprint) continue with open(blueprint, "r") as f: blueprint_toml = f.read() result = client.post_url_toml(socket_path, api_route, blueprint_toml) if handle_api_result(result, show_json)[0]: rval = 1 return rval
def blueprints_push(socket_path, api_version, args, show_json=False): """Push a blueprint TOML file to the server, updating the blueprint :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool push <blueprint> Push a blueprint TOML file to the server. """ api_route = client.api_url(api_version, "/blueprints/new") rval = 0 for blueprint in argify(args): if not os.path.exists(blueprint): log.error("Missing blueprint file: %s", blueprint) continue blueprint_toml = open(blueprint, "r").read() result = client.post_url_toml(socket_path, api_route, blueprint_toml) if handle_api_result(result, show_json): rval = 1 return rval
def blueprints_changes(socket_path, api_version, args, show_json=False): """Display the changes for each of the blueprints :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool blueprints changes <blueprint,...> Display the changes for each blueprint. """ def changes_total_fn(data): """Return the maximum number of possible changes""" # Each blueprint can have a different total, return the largest one return max([c["total"] for c in data["blueprints"]]) api_route = client.api_url(api_version, "/blueprints/changes/%s" % (",".join(argify(args)))) result = client.get_url_json_unlimited(socket_path, api_route, total_fn=changes_total_fn) (rc, exit_now) = handle_api_result(result, show_json) if exit_now: return rc for blueprint in result["blueprints"]: print(blueprint["name"]) for change in blueprint["changes"]: prettyCommitDetails(change) return rc
def blueprints_undo(socket_path, api_version, args, show_json=False): """Undo changes to a blueprint :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool blueprints undo <blueprint> <commit> Undo changes to a blueprint by reverting to the selected commit. """ if len(args) == 0: log.error("undo is missing the blueprint name and commit hash") return 1 elif len(args) == 1: log.error("undo is missing commit hash") return 1 api_route = client.api_url(api_version, "/blueprints/undo/%s/%s" % (args[0], args[1])) result = client.post_url(socket_path, api_route, "") return handle_api_result(result, show_json)
def status_cmd(opts): """Process status commands :param opts: Cmdline arguments :type opts: argparse.Namespace :returns: Value to return from sys.exit() :rtype: int """ if opts.args[1] == "help" or opts.args[1] == "--help": print(status_help) return 0 elif opts.args[1] != "show": log.error("Unknown status command: %s", opts.args[1]) return 1 result = client.get_url_json(opts.socket, "/api/status") (rc, exit_now) = handle_api_result(result, opts.json) if exit_now: return rc print("API server status:") print(" Database version: " + result["db_version"]) print(" Database supported: %s" % result["db_supported"]) print(" Schema version: " + result["schema_version"]) print(" API version: " + result["api"]) print(" Backend: " + result["backend"]) print(" Build: " + result["build"]) if result["msgs"]: print("Error messages:") print("\n".join([" " + r for r in result["msgs"]])) return rc
def compose_delete(socket_path, api_version, args, show_json=False, testmode=0, api=None): """Delete a finished compose's results :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool :param testmode: unused in this function :type testmode: int compose delete <uuid,...> Delete the listed compose results. It will only delete results for composes that have finished or failed, not a running compose. """ if len(args) == 0: log.error("delete is missing the compose build id") return 1 api_route = client.api_url(api_version, "/compose/delete/%s" % (",".join(argify(args)))) result = client.delete_url_json(socket_path, api_route) return handle_api_result(result, show_json)[0]
def test_api_result_5(self): """Test a result with status=False, and errors=[{"id": INVALID_CHARS, "msg": "some error"}]""" result = { "status": False, "errors": [{ "id": INVALID_CHARS, "msg": "some error" }] } self.assertEqual(handle_api_result(result, show_json=False), (1, True))
def compose_info(socket_path, api_version, args, show_json=False, testmode=0, api=None): """Return detailed information about the compose :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool :param testmode: unused in this function :type testmode: int compose info <uuid> This returns information about the compose, including the blueprint and the dependencies. """ if len(args) == 0: log.error("info is missing the compose build id") return 1 api_route = client.api_url(api_version, "/compose/info/%s" % args[0]) result = client.get_url_json(socket_path, api_route) (rc, exit_now) = handle_api_result(result, show_json) if exit_now: return rc if result["image_size"] > 0: image_size = str(result["image_size"]) else: image_size = "" print("%s %-8s %-15s %s %-16s %s" % (result["id"], result["queue_status"], result["blueprint"]["name"], result["blueprint"]["version"], result["compose_type"], image_size)) print("Packages:") for p in result["blueprint"]["packages"]: print(" %s-%s" % (p["name"], p["version"])) print("Modules:") for m in result["blueprint"]["modules"]: print(" %s-%s" % (m["name"], m["version"])) print("Dependencies:") for d in result["deps"]["packages"]: print(" " + packageNEVRA(d)) return rc
def blueprints_freeze(socket_path, api_version, args, show_json=False): """Handle the blueprints freeze commands :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool blueprints freeze <blueprint,...> Display the frozen blueprint's modules and packages. blueprints freeze show <blueprint,...> Display the frozen blueprint in TOML format. blueprints freeze save <blueprint,...> Save the frozen blueprint to a file, <blueprint-name>.frozen.toml. """ if args[0] == "show": return blueprints_freeze_show(socket_path, api_version, args[1:], show_json) elif args[0] == "save": return blueprints_freeze_save(socket_path, api_version, args[1:], show_json) if len(args) == 0: log.error("freeze is missing the blueprint name") return 1 api_route = client.api_url( api_version, "/blueprints/freeze/%s" % (",".join(argify(args)))) result = client.get_url_json(socket_path, api_route) (rc, exit_now) = handle_api_result(result, show_json) if exit_now: return rc for entry in result["blueprints"]: blueprint = entry["blueprint"] if blueprint.get("version", ""): print("blueprint: %s v%s" % (blueprint["name"], blueprint["version"])) else: print("blueprint: %s" % (blueprint["name"])) for m in blueprint["modules"]: print(" %s-%s" % (m["name"], m["version"])) for p in blueprint["packages"]: print(" %s-%s" % (p["name"], p["version"])) return rc
def upload_start(socket_path, api_version, args, show_json=False, testmode=0): """Start upload up a build uuid image :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool :param testmode: unused in this function :type testmode: int upload start <build-uuid> <image-name> [<provider> <profile> | <profile.toml>] """ if len(args) == 0: log.error("start is missing the compose build id") return 1 if len(args) == 1: log.error("start is missing the image name") return 1 if len(args) == 2: log.error("start is missing the provider and profile details") return 1 body = {"image_name": args[1]} if len(args) == 3: try: body.update(toml.load(args[2])) except toml.TomlDecodeError as e: log.error(str(e)) return 1 elif len(args) == 4: body["provider"] = args[2] body["profile"] = args[3] else: log.error("start has incorrect number of arguments") return 1 api_route = client.api_url(api_version, "/compose/uploads/schedule/%s" % args[0]) result = client.post_url_json(socket_path, api_route, json.dumps(body)) (rc, exit_now) = handle_api_result(result, show_json) if exit_now: return rc print("Upload %s added to the queue" % result["upload_id"]) return rc
def sources_delete(socket_path, api_version, args, show_json=False): """Delete a source :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool sources delete <source-name> """ api_route = client.api_url(api_version, "/projects/source/delete/%s" % args[0]) result = client.delete_url_json(socket_path, api_route) return handle_api_result(result, show_json)
def blueprints_tag(socket_path, api_version, args, show_json=False): """Tag the most recent blueprint commit as a release :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool blueprints tag <blueprint> Tag the most recent blueprint commit as a release. """ api_route = client.api_url(api_version, "/blueprints/tag/%s" % args[0]) result = client.post_url(socket_path, api_route, "") return handle_api_result(result, show_json)
def projects_info(socket_path, api_version, args, show_json=False): """Output info on a list of projects :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool projects info <project,...> """ if len(args) == 0: log.error("projects info is missing the packages") return 1 api_route = client.api_url(api_version, "/projects/info/%s" % ",".join(args)) result = client.get_url_json(socket_path, api_route) (rc, exit_now) = handle_api_result(result, show_json) if exit_now: return rc for proj in result["projects"]: for k in [ field for field in ("name", "summary", "homepage", "description") if proj[field] ]: print("%s: %s" % (k.title(), textwrap.fill(proj[k], subsequent_indent=" " * (len(k) + 2)))) print("Builds: ") for build in proj["builds"]: print(" %s%s-%s.%s at %s for %s" % ("" if not build["epoch"] else str(build["epoch"]) + ":", build["source"]["version"], build["release"], build["arch"], build["build_time"], build["changelog"])) print("") return rc
def blueprints_diff(socket_path, api_version, args, show_json=False): """Display the differences between 2 versions of a blueprint :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool blueprints diff <blueprint-name> Display the differences between 2 versions of a blueprint. <from-commit> Commit hash or NEWEST <to-commit> Commit hash, NEWEST, or WORKSPACE """ if len(args) == 0: log.error( "blueprints diff is missing the blueprint name, from commit, and to commit" ) return 1 elif len(args) == 1: log.error( "blueprints diff is missing the from commit, and the to commit") return 1 elif len(args) == 2: log.error("blueprints diff is missing the to commit") return 1 api_route = client.api_url( api_version, "/blueprints/diff/%s/%s/%s" % (args[0], args[1], args[2])) result = client.get_url_json(socket_path, api_route) (rc, exit_now) = handle_api_result(result, show_json) if exit_now: return rc for diff in result["diff"]: print(pretty_diff_entry(diff)) return rc
def compose_start(socket_path, api_version, args, show_json=False, testmode=0): """Start a new compose using the selected blueprint and type :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool :param testmode: Set to 1 to simulate a failed compose, set to 2 to simulate a finished one. :type testmode: int compose start <blueprint-name> <compose-type> """ if len(args) == 0: log.error("start is missing the blueprint name and output type") return 1 if len(args) == 1: log.error("start is missing the output type") return 1 config = { "blueprint_name": args[0], "compose_type": args[1], "branch": "master" } if testmode: test_url = "?test=%d" % testmode else: test_url = "" api_route = client.api_url(api_version, "/compose" + test_url) result = client.post_url_json(socket_path, api_route, json.dumps(config)) (rc, exit_now) = handle_api_result(result, show_json) if exit_now: return rc print("Compose %s added to the queue" % result["build_id"]) return rc
def upload_cancel(socket_path, api_version, args, show_json=False, testmode=0): """Cancel the queued or running upload :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool :param testmode: unused in this function :type testmode: int upload cancel <build-uuid> """ if len(args) == 0: log.error("cancel is missing the upload uuid") return 1 api_route = client.api_url(api_version, "/upload/cancel/%s" % args[0]) result = client.delete_url_json(socket_path, api_route) return handle_api_result(result, show_json)[0]
def sources_list(socket_path, api_version, args, show_json=False): """Output the list of available sources :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool sources list """ api_route = client.api_url(api_version, "/projects/source/list") result = client.get_url_json(socket_path, api_route) (rc, exit_now) = handle_api_result(result, show_json) if exit_now: return rc # "list" should output a plain list of identifiers, one per line. print("\n".join(result["sources"])) return rc
def upload_reset(socket_path, api_version, args, show_json=False, testmode=0): """Reset the upload and execute it again :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool :param testmode: unused in this function :type testmode: int upload reset <build-uuid> """ if len(args) == 0: log.error("reset is missing the upload uuid") return 1 api_route = client.api_url(api_version, "/upload/reset/%s" % args[0]) result = client.post_url_json(socket_path, api_route, json.dumps({})) return handle_api_result(result, show_json)[0]
def upload_info(socket_path, api_version, args, show_json=False, testmode=0): """Return detailed information about the upload :param socket_path: Path to the Unix socket to use for API communication :type socket_path: str :param api_version: Version of the API to talk to. eg. "0" :type api_version: str :param args: List of remaining arguments from the cmdline :type args: list of str :param show_json: Set to True to show the JSON output instead of the human readable output :type show_json: bool :param testmode: unused in this function :type testmode: int upload info <uuid> This returns information about the upload, including uuid, name, status, service, and image. """ if len(args) == 0: log.error("info is missing the upload uuid") return 1 api_route = client.api_url(api_version, "/upload/info/%s" % args[0]) result = client.get_url_json(socket_path, api_route) (rc, exit_now) = handle_api_result(result, show_json) if exit_now: return rc image_path = result["upload"]["image_path"] print("%s %-8s %-15s %-8s %s" % (result["upload"]["uuid"], result["upload"]["status"], result["upload"]["image_name"], result["upload"]["provider_name"], os.path.basename(image_path) if image_path else "UNFINISHED")) return rc