Runs an eecli command.
(*argv)
| 24 | |
| 25 | |
| 26 | def _run_command(*argv): |
| 27 | """Runs an eecli command.""" |
| 28 | del argv # Unused |
| 29 | |
| 30 | # Set the program name to 'earthengine' for proper help text display. |
| 31 | parser = argparse.ArgumentParser( |
| 32 | prog='earthengine', description='Earth Engine Command Line Interface.') |
| 33 | parser.add_argument( |
| 34 | '--ee_config', help='Path to the earthengine configuration file. ' |
| 35 | 'Defaults to "~/%s".' % utils.DEFAULT_EE_CONFIG_FILE_RELATIVE) |
| 36 | parser.add_argument( |
| 37 | '--service_account_file', help='Path to a service account credentials' |
| 38 | 'file. Overrides any ee_config if specified.') |
| 39 | parser.add_argument( |
| 40 | '--project', |
| 41 | help='Specifies a Google Cloud Platform Project id to override the call.', |
| 42 | dest='project_override') |
| 43 | version = ee.__version__ |
| 44 | parser.add_argument( |
| 45 | '--version', action='version', version=f'%(prog)s {version}' |
| 46 | ) |
| 47 | |
| 48 | dispatcher = CommandDispatcher(parser) |
| 49 | |
| 50 | # Print the list of commands if the user supplied no arguments at all. |
| 51 | if len(sys.argv) == 1: |
| 52 | parser.print_help() |
| 53 | return |
| 54 | |
| 55 | args = parser.parse_args() |
| 56 | config = utils.CommandLineConfig( |
| 57 | config_file=args.ee_config, |
| 58 | service_account_file=args.service_account_file, |
| 59 | project_override=args.project_override, |
| 60 | ) |
| 61 | |
| 62 | # Catch EEException errors, which wrap server-side Earth Engine |
| 63 | # errors, and print the error message without the irrelevant local |
| 64 | # stack trace. (Individual commands may also catch EEException if |
| 65 | # they want to be able to continue despite errors.) |
| 66 | try: |
| 67 | dispatcher.run(args, config) |
| 68 | except ee.EEException as e: |
| 69 | print(e) |
| 70 | sys.exit(1) |
| 71 | |
| 72 | |
| 73 | def _get_tensorflow(): |
no test coverage detected