summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@gnome.org>2016-08-10 15:07:38 -0400
committerThibault Saunier <thibault.saunier@osg.samsung.com>2016-09-17 10:09:33 -0300
commite6950e10eb93fe197eb6d39f8ea2fcec8416865c (patch)
tree8453bdea801b55af13c9997cb30e8b68b7dbf334
parentf47cfd960028fd8be3a15e6e820ff7958f92a58c (diff)
Avoid trying to connect to phab when not needed
Making GitPhab.phabricator a @property so that we do not actually set connect when not calling it. Reviewed-by: Thibault Saunier <tsaunier@gnome.org> Differential Revision: https://phabricator.freedesktop.org/D1272
-rwxr-xr-xgit-phab25
1 files changed, 20 insertions, 5 deletions
diff --git a/git-phab b/git-phab
index 9978621..7943564 100755
--- a/git-phab
+++ b/git-phab
@@ -94,20 +94,26 @@ class GitPhab:
94 94
95 self.repo = git.Repo(os.getcwd(), search_parent_directories=True) 95 self.repo = git.Repo(os.getcwd(), search_parent_directories=True)
96 self.read_arcconfig() 96 self.read_arcconfig()
97 self.login()
98 97
99 def login(self): 98 self._phabricator = None
99 self._phab_user = None
100
101 @property
102 def phabricator(self):
103 if self._phabricator:
104 return self._phabricator
105
100 needs_credential = False 106 needs_credential = False
101 try: 107 try:
102 host = self.phabricator_uri + "/api/" 108 host = self.phabricator_uri + "/api/"
103 self.phabricator = phabricator.Phabricator(timeout=120, host=host) 109 self._phabricator = phabricator.Phabricator(timeout=120, host=host)
104 110
105 if not self.phabricator.token and not self.phabricator.certificate: 111 if not self.phabricator.token and not self.phabricator.certificate:
106 needs_credential = True 112 needs_credential = True
107 113
108 # FIXME, workaround 114 # FIXME, workaround
109 # https://github.com/disqus/python-phabricator/issues/37 115 # https://github.com/disqus/python-phabricator/issues/37
110 self.phabricator.differential.creatediff.api.interface[ 116 self._phabricator.differential.creatediff.api.interface[
111 "differential"]["creatediff"]["required"]["changes"] = dict 117 "differential"]["creatediff"]["required"]["changes"] = dict
112 except phabricator.ConfigurationError: 118 except phabricator.ConfigurationError:
113 needs_credential = True 119 needs_credential = True
@@ -119,7 +125,16 @@ class GitPhab:
119 else: 125 else:
120 self.die("Please setup login certificate before trying again") 126 self.die("Please setup login certificate before trying again")
121 127
122 self.phab_user = self.phabricator.user.whoami() 128 return self._phabricator
129
130 @property
131 def phab_user(self):
132 if self._phab_user:
133 return self._phab_user
134
135 self._phab_user = self.phabricator.user.whoami()
136
137 return self._phab_user
123 138
124 def setup_login_certificate(self): 139 def setup_login_certificate(self):
125 token = input("""LOGIN TO PHABRICATOR 140 token = input("""LOGIN TO PHABRICATOR