Skip to content

Commit

Permalink
roomservice: Handling URLError exception during fetch device process
Browse files Browse the repository at this point in the history
BEFORE:

humberos@fedora:/android/omni-6.0$ bib leo
WARNING: Trying to fetch a device that's already there
Traceback (most recent call last):
  File "build/tools/roomservice.py", line 319, in <module>
    fetch_dependencies(device)
  File "build/tools/roomservice.py", line 275, in fetch_dependencies
    fetch_device(device)
  File "build/tools/roomservice.py", line 287, in fetch_device
    git_data = search_gerrit_for_device(device)
  File "build/tools/roomservice.py", line 71, in search_gerrit_for_device
    response = urllib.request.urlopen(git_req)
  File "/usr/lib64/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python2.7/urllib2.py", line 431, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.7/urllib2.py", line 449, in _open
    '_open', req)
  File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.7/urllib2.py", line 1242, in https_open
    context=self._context)
  File "/usr/lib64/python2.7/urllib2.py", line 1199, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno -5] No address associated with hostname>

AFTER:

humberos@fedora:/android/omni-6.0$ bib leo
WARNING: Trying to fetch a device that's already there
WARNING: No network connection available.

Signed-off-by: Humberto Borba <[email protected]>
Change-Id: I18950704c5b7d13553374611d164c2464c1ceab2
  • Loading branch information
humberos authored and fusionjack committed May 10, 2016
1 parent 4289282 commit cb2bba3
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions tools/roomservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,18 @@ def search_gerrit_for_device(device):
git_req = urllib.request.Request(git_search_url)
try:
response = urllib.request.urlopen(git_req)
except urllib.request.HTTPError:
raise Exception("There was an issue connecting to gerrit."
except urllib.request.HTTPError as e:
print("There was an issue connecting to gerrit."
" Please try again in a minute")
# Skip silly gerrit "header"
response.readline()
git_data = json.load(response)
device_data = check_repo_exists(git_data, device)
print("found the {} device repo".format(device))
return device_data
except urllib.request.URLError as e:
print("WARNING: No network connection available.")
else:
# Skip silly gerrit "header"
response.readline()
git_data = json.load(response)
device_data = check_repo_exists(git_data, device)
print("found the {} device repo".format(device))
return device_data


def parse_device_directory(device_url, device):
Expand Down Expand Up @@ -285,18 +288,19 @@ def fetch_device(device):
if check_device_exists(device):
print("WARNING: Trying to fetch a device that's already there")
git_data = search_gerrit_for_device(device)
device_url = git_data['id']
device_dir = parse_device_directory(device_url, device)
project = create_manifest_project(device_url,
if git_data is not None:
device_url = git_data['id']
device_dir = parse_device_directory(device_url, device)
project = create_manifest_project(device_url,
device_dir,
remote=default_team_rem)
if project is not None:
manifest = append_to_manifest(project)
write_to_manifest(manifest)
# In case a project was written to manifest, but never synced
if project is not None or not check_target_exists(device_dir):
print("syncing the device config")
os.system('repo sync -f --no-clone-bundle %s' % device_dir)
if project is not None:
manifest = append_to_manifest(project)
write_to_manifest(manifest)
# In case a project was written to manifest, but never synced
if project is not None or not check_target_exists(device_dir):
print("syncing the device config")
os.system('repo sync -f --no-clone-bundle %s' % device_dir)


if __name__ == '__main__':
Expand Down

0 comments on commit cb2bba3

Please sign in to comment.