def fetch_dsym(self, project, image_uuid): image_uuid = image_uuid.lower() for path in self.get_project_path(project), self.get_global_path(): base = self.get_project_path(project) dsym = os.path.join(base, image_uuid) try: stat = os.stat(dsym) except OSError as e: if e.errno != errno.ENOENT: raise else: return base, self.try_bump_timestamp(dsym, stat) dsf = find_dsym_file(project, image_uuid) if dsf is None: return None if dsf.is_global: base = self.get_global_path() else: base = self.get_project_path(project) dsym = os.path.join(base, image_uuid) try: os.makedirs(base) except OSError: pass with dsf.file.getfile() as sf: with open(dsym + '_tmp', 'w') as df: shutil.copyfileobj(sf, df) os.rename(dsym + '_tmp', dsym) return base, dsym
def fetch_dsym(self, project, image_uuid, on_dsym_file_referenced=None): image_uuid = image_uuid.lower() for path in self.get_project_path(project), self.get_global_path(): base = self.get_project_path(project) dsym = os.path.join(base, image_uuid) try: os.stat(dsym) except OSError as e: if e.errno != errno.ENOENT: raise else: return base dsf = find_dsym_file(project, image_uuid) if dsf is None: return None if dsf.is_global: base = self.get_global_path() else: if on_dsym_file_referenced is not None: on_dsym_file_referenced(dsf) base = self.get_project_path(project) dsym = os.path.join(base, image_uuid) try: os.makedirs(base) except OSError: pass with dsf.file.getfile() as sf: suffix = '_%s' % uuid.uuid4() done = False try: with open(dsym + suffix, 'w') as df: shutil.copyfileobj(sf, df) os.rename(dsym + suffix, dsym) done = True finally: # Use finally here because it does not lie about the # error on exit if not done: try: os.remove(dsym + suffix) except Exception: pass return base
def fetch_dsym(self, project, image_uuid): image_uuid = image_uuid.lower() base = self.get_project_path(project) dsym = os.path.join(base, image_uuid) if os.path.isfile(dsym): return dsym dsf = find_dsym_file(project, image_uuid) if dsf is None: return None try: os.makedirs(base) except OSError: pass with dsf.file.getfile() as sf: with open(dsym + '_tmp', 'w') as df: shutil.copyfileobj(sf, df) os.rename(dsym + '_tmp', dsym) return dsym