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

Commit 5afda3b9 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

roomservice: Add support for netrc

Change-Id: I1f5e11e40125abd0c4e4c8d8294d4fc09bfdc30a
parent 05755de0
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import sys
import urllib2
import json
import re
import netrc, base64
from xml.etree import ElementTree

product = sys.argv[1];
@@ -23,9 +24,19 @@ if not depsonly:

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 not depsonly:
    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: