| @@ 18-68 (lines=51) @@ | ||
| 15 | __license__ = "WTFPL v2" |
|
| 16 | __copyright__ = "2017-2018 Thurask" |
|
| 17 | ||
| 18 | ||
| 19 | def grab_args(): |
|
| 20 | """ |
|
| 21 | Parse arguments from argparse/questionnaire. |
|
| 22 | ||
| 23 | Invoke :func:`tclloader.tclloader_main` with those arguments. |
|
| 24 | """ |
|
| 25 | parser = scriptutils.default_parser("bb-tclloader", "Create autoloaders from TCL templates") |
|
| 26 | parser.add_argument("loaderfile", |
|
| 27 | help="Loader zip file or directory", |
|
| 28 | type=utilities.file_exists) |
|
| 29 | parser.add_argument( |
|
| 30 | "-n", |
|
| 31 | "--name", |
|
| 32 | dest="loadername", |
|
| 33 | help="Manually specify loader name", |
|
| 34 | metavar="NAME", |
|
| 35 | default=None) |
|
| 36 | parser.add_argument( |
|
| 37 | "-d", |
|
| 38 | "--directory", |
|
| 39 | dest="directory", |
|
| 40 | help="Use a directory instead of a zip file", |
|
| 41 | action="store_true", |
|
| 42 | default=False) |
|
| 43 | parser.add_argument( |
|
| 44 | "-l", |
|
| 45 | "--localtools", |
|
| 46 | dest="localtools", |
|
| 47 | help="Use local fastboot tools instead of remote", |
|
| 48 | action="store_true", |
|
| 49 | default=False) |
|
| 50 | parser.add_argument( |
|
| 51 | "-c", |
|
| 52 | "--compress", |
|
| 53 | dest="compress", |
|
| 54 | help="Compress final autoloader", |
|
| 55 | action="store_true", |
|
| 56 | default=False) |
|
| 57 | parser.add_argument( |
|
| 58 | "-nw", |
|
| 59 | "--no-wipe", |
|
| 60 | dest="wipe", |
|
| 61 | help="Don't include lines to wipe userdata", |
|
| 62 | action="store_false", |
|
| 63 | default=True) |
|
| 64 | if len(sys.argv) == 1 and getattr(sys, 'frozen', False): |
|
| 65 | print("You're better off running this from command line") |
|
| 66 | decorators.enter_to_exit(True) |
|
| 67 | args = parser.parse_args(sys.argv[1:]) |
|
| 68 | parser.set_defaults() |
|
| 69 | tclloader_main(args.loaderfile, args.loadername, args.directory, args.localtools, args.compress, args.wipe) |
|
| 70 | ||
| 71 | ||
| @@ 14-58 (lines=45) @@ | ||
| 11 | __copyright__ = "2017-2018 Thurask" |
|
| 12 | ||
| 13 | ||
| 14 | def grab_args(): |
|
| 15 | """ |
|
| 16 | Parse arguments from argparse/questionnaire. |
|
| 17 | ||
| 18 | Invoke a function with those arguments. |
|
| 19 | """ |
|
| 20 | parser = scriptutils.default_parser("bb-tcldelta", "Check for delta updates for TCL devices") |
|
| 21 | parser.add_argument("curef", help="PRD to check", default=None, nargs="?") |
|
| 22 | parser.add_argument("fvver", help="Current OS version", default=None, nargs="?") |
|
| 23 | parser.add_argument( |
|
| 24 | "-d", |
|
| 25 | "--download", |
|
| 26 | dest="download", |
|
| 27 | help="Download update file", |
|
| 28 | action="store_true", |
|
| 29 | default=False) |
|
| 30 | parser.add_argument( |
|
| 31 | "-o", |
|
| 32 | "--original-filename", |
|
| 33 | dest="original", |
|
| 34 | help="Save with original filename (implies -d)", |
|
| 35 | action="store_true", |
|
| 36 | default=False) |
|
| 37 | parser.add_argument( |
|
| 38 | "-r", |
|
| 39 | "--remote", |
|
| 40 | dest="remote", |
|
| 41 | help="Get latest OTA versions from remote server", |
|
| 42 | action="store_true", |
|
| 43 | default=False) |
|
| 44 | parser.add_argument( |
|
| 45 | "-x", |
|
| 46 | "--export", |
|
| 47 | dest="export", |
|
| 48 | help="Write XML to logs folder", |
|
| 49 | action="store_true", |
|
| 50 | default=False) |
|
| 51 | args = parser.parse_args(sys.argv[1:]) |
|
| 52 | parser.set_defaults() |
|
| 53 | if args.curef is None: |
|
| 54 | args = questionnaire(args) |
|
| 55 | elif args.fvver is None and not args.remote: |
|
| 56 | args = questionnaire(args) |
|
| 57 | tcldelta_main(args.curef, args.fvver, args.download, args.original, args.export) |
|
| 58 | decorators.enter_to_exit(True) |
|
| 59 | ||
| 60 | ||
| 61 | def questionnaire(args): |
|