コード例 #1
0
ファイル: select_command.py プロジェクト: MDunitz/dcp-cli
 def _select_area_by_alias(self, alias):
     try:
         config = UploadConfig()
         uuid = config.area_uuid_from_partial_uuid(partial_uuid=alias)
         config.select_area(uuid)
         print("Upload area %s selected." % uuid)
     except UploadException as e:
         print(str(e))
コード例 #2
0
 def _store_credentials(self):
     stored_creds = {
         'aws_access_key_id': 'skey',
         'aws_secret_access_key': 'ssecret',
         'aws_session_token': 'stoken'
     }
     config = UploadConfig()
     config.areas[self.area.uuid]['credentials'] = stored_creds
     config.save()
     return stored_creds
コード例 #3
0
ファイル: test_forget_area.py プロジェクト: mckinsel/dcp-cli
    def test_when_given_an_alias_that_matches_one_area_it_forgets_that_area(
            self):
        area = self.mock_current_upload_area()
        self.assertIn(area.uuid, UploadConfig().areas)
        self.assertEqual(area.uuid, UploadConfig().current_area)

        forget_area(area.uuid)

        self.assertNotIn(area.uuid, UploadConfig().areas)
        self.assertEqual(None, UploadConfig().current_area)
コード例 #4
0
ファイル: test_api_client.py プロジェクト: MDunitz/dcp-cli
    def setUp(self):
        super(self.__class__, self).setUp()
        config = UploadConfig()
        config._config.upload.preprod_api_url_template = "https://prefix.{deployment_stage}.suffix/v1"
        config._config.upload.production_api_url = "https://prefix.suffix/v1"
        config.save()

        self.api_key = "api-key-{}".format(random.randint(0, 999999999))
        self.api_client = ApiClient(deployment_stage="test",
                                    authentication_token=self.api_key)
コード例 #5
0
ファイル: test_forget.py プロジェクト: MDunitz/dcp-cli
    def test_when_given_an_alias_that_matches_one_area_it_forgets_that_area(
            self):
        area = self.mock_current_upload_area()
        self.assertIn(area.uuid, UploadConfig().areas)
        self.assertEqual(area.uuid, UploadConfig().current_area)

        with CapturingIO('stdout'):
            args = Namespace(uuid_or_alias=area.uuid)
            ForgetCommand(args)

        self.assertNotIn(area.uuid, UploadConfig().areas)
        self.assertEqual(None, UploadConfig().current_area)
コード例 #6
0
 def mock_upload_area(self, area_uuid=None, bucket_name=None):
     """
     Create a UUID and URI for a fake upload area, store it in Tweak config.
     """
     if not area_uuid:
         area_uuid = str(uuid.uuid4())
     if not bucket_name:
         bucket_name = self.UPLOAD_BUCKET_NAME_TEMPLATE.format(deployment_stage=self.deployment_stage)
     area_uri_str = "s3://{bucket}/{uuid}/".format(bucket=bucket_name, uuid=area_uuid)
     area_uri = UploadAreaURI(area_uri_str)
     config = UploadConfig()
     config.add_area(area_uri)
     area = self.upload_service.upload_area(area_uri=area_uri)
     return area
コード例 #7
0
 def __init__(self, args):
     area_uuid = args.uuid
     env = args.env
     out_put = args.output_file_name
     config = UploadConfig()
     if not area_uuid:
         area_uuid = config.current_area
     if not env:
         area_uri = config.area_uri(area_uuid)
         env = area_uri.deployment_stage
     if not out_put:
         out_put = area_uuid
     UploadAreaFilesStatusCheck(env).check_file_statuses(area_uuid, out_put)
     print('File status report for {}/{} generated, located {}.txt'.format(
         env, area_uuid, out_put))
コード例 #8
0
 def __init__(self, args):
     area_uuid = args.uuid
     env = args.env
     config = UploadConfig()
     if not area_uuid:
         area_uuid = config.current_area
     if not env:
         area_uri = config.area_uri(area_uuid)
         env = area_uri.deployment_stage
     filename = args.filename
     status = FileStatusCheck(env).check_file_status(area_uuid, filename)
     if re.search('STATUS_RETRIEVAL_ERROR', status):
         print(status)
     else:
         print("File: {} in UploadArea: {}/{} is currently {}".format(filename, env, area_uuid, status))
コード例 #9
0
ファイル: select_command.py プロジェクト: MDunitz/dcp-cli
 def _save_and_select_area_by_uri(self, uri_string):
     if not uri_string.endswith('/'):
         uri_string += '/'
     uri = UploadAreaURI(uri_string)
     config = UploadConfig()
     if uri.area_uuid in config.areas:
         config.select_area(uri.area_uuid)
     else:
         config.add_area(uri)
         config.select_area(uri.area_uuid)
     print("Upload area %s selected." % uri.area_uuid)
     print(
         "In future you may refer to this upload area using the alias \"%s\""
         % config.unique_prefix(uri.area_uuid))
コード例 #10
0
ファイル: list_area_command.py プロジェクト: MDunitz/dcp-cli
    def __init__(self, args):
        config = UploadConfig()
        area_uuid = config.current_area
        area_uri = config.area_uri(area_uuid)
        upload_service = UploadService(
            deployment_stage=area_uri.deployment_stage)
        upload_area = upload_service.upload_area(area_uri=area_uri)

        for f in upload_area.list(detail=args.long):
            print(f['name'])
            if args.long:
                print("\t%-12s %d bytes\n\t%-12s %s\n\t%-12s %s" %
                      ('size', f['size'], 'URL', f['url'], 'Content-Type',
                       f['content_type']))
                if 'checksums' in f:
                    for checksum in ('S3_Etag', 'CRC32C', 'SHA1', 'SHA256'):
                        if checksum.lower() in f['checksums']:
                            print("\t%-12s %s" %
                                  (checksum, f['checksums'][checksum.lower()]))
コード例 #11
0
 def __init__(self, args):
     upload_area = args.uuid
     env = args.env
     config = UploadConfig()
     if not upload_area:
         upload_area = config.current_area
     if not env:
         env = UploadArea(uuid=upload_area).deployment_stage
     filename = args.filename
     status = FileStatusCheck(env).check_file_status(upload_area, filename)
     if re.search('STATUS_RETRIEVAL_ERROR', status):
         print(status)
     else:
         print("File: {} in UploadArea: {}/{} is currently {}".format(
             filename, env, upload_area, status))
コード例 #12
0
 def __init__(self, args):
     upload_area = args.uuid
     env = args.env
     out_put = args.output_file_name
     config = UploadConfig()
     if not upload_area:
         upload_area = config.current_area
     if not env:
         env = UploadArea(uuid=upload_area).deployment_stage
     if not out_put:
         out_put = upload_area
     UploadAreaFilesStatusCheck(env).check_file_statuses(
         upload_area, out_put)
     print('File status report for {}/{} generated, located {}.txt'.format(
         env, upload_area, out_put))
コード例 #13
0
 def setUp(self):
     super(self.__class__, self).setUp()
     config = UploadConfig()
     config._config.upload.preprod_api_url_template = "https://prefix.{deployment_stage}.suffix"
     config._config.upload.production_api_url = "https://prefix.suffix"
     config.save()
コード例 #14
0
 def mock_current_upload_area(self, area_uuid=None, bucket_name=None):
     area = self.mock_upload_area(area_uuid=area_uuid, bucket_name=bucket_name)
     UploadConfig().select_area(area.uuid)
     return area