[Pythonmac-SIG] socket code works on Win32 but not Mac :-(
Dear All, I'm writing a Python FOSS application and am *very* keen to keep it platform agnostic. I don't own a Mac, but have access to some sympathetic Mac owners. :-) The following code works just fine under Windows XP and Vista but not on MacOS X (currently no idea what version, though Python is 2.5.?). Any thoughts? def get_my_ip_address(): ret=None try: s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(('google.com', 0)) sn=s.getsockname() if sn: ret=sn[0] except socket.error, e: hn=socket.gethostname() ret=socket.gethostbyname(hn) return ret produces the stack: Traceback (most recent call last): File ./sarnie_client.py, line 181, in get_my_ip_address s.connect(('google.com', 0)) File string, line 1, in connect socket.error: (49, Can't assign requested address) My application has been given firewall rights accept connections from the Internet. Is there perhaps anything else that I should configure? TIA -R ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Py2App and PyQT
Christopher Barker wrote: Some quick poking did not make it clear to me where py2app builds the __boot.__py file though. If you create an app with py2app then right click on it and click show package contents then you can browse the app's contents. __boot__.py is located in Content/resources/__boot__.py. Christopher Barker wrote: Anyway, you can always hack around this by adding some code to your setup.py that changes __boot__.py after building the app. Yeah, I tried adding my custom __boot__.py to the data files since they were being stored in the same location but py2app still used it's own creation. Any ideas as to how I could change the file after it's been made? I'm new to py2app so just a point in the right direction would be very helpful. -Eddie -- View this message in context: http://www.nabble.com/Py2App-and-PyQT-tp20175194p21441495.html Sent from the Python - pythonmac-sig mailing list archive at Nabble.com. ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] socket code works on Win32 but not Mac :-(
temporary answer http://www.artima.com/forums/flat.jsp?forum=181thread=113874 On Thu, Jan 15, 2009 at 4:27 AM, Ranec python-...@cemery.org.uk wrote: Dear All, I'm writing a Python FOSS application and am *very* keen to keep it platform agnostic. I don't own a Mac, but have access to some sympathetic Mac owners. :-) The following code works just fine under Windows XP and Vista but not on MacOS X (currently no idea what version, though Python is 2.5.?). Any thoughts? def get_my_ip_address(): ret=None try: s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(('google.com', 0)) sn=s.getsockname() if sn: ret=sn[0] except socket.error, e: hn=socket.gethostname() ret=socket.gethostbyname(hn) return ret produces the stack: Traceback (most recent call last): File ./sarnie_client.py, line 181, in get_my_ip_address s.connect(('google.com', 0)) File string, line 1, in connect socket.error: (49, Can't assign requested address) My application has been given firewall rights accept connections from the Internet. Is there perhaps anything else that I should configure? TIA -R ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig -- lalalalala! it's not broken because I can use it http://linux.slashdot.org/comments.pl?sid=194281threshold=1commentsort=0mode=threadcid=15927703 ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Py2App and PyQT
Eddie L wrote: Christopher Barker wrote: Some quick poking did not make it clear to me where py2app builds the __boot.__py file though. If you create an app with py2app then right click on it and click show package contents then you can browse the app's contents. __boot__.py is located in Content/resources/__boot__.py. yes, I meant I have no idea where in the Py2app code, py2app actually generates the __boot__.py file, so I can't see where to add a patch... Yeah, I tried adding my custom __boot__.py to the data files since they were being stored in the same location but py2app still used it's own creation. Any ideas as to how I could change the file after it's been made? I'm new to py2app so just a point in the right direction would be very helpful. as you've seen, an app bundle is simply a directory with a special name and structure -- Finder shows it in a special way, but you can manipulate the files in it from the command line or a python script just like you'd manipulate any files. so, in your setup.py, after running setup(), you can add code that either adds stuff to __boot__.py, or replaces it with another one -- whatever is easiest. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] socket code works on Win32 but not Mac :-(
Ranec python-...@cemery.org.uk wrote: s.connect(('google.com', 0)) What does this even mean? google.com is a domain, not a server (though it does forward to www.google.com). And port 0? Does anything listen on port 0? Sounds like OS X is the only platform that gets this right :-). Try this: s.connect(('www.google.com', 80)) for instance, to connect to the Web server. Bill ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] socket code works on Win32 but not Mac :-(
Sorry, my mistake. I didn't see you were using UDP... Bill Janssen jans...@parc.com wrote: does anything listen on port 0? Bill ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] socket code works on Win32 but not Mac :-(
In article 496f0fac.30...@cemery.org.uk, Ranec python-...@cemery.org.uk wrote: The following code works just fine under Windows XP and Vista but not on MacOS X (currently no idea what version, though Python is 2.5.?). Any thoughts? def get_my_ip_address(): ret=None try: s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(('google.com', 0)) sn=s.getsockname() if sn: ret=sn[0] except socket.error, e: hn=socket.gethostname() ret=socket.gethostbyname(hn) return ret produces the stack: Traceback (most recent call last): File ./sarnie_client.py, line 181, in get_my_ip_address s.connect(('google.com', 0)) File string, line 1, in connect socket.error: (49, Can't assign requested address) My application has been given firewall rights accept connections from the Internet. Is there perhaps anything else that I should configure? Don't use port 0. import socket s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(('google.com', 0)) Traceback (most recent call last): File stdin, line 1, in module File string, line 1, in connect socket.error: [Errno 49] Can't assign requested address s.connect(('google.com', 1)) sn = s.getsockname() sn ('10.20.30.40', 56621) -- Ned Deily, n...@acm.org ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig