Skip to content

Commit

Permalink
fix github TLS error
Browse files Browse the repository at this point in the history
  • Loading branch information
kmarkley committed Feb 23, 2018
1 parent a1d95f0 commit 28f9583
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Timed Devices.indigoPlugin/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>PluginVersion</key>
<string>0.0.19</string>
<string>0.0.20</string>
<key>ServerApiVersion</key>
<string>2.0</string>
<key>IwsApiVersion</key>
Expand Down
32 changes: 17 additions & 15 deletions Timed Devices.indigoPlugin/Contents/Server Plugin/ghpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,27 +131,29 @@ def getRateLimit(self):
# form a GET request to api.github.com and return the parsed JSON response
def _GET(self, requestPath):
self._debug('GET %s' % requestPath)

headers = {
'User-Agent': 'Indigo-Plugin-Updater',
'Accept': 'application/vnd.github.v3+json'
}

}
data = None

conn = httplib.HTTPSConnection('api.github.com')
conn.request('GET', requestPath, None, headers)

resp = conn.getresponse()
self._debug('HTTP %d %s' % (resp.status, resp.reason))

if (resp.status == 200):
data = json.loads(resp.read())
elif (400 <= resp.status < 500):
error = json.loads(resp.read())
requestPath = 'https://api.github.com'+ requestPath
#conn = httplib.HTTPSConnection('api.github.com')
#conn.request('GET', requestPath, None, headers)
#resp = conn.getresponse()
f = subprocess.Popen(["curl", requestPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
#'-H', str(headers), "-k",
out, err = f.communicate()
self._debug(u'HTTP Err result:'+unicode(err) )
self._debug(u'ReturnCode:{0}'.format(unicode(f.returncode)))
#self.sleep(1)
if (int(f.returncode) == 0):
data = json.loads(out)
self._debug(u'Json results:'+unicode(data))
elif (400 <= f.status < 500):
error = json.loads(out)
self._error('%s' % error['message'])
else:
self._error('Error: %s' % resp.reason)
self._error('Error: %s' % unicode(err))

return data

Expand Down

0 comments on commit 28f9583

Please sign in to comment.