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
9 changes: 5 additions & 4 deletions pytor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ class pytor:

def __init__(self, host='localhost', port=9050, controller=False, controlPort = 9051, password=''):
self.controlPort = controlPort
self.host = host
self.port = port
self.controller = controller
self._proxies['http'] = 'socks5://localhost:' + str(self.port)
self._proxies['https'] = 'socks5://localhost:' + str(self.port)
self._proxies['http'] = 'socks5://' + str(self.host) +':' + str(self.port)
self._proxies['https'] = 'socks5://'+ str(self.host) + ':' + str(self.port)
if self.controller:
self.torControl = Controller.from_port(port=controlPort)
self.torControl.authenticate(self.password)
Expand Down Expand Up @@ -91,7 +92,7 @@ def downloadFile(self, url, file):
return True

def newIdentity(self):
print "## NEW IDENTITY ## "
print("## NEW IDENTITY ## ")
if not self._connected:
self.torControl = Controller.from_port(port=self.controlPort)
self.torControl.authenticate(self.password)
Expand All @@ -104,7 +105,7 @@ def newIdentity(self):
def _checkIdentityTime(self):
if self._id_time != None and self._last_id_time != None:
if (datetime.datetime.now() - self._last_id_time).seconds >= self._id_time:
print 'Getting new identity'
print('Getting new identity')
self.newIdentity()
return

Expand Down