aboutsummaryrefslogtreecommitdiff
path: root/wmfphablib/phabapi.py
diff options
context:
space:
mode:
Diffstat (limited to 'wmfphablib/phabapi.py')
-rwxr-xr-xwmfphablib/phabapi.py50
1 files changed, 33 insertions, 17 deletions
diff --git a/wmfphablib/phabapi.py b/wmfphablib/phabapi.py
index 9f2dbe7..e1d753d 100755
--- a/wmfphablib/phabapi.py
+++ b/wmfphablib/phabapi.py
@@ -84,7 +84,16 @@ class phabapi:
auxiliary={"std:maniphest:external_reference":"%s" % (reference,),
"std:maniphest:security_topic": security})
+ def get_project_phid(self, name):
+ proj = self.con.project.query(names=[name])
+ if len(proj['data']) > 0:
+ phid = proj['data'][proj['data'].keys()[0]]['phid']
+ return phid
+ else:
+ return None
+
def ensure_project(self, project_name,
+ parent_phid=None,
pmembers=[],
view='public',
edit='public'):
@@ -93,28 +102,35 @@ class phabapi:
:param pmembers: list
:param view: str
:param edit str"""
- existing_proj = phabdb.get_project_phid(project_name)
+ existing_proj = self.con.project.query(names=[project_name])
+ log(str(existing_proj))
+ #existing_proj = phabdb.get_project_phid(project_name)
#print "EXISTING PROJ: ", existing_proj
#print "EXISTING PROJ TYPE: ", type(existing_proj)
#existing_proj = self.con.project.query(names=[project_name])
- if not existing_proj:
+ if len(existing_proj['data']) < 1:
log('need to create project(s) ' + project_name)
- try:
- new_proj = self.con.project.create(name=project_name, members=pmembers)
- #XXX: Bug where we have to specify a members array!
- except phabricator.APIError:
- pass
- phid = phabdb.get_project_phid(project_name)
- if not phid:
- raise Exception("Project %s does not exist still." % (project_name,))
- #existing_proj = self.con.project.query(names=[project_name])
- #log(str(existing_proj))
- #phid = existing_proj['data'][existing_proj['data'].keys()[0]]['phid']
- phabdb.set_project_policy(phid, view, edit)
+ #try:
+ print "name = %s" % project_name
+ print "members = %s" % pmembers
+ # obsoleted API call
+ #new_proj = self.con.project.create(name=project_name, members=pmembers)
+ tlist = [
+ {"type":"name", "value":project_name},
+ {"type":"view", "value":view},
+ {"type":"edit", "value":edit},
+ ]
+
+ if len(pmembers) > 0:
+ tlist.append( {"type":"members.set", "value":pmembers} )
+ if parent_phid != None:
+ tlist.append( {"type":"parent", "value":parent_phid} )
+
+ existing_proj = self.con.project.edit( transactions = tlist )
+ phid = existing_proj['object']['phid']
else:
- phid = existing_proj
- #phid = existing_proj['data'][existing_proj['data'].keys()[0]]['phid']
- log(project_name + ' exists')
+ print existing_proj
+ phid = existing_proj['data'].keys()[0]
return phid
def upload_file(self, name, data, viewPolicy, dump=False):