diff --git a/gitso/trunk/ConnectionWindow.py b/gitso/trunk/ConnectionWindow.py index 49bbdf9..3a9594f 100644 --- a/gitso/trunk/ConnectionWindow.py +++ b/gitso/trunk/ConnectionWindow.py @@ -84,7 +84,9 @@ class ConnectionWindow(wx.Frame): self.Bind(wx.EVT_RADIOBUTTON, self.RadioToggle, id=self.rb2.GetId()) # checkbox for natpmp - self.cb1 = wx.CheckBox(self, -1, 'Use NAT-PMP', (130, 48)) + if sys.platform == 'darwin' or sys.platform.find('linux') != -1: + self.cb1 = wx.CheckBox(self, -1, 'Use NAT-PMP', (130, 48)) + self.cb1.Enable(False) # the combobox Control @@ -134,7 +136,6 @@ class ConnectionWindow(wx.Frame): self.SetDefaultItem(self.hostField) self.hostField.SetFocus() - self.cb1.Enable(False) self.SetThemeEnabled(True) self.Centre() @@ -161,11 +162,13 @@ class ConnectionWindow(wx.Frame): if self.rb1.GetValue(): self.ToggleValue = 0 self.hostField.Enable(True) - self.cb1.Enable(False) + if sys.platform == 'darwin' or sys.platform.find('linux') != -1: + self.cb1.Enable(False) else: self.ToggleValue = 1 self.hostField.Enable(False) - self.cb1.Enable(True) + if sys.platform == 'darwin' or sys.platform.find('linux') != -1: + self.cb1.Enable(True) def ConnectSupport(self, event): diff --git a/gitso/trunk/GitsoThread.py b/gitso/trunk/GitsoThread.py index a6cd781..a1c9b75 100755 --- a/gitso/trunk/GitsoThread.py +++ b/gitso/trunk/GitsoThread.py @@ -26,7 +26,9 @@ along with Gitso. If not, see . 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): @@ -57,9 +59,10 @@ class GitsoThread(threading.Thread): 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) @@ -95,11 +98,12 @@ class GitsoThread(threading.Thread): @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 @@ -143,18 +147,20 @@ class GitsoThread(threading.Thread): @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."