diff --git a/utils/deactivate_repo.py b/utils/deactivate_repo.py index f00f40c..e44e5b9 100755 --- a/utils/deactivate_repo.py +++ b/utils/deactivate_repo.py @@ -1,56 +1,57 @@ #!/usr/bin/env python3 from phabricator import Phabricator phab = Phabricator(host='https://c4science.ch/api/') phab.update_interfaces() #phab.diffusion.repository.edit( # objectIdentifier = phid, # transactions = [ # {'type': 'status', 'value': 'inactive'}, # ], #) repos = open('/tmp/repo-id', 'r').read().split('\n') ids = [] callsigns = [] # Parse file for IDs for r in repos: if len(r) ==0: continue if r[0] == 'R': ids.append(int(r[1:])) else: callsigns.append(r[1:]) # Deactivate repo def deactivate(phid): phab.diffusion.repository.edit( objectIdentifier = phid, transactions = [ {'type': 'status', 'value': 'inactive'}, ], ) # Search repo def search(constraints): after = 0 while after != None: search = phab.diffusion.repository.search(after=after, constraints=constraints) after = search['cursor']['after'] for s in search['data']: state = s['fields']['status'] - print((s['id']), state) + print(s['id'], state) deactivate(s['phid']) for i in ids: # for some reasons it doesn't work in batch for ids but for callsigns.... search({'ids': [i]}) -search({'callsigns': callsigns}) +if len(callsigns) > 0: + search({'callsigns': callsigns})