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

Commit d501e605 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

roomservice: Add support for netrc

Change-Id: I1f5e11e40125abd0c4e4c8d8294d4fc09bfdc30a
parent 15a59b6b
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ import os
import sys
import urllib2
import json
import netrc, base64
from xml.etree import ElementTree

product = sys.argv[1];
@@ -11,9 +12,19 @@ print "Device %s not found. Attempting to retrieve device repository from Cyanog

repositories = []

authtuple = netrc.netrc().authenticators("api.github.com")

if authtuple:
    githubauth = base64.encodestring('%s:%s' % (authtuple[0], authtuple[2])).replace('\n', '')
else:
    githubauth = None

page = 1
while True:
    result = json.loads(urllib2.urlopen("https://api.github.com/users/CyanogenMod/repos?page=%d" % page).read())
    githubreq = urllib2.Request("https://api.github.com/users/CyanogenMod/repos?per_page=100&page=%d" % page)
    if githubauth:
        githubreq.add_header("Authorization","Basic %s" % githubauth)
    result = json.loads(urllib2.urlopen(githubreq).read())
    if len(result) == 0:
        break
    for res in result: