summaryrefslogtreecommitdiffstats
path: root/ogcli
Commit message (Collapse)AuthorAgeFilesLines
* ogcli: move configuration data into a different fileAlejandro Sirgo Rica12 days1-17/+1
| | | | | Move the configuration into its own file so it is easier to access from multiple files.
* cli: ensure the program returns 0 on success and 1 on errorAlejandro Sirgo Rica12 days1-1/+2
| | | | | | | | | | propagate a returncode in each operation and make it the returncode of the program. Prevent sys.exit calls in post(), get() and delete() request handlers to enable cleanup code and error handling. Keep a basic error log inside the request functions if the connection can't be established or if the response contains an error code.
* ogcli: really ignore SIGPIPEv0.3.3-5OpenGnSys Support Team2024-01-041-1/+1
| | | | SIG_DFL needs to be used to disable SIGPIPE in python, SIG_IGN does not work.
* src: update copyright statementOpenGnSys Support Team2024-01-021-1/+1
| | | | use opengnsys@soleta.eu email instead of info@soleta.eu
* ogcli: add SIGINT handlerOpenGnSys Support Team2023-11-301-0/+4
| | | | if user presses ctrl-c, interrupt ongoing operation to avoid python backtrace.
* ogcli: ignore SIGPIPEv0.3.3-2OpenGnSys Support Team2023-11-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | # ogcli list scope | less ... leave it open for one minute, then press 'q' to exit less it shows: Traceback (most recent call last): File "/usr/bin/ogcli", line 60, in <module> CLI() File "/usr/bin/ogcli", line 56, in __init__ getattr(self.ogcli, args.command)(sys.argv[2:]) File "/opt/opengnsys/bin/cli/cli.py", line 93, in list OgScope.list_scopes(self.rest) File "/opt/opengnsys/bin/cli/objects/scopes.py", line 18, in list_scopes print_json(r.text) File "/opt/opengnsys/bin/cli/utils.py", line 34, in print_json print(json.dumps(payload, sort_keys=True, indent=2)) BrokenPipeError: [Errno 32] Broken pipe It seems that the request library in python leaves the socket open while it still displays the listing. Ignore SIGPIPE which reports that socket is not there anymore, it is a common practise to ignore this signal in socket.
* ogcli: improve handling of subcommand errorsJose M. Guisado2023-10-061-2/+8
| | | | | If no subcommand or an invalid one is specified print an error message followed by ogcli --help. Also exit with status code 1.
* format: use autopep8Jose M. Guisado2022-05-201-32/+34
| | | | | | | | | | | | | | Use autopep8 for coding format, and only for whitespace changes. This change drops use of tabs in favor of spaces. Doesn't use autopep8 --aggresive option. Format command: $ autopep8 --inline --recursive . When using git-blame, use --ignore-rev in order to ignore this reformatting commit.
* Fix --helpJose M. Guisado2022-05-101-3/+5
| | | | | | | | | | | | | | | | | | | Non-method attributes are shown using dir() when listing available commands. usage: ogcli [-h] [{create,list,restore,rest,send,set,setup}] 'rest' is a class instance of OgRest and must not be shown when listing available commands. Method members of OgCLI class are the available commands that ogcli can execute. Use inspect module in order to get class members (getmembers) and filter only those that are a method (ismethod). usage: ogcli [-h] [{create,list,restore,send,set,setup}] Fixes: 0f2d1f1dba4 ("Show all valid commands when running ogcli --help")
* Show all valid commands when running ogcli --helpJose M. Guisado2021-09-271-1/+3
| | | | | | | | | | | | | | | | Commands are retrieved using dir() so future commands will show accordingly. "ogcli --help" now will print: usage: ogcli [-h] {create,list,rest,restore,send,set,setup} positional arguments: {create,list,rest,restore,send,set,setup} Subcommand to run optional arguments: -h, --help show this help message and exit
* ogCLI is AGPLv3+OpenGnSys Support Team2021-05-141-4/+3
| | | | Update license header in files.
* Fix ogcli shebangRoberto Hueso Gómez2020-07-011-1/+1
| | | | This uses python3 and improves portability by using '/usr/bin/env'.
* add license header to source code filesOpenGnSys Support Team2020-07-011-0/+8
|
* Rename files to remove 'og' prefixRoberto Hueso Gómez2020-06-307-58/+41
| | | | | This prefix is redundant on almost every file, so the prefix is removed from filenames and imports.
* Add list modes commandRoberto Hueso Gómez2020-06-302-1/+10
| | | | This is consistent with HTTP GET /modes
* Add list scopes commandRoberto Hueso Gómez2020-06-192-2/+12
| | | | This is consistent with HTTP GET /scopes
* Rewrite basic structureRoberto Hueso Gómez2020-06-193-9/+29
| | | | | | | This commit: - Adds OgREST class as a wrapper for HTTP REST requests. - Adds objects folder which will contain available functions for each object in the OpenGnsys ecosystem (e.g. client, image, etc.).
* First commitOpenGnSys Support Team2020-06-182-0/+19
Add basic OgCLI structure.