import threading, time␊ |
import os, sys, signal, os.path␊ |
import Processes␊ |
import NATPMP␊ |
␊ |
if sys.platform == 'darwin' or sys.platform.find('linux') != -1:␊ |
␉import NATPMP␊ |
␊ |
class GitsoThread(threading.Thread):␊ |
␉def __init__(self, window, paths):␊ |
|
␉␉␉␉self.error = True␊ |
␉␉else:␊ |
␉␉␉# Give Support␊ |
␉␉␉self.window.cb1.Enable(False)␊ |
␉␉␉if self.window.cb1.GetValue() == True:␊ |
␉␉␉␉self.NATPMP('request')␊ |
␉␉␉if sys.platform == 'darwin' or sys.platform.find('linux') != -1:␊ |
␉␉␉␉self.window.cb1.Enable(False)␊ |
␉␉␉␉if self.window.cb1.GetValue() == True:␊ |
␉␉␉␉␉self.NATPMP('request')␊ |
␉␉␉␊ |
␉␉␉self.pid = self.process.giveSupport()␊ |
␉␉␉time.sleep(.5)␊ |
|
␉␉␊ |
␉␉@author: Aaron Gerber␊ |
␉␉"""␊ |
␉␉if self.window.rb1.GetValue() == False: #give support␊ |
␉␉␉if self.window.cb1.GetValue() == True:␊ |
␉␉␉␉self.NATPMP('giveup')␊ |
␉␉␉self.window.cb1.Enable(True)␊ |
␊ |
␉␉if sys.platform == 'darwin' or sys.platform.find('linux') != -1:␊ |
␉␉␉if self.window.rb1.GetValue() == False: #give support␊ |
␉␉␉␉if self.window.cb1.GetValue() == True:␊ |
␉␉␉␉␉self.NATPMP('giveup')␊ |
␉␉␉␉self.window.cb1.Enable(True)␊ |
␉␊ |
␉␉self.process.KillPID()␊ |
␉␉self.pid = 0␊ |
␉␉self.running = False␊ |
|
␉␉␊ |
␉␉@author: Dennis Koot␊ |
␉␉"""␊ |
␉␉if action == 'request':␊ |
␉␉␉lifetime = 3600␊ |
␉␉␉print "Request port 5500 (NAT-PMP)."␊ |
␉␉else:␊ |
␉␉␉lifetime = 0␊ |
␉␉␉print "Give up port 5500 (NAT-PMP)."␊ |
␉␉␊ |
␉␉pubpriv_port = int(5500)␊ |
␉␉protocol = NATPMP.NATPMP_PROTOCOL_TCP␊ |
␉␉gateway = NATPMP.get_gateway_addr()␊ |
␉␉try:␊ |
␉␉␉print NATPMP.map_port(protocol, pubpriv_port, pubpriv_port, lifetime, gateway_ip=gateway)␊ |
␉␉except:␊ |
␉␉␉print "Warning: Unable to automap port."␊ |
␉␉if sys.platform == 'darwin' or sys.platform.find('linux') != -1:␊ |
␉␉␉if action == 'request':␊ |
␉␉␉␉lifetime = 3600␊ |
␉␉␉␉print "Request port 5500 (NAT-PMP)."␊ |
␉␉␉else:␊ |
␉␉␉␉lifetime = 0␊ |
␉␉␉␉print "Give up port 5500 (NAT-PMP)."␊ |
␉␊ |
␉␉␉pubpriv_port = int(5500)␊ |
␉␉␉protocol = NATPMP.NATPMP_PROTOCOL_TCP␊ |
␉␉␉␊ |
␉␉␉try:␊ |
␉␉␉␉gateway = NATPMP.get_gateway_addr()␊ |
␉␉␉␉print NATPMP.map_port(protocol, pubpriv_port, pubpriv_port, lifetime, gateway_ip=gateway)␊ |
␉␉␉except:␊ |
␉␉␉␉print "Warning: Unable to automap port."␊ |
␊ |