From: <jda...@us...> - 2010-08-17 15:03:18
|
Revision: 507 http://pyscard.svn.sourceforge.net/pyscard/?rev=507&view=rev Author: jdaussel Date: 2010-08-17 15:03:12 +0000 (Tue, 17 Aug 2010) Log Message: ----------- Added support for py2exe Modified Paths: -------------- trunk/pyscard/src/smartcard/Examples/wx/apdumanager/apdumanager.py trunk/pyscard/src/smartcard/Examples/wx/cardmonitor/cardmonitor.py trunk/pyscard/src/smartcard/Examples/wx/readerviewer/readerviewer.py Added Paths: ----------- trunk/pyscard/src/smartcard/Examples/wx/apdumanager/setup.py trunk/pyscard/src/smartcard/Examples/wx/cardmonitor/setup.py trunk/pyscard/src/smartcard/Examples/wx/readerviewer/setup.py Modified: trunk/pyscard/src/smartcard/Examples/wx/apdumanager/apdumanager.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/wx/apdumanager/apdumanager.py 2010-08-03 14:22:04 UTC (rev 506) +++ trunk/pyscard/src/smartcard/Examples/wx/apdumanager/apdumanager.py 2010-08-17 15:03:12 UTC (rev 507) @@ -24,18 +24,38 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ +import os +import sys import os.path from smartcard.wx.SimpleSCardApp import * from SampleAPDUManagerPanel import SampleAPDUManagerPanel +def we_are_frozen(): + """Returns whether we are frozen via py2exe. + This will affect how we find out where we are located. + From WhereAmI page on py2exe wiki.""" + + return hasattr(sys, "frozen") + + +def module_path(): + """ This will get us the program's directory, + even if we are frozen using py2exe. From WhereAmI page on py2exe wiki.""" + + + if we_are_frozen(): + return os.path.dirname( unicode(sys.executable, sys.getfilesystemencoding( )) ) + + return os.path.dirname(unicode(__file__, sys.getfilesystemencoding( ))) + def main(argv): app = SimpleSCardApp( appname='A tool to send apdu to a card', apppanel=SampleAPDUManagerPanel, appstyle=TR_SMARTCARD | TR_READER | PANEL_APDUTRACER, - appicon=os.path.join(os.path.dirname(__file__), 'images', 'mysmartcard.ico'), + appicon=os.path.join( module_path(), 'images', 'mysmartcard.ico'), size=(800, 600)) app.MainLoop() Added: trunk/pyscard/src/smartcard/Examples/wx/apdumanager/setup.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/wx/apdumanager/setup.py (rev 0) +++ trunk/pyscard/src/smartcard/Examples/wx/apdumanager/setup.py 2010-08-17 15:03:12 UTC (rev 507) @@ -0,0 +1,44 @@ +#! /usr/bin/env python +""" +Setup script to build a standalone apdumanager.exe executable on windows +using py2exe. Run: python.exe setup.py py2exe, to build executable file. + +__author__ = "http://www.gemalto.com" + +Copyright 2001-2010 gemalto +Author: Jean-Daniel Aussel, mailto:jea...@ge... + +This file is part of pyscard. + +pyscard is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +pyscard is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with pyscard; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +""" + +from distutils.core import setup +import py2exe + +from smartcard.wx import ICO_SMARTCARD, ICO_READER + +Mydata_files = [('images', ['images/mysmartcard.ico', ICO_SMARTCARD, ICO_READER ])] + + +setup( windows=['apdumanager.py'], + data_files = Mydata_files, + options = + { + "py2exe":{"dll_excludes":["MSVCP90.dll"]} + } + ) + + Modified: trunk/pyscard/src/smartcard/Examples/wx/cardmonitor/cardmonitor.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/wx/cardmonitor/cardmonitor.py 2010-08-03 14:22:04 UTC (rev 506) +++ trunk/pyscard/src/smartcard/Examples/wx/cardmonitor/cardmonitor.py 2010-08-17 15:03:12 UTC (rev 507) @@ -25,12 +25,31 @@ """ import os.path +import sys from smartcard.wx.SimpleSCardApp import * from smartcard.wx.SimpleSCardAppEventObserver import SimpleSCardAppEventObserver ID_TEXT = 10000 +def we_are_frozen(): + """Returns whether we are frozen via py2exe. + This will affect how we find out where we are located. + From WhereAmI page on py2exe wiki.""" + return hasattr(sys, "frozen") + + +def module_path(): + """ This will get us the program's directory, + even if we are frozen using py2exe. From WhereAmI page on py2exe wiki.""" + + + if we_are_frozen(): + return os.path.dirname( unicode(sys.executable, sys.getfilesystemencoding( )) ) + + return os.path.dirname(unicode(__file__, sys.getfilesystemencoding( ))) + + class SamplePanel(wx.Panel, SimpleSCardAppEventObserver): '''A simple panel that displays activated cards and readers. The panel implements the SimpleSCardAppEventObserver, and has @@ -92,7 +111,7 @@ appname='A simple card monitoring tool', apppanel=SamplePanel, appstyle=TR_SMARTCARD | TR_READER, - appicon=os.path.join(os.path.dirname(__file__), 'images', 'mysmartcard.ico'), + appicon=os.path.join(module_path(), 'images', 'mysmartcard.ico'), size=(800, 600)) app.MainLoop() Added: trunk/pyscard/src/smartcard/Examples/wx/cardmonitor/setup.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/wx/cardmonitor/setup.py (rev 0) +++ trunk/pyscard/src/smartcard/Examples/wx/cardmonitor/setup.py 2010-08-17 15:03:12 UTC (rev 507) @@ -0,0 +1,43 @@ +#! /usr/bin/env python +""" +Setup script to build a standalone cardmonitor.exe executable on windows +using py2exe. Run: python.exe setup.py py2exe, to build executable file. + +__author__ = "http://www.gemalto.com" + +Copyright 2001-2010 gemalto +Author: Jean-Daniel Aussel, mailto:jea...@ge... + +This file is part of pyscard. + +pyscard is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +pyscard is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with pyscard; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +""" + +from distutils.core import setup +import py2exe + +from smartcard.wx import ICO_SMARTCARD, ICO_READER + +Mydata_files = [('images', ['images/mysmartcard.ico', ICO_SMARTCARD, ICO_READER ])] + +setup( windows=['cardmonitor.py'], + data_files = Mydata_files, + options = + { + "py2exe":{"dll_excludes":["MSVCP90.dll"]} + } + ) + + Modified: trunk/pyscard/src/smartcard/Examples/wx/readerviewer/readerviewer.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/wx/readerviewer/readerviewer.py 2010-08-03 14:22:04 UTC (rev 506) +++ trunk/pyscard/src/smartcard/Examples/wx/readerviewer/readerviewer.py 2010-08-17 15:03:12 UTC (rev 507) @@ -24,15 +24,35 @@ """ import os.path +import sys from smartcard.wx.SimpleSCardApp import * +def we_are_frozen(): + """Returns whether we are frozen via py2exe. + This will affect how we find out where we are located. + From WhereAmI page on py2exe wiki.""" + + return hasattr(sys, "frozen") + + +def module_path(): + """ This will get us the program's directory, + even if we are frozen using py2exe. From WhereAmI page on py2exe wiki.""" + + + if we_are_frozen(): + return os.path.dirname( unicode(sys.executable, sys.getfilesystemencoding( )) ) + + return os.path.dirname(unicode(__file__, sys.getfilesystemencoding( ))) + + def main(argv): app = SimpleSCardApp( appname='A simple reader monitoring tool', apppanel=None, appstyle=TR_READER, - appicon=os.path.join(os.path.dirname(__file__), 'images', 'readerviewer.ico'), + appicon=os.path.join(module_path(), 'images', 'readerviewer.ico'), size=(800, 600)) app.MainLoop() Added: trunk/pyscard/src/smartcard/Examples/wx/readerviewer/setup.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/wx/readerviewer/setup.py (rev 0) +++ trunk/pyscard/src/smartcard/Examples/wx/readerviewer/setup.py 2010-08-17 15:03:12 UTC (rev 507) @@ -0,0 +1,44 @@ +#! /usr/bin/env python +""" +Setup script to build a standalone readerviewer.exe executable on windows +using py2exe. Run: python.exe setup.py py2exe, to build executable file. + +__author__ = "http://www.gemalto.com" + +Copyright 2001-2010 gemalto +Author: Jean-Daniel Aussel, mailto:jea...@ge... + +This file is part of pyscard. + +pyscard is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +pyscard is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with pyscard; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +""" + +from distutils.core import setup +import py2exe + +from smartcard.wx import ICO_SMARTCARD, ICO_READER + +Mydata_files = [('images', ['images/readerviewer.ico', ICO_SMARTCARD, ICO_READER ])] + + +setup( windows=['readerviewer.py'], + data_files = Mydata_files, + options = + { + "py2exe":{"dll_excludes":["MSVCP90.dll"]} + } + ) + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |