本文整理汇总了Python中libraries.app.app.App.pre_convert_s3_handler方法的典型用法代码示例。如果您正苦于以下问题:Python App.pre_convert_s3_handler方法的具体用法?Python App.pre_convert_s3_handler怎么用?Python App.pre_convert_s3_handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libraries.app.app.App
的用法示例。
在下文中一共展示了App.pre_convert_s3_handler方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import pre_convert_s3_handler [as 别名]
def setUp(self):
"""Runs before each test."""
App(prefix='{0}-'.format(self._testMethodName), db_connection_string='sqlite:///:memory:')
App.cdn_s3_handler().create_bucket()
App.pre_convert_s3_handler().create_bucket()
App.cdn_s3_handler().upload_file = self.mock_cdn_upload_file
App.cdn_s3_handler().get_json = self.mock_cdn_get_json
App.pre_convert_s3_handler().upload_file = self.mock_s3_upload_file
try:
os.makedirs(ClientWebhookTest.base_temp_dir)
except:
pass
self.temp_dir = tempfile.mkdtemp(dir=self.base_temp_dir, prefix='webhookTest_')
self.job_converter_count = 0
self.job_linter_count = 0
self.uploaded_files = []
self.job_data = {
'job_id': '123456890',
'status': 'started',
'success': False,
'resource_type': 'obs',
'input_format': 'md',
'output_format': 'html',
'convert_module': 'module1',
'created_at': datetime.utcnow(),
'errors': []
}
self.register_modules()
示例2: upload_zip_file
# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import pre_convert_s3_handler [as 别名]
def upload_zip_file(self, commit_id, zip_filepath):
file_key = 'preconvert/{0}.zip'.format(commit_id)
App.logger.debug('Uploading {0} to {1}/{2}...'.format(zip_filepath, App.pre_convert_bucket, file_key))
try:
App.pre_convert_s3_handler().upload_file(zip_filepath, file_key, cache_time=0)
except Exception as e:
App.logger.error('Failed to upload zipped repo up to server')
App.logger.exception(e)
finally:
App.logger.debug('finished.')
return file_key
示例3: check_download
# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import pre_convert_s3_handler [as 别名]
def check_download(self, commit_id):
if not commit_id:
commit_id = ''
App.logger.debug("Start: check for download: " + commit_id)
response = { # default to error
'ErrorMessage': DownloadMetrics.ACCESS_FAILED_ERROR + commit_id
}
if not commit_id:
App.logger.warning("Invalid commit: " + commit_id)
return response
key = 'preconvert/{0}.zip'.format(commit_id)
try:
download_exists = App.pre_convert_s3_handler().key_exists(key)
except Exception as e:
App.logger.error("Access failure for '" + key + "': " + str(e))
return response
del response['ErrorMessage']
App.logger.debug("Download exists for '" + key + "': " + str(download_exists))
response['download_exists'] = download_exists
return response
示例4: test_check_present_download
# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import pre_convert_s3_handler [as 别名]
def test_check_present_download(self):
# given
commit_id = '39a099622d'
key = 'preconvert/' + commit_id + '.zip'
App.pre_convert_s3_handler().put_contents(key, "dummy")
exists = App.pre_convert_s3_handler().key_exists(key)
self.callback = 'callback'
event = {
'data': {
'commit_id': commit_id,
'callback': self.callback
}
}
self.expected_download_exists = True
self.error_response = None
handler = CheckDownloadHandler()
# when
results = handler.handle(event, None)
# then
self.validate_results(results)
示例5: setUp
# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import pre_convert_s3_handler [as 别名]
def setUp(self):
"""Runs before each test."""
App(prefix='{0}-'.format(self._testMethodName), db_connection_string='sqlite:///:memory:')
App.pre_convert_s3_handler().create_bucket()
示例6: mock_cdn_upload_file
# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import pre_convert_s3_handler [as 别名]
def mock_cdn_upload_file(self, project_file, s3_key, cache_time=0):
bucket_name = App.pre_convert_s3_handler().bucket.name
return self.upload_file(bucket_name, project_file, s3_key)
示例7: delete_preconvert_zip_file
# 需要导入模块: from libraries.app.app import App [as 别名]
# 或者: from libraries.app.app.App import pre_convert_s3_handler [as 别名]
def delete_preconvert_zip_file(self, commit_sha):
self.preconvert_handler = App.pre_convert_s3_handler()
preconvert_key = self.get_preconvert_s3_key(commit_sha)
if App.pre_convert_s3_handler().key_exists(preconvert_key):
App.logger.debug("deleting preconvert file: " + preconvert_key)
App.pre_convert_s3_handler().delete_file(preconvert_key, catch_exception=True)