[Pythonmac-SIG] Building a multi-component application with py2app
I have a wxPython application where the main process has a number of components that can be started as separate processes when required, for example, an independent GUI help viewer and several console-type helper tasks. With py2exe under MSW I can build them all into the same 'Dist' with a single setup.py so they share the same support modules and libraries. Is the same thing achievable with py2app? I can obviously build each component as a separate application, with no sharing, but the overhead is 10+ Mb per component. The py2app examples for drpython imply that the 'app' parameter in the call to setup can be a list of .pyw(?) files but when I try something similar, I get "error: Multiple targets not currently supported". Is it possible to achieve this, or maybe to 'merge' a number of standalone apps? Regards, David Hughes Forestfield Software ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Getting Sharing name of the Macintosh via Python?
> *From:* "Schollnick, Benjamin" <[EMAIL PROTECTED]> > *To:* > *Date:* Wed, 3 Aug 2005 15:21:53 -0400 > > Anyone have any idea on how to get the Machine Name from the Sharing > Preference pane? import os def get_system_info(): """ Use system_profiler command to return a dict of information about system """ info_dict = {'systemversion': None, 'kernelversion': None, 'bootvolume': None, 'computername': None, 'username': None } command = 'system_profiler SPSoftwareDataType' fo = os.popen(command, 'r') for line in fo.readlines(): ilist = line[:-1].split(':') if len(ilist) >= 2: for key in info_dict: if key == ilist[0].replace(' ','').lower(): info_dict[key] = ilist[1] return info_dict print repr(get_system_info()) Regards, David Hughes Forestfield Software www.foresoft.co.uk ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Connecting to Windows shares
> *From:* Simon Brunning <[EMAIL PROTECTED]> > *To:* pythonmac-sig@python.org > *Date:* Thu, 22 Sep 2005 10:24:34 +0100 > > I want to use a python script to copy some files from a Windows share > to my Mac. Connecting to a Windows share with Finder is easy, but how > do I do it from a script? (Python 2.4.1 on OSX 10.4.2, if it matters. > > -- > Cheers, > Simon B, If the Windows partition you've attached appears as an 'ejectable' drive in the leftmost Finder pane, you can see it and its contents under /volumes using a Terminal session. Here, it appears as a directory of the form ";". A problem arises if you attach more than one partition, as they are then given suffixes '-1' etc that depend on the order you attached them. Regards, David Hughes Forestfield Software ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Connecting to Windows shares
> *From:* [EMAIL PROTECTED] (David Hughes) > *To:* pythonmac-sig@python.org > *Date:* Thu, 22 Sep 2005 11:12 +0100 (BST) > > > *From:* Simon Brunning <[EMAIL PROTECTED]> > > *To:* pythonmac-sig@python.org > > *Date:* Thu, 22 Sep 2005 10:24:34 +0100 > > > > I want to use a python script to copy some files from a Windows share > > to my Mac. Connecting to a Windows share with Finder is easy, but how > > do I do it from a script? (Python 2.4.1 on OSX 10.4.2, if it matters. > > > > -- > > Cheers, > > Simon B, > > If the Windows partition you've attached appears as an 'ejectable' > drive in the leftmost Finder pane, you can see it and its contents > under /volumes using a Terminal session. Here, it appears as a > directory of the form ";". A problem arises if you > attach more than one partition, as they are then given suffixes '-1' > etc that depend on the order you attached them. > > Regards, > > David Hughes > Forestfield Software ...but of course, having just pressed the send button, I see that your actual question is how do I *connect* to the Windows share from a script - and I'm sorry but I don't know :-< DH ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] Py2app and shared libraries under Leopard
I've recently been involved with Robin Becker of Reportlabs building and testing one of their extension libraries across Intel and PPC hardware. Built using Distutils under Leopard, the library is working exactly as intended/expected. However, comparing the .so file produced, it is under half the size of the same built using Tiger - as well as having the execute permissions set, so Finder reports it as a Unix executable instead of a document. Both versions are reported as Mach-O universal binaries. $ cd /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ $ ls -l _render* -rwxr-xr-x 1 forestfield admin 244620 10 Dec 12:40 _renderPM-Leopard.so -rw-r--r-- 1 forestfield admin 570732 10 Dec 16:38 _renderPM.so $ file _render* _renderPM-Leopard.so: Mach-O universal binary with 2 architectures _renderPM-Leopard.so (for architecture i386):Mach-O bundle i386 _renderPM-Leopard.so (for architecture ppc):Mach-O bundle ppc _renderPM.so: Mach-O universal binary with 2 architectures _renderPM.so (for architecture i386):Mach-O bundle i386 _renderPM.so (for architecture ppc):Mach-O bundle ppc The shared libraries in PIL also show the same effects when built under Leopard and Tiger respectively. When I apply py2app to an application that uses these libraries, when the Leopard-built versions are used, I get ValueError: Unknown load command: 27 as detailed in the attached log file. If I replace the libraries with their Tiger-built counterparts, the application builds OK (under Leopard). I installed Xcode on Leopard using default settings. Any ideas please? Regards, David Hughes Forestfield Software $ cd /users/pydevsrc/dp6mac_v630 $ ./build_all running py2app creating /Users/pydevsrc/dp6mac_v630/build creating /Users/pydevsrc/dp6mac_v630/build/bdist.macosx-10.3-fat creating /Users/pydevsrc/dp6mac_v630/build/bdist.macosx-10.3-fat/python2.5-standalone creating /Users/pydevsrc/dp6mac_v630/build/bdist.macosx-10.3-fat/python2.5-standalone/app creating /Users/pydevsrc/dp6mac_v630/build/bdist.macosx-10.3-fat/python2.5-standalone/app/collect creating /Users/pydevsrc/dp6mac_v630/build/bdist.macosx-10.3-fat/python2.5-standalone/app/temp creating /Users/pydevsrc/dp6mac_v630/dist creating build/bdist.macosx-10.3-fat/python2.5-standalone/app/lib-dynload creating build/bdist.macosx-10.3-fat/python2.5-standalone/app/Frameworks /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/reportlab/lib/PyFontify.py:35: Warning: 'with' will become a reserved keyword in Python 2.6 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/reportlab/lib/PyFontify.py:36: Warning: 'with' will become a reserved keyword in Python 2.6 *** using recipe: PIL *** *** filtering dependencies *** 754 total 40 filtered 6 orphaned 714 remaining *** create binaries *** creating python loader for extension 'MacOS' creating python loader for extension 'Nav' creating python loader for extension '_AE' creating python loader for extension '_Ctl' creating python loader for extension '_Dlg' creating python loader for extension '_Evt' creating python loader for extension '_File' creating python loader for extension '_Folder' creating python loader for extension '_Menu' creating python loader for extension '_Qd' creating python loader for extension '_Res' creating python loader for extension '_Win' creating python loader for extension '_bisect' creating python loader for extension '_codecs_cn' creating python loader for extension '_codecs_hk' creating python loader for extension '_codecs_iso2022' creating python loader for extension '_codecs_jp' creating python loader for extension '_codecs_kr' creating python loader for extension '_codecs_tw' creating python loader for extension '_ctypes' creating python loader for extension '_hashlib' creating python loader for extension '_heapq' creating python loader for extension '_locale' creating python loader for extension '_multibytecodec' creating python loader for extension '_random' creating python loader for extension '_sha256' creating python loader for extension '_sha512' creating python loader for extension '_socket' creating python loader for extension '_sqlite3' creating python loader for extension '_ssl' creating python loader for extension '_struct' creating python loader for extension '_weakref' creating python loader for extension 'array' creating python loader for extension 'binascii' creating python loader for extension 'bz2' creating python loader for extension 'cPickle' creating python
Re: [Pythonmac-SIG] Py2app and shared libraries under Leopard
David Hughes wrote: .Built using Distutils under Leopard, the library [/Reportlab's _Render.pm]/ is working exactly as intended/expected. However, comparing the .so file produced, it is under half the size of the same built using Tiger [/and it generates an error when it is include in a Py2app build/] ... I posted this here about a week ago but there were no responses. Am I doing something so incredibly stupid that people are too polite to point it out?? -- David Hughes ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] py2app traceback with wxPython 2.8.9.2
Paul McNett wrote: Hi, I get a traceback running py2app with wxPython 2.8.9.2, but not with wxPython 2.8.9.1. Here's the traceback: copying /Library/Frameworks/Python.framework/Versions/2.5/lib/libncurses.5.dylib -> ValueError: Unknown load command: 27 > /Users/pmcnett/py/sbs/shutter_studio/trunk/clients/shutter_studio/build/bdist.macosx-10.3-i386/egg/macholib/MachO.py(178)load() (Pdb) Everything is the same, except the wxPython version. Any ideas? Paul I recall getting an "Unknown load command" message from py2app after I compiled the Reportlab extension *_renderPM.so* as a universal binary under OS X 10.5 (Leopard) and tried to include it in the app. When I compiled it again under 10.4 (Tiger), py2app (running under 10.5) accepted it without any problem. I didn't (have time to) investigate any further, only to note that the 10.5-built version was only 240 Kb compared to 560Kb for the working, 10.4-built version. Maybe there are extensions in wxPython 2.8.9.2 built using OS X 10.5 that were previously built using 10.4 and causing a similar problem? Later I have just rerun py2app with my original 10.5-built *_renderPM.so* and -apart from me using a slightly earlier version of py2app than Paul - it produces the self same error word for word (see attachments). Could it be *_renderPM.so* itself that is causing your error Paul? --- Regards, David Hughes Forestfield Software Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.3.dev_r954-py2.5.egg/py2app/build_app.py", line 530, in _run self.run_normal() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.3.dev_r954-py2.5.egg/py2app/build_app.py", line 601, in run_normal self.create_binaries(py_files, pkgdirs, extensions, loader_files) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.3.dev_r954-py2.5.egg/py2app/build_app.py", line 709, in create_binaries platfiles = mm.run() File "build/bdist.macosx-10.3-i386/egg/macholib/MachOStandalone.py", line 102, in run mm.run_file(fn) File "build/bdist.macosx-10.3-i386/egg/macholib/MachOGraph.py", line 66, in run_file m = self.createNode(MachO, pathname) File "build/bdist.macosx-10.3-i386/egg/macholib/MachOStandalone.py", line 23, in createNode res = super(FilteredMachOGraph, self).createNode(cls, name) File "build/bdist.macosx-10.3-i386/egg/altgraph/ObjectGraph.py", line 148, in createNode m = cls(name, *args, **kw) File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 61, in __init__ self.load(file(filename, 'rb')) File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 71, in load self.load_fat(fh) File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 82, in load_fat self.load_header(fh, arch.offset, arch.size) File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 106, in load_header hdr = MachOHeader(self, fh, offset, size, magic, hdr, endian) File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 146, in __init__ self.load(fh) File "build/bdist.macosx-10.3-i386/egg/macholib/MachO.py", line 178, in load raise ValueError("Unknown load command: %d" % (cmd_load.cmd,)) ValueError: Unknown load command: 27 Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.3.6-py2.5.egg/py2app/build_app.py", line 560, in _run self.run_normal() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.3.6-py2.5.egg/py2app/build_app.py", line 631, in run_normal self.create_binaries(py_files, pkgdirs, extensions, loader_files) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/py2app-0.3.6-py2.5.egg/py2app/build_app.py", line 744, in create_binaries platfiles = mm.run() File "build/bdist.macosx-10.3-fat/egg/macholib/MachOStandalone.py", line 102, in run mm.run_file(fn) File "build/bdist.macosx-10.3-fat/egg/macholib/MachOGraph.py", line 66, in run_file m = self.createNode(MachO, pathname) File "build/bdist.macosx-10.3-fat/egg/macholib/MachOStandalone.py", line 23, in createNode res = super(FilteredMachOGraph, self).createNode(cls, name) File "build/bdist.macosx-10.3-fat/egg/altgraph/ObjectGraph.py", line 148, in createNode m = cls(name, *args, **kw) File "build/bdist.macosx-10.3-fat/egg/macholib/MachO.py", line 61, in __init__ self.load(file(filename, 'rb')) File "build/bdist.macosx-10.3-fat/egg/macholib/MachO.py", line 71,
Re: [Pythonmac-SIG] py2app traceback with wxPython 2.8.9.2
Christopher Barker wrote: Paul McNett wrote: I get a traceback running py2app with wxPython 2.8.9.2, but not with wxPython 2.8.9.1. Here's the traceback: copying /Library/Frameworks/Python.framework/Versions/2.5/lib/libncurses.5.dylib -> ValueError: Unknown load command: 27 Are you using the latest py2app and macholib? $ easy_install macholib==dev Updating macholib has fixed the problem for me. Thanks, Chris. -- David Hughes Forestfield Software ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] how to retrieve unique serial number from usb storage device
On 25/11/2011 11:22, Brendan Simon (eTRIX) wrote: Anyone know how to retrieve the unique serial number of a usb storage device using python on OS X ?? How about using system_profiler SPUSBDataType -- Regards David Hughes Forestfield Software ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] how to retrieve unique serial number from usb storage device
On 25/11/2011 22:20, Brendan Simon (eTRIX) wrote: On 26/11/11 12:12 AM, David Hughes wrote: On 25/11/2011 11:22, Brendan Simon (eTRIX) wrote: Anyone know how to retrieve the unique serial number of a usb storage device using python on OS X ?? How about using system_profiler SPUSBDataType I treid the system_profiler and got the following results when I plugged a couple of usb flash sticks in. I couldn't see anything that resembles a unique usb storage device serial number :( I think it is supposed to be a 12 digit (hex) number. Either system_profiler doesn't report it, or these devices don't have unique serial numbers (unlikely), or I am missing something (not unlikely). Any thoughts ?? Strange, I just tried it here and got a serial number as usual (OS X 10.7.2 and also 10.6.8): STORE N GO: Capacity: 4 GB (4,001,366,016 bytes) Removable Media: Yes Detachable Drive: Yes BSD Name: disk1 Product ID: 0x3623 Vendor ID: 0x13fe (Phison Electronics Corp.) Version: 1.10 Serial Number: 079A814F57E3 Speed: Up to 480 Mb/sec Manufacturer: Verbatim Location ID: 0xfa13 / 6 Current Available (mA): 500 Current Required (mA): 200 Partition Map Type: MBR (Master Boot Record) S.M.A.R.T. status: Not Supported Volumes: DEVELOPER: Capacity: 4 GB (3,997,237,248 bytes) Available: 3.76 GB (3,759,636,480 bytes) Writable: Yes File System: MS-DOS FAT32 BSD Name: disk1s1 Mount Point: /Volumes/DEVELOPER Content: DOS_FAT_32 To check if your device does have a serial number can you run the attached python script using Windows? The above device reports: USB Device Id is USB\VID_13FE&PID_3623\079A814F57E3 (VBscript) -- Regards David Hughes Forestfield Software import sys, os def usbid_script(usbstring=''): """ Return True if usbid string matches (any) USB mass storage device Information is obtained from WMI via a VBscript that is run by Windows CScript.exe """ script = 'temp_script.vbs' fi = open(script, 'w') s = [ 'Set wbemServices = GetObject("winmgmts:")\n', 'Set wbemObjectSet = wbemServices.InstancesOf("Win32_PnPEntity")\n', 'For Each wbemObject In wbemObjectSet\n', 'If wbemObject.Name = "USB Mass Storage Device" Then\n', 'WScript.Echo wbemObject.PNPDeviceID\n', 'End If\n', 'Next\n' ] fi.writelines(s) fi.close() usb_isok = False script_error = False numlines = 0 fo = os.popen('CScript %s //NoLogo' % script , 'r') for device in fo.readlines(): numlines += 1 script_error = (device.lower().find('error') >= 0) if usbstring: usb_isok = compare_strings(usbstring, device.strip(), 2) if usb_isok: break else: print 'USB Device Id is %s (VBscript)' % device.strip() fo.close() os.remove(script) if script_error or numlines == 0: usb_isok = None # script failed return usb_isok usbid_script('') ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG