@@ 17-73 (lines=57) @@ | ||
14 | __copyright__ = "2017-2019 Thurask" |
|
15 | ||
16 | ||
17 | def grab_args(): |
|
18 | """ |
|
19 | Parse arguments from argparse/questionnaire. |
|
20 | ||
21 | Invoke a function with those arguments. |
|
22 | """ |
|
23 | if getattr(sys, "frozen", False) and len(sys.argv) == 1: |
|
24 | questionnaire() |
|
25 | else: |
|
26 | parser = argutils.default_parser("bb-tclnewprd", "Check for new PRDs for TCL devices") |
|
27 | parser.add_argument( |
|
28 | "prds", |
|
29 | help="Only scan space separated list of PRDs", |
|
30 | default=None, |
|
31 | nargs="*") |
|
32 | parser.add_argument( |
|
33 | "-f", |
|
34 | "--floor", |
|
35 | dest="floor", |
|
36 | help="When to start, default=1", |
|
37 | default=1, |
|
38 | type=int, |
|
39 | choices=range(0, 998), |
|
40 | metavar="INT") |
|
41 | parser.add_argument( |
|
42 | "-c", |
|
43 | "--ceiling", |
|
44 | dest="ceiling", |
|
45 | help="When to stop, default=60", |
|
46 | default=None, |
|
47 | type=int, |
|
48 | choices=range(1, 999), |
|
49 | metavar="INT") |
|
50 | parser.add_argument( |
|
51 | "-x", |
|
52 | "--export", |
|
53 | dest="export", |
|
54 | help="Write XML to logs folder", |
|
55 | action="store_true", |
|
56 | default=False) |
|
57 | parser.add_argument( |
|
58 | "-np", |
|
59 | "--no-prefix", |
|
60 | dest="noprefix", |
|
61 | help="Don't add PRD- prefix", |
|
62 | action="store_true", |
|
63 | default=False) |
|
64 | parser.add_argument( |
|
65 | "-k", |
|
66 | "--key2", |
|
67 | dest="key2mode", |
|
68 | help="Use KEY2 syntax", |
|
69 | action="store_true", |
|
70 | default=False) |
|
71 | args = parser.parse_args(sys.argv[1:]) |
|
72 | parser.set_defaults() |
|
73 | execute_args(args) |
|
74 | ||
75 | ||
76 | def questionnaire(): |
@@ 20-74 (lines=55) @@ | ||
17 | __copyright__ = "2017-2019 Thurask" |
|
18 | ||
19 | ||
20 | def grab_args(): |
|
21 | """ |
|
22 | Parse arguments from argparse/questionnaire. |
|
23 | ||
24 | Invoke a function with those arguments. |
|
25 | """ |
|
26 | if getattr(sys, "frozen", False) and len(sys.argv) == 1: |
|
27 | questionnaire() |
|
28 | else: |
|
29 | parser = argutils.default_parser("bb-tclscan", "Check for updates for TCL devices") |
|
30 | parser.add_argument("prd", help="Only scan one PRD", default=None, nargs="?") |
|
31 | parser.add_argument( |
|
32 | "-l", |
|
33 | "--list", |
|
34 | dest="printlist", |
|
35 | help="List PRDs in database", |
|
36 | action="store_true", |
|
37 | default=False) |
|
38 | parser.add_argument( |
|
39 | "-d", |
|
40 | "--download", |
|
41 | dest="download", |
|
42 | help="Download update, assumes single PRD", |
|
43 | action="store_true", |
|
44 | default=False) |
|
45 | parser.add_argument( |
|
46 | "-o", |
|
47 | "--ota-version", |
|
48 | dest="otaver", |
|
49 | help="Query OTA updates from a given version instead of full OS", |
|
50 | default=None) |
|
51 | parser.add_argument( |
|
52 | "-r", |
|
53 | "--remote", |
|
54 | dest="remote", |
|
55 | help="Get latest OTA versions from remote server", |
|
56 | action="store_true", |
|
57 | default=False) |
|
58 | parser.add_argument( |
|
59 | "-t", |
|
60 | "--device-type", |
|
61 | dest="device", |
|
62 | help="Scan only one device", |
|
63 | default=None, |
|
64 | type=argutils.droidlookup_devicetype) |
|
65 | parser.add_argument( |
|
66 | "-x", |
|
67 | "--export", |
|
68 | dest="export", |
|
69 | help="Write XML to logs folder", |
|
70 | action="store_true", |
|
71 | default=False) |
|
72 | args = parser.parse_args(sys.argv[1:]) |
|
73 | parser.set_defaults() |
|
74 | execute_args(args) |
|
75 | ||
76 | ||
77 | def execute_args(args): |