Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db420bd8 authored by Anthony King's avatar Anthony King Committed by Steve Kondik
Browse files

roomservice: Improve error handling on search

Use the relevant forms of 'except' for urllib and parsing instead of a
general except which was performed too late anyways.

Change-Id: Ia1fc89dd5a8a703fc0175aef7b6dd013a44a2c8e
parent 0050955f
Loading
Loading
Loading
Loading
+6 −7
Original line number Original line Diff line number Diff line
@@ -72,16 +72,15 @@ def add_auth(githubreq):
if not depsonly:
if not depsonly:
    githubreq = urllib.request.Request("https://api.github.com/search/repositories?q=%s+user:CyanogenMod+in:name+fork:true" % device)
    githubreq = urllib.request.Request("https://api.github.com/search/repositories?q=%s+user:CyanogenMod+in:name+fork:true" % device)
    add_auth(githubreq)
    add_auth(githubreq)
    result = json.loads(urllib.request.urlopen(githubreq).read().decode())
    try:
    try:
        numresults = int(result['total_count'])
        result = json.loads(urllib.request.urlopen(githubreq).read().decode())
    except:
    except urllib.error.URLError:
        print("Failed to search GitHub (offline?)")
        print("Failed to search GitHub")
        sys.exit()
        sys.exit()
    if (numresults == 0):
    except ValueError:
        print("Could not find device %s on github.com/CyanogenMod" % device)
        print("Failed to parse return data from GitHub")
        sys.exit()
        sys.exit()
    for res in result['items']:
    for res in result.get('items', []):
        repositories.append(res)
        repositories.append(res)


local_manifests = r'.repo/local_manifests'
local_manifests = r'.repo/local_manifests'