def ConfigureCommandArgumentParsers(self, subparsers): """Configures argparse arguments and argcomplete completers for commands. Args: subparsers: argparse object that can be used to add parsers for subcommands (called just 'commands' in gsutil) """ # This should match the support map for the "ls" command. support_map = { 'gs': [ApiSelector.XML, ApiSelector.JSON], 's3': [ApiSelector.XML] } default_map = {'gs': ApiSelector.JSON, 's3': ApiSelector.XML} gsutil_api_map = GsutilApiMapFactory.GetApiMap( self.gsutil_api_class_map_factory, support_map, default_map) logger = CreateGsutilLogger('tab_complete') gsutil_api = CloudApiDelegator(self.bucket_storage_uri_class, gsutil_api_map, logger, debug=0) for command in set(self.command_map.values()): command_parser = subparsers.add_parser( command.command_spec.command_name, add_help=False) if isinstance(command.command_spec.argparse_arguments, dict): subcommand_parsers = command_parser.add_subparsers() subcommand_argument_dict = command.command_spec.argparse_arguments for subcommand, arguments in subcommand_argument_dict.iteritems( ): subcommand_parser = subcommand_parsers.add_parser( subcommand, add_help=False) self._ConfigureCommandArgumentParserArguments( subcommand_parser, arguments, gsutil_api) else: self._ConfigureCommandArgumentParserArguments( command_parser, command.command_spec.argparse_arguments, gsutil_api)
def testTranslateApitoolsResumableUploadException(self): """Tests that _TranslateApitoolsResumableUploadException works correctly.""" gsutil_api = GcsJsonApi( GSMockBucketStorageUri, CreateGsutilLogger('copy_test'), DiscardMessagesQueue()) gsutil_api.http.disable_ssl_certificate_validation = True exc = apitools_exceptions.HttpError({'status': 503}, None, None) translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc) self.assertTrue(isinstance(translated_exc, ServiceException)) gsutil_api.http.disable_ssl_certificate_validation = False exc = apitools_exceptions.HttpError({'status': 503}, None, None) translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc) self.assertTrue(isinstance(translated_exc, ResumableUploadException)) gsutil_api.http.disable_ssl_certificate_validation = False exc = apitools_exceptions.HttpError({'status': 429}, None, None) translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc) self.assertTrue(isinstance(translated_exc, ResumableUploadException)) exc = apitools_exceptions.HttpError({'status': 410}, None, None) translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc) self.assertTrue(isinstance(translated_exc, ResumableUploadStartOverException)) exc = apitools_exceptions.HttpError({'status': 404}, None, None) translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc) self.assertTrue(isinstance(translated_exc, ResumableUploadStartOverException)) exc = apitools_exceptions.HttpError({'status': 401}, None, None) translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc) self.assertTrue(isinstance(translated_exc, ResumableUploadAbortException)) exc = apitools_exceptions.TransferError('Aborting transfer') translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc) self.assertTrue(isinstance(translated_exc, ResumableUploadAbortException))
def setUp(self): super(TestAcl, self).setUp() self.sample_uri = self.CreateBucket() self.sample_url = StorageUrlFromString(str(self.sample_uri)) self.logger = CreateGsutilLogger('acl')
def __init__(self, do_parallel): self.logger = CreateGsutilLogger('FakeCommand') self.parallel_operations = do_parallel self.failure_count = 0 self.multiprocessing_is_available = MultiprocessingIsAvailable()[0]
def setUp(self): super(TestTabComplete, self).setUp() self.logger = CreateGsutilLogger('tab_complete')
def setUp(self): super(TestAcl, self).setUp() self.sample_uri = self.CreateBucket() self.logger = CreateGsutilLogger('acl')