From 45ac7bd6d0519cae755a296363e19f6eff5f9203 Mon Sep 17 00:00:00 2001 From: Developer Date: Wed, 15 Mar 2017 18:20:22 -0700 Subject: [PATCH 1/3] Replaced .linux.spec to fix build problem and add about.txt to the distribution. Replaced self.appdir code so application retrieves proper leading path when run from both source and executable distribution. --- BlocklyPropClient.linux.spec | 37 +++++++++++++++++++++++++----------- BlocklyPropClient.py | 10 ++++++---- BlocklyServer.py | 3 ++- PropellerLoad.py | 7 +++++-- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/BlocklyPropClient.linux.spec b/BlocklyPropClient.linux.spec index 21b441c..5ab1044 100644 --- a/BlocklyPropClient.linux.spec +++ b/BlocklyPropClient.linux.spec @@ -1,28 +1,43 @@ # -*- mode: python -*- -a = Analysis(['BlocklyPropClient.py'], +block_cipher = None + + +a = Analysis(['BlocklyPropClient.py'], + binaries=None, + datas=None, hiddenimports=[], - hookspath=None, - runtime_hooks=None) -pyz = PYZ(a.pure) + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) exe = EXE(pyz, a.scripts, exclude_binaries=True, name='BlocklyPropClient', debug=False, - strip=None, - upx=false, - console=True, - icon='blocklyprop.ico' ) + strip=False, + upx=False, + console=False , icon='BlocklyPropClient.ico') + +#Propeller Tools propeller_libs_and_tools = Tree('propeller-tools', prefix='propeller-tools', excludes=['*.pdf', 'windows', 'mac']) +propeller_libs_and_tools += [('about.txt', 'about.txt', 'About file')] + +#Collection (edited to include Propeller Tools) coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, propeller_libs_and_tools, - strip=None, + strip=False, upx=False, - name='BlocklyPropClient.linux') + name='BlocklyPropClient') # Analysis -# pathex=['D:\\Development\\python\\BlocklyPropClient'], +# pathex=['/home/developer/Projects/BlocklyPropClient'], + diff --git a/BlocklyPropClient.py b/BlocklyPropClient.py index 3e1ea7e..c5c627e 100644 --- a/BlocklyPropClient.py +++ b/BlocklyPropClient.py @@ -34,7 +34,7 @@ # NOTE: # # Please verify that the version number in the local about.txt and the -# ./package/win0resources/blocklypropclient-installer.iss +# ./package/win-resources/blocklypropclient-installer.iss matches this. # ----------------------------------------------------------------------- VERSION = "0.5.4" @@ -65,9 +65,11 @@ def __init__(self, *args, **kwargs): self.connected = False # Path to where application was launched - self.appdir = os.path.dirname(sys.argv[0]) - self.logger.info('Logging is enabled') - self.logger.info('Application launched from %s', self.appdir) + # self.appdir = os.path.dirname(sys.argv[0]) + # self.appdir = os.getcwd() #works + self.appdir = os.path.dirname(os.path.realpath(__file__)) + self.logger.info('Logging is enabled') + self.logger.info('Application launched from %s', self.appdir) # initialize config variables self.ip_address = tk.StringVar() diff --git a/BlocklyServer.py b/BlocklyServer.py index 99fd158..02918d3 100644 --- a/BlocklyServer.py +++ b/BlocklyServer.py @@ -27,7 +27,8 @@ def __init__(self, version, queue): self.version = version self.queue = queue - self.appdir = os.path.dirname(sys.argv[0]) + # self.appdir = os.path.dirname(sys.argv[0]) + self.appdir = os.path.dirname(os.path.realpath(__file__)) self.logger.debug("Application started from: %s", self.appdir) queue.put((10, 'INFO', 'Server started')) diff --git a/PropellerLoad.py b/PropellerLoad.py index 40e57a5..13864a7 100644 --- a/PropellerLoad.py +++ b/PropellerLoad.py @@ -19,7 +19,9 @@ def __init__(self): self.logger.info('Creating loader logger.') # Find the path to the application launch directory - self.appdir = os.path.dirname(sys.argv[0]) + # self.appdir = os.path.dirname(sys.argv[0]) + # self.appdir = os.getcwd() # works + self.appdir = os.path.dirname(os.path.realpath(__file__)) self.logger.debug("Application running from: %s", self.appdir) # if not self.appdir: @@ -72,7 +74,8 @@ def load(self, action, file_to_load, com_port): # Patch until we figure out why the __init__ is not getting called if not self.appdir or self.appdir == '': - self.appdir = os.path.dirname(sys.argv[0]) + # self.appdir = os.path.dirname(sys.argv[0]) + self.appdir = os.path.dirname(os.path.realpath(__file__)) executable = self.appdir + self.propeller_load_executables[platform.system()] self.logger.debug('Loader executable path is: %s)', executable) From 8d4146c5055177df360a9bfe7c6341f0d4554784 Mon Sep 17 00:00:00 2001 From: Developer Date: Wed, 15 Mar 2017 19:10:04 -0700 Subject: [PATCH 2/3] Updated self.appdir code to try one or two methods of finding working folder, with .realpath in each case. --- BlocklyPropClient.py | 5 +++-- BlocklyServer.py | 4 +++- PropellerLoad.py | 14 +++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/BlocklyPropClient.py b/BlocklyPropClient.py index c5c627e..cdd8084 100644 --- a/BlocklyPropClient.py +++ b/BlocklyPropClient.py @@ -65,9 +65,10 @@ def __init__(self, *args, **kwargs): self.connected = False # Path to where application was launched - # self.appdir = os.path.dirname(sys.argv[0]) - # self.appdir = os.getcwd() #works + # realpath expands to full path if __file__ or sys.argv[0] contains just a filename self.appdir = os.path.dirname(os.path.realpath(__file__)) + if self.appdir == "": + self.appdir = os.path.dirname(os.path.realpath(sys.argv[0])) self.logger.info('Logging is enabled') self.logger.info('Application launched from %s', self.appdir) diff --git a/BlocklyServer.py b/BlocklyServer.py index 02918d3..1a894fd 100644 --- a/BlocklyServer.py +++ b/BlocklyServer.py @@ -27,8 +27,10 @@ def __init__(self, version, queue): self.version = version self.queue = queue - # self.appdir = os.path.dirname(sys.argv[0]) + # realpath expands to full path if __file__ or sys.argv[0] contains just a filename self.appdir = os.path.dirname(os.path.realpath(__file__)) + if self.appdir == "": + self.appdir = os.path.dirname(os.path.realpath(sys.argv[0])) self.logger.debug("Application started from: %s", self.appdir) queue.put((10, 'INFO', 'Server started')) diff --git a/PropellerLoad.py b/PropellerLoad.py index 13864a7..fe10815 100644 --- a/PropellerLoad.py +++ b/PropellerLoad.py @@ -19,14 +19,12 @@ def __init__(self): self.logger.info('Creating loader logger.') # Find the path to the application launch directory - # self.appdir = os.path.dirname(sys.argv[0]) - # self.appdir = os.getcwd() # works + # realpath expands to full path if __file__ or sys.argv[0] contains just a filename self.appdir = os.path.dirname(os.path.realpath(__file__)) + if self.appdir == "": + self.appdir = os.path.dirname(os.path.realpath(sys.argv[0])) self.logger.debug("Application running from: %s", self.appdir) -# if not self.appdir: -# self.appdir = os.getcwd() - self.propeller_load_executables = { "Windows": "/propeller-tools/windows/propeller-load.exe", "Linux": "/propeller-tools/linux/propeller-load", @@ -73,9 +71,11 @@ def load(self, action, file_to_load, com_port): self.loading = True # Patch until we figure out why the __init__ is not getting called - if not self.appdir or self.appdir == '': - # self.appdir = os.path.dirname(sys.argv[0]) + if not self.appdir or self.appdir == '': + # realpath expands to full path if __file__ or sys.argv[0] contains just a filename self.appdir = os.path.dirname(os.path.realpath(__file__)) + if self.appdir == "": + self.appdir = os.path.dirname(os.path.realpath(sys.argv[0])) executable = self.appdir + self.propeller_load_executables[platform.system()] self.logger.debug('Loader executable path is: %s)', executable) From 02c380b399791da6fb5844897fe72d5e943bf572 Mon Sep 17 00:00:00 2001 From: Jeff Martin Date: Thu, 16 Mar 2017 10:22:54 -0700 Subject: [PATCH 3/3] Enhanced self.appdir code to take care of both blank launch path as well as root launch path cases. --- BlocklyPropClient.py | 8 +++++--- BlocklyServer.py | 8 ++++++-- PropellerLoad.py | 12 +++++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/BlocklyPropClient.py b/BlocklyPropClient.py index cdd8084..f7c99fc 100644 --- a/BlocklyPropClient.py +++ b/BlocklyPropClient.py @@ -64,13 +64,15 @@ def __init__(self, *args, **kwargs): self.app_version = "0.0" self.connected = False - # Path to where application was launched + # Find the path from which application was launched # realpath expands to full path if __file__ or sys.argv[0] contains just a filename self.appdir = os.path.dirname(os.path.realpath(__file__)) - if self.appdir == "": + if self.appdir == "" or self.appdir == "/": + # launch path is blank; try extracting from argv self.appdir = os.path.dirname(os.path.realpath(sys.argv[0])) + self.logger.info('Logging is enabled') - self.logger.info('Application launched from %s', self.appdir) + self.logger.info('BlocklyPropClient.py: Application launched from %s', self.appdir) # initialize config variables self.ip_address = tk.StringVar() diff --git a/BlocklyServer.py b/BlocklyServer.py index 1a894fd..2936daf 100644 --- a/BlocklyServer.py +++ b/BlocklyServer.py @@ -27,11 +27,15 @@ def __init__(self, version, queue): self.version = version self.queue = queue + + # Find the path from which application was launched # realpath expands to full path if __file__ or sys.argv[0] contains just a filename self.appdir = os.path.dirname(os.path.realpath(__file__)) - if self.appdir == "": + if self.appdir == "" or self.appdir == "/": + # launch path is blank; try extracting from argv self.appdir = os.path.dirname(os.path.realpath(sys.argv[0])) - self.logger.debug("Application started from: %s", self.appdir) + + self.logger.debug("BlocklyServer.py: Application started from: %s", self.appdir) queue.put((10, 'INFO', 'Server started')) diff --git a/PropellerLoad.py b/PropellerLoad.py index fe10815..09beba5 100644 --- a/PropellerLoad.py +++ b/PropellerLoad.py @@ -18,12 +18,13 @@ def __init__(self): self.logger = logging.getLogger('blockly.loader') self.logger.info('Creating loader logger.') - # Find the path to the application launch directory + # Find the path from which application was launched # realpath expands to full path if __file__ or sys.argv[0] contains just a filename self.appdir = os.path.dirname(os.path.realpath(__file__)) - if self.appdir == "": + if self.appdir == "" or self.appdir == "/": + # launch path is blank; try extracting from argv self.appdir = os.path.dirname(os.path.realpath(sys.argv[0])) - self.logger.debug("Application running from: %s", self.appdir) + self.logger.debug("PropellerLoad.py: Application running from: %s", self.appdir) self.propeller_load_executables = { "Windows": "/propeller-tools/windows/propeller-load.exe", @@ -72,9 +73,10 @@ def load(self, action, file_to_load, com_port): # Patch until we figure out why the __init__ is not getting called if not self.appdir or self.appdir == '': - # realpath expands to full path if __file__ or sys.argv[0] contains just a filename + # realpath expands to full path if __file__ or sys.argv[0] contains just a filename self.appdir = os.path.dirname(os.path.realpath(__file__)) - if self.appdir == "": + if self.appdir == "" or self.appdir == "/": + # launch path is blank; try extracting from argv self.appdir = os.path.dirname(os.path.realpath(sys.argv[0])) executable = self.appdir + self.propeller_load_executables[platform.system()]