|
23 | 23 | This package implements the "official" WebScripts client.
|
24 | 24 | This package implements client for default WebScripts features.
|
25 | 25 |
|
| 26 | +Basic: |
| 27 | +
|
| 28 | +~# python -m WebScriptsClient -u Admin -p Admin exec "show_license.py" http://127.0.0.1:8000/web/auth/ |
| 29 | +
|
| 30 | +ExitCode: 1 |
| 31 | +Errors: USAGE: show_license.py [part required string] |
| 32 | +
|
| 33 | +~# python -m WebScriptsClient -u Admin -p Admin exec "show_license.py copyright" http://127.0.0.1:8000/web/auth/ |
| 34 | +
|
| 35 | +WebScripts Copyright (C) 2021, 2022 Maurice Lambert |
| 36 | +This program comes with ABSOLUTELY NO WARRANTY. |
| 37 | +This is free software, and you are welcome to redistribute it |
| 38 | +under certain conditions. |
| 39 | +
|
| 40 | +
|
| 41 | +ExitCode: 0 |
| 42 | +Errors: |
| 43 | +
|
| 44 | +~# python -m WebScriptsClient -u Admin -p Admin exec "show_license.py copyright error" http://127.0.0.1:8000/web/auth/ |
| 45 | +
|
| 46 | +WebScripts Copyright (C) 2021, 2022 Maurice Lambert |
| 47 | +This program comes with ABSOLUTELY NO WARRANTY. |
| 48 | +This is free software, and you are welcome to redistribute it |
| 49 | +under certain conditions. |
| 50 | +
|
| 51 | +
|
| 52 | +ExitCode: 2 |
| 53 | +Errors: ERROR: unexpected arguments ['error'] |
| 54 | +
|
| 55 | +Full examples: |
| 56 | +
|
26 | 57 | ~# python WebScriptsClient.py -v -u Admin -p Admin test http://127.0.0.1:8000/web/
|
27 | 58 |
|
28 | 59 | ~# python WebScriptsClient.py -v -u Admin -p Admin download -f "LICENSE.txt" "LICENSE.txt" http://127.0.0.1:8000/web/
|
|
41 | 72 | ~# python -c "print('test')" > test.txt
|
42 | 73 | ~# python WebScriptsClient.py -v -u Admin -p Admin exec "test_config.py" -I test.txt http://127.0.0.1:8000/web/
|
43 | 74 | ~# python WebScriptsClient.py -v -u Admin -p Admin exec "test_config.py --test test3 --test4 -t" -i "test1" "test2" http://127.0.0.1:8000/web/
|
| 75 | +~# python -m WebScriptsClient -u Admin -p Admin exec password_generator.py http://127.0.0.1:8000/web/auth/ |
| 76 | +~# python -m WebScriptsClient -u Admin -p Admin exec "show_license.py license" http://127.0.0.1:8000/web/auth/ |
| 77 | +~# python -m WebScriptsClient -u Admin -p Admin exec "show_license.py copyright codeheader" http://127.0.0.1:8000/web/auth/ |
44 | 78 |
|
45 | 79 | ~# python WebScriptsClient.py -v info http://127.0.0.1:8000/web/
|
46 | 80 | ~# python WebScriptsClient.py -a AdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdminAdmin info -a -c -d -s "test_config.py" "/auth/" http://127.0.0.1:8000/web/
|
|
58 | 92 | >>> print(f"Error: {error}")
|
59 | 93 | """
|
60 | 94 |
|
61 |
| -__version__ = "0.0.2" |
| 95 | +__version__ = "0.0.3" |
62 | 96 | __author__ = "Maurice Lambert"
|
63 | 97 | __author_email__ = "mauricelambert434@gmail.com"
|
64 | 98 | __maintainer__ = "Maurice Lambert"
|
@@ -231,7 +265,8 @@ def http_error_403(
|
231 | 265 | log = f"HTTP error {code}: {message} -> you do not have permissions."
|
232 | 266 | url = request.get_full_url()
|
233 | 267 | command = (
|
234 |
| - f"{argv[0]} request -n [name] -t Access -r" |
| 268 | + f"{argv[0]} [(-a <KEY>|-A|-u <USER> -p <PASSWORD>|-u -P)]" |
| 269 | + " request -n [name] -s Access -r" |
235 | 270 | f' "I need access to this script." {url}'
|
236 | 271 | )
|
237 | 272 | logger_error(log)
|
@@ -280,7 +315,8 @@ def http_error_302(
|
280 | 315 | log = f"HTTP error {code}: {message} -> you do not have permissions."
|
281 | 316 | url = request.get_full_url()
|
282 | 317 | command = (
|
283 |
| - f"{argv[0]} request -n [name] -t Access -r" |
| 318 | + f"{argv[0]} [(-a <KEY>|-A|-u <USER> -p <PASSWORD>|-u -P)]" |
| 319 | + " request -n [name] -s Access -r" |
284 | 320 | f' "I need access to this script." {url}'
|
285 | 321 | )
|
286 | 322 | logger_error(log)
|
@@ -1179,7 +1215,16 @@ def cli_request(args: Namespace) -> None:
|
1179 | 1215 | logger_debug("Authenticate the WebScriptsClient...")
|
1180 | 1216 | client.auth()
|
1181 | 1217 |
|
1182 |
| - client.request(args.subject, args.request, args.name, args.error_code) |
| 1218 | + try: |
| 1219 | + client.request(args.subject, args.request, args.name, args.error_code) |
| 1220 | + except WebScriptsPermissionsError: |
| 1221 | + log = ( |
| 1222 | + "Please, retry with authentication. " |
| 1223 | + "An authentication is required on this server." |
| 1224 | + ) |
| 1225 | + logger_error(log) |
| 1226 | + print(log) |
| 1227 | + |
1183 | 1228 | logger_debug("Request sent without error.")
|
1184 | 1229 |
|
1185 | 1230 |
|
|
0 commit comments