Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package linode-cli for openSUSE:Factory checked in at 2022-11-15 13:18:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/linode-cli (Old) and /work/SRC/openSUSE:Factory/.linode-cli.new.1597 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "linode-cli" Tue Nov 15 13:18:48 2022 rev:3 rq:1035678 version:5.25.0 Changes: -------- --- /work/SRC/openSUSE:Factory/linode-cli/linode-cli.changes 2022-05-05 23:07:32.913643819 +0200 +++ /work/SRC/openSUSE:Factory/.linode-cli.new.1597/linode-cli.changes 2022-11-15 13:21:33.472841771 +0100 @@ -1,0 +2,14 @@ +Thu Nov 10 14:57:20 UTC 2022 - Andrea Manzini <[email protected]> + +- Update to version 5.25.0 + * refreshed openapi specs + * Link to endpoint documentation in command help page + * output: print default values being used + * Add support for action aliasing + * Add support for autocompletion + * Accepted integer chunk_size instead of float + * Refactor for Python 3 + +- refreshed the patch used to remove shebang line in __init__.py + +------------------------------------------------------------------- Old: ---- linode-cli-5.19.0.tar.gz New: ---- linode-cli-5.25.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ linode-cli.spec ++++++ --- /var/tmp/diff_new_pack.4C7qVS/_old 2022-11-15 13:21:33.916844063 +0100 +++ /var/tmp/diff_new_pack.4C7qVS/_new 2022-11-15 13:21:33.920844083 +0100 @@ -20,7 +20,7 @@ %bcond_without python2 Name: linode-cli -Version: 5.19.0 +Version: 5.25.0 Release: 0 Summary: The Linode command-line interface License: BSD-3-Clause ++++++ 0001-Remove-shebang-from-non-executable-files.patch ++++++ --- /var/tmp/diff_new_pack.4C7qVS/_old 2022-11-15 13:21:33.940844187 +0100 +++ /var/tmp/diff_new_pack.4C7qVS/_new 2022-11-15 13:21:33.944844208 +0100 @@ -1,22 +1,10 @@ -From 171d0cab39579541e8d167b31acd93d0286556e2 Mon Sep 17 00:00:00 2001 -From: Robert Munteanu <[email protected]> -Date: Tue, 4 Jan 2022 14:37:07 +0100 -Subject: [PATCH] Remove shebang from non-executable files - ---- - linodecli/__init__.py | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/linodecli/__init__.py b/linodecli/__init__.py -index 3af9a36..8702e39 100755 ---- a/linodecli/__init__.py -+++ b/linodecli/__init__.py -@@ -1,4 +1,3 @@ +diff --color -ur linode-cli-5.25.0.orig/linodecli/__init__.py linode-cli-5.25.0/linodecli/__init__.py +--- linode-cli-5.25.0.orig/linodecli/__init__.py 2022-10-31 21:37:30.000000000 +0100 ++++ linode-cli-5.25.0/linodecli/__init__.py 2022-11-14 15:09:51.404846258 +0100 +@@ -1,5 +1,3 @@ -#!/usr/local/bin/python3 - from __future__ import print_function - +- import argparse --- -2.34.1 - + import os + from importlib import import_module ++++++ linode-cli-5.19.0.tar.gz -> linode-cli-5.25.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/.github/ISSUE_TEMPLATE/bug.yml new/linode-cli-5.25.0/.github/ISSUE_TEMPLATE/bug.yml --- old/linode-cli-5.19.0/.github/ISSUE_TEMPLATE/bug.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/linode-cli-5.25.0/.github/ISSUE_TEMPLATE/bug.yml 2022-10-31 21:37:30.000000000 +0100 @@ -0,0 +1,44 @@ +name: Bug Report +description: File a bug report +title: "[Bug]: " +labels: ["bug"] +body: + - type: input + id: cli-version + attributes: + label: CLI Version + description: What version of linode-cli are you running? `linode-cli -v` + placeholder: linode-cli 5.24.0 Built off spec version 4.138.0 + validations: + required: true + - type: textarea + id: resources + attributes: + label: Command + description: The command executed to encounter this bug. Please ensure that all sensitive data has been removed. + placeholder: | + linode-cli linodes create --type g6-standard-1 --region us-southeast + - type: textarea + id: output + attributes: + label: Output + description: The output of the command affected by the bug. Please ensure that all sensitive data has been removed. + - type: textarea + id: expected + attributes: + label: Expected Behavior + description: What should have happened? + validations: + required: true + - type: textarea + id: actual + attributes: + label: Actual Behavior + description: What actually happened? + validations: + required: true + - type: textarea + id: reproduce + attributes: + label: Steps to Reproduce + description: If you are able to reproduce this issue, please list the steps below. \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/.github/ISSUE_TEMPLATE/enhancement.yml new/linode-cli-5.25.0/.github/ISSUE_TEMPLATE/enhancement.yml --- old/linode-cli-5.19.0/.github/ISSUE_TEMPLATE/enhancement.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/linode-cli-5.25.0/.github/ISSUE_TEMPLATE/enhancement.yml 2022-10-31 21:37:30.000000000 +0100 @@ -0,0 +1,17 @@ +name: Enhancement +description: Request a feature +title: "[Feature]: " +labels: ["enhancement"] +body: + - type: textarea + id: description + attributes: + label: Description + description: What would you like this feature to do in detail? + validations: + required: true + - type: textarea + id: usage + attributes: + label: Potential Usage Example + description: A small codeblock example of how this feature will be used. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/CONTRIBUTING.md new/linode-cli-5.25.0/CONTRIBUTING.md --- old/linode-cli-5.19.0/CONTRIBUTING.md 1970-01-01 01:00:00.000000000 +0100 +++ new/linode-cli-5.25.0/CONTRIBUTING.md 2022-10-31 21:37:30.000000000 +0100 @@ -0,0 +1,49 @@ +# Contributing Guidelines + +:+1::tada: First off, we appreciate you taking the time to contribute! THANK YOU! :tada::+1: + +We put together the handy guide below to help you get support for your work. Read on! + +## I Just Want to Ask the Maintainers a Question + +The [Linode Community](https://www.linode.com/community/questions/) is a great place to get additional support. + +## How Do I Submit A (Good) Bug Report or Feature Request + +Please open a [GitHub issue](../../issues/new/choose) to report bugs or suggest features. + +Please accurately fill out the appropriate GitHub issue form. + +When filing an issue or feature request, help us avoid duplication and redundant effort -- check existing open or recently closed issues first. + +Detailed bug reports and requests are easier for us to work with. Please include the following in your issue: + +* A reproducible test case or series of steps +* The version of our code being used +* Any modifications you've made, relevant to the bug +* Anything unusual about your environment or deployment +* Screenshots and code samples where illustrative and helpful + +## How to Open a Pull Request + +We follow the [fork and pull model](https://opensource.guide/how-to-contribute/#opening-a-pull-request) for open source contributions. + +Tips for a faster merge: +* address one feature or bug per pull request. +* large formatting changes make it hard for us to focus on your work. +* follow language coding conventions. +* make sure that tests pass. +* make sure your commits are atomic, [addressing one change per commit](https://chris.beams.io/posts/git-commit/). +* add tests! + +## Code of Conduct + +This project follows the [Linode Community Code of Conduct](https://www.linode.com/community/questions/conduct). + +## Vulnerability Reporting + +If you discover a potential security issue in this project we ask that you notify Linode Security via our [vulnerability reporting process](https://hackerone.com/linode). Please do **not** create a public github issue. + +## Licensing + +See the [LICENSE file](/LICENSE) for our project's licensing. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/MANIFEST.in new/linode-cli-5.25.0/MANIFEST.in --- old/linode-cli-5.19.0/MANIFEST.in 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/MANIFEST.in 2022-10-31 21:37:30.000000000 +0100 @@ -1,4 +1,3 @@ -include linodecli/data-2 include linodecli/data-3 include linodecli/oauth-landing-page.html include linode-cli.sh diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/Makefile new/linode-cli-5.25.0/Makefile --- old/linode-cli-5.19.0/Makefile 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/Makefile 2022-10-31 21:37:30.000000000 +0100 @@ -2,38 +2,24 @@ # Makefile for more convenient building of the Linode CLI and its baked content # -PYTHON ?= 3 SPEC ?= https://www.linode.com/docs/api/openapi.yaml -ifeq ($(PYTHON), 3) - PYCMD=python3 - PIPCMD=pip3 -else - PYCMD=python - PIPCMD=pip -endif - install: check-prerequisites requirements build - ls dist/ | xargs -I{} $(PIPCMD) install --force dist/{} + ls dist/ | xargs -I{} pip3 install --force dist/{} .PHONY: build build: clean - python -m linodecli bake ${SPEC} --skip-config python3 -m linodecli bake ${SPEC} --skip-config - cp data-2 linodecli/ cp data-3 linodecli/ - $(PYCMD) setup.py bdist_wheel --universal + python3 setup.py bdist_wheel --universal .PHONY: requirements requirements: - pip install -r requirements.txt pip3 install -r requirements.txt .PHONY: check-prerequisites check-prerequisites: - @ pip -v >/dev/null @ pip3 -v >/dev/null - @ python -V >/dev/null @ python3 -V >/dev/null .PHONY: clean diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/README.rst new/linode-cli-5.25.0/README.rst --- old/linode-cli-5.19.0/README.rst 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/README.rst 2022-10-31 21:37:30.000000000 +0100 @@ -141,6 +141,26 @@ When configuring multiple users using web-based configuration, you may need to log out of cloud.linode.com before configuring a second user. +Specifying List Arguments +""""""""""""""""""""""""" + +When running certain commands, you may need to specify multiple values for a list +argument. This can be done by specifying the argument multiple times for each +value in the list. For example, to create a Linode with multiple ``tags`` +you can execute the following:: + + linode-cli linodes create --region us-east --type g6-nanode-1 --tags tag1 --tags tag2 + +Specifying Nested Arguments +""""""""""""""""""""""""""" + +When running certain commands, you may need to specify an argument that is nested +in another field. These arguments can be specified using a ``.`` delimited path to +the argument. For example, to create a firewall with an inbound policy of ``DROP`` +and an outbound policy of ``ACCEPT``, you can execute the following:: + + linode-cli firewalls create --label example-firewall --rules.outbound_policy ACCEPT --rules.inbound_policy DROP + Suppressing Defaults """""""""""""""""""" @@ -320,8 +340,8 @@ In order to successfully build the CLI, your system will require the following: * The ``make`` command - * ``python`` and ``python3`` (both versions are required to build a package) - * ``pip`` and ``pip3`` (to install ``requirements.txt`` for both python versions) + * ``python3`` + * ``pip3`` (to install ``requirements.txt``) Before attempting a build, install python dependencies like this:: @@ -337,11 +357,7 @@ To install the package as part of the build process, use this command:: - make install PYTHON=3 - -When using ``install``, the ``PYTHON`` argument is optional - if provided, it -will install the CLI for that version of python. Valid values are ``2`` and -``3``, and it will default to ``3``. + make install Testing ------- @@ -396,6 +412,10 @@ This CLI is generated based on the OpenAPI specification for Linode's API. As such, many changes are made directly to the spec. +Please follow the `Contributing Guidelines`_ when making a contribution. + +.. _Contributing Guidelines: https://github.com/linode/linode-cli/blob/master/CONTRIBUTING.md + Specification Extensions ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -407,13 +427,13 @@ +-----------------------------+-------------+-------------------------------------------------------------------------------------------+ |x-linode-cli-action | method | The action name for operations under this path. If not present, operationId is used. | +-----------------------------+-------------+-------------------------------------------------------------------------------------------+ -|x-linode-cli-color  | property | If present, defines key-value pairs of property value: color. Colors must be one of | -|           |     | "red", "green", "yellow", "white", and "black". Must include a default. | +|x-linode-cli-color | property | If present, defines key-value pairs of property value: color. Colors must be one of | +| | | "red", "green", "yellow", "white", and "black". Must include a default. | +-----------------------------+-------------+-------------------------------------------------------------------------------------------+ |x-linode-cli-command | path | The command name for operations under this path. If not present, "default" is used. | +-----------------------------+-------------+-------------------------------------------------------------------------------------------+ |x-linode-cli-display | property | If truthy, displays this as a column in output. If a number, determines the ordering | -|           | | (left to right). | +| | | (left to right). | +-----------------------------+-------------+-------------------------------------------------------------------------------------------+ |x-linode-cli-format | property | Overrides the "format" given in this property for the CLI only. Valid values are `file` | | | | and `json`. | @@ -423,5 +443,16 @@ +x-linode-cli-allowed-defaults| requestBody | Tells the CLI what configured defaults apply to this request. Value values are "region", | + | | "image", and "type". | +-----------------------------+-------------+-------------------------------------------------------------------------------------------+ ++x-linode-cli-nested-list | content-type| Tells the CLI to flatten a single object into multiple table rows based on the keys | +| | | included in this value. Values should be comma-delimited JSON paths, and must all be | +| | | present on response objects. | +| | | | +| | | When used, a new key ``_split`` is added to each flattened object whose value is the last | +| | | segment of the JSON path used to generate the flattened object from the source. | ++-----------------------------+-------------+-------------------------------------------------------------------------------------------+ +|x-linode-cli-use-schema | content-type| Overrides the normal schema for the object and uses this instead. Especially useful when | +| | | paired with ``x-linode-cli-nested-list``, allowing a schema to describe the flattened | +| | | object instead of the original object. | ++-----------------------------+-------------+-------------------------------------------------------------------------------------------+ .. _Specification Extensions: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#specificationExtensions diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/linodecli/__init__.py new/linode-cli-5.25.0/linodecli/__init__.py --- old/linode-cli-5.19.0/linodecli/__init__.py 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/linodecli/__init__.py 2022-10-31 21:37:30.000000000 +0100 @@ -1,5 +1,4 @@ #!/usr/local/bin/python3 -from __future__ import print_function import argparse import os @@ -272,12 +271,10 @@ ) exit(13) elif plugin_name in plugins.available(cli.config): - from linodecli.configuration import input_helper - # this isn't an internal plugin, so warn that we're re-registering it print("WARNING: Plugin {} is already registered.".format(plugin_name)) print("") - answer = input_helper( + answer = input( "Allow re-registration of {}? [y/N] ".format(plugin_name) ) @@ -404,7 +401,7 @@ print() print("Available commands:") - content = [c for c in cli.ops.keys()] + content = [c for c in sorted(cli.ops.keys())] proc = [] for i in range(0, len(content), 3): proc.append(content[i : i + 3]) @@ -553,7 +550,7 @@ " --{}: {}{}".format( arg.path, "(required) " - if operation.method == "post" and arg.required + if operation.method in {"post", "put"} and arg.required else "", arg.description, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/linodecli/__main__.py new/linode-cli-5.25.0/linodecli/__main__.py --- old/linode-cli-5.19.0/linodecli/__main__.py 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/linodecli/__main__.py 2022-10-31 21:37:30.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from linodecli import main main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/linodecli/cli.py new/linode-cli-5.25.0/linodecli/cli.py --- old/linode-cli-5.19.0/linodecli/cli.py 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/linodecli/cli.py 2022-10-31 21:37:30.000000000 +0100 @@ -1,7 +1,6 @@ """ Responsible for managing spec and routing commands to operations. """ -from __future__ import print_function import json import os @@ -94,7 +93,7 @@ for arg, info in node.items(): if "allOf" in info: info = self._resolve_allOf(info["allOf"]) - if "$ref" in info: + while "$ref" in info: info = self._resolve_ref(info["$ref"]) if "properties" in info: self._parse_args(info["properties"], prefix=prefix + [arg], args=args) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/linodecli/configuration.py new/linode-cli-5.25.0/linodecli/configuration.py --- old/linode-cli-5.19.0/linodecli/configuration.py 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/linodecli/configuration.py 2022-10-31 21:37:30.000000000 +0100 @@ -2,7 +2,6 @@ Handles configuring the cli, as well as loading configs so that they can be used elsewhere. """ -from __future__ import print_function import argparse import re @@ -39,8 +38,7 @@ # this is a list of browser that _should_ work for web-based auth. This is mostly # intended to exclude lynx and other terminal browsers which could be opened, but # won't work. -KNOWN_GOOD_BROWSERS = set( - ( +KNOWN_GOOD_BROWSERS = { "chrome", "firefox", "mozilla", @@ -50,8 +48,7 @@ "chromium", "chromium-browser", "epiphany", - ) -) +} # in the event that we can't load the styled landing page from file, this will # do as a landing page @@ -66,17 +63,6 @@ """ -def input_helper(prompt): - """ - Handles python2 and python3 differences in input command - """ - if sys.version_info[0] == 2: - # python2 input is scary - we want raw_input - return raw_input(prompt) - else: - return input(prompt) - - class CLIConfig: def __init__(self, base_url, username=None, skip_config=False): self.base_url = base_url @@ -346,7 +332,7 @@ ) while True: - token = input_helper("Personal Access Token: ") + token = input("Personal Access Token: ") username = self._username_for_token(token) if username is not None: @@ -519,7 +505,7 @@ ) while True: - r = input_helper("Try it anyway? [y/N]: ") + r = input("Try it anyway? [y/N]: ") if r.lower() in "yn ": can_use_browser = r.lower() == "y" break @@ -533,7 +519,7 @@ "If you prefer to supply a Personal Access Token, use `linode-cli configure --token`. " ) print() - input_helper( + input( "Press enter to continue. This will open a browser and proceed with authentication." ) username, config["token"] = self._get_token_web() @@ -575,7 +561,7 @@ if not is_default: if username != self.default_username(): while True: - value = input_helper("Make active user? [y/N]: ") + value = input("Make this user the default when using the CLI? [y/N]: ") if value.lower() in "yn": is_default = value.lower() == "y" @@ -641,7 +627,7 @@ ret = "" while True: - choice = input_helper(prompt) + choice = input(prompt) if choice: try: @@ -744,7 +730,7 @@ print() while True: - username = input_helper("Active user: ") + username = input("Active user: ") if username in users: self.config.set("DEFAULT", "default-user", username) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/linodecli/operation.py new/linode-cli-5.25.0/linodecli/operation.py --- old/linode-cli-5.19.0/linodecli/operation.py 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/linodecli/operation.py 2022-10-31 21:37:30.000000000 +0100 @@ -1,7 +1,6 @@ """ Classes related to OpenAPI-defined operations and their arguments and parameters. """ -from __future__ import print_function import argparse import json @@ -41,7 +40,7 @@ """ def __init__(self, *args, **kwargs): - super(PasswordPromptAction, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def __call__(self, parser, namespace, values, option_string=None): # if not provided on the command line, pull from the environment if it diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/linodecli/output.py new/linode-cli-5.25.0/linodecli/output.py --- old/linode-cli-5.19.0/linodecli/output.py 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/linodecli/output.py 2022-10-31 21:37:30.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import print_function - import json from enum import Enum from sys import stdout diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/linodecli/plugins/__init__.py new/linode-cli-5.25.0/linodecli/plugins/__init__.py --- old/linode-cli-5.19.0/linodecli/plugins/__init__.py 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/linodecli/plugins/__init__.py 2022-10-31 21:37:30.000000000 +0100 @@ -47,7 +47,7 @@ print( "Expected module '{}' not found. Either {} is misconfigured, " "or the backing module was uninstalled.".format( - plugin_moduel_name, name + plugin_module_name, name ) ) sys.exit(10) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/linodecli/plugins/image-upload.py new/linode-cli-5.25.0/linodecli/plugins/image-upload.py --- old/linode-cli-5.19.0/linodecli/plugins/image-upload.py 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/linodecli/plugins/image-upload.py 2022-10-31 21:37:30.000000000 +0100 @@ -5,7 +5,6 @@ linode-cli image-upload --region us-east --label my-image /path/to/image.gz """ -from __future__ import print_function import argparse import os @@ -21,7 +20,7 @@ """ Draws the upload progress bar. """ - percent = "{0:.1f}".format(100 * (cur / float(total))) + percent = "{:.1f}".format(100 * (cur / float(total))) progress = int(100 * cur // total) bar = ("#" * progress) + ("-" * (100 - progress)) print("\r |{}| {}%".format(bar, percent), end="", flush=True) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/linodecli/plugins/obj.py new/linode-cli-5.25.0/linodecli/plugins/obj.py --- old/linode-cli-5.19.0/linodecli/plugins/obj.py 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/linodecli/plugins/obj.py 2022-10-31 21:37:30.000000000 +0100 @@ -1,5 +1,3 @@ -from __future__ import print_function - import argparse import getpass import math @@ -12,8 +10,6 @@ from terminaltables import SingleTable -from linodecli.configuration import input_helper - ENV_ACCESS_KEY_NAME = "LINODE_CLI_OBJ_ACCESS_KEY" ENV_SECRET_KEY_NAME = "LINODE_CLI_OBJ_SECRET_KEY" @@ -63,9 +59,27 @@ # Files larger than this need to be uploaded via a multipart upload UPLOAD_MAX_FILE_SIZE = 1024 * 1024 * 1024 * 5 -# This is how big the chunks of the file that we upload will be -# This is a float so that division works like we want later -MULTIPART_UPLOAD_CHUNK_SIZE = 1024 * 1024 * 1024 * 5.0 +# This is how big (in MB) the chunks of the file that we upload will be +MULTIPART_UPLOAD_CHUNK_SIZE_DEFAULT = 1024 + +def restricted_int_arg_type(max, min=1): + """ + An ArgumentParser arg type for integers that restricts the value to between `min` and `max` + (inclusive for both.) + """ + def restricted_int(string): + err_msg = "Value must be an integer between {} and {}".format(min, max) + try: + value = int(string) + except ValueError: + # argparse can handle ValueErrors, but shows an unfriendly "invalid restricted_int + # value: '0.1'" message, so catch and raise with a better message. + raise argparse.ArgumentTypeError(err_msg) + if value < min or value > max: + raise argparse.ArgumentTypeError(err_msg) + return value + return restricted_int + def list_objects_or_buckets(get_client, args): @@ -204,6 +218,12 @@ action="store_true", help="If set, the new object can be downloaded without " "authentication.", ) + parser.add_argument( + "--chunk-size", + type=restricted_int_arg_type(5120), + default=MULTIPART_UPLOAD_CHUNK_SIZE_DEFAULT, + help="The size of file chunks when uploading large files, in MB." + ) # parser.add_argument('--recursive', action='store_true', # help="If set, upload directories recursively.") @@ -237,6 +257,7 @@ sys.exit(2) policy = "public-read" if parsed.acl_public else None + chunk_size = 1024 * 1024 * parsed.chunk_size for filename, file_path in to_upload: k = Key(bucket) @@ -246,12 +267,12 @@ k.set_contents_from_filename(file_path, cb=_progress, num_cb=100, policy=policy) for filename, file_path, file_size in to_multipart_upload: - _do_multipart_upload(bucket, filename, file_path, file_size, policy) + _do_multipart_upload(bucket, filename, file_path, file_size, policy, chunk_size) print("Done.") -def _do_multipart_upload(bucket, filename, file_path, file_size, policy): +def _do_multipart_upload(bucket, filename, file_path, file_size, policy, chunk_size): """ Handles the internals of a multipart upload for a large file. @@ -267,25 +288,41 @@ completes. None for no ACLs, or "public-read" to make the key accessible publicly. :type policy: str + :param chunk_size: The size of chunks to upload, in bytes. + :type chunk_size: int """ upload = bucket.initiate_multipart_upload(filename, policy=policy) - num_chunks = int(math.ceil(file_size / MULTIPART_UPLOAD_CHUNK_SIZE)) - upload_exception = None + # convert chunk_size to float so that division works like we want + num_chunks = int(math.ceil(file_size / float(chunk_size))) print("{} ({} parts)".format(filename, num_chunks)) + num_tries = 3 + retry_delay = 2 + try: with open(file_path, "rb") as f: for i in range(num_chunks): print(" Part {}".format(i + 1)) - upload.upload_part_from_file( - f, i + 1, cb=_progress, num_cb=100, size=MULTIPART_UPLOAD_CHUNK_SIZE - ) - except Exception as e: + for attempt in range(num_tries): + try: + upload.upload_part_from_file( + f, i + 1, cb=_progress, num_cb=100, size=chunk_size + ) + except S3ResponseError: + if attempt < num_tries - 1: + print( " Part failed ({} of {} attempts). Retrying in {} seconds...".format(attempt + 1, num_tries, retry_delay)) + time.sleep(retry_delay) + continue + else: + raise + else: + break + except Exception: print("Upload failed! Cleaning up!") upload.cancel_upload() - raise upload_exception + raise upload.complete_upload() @@ -1001,7 +1038,7 @@ """ Draws the upload progress bar. """ - percent = ("{0:.1f}").format(100 * (cur / float(total))) + percent = ("{:.1f}").format(100 * (cur / float(total))) progress = int(100 * cur // total) bar = ("#" * progress) + ("-" * (100 - progress)) print("\r |{}| {}%".format(bar, percent), end="\r") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/linodecli/plugins/ssh.py new/linode-cli-5.25.0/linodecli/plugins/ssh.py --- old/linode-cli-5.19.0/linodecli/plugins/ssh.py 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/linodecli/plugins/ssh.py 2022-10-31 21:37:30.000000000 +0100 @@ -13,16 +13,6 @@ from sys import exit, platform, version_info -def input_helper(prompt): - """ - Handles python2 and python3 differences in input command - """ - if version_info[0] == 2: - # python2 input is scary - we want raw_input - return raw_input(prompt) - else: - return input(prompt) - def call(args, context): """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/linodecli/response.py new/linode-cli-5.25.0/linodecli/response.py --- old/linode-cli-5.19.0/linodecli/response.py 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/linodecli/response.py 2022-10-31 21:37:30.000000000 +0100 @@ -2,7 +2,6 @@ Classes related to parsing responses and display output from the API, based on the OpenAPI spec. """ -from __future__ import print_function import os import platform @@ -166,15 +165,26 @@ if "pages" in json: json = json["data"] + nested_lists = [c.strip() for c in self.nested_list.split(",")] ret = [] - if not isinstance(json, list): - json = [json] - for cur in json: - nlist = cur.get(self.nested_list) - for item in nlist: - cobj = {k: v for k, v in cur.items() if k != self.nested_list} - cobj[self.nested_list] = item - ret.append(cobj) + + for nested_list in nested_lists: + path_parts = nested_list.split(".") + + if not isinstance(json, list): + json = [json] + for cur in json: + + nlist_path = cur + for p in path_parts: + nlist_path = nlist_path.get(p) + nlist = nlist_path + + for item in nlist: + cobj = {k: v for k, v in cur.items() if k != path_parts[0]} + cobj["_split"] = path_parts[-1] + cobj[path_parts[0]] = item + ret.append(cobj) return ret elif "pages" in json: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/setup.py new/linode-cli-5.25.0/setup.py --- old/linode-cli-5.19.0/setup.py 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/setup.py 2022-10-31 21:37:30.000000000 +0100 @@ -1,6 +1,5 @@ #!/usr/bin/env python3 import subprocess -from io import open from os import path from setuptools import setup @@ -62,6 +61,6 @@ ] }, data_files=get_baked_files(), - python_requires=">=2.7", + python_requires=">=3.6", include_package_data=True, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/test/common.bash new/linode-cli-5.25.0/test/common.bash --- old/linode-cli-5.19.0/test/common.bash 2022-04-19 16:57:46.000000000 +0200 +++ new/linode-cli-5.25.0/test/common.bash 2022-10-31 21:37:30.000000000 +0100 @@ -14,6 +14,11 @@ if [ -z "$uniqueTag" ]; then export uniqueTag="$(date +%s)-tag" fi +# +# A Unique user to use in user related tests +if [ -z "$uniqueUser" ]; then + export uniqueUser="test-user-$(date +%s)" +fi createLinode() { local region=${1:-us-east} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/linode-cli-5.19.0/test/users/users.bats new/linode-cli-5.25.0/test/users/users.bats --- old/linode-cli-5.19.0/test/users/users.bats 1970-01-01 01:00:00.000000000 +0100 +++ new/linode-cli-5.25.0/test/users/users.bats 2022-10-31 21:37:30.000000000 +0100 @@ -0,0 +1,48 @@ +#!/usr/bin/env bats + +load '../test_helper/bats-assert/load' +load '../test_helper/bats-support/load' +load '../common' + +setup() { + suiteName="users" + setToken "$suiteName" +} + +teardown() { + if [ "$LAST_TEST" = "TRUE" ]; then + clearToken "$suiteName" + rm .tmp-user + fi +} + +@test "it should display users" { + run linode-cli users list + assert_success +} + +@test "it should create a user" { + echo "export user=$uniqueUser" > .tmp-user + run linode-cli users create \ + --username $uniqueUser \ + --email [email protected] \ + --restricted true \ + --text \ + --no-headers + assert_success +} + +@test "it should view a user" { + source .tmp-user + + run linode-cli users view $user + assert_success +} + +@test "it should remove a user" { + LAST_TEST="TRUE" + source .tmp-user + + run linode-cli users delete $user + assert_success +} ++++++ openapi.yaml ++++++ ++++ 4928 lines (skipped) ++++ between /work/SRC/openSUSE:Factory/linode-cli/openapi.yaml ++++ and /work/SRC/openSUSE:Factory/.linode-cli.new.1597/openapi.yaml
