Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading default host as set by phabricator.uri or default config option #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion phabricator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ def __getitem__(self, key):
def __getattr__(self, key):
return self.response[key]

def __getstate__(self):
return self.response

def __setstate__(self, state):
self.response = state

def __len__(self):
return len(self.response.keys())

Expand Down Expand Up @@ -292,7 +298,17 @@ def __init__(self, username=None, certificate=None, host=None,

# Set values in ~/.arcrc as defaults
if ARCRC:
self.host = host if host else ARCRC['hosts'].keys()[0]
if host:
self.host = host
else:
hostbase = (ARCRC.get('config', {}).get('phabricator.uri') or
ARCRC.get('config', {}).get('default'))
if hostbase:
# Hardcoding the path info to '/api/' to match arcanist.php
# behavior.
self.host = urlparse.urljoin(hostbase, "/api/")
else:
self.host = ARCRC['hosts'].keys()[0]
self.username = username if username else ARCRC['hosts'][self.host]['user']
self.certificate = certificate if certificate else ARCRC['hosts'][self.host]['cert']
else:
Expand Down