def check_storage(self): self.logger.debug("check storage") contents = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(15)) file_name = "checker_test_"+ str(uuid.uuid4()) path = "/tmp/" + file_name download_path = "" with open(path, 'w') as f: f.write(contents) try: with open(path, 'rb') as f: storage.upload_cache(f, file_name) self.logger.debug("upload file %s" % \ path) download_path = storage.download_cache(file_name) self.logger.debug("download file %s" % \ download_path) except Exception as e: self.logger.exception('Got exception on check storage') self.check_result = False finally: self.logger.debug("check api result: %s, retry times %s" % \ (self.check_result, self.retry_times)) for f in [path, download_path]: if os.path.exists(f): os.remove(f) storage.delete_cache(file_name)
def get(self): project_id = g.token['project']['id'] job_name = g.token['job']['name'] template = 'project_%s_job_%s.tar.gz' key = template % (project_id, job_name) key = key.replace('/', '_') f = storage.download_cache(key) if not f: abort(404) return send_file(f)
def get(self): g.release_db() project_id = g.token['project']['id'] job_name = g.token['job']['name'] filename = request.args.get('filename', None) template = 'project_%s_job_%s_%s' key = template % (project_id, job_name, filename) key = key.replace('/', '_') f = storage.download_cache(key) if not f: abort(404) return send_file(f)
def _storage_download_with_metrics(self, file_name): storage.download_cache(file_name)