def sync(self, git_gecko, git_wpt): process_name = self.process_name syncs = get_syncs(git_gecko, git_wpt, process_name.subtype, process_name.obj_id) if len(syncs) == 0: return None if len(syncs) == 1: return syncs.pop() for item in syncs: if item.status == "open": return item raise ValueError("Got multiple syncs and none were open")
def do_delete(git_gecko, git_wpt, sync_type, obj_id, *args, **kwargs): import trypush if kwargs["try"]: try_pushes = trypush.TryPush.load_all(git_gecko, sync_type, obj_id) for try_push in try_pushes: try_push.delete() else: syncs = get_syncs(git_gecko, git_wpt, sync_type, obj_id) for sync in syncs: for try_push in sync.try_pushes(): try_push.delete() sync.delete()
def do_delete(git_gecko, git_wpt, sync_type, obj_ids, *args, **kwargs): import trypush for obj_id in obj_ids: logger.info("%s %s" % (sync_type, obj_id)) if kwargs["try"]: objs = trypush.TryPush.load_by_obj(git_gecko, sync_type, obj_id, seq_id=kwargs["seq_id"]) else: objs = get_syncs(git_gecko, git_wpt, sync_type, obj_id, seq_id=kwargs["seq_id"]) if not kwargs["all"] and objs: objs = sorted(objs, key=lambda x: -int(x.process_name.seq_id))[:1] for obj in objs: with SyncLock.for_process(obj.process_name) as lock: with obj.as_mut(lock): obj.delete()
def do_detail(git_gecko, git_wpt, sync_type, obj_id, *args, **kwargs): syncs = get_syncs(git_gecko, git_wpt, sync_type, obj_id) for sync in syncs: print(sync.output())