Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import urllib
import urllib2
import sys
import ssl
import httplib, socket
from optparse import OptionParser

try:
Expand All @@ -32,6 +34,21 @@
print "or simpejson."
sys.exit(-1)

#force connection to be TLSv1
class HTTPSConnectionV1(httplib.HTTPSConnection):
def __init__(self, *args, **kwargs):
httplib.HTTPSConnection.__init__(self, *args, **kwargs)

def connect(self):
sock = socket.create_connection((self.host, self.port), self.timeout)
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version=ssl.PROTOCOL_TLSv1)

class HTTPSHandlerV1(urllib2.HTTPSHandler):
def https_open(self, req):
return self.do_open(HTTPSConnectionV1, req)
# install opener
urllib2.install_opener(urllib2.build_opener(HTTPSHandlerV1()))

class Nest:
def __init__(self, username, password, serial=None, index=0, units="F"):
self.username = username
Expand Down