當前位置: 首頁>>代碼示例>>Python>>正文


Python App.pre_convert_s3_handler方法代碼示例

本文整理匯總了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()
開發者ID:unfoldingWord-dev,項目名稱:tx-manager,代碼行數:33,代碼來源:test_client_webhook.py

示例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
開發者ID:unfoldingWord-dev,項目名稱:tx-manager,代碼行數:13,代碼來源:client_webhook.py

示例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
開發者ID:unfoldingWord-dev,項目名稱:tx-manager,代碼行數:27,代碼來源:download_metrics.py

示例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)
開發者ID:unfoldingWord-dev,項目名稱:tx-manager,代碼行數:24,代碼來源:test_checkDownloadHandler.py

示例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()
開發者ID:unfoldingWord-dev,項目名稱:tx-manager,代碼行數:6,代碼來源:test_checkDownloadHandler.py

示例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)
開發者ID:unfoldingWord-dev,項目名稱:tx-manager,代碼行數:5,代碼來源:test_client_webhook.py

示例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)
開發者ID:unfoldingWord-dev,項目名稱:tx-manager,代碼行數:8,代碼來源:test_conversion.py


注:本文中的libraries.app.app.App.pre_convert_s3_handler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。