def _store_dependency(self, dependency_path, fileobj, target_type): try: if target_type == 'directory': un_tar_directory(fileobj, dependency_path, 'gz') else: with open(dependency_path, 'wb') as f: shutil.copyfileobj(fileobj, f) except: remove_path(dependency_path) raise
def _store_dependency(self, dependency_path, fileobj, filename): try: if filename.endswith('.tar.gz'): un_tar_directory(fileobj, dependency_path, 'gz') else: with open(dependency_path, 'wb') as f: shutil.copyfileobj(un_gzip_stream(fileobj), f) except: remove_path(dependency_path) raise
def _upgrade(self): logger.debug('Upgrading') worker_dir = os.path.dirname(os.path.realpath(__file__)) while True: try: with closing(self._bundle_service.get_code()) as code: remove_path(worker_dir) un_tar_directory(code, worker_dir, 'gz') break except Exception: traceback.print_exc() time.sleep(1) exit(123)