|
1 | 1 | #!/usr/bin/env python |
2 | 2 |
|
3 | | -import logging |
4 | 3 | import sys |
5 | 4 |
|
6 | | -from edge_addons_api.client import Client, Options |
| 5 | +from edge_addons_api.client import Client |
7 | 6 | from edge_addons_api.exceptions import UploadException |
8 | 7 |
|
9 | | -if len(sys.argv) < 6: |
10 | | - print("Incorrect number of arguments given. Please check action parameters") |
11 | | - sys.exit(1) |
12 | | - |
13 | | -product_id = sys.argv[1] |
14 | | -client_id = sys.argv[2] |
15 | | -api_key = sys.argv[3] |
16 | | -file_path = sys.argv[5] |
17 | | -notes = sys.argv[6] |
18 | | -debug = sys.argv[7].lower() in ["true", "1"] |
19 | | -retry_count = int(sys.argv[8]) |
20 | | -sleep_seconds = int(sys.argv[9]) |
21 | | - |
22 | | -logger = logging.getLogger() |
23 | | -handler = logging.StreamHandler(sys.stdout) |
24 | | -logger.addHandler(handler) |
25 | | - |
26 | | -if debug: |
27 | | - logger.setLevel(logging.DEBUG) |
28 | | - logging.getLogger("urllib3").setLevel(logging.WARNING) |
29 | | - |
| 8 | +from edge_addon.config import create_options |
| 9 | +from edge_addon.logging_utils import setup_logging |
30 | 10 |
|
31 | | -options = Options( |
32 | | - product_id=product_id, |
33 | | - client_id=client_id, |
34 | | - api_key=api_key, |
35 | | - retry_count=retry_count, |
36 | | - sleep_seconds=sleep_seconds, |
37 | | -) |
| 11 | +options = create_options() |
| 12 | +setup_logging(options.debug) |
38 | 13 |
|
39 | | -client = Client(options) |
| 14 | +client = Client(options.to_edge_options()) |
40 | 15 |
|
41 | 16 | print("Submitting addon") |
42 | 17 |
|
43 | 18 | try: |
44 | | - operation_id = client.submit(file_path=file_path, notes=notes) |
| 19 | + operation_id = client.submit(file_path=options.file_path, notes=options.notes) |
45 | 20 | client.fetch_publish_status(operation_id) |
46 | 21 |
|
47 | 22 | print("Successfully uploaded addon") |
|
0 commit comments