Skip to content

Commit 02c380b

Browse files
committed
Enhanced self.appdir code to take care of both blank launch path as well as root launch path cases.
1 parent 8d4146c commit 02c380b

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

BlocklyPropClient.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@ def __init__(self, *args, **kwargs):
6464
self.app_version = "0.0"
6565
self.connected = False
6666

67-
# Path to where application was launched
67+
# Find the path from which application was launched
6868
# realpath expands to full path if __file__ or sys.argv[0] contains just a filename
6969
self.appdir = os.path.dirname(os.path.realpath(__file__))
70-
if self.appdir == "":
70+
if self.appdir == "" or self.appdir == "/":
71+
# launch path is blank; try extracting from argv
7172
self.appdir = os.path.dirname(os.path.realpath(sys.argv[0]))
73+
7274
self.logger.info('Logging is enabled')
73-
self.logger.info('Application launched from %s', self.appdir)
75+
self.logger.info('BlocklyPropClient.py: Application launched from %s', self.appdir)
7476

7577
# initialize config variables
7678
self.ip_address = tk.StringVar()

BlocklyServer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ def __init__(self, version, queue):
2727

2828
self.version = version
2929
self.queue = queue
30+
31+
# Find the path from which application was launched
3032
# realpath expands to full path if __file__ or sys.argv[0] contains just a filename
3133
self.appdir = os.path.dirname(os.path.realpath(__file__))
32-
if self.appdir == "":
34+
if self.appdir == "" or self.appdir == "/":
35+
# launch path is blank; try extracting from argv
3336
self.appdir = os.path.dirname(os.path.realpath(sys.argv[0]))
34-
self.logger.debug("Application started from: %s", self.appdir)
37+
38+
self.logger.debug("BlocklyServer.py: Application started from: %s", self.appdir)
3539

3640
queue.put((10, 'INFO', 'Server started'))
3741

PropellerLoad.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ def __init__(self):
1818
self.logger = logging.getLogger('blockly.loader')
1919
self.logger.info('Creating loader logger.')
2020

21-
# Find the path to the application launch directory
21+
# Find the path from which application was launched
2222
# realpath expands to full path if __file__ or sys.argv[0] contains just a filename
2323
self.appdir = os.path.dirname(os.path.realpath(__file__))
24-
if self.appdir == "":
24+
if self.appdir == "" or self.appdir == "/":
25+
# launch path is blank; try extracting from argv
2526
self.appdir = os.path.dirname(os.path.realpath(sys.argv[0]))
26-
self.logger.debug("Application running from: %s", self.appdir)
27+
self.logger.debug("PropellerLoad.py: Application running from: %s", self.appdir)
2728

2829
self.propeller_load_executables = {
2930
"Windows": "/propeller-tools/windows/propeller-load.exe",
@@ -72,9 +73,10 @@ def load(self, action, file_to_load, com_port):
7273

7374
# Patch until we figure out why the __init__ is not getting called
7475
if not self.appdir or self.appdir == '':
75-
# realpath expands to full path if __file__ or sys.argv[0] contains just a filename
76+
# realpath expands to full path if __file__ or sys.argv[0] contains just a filename
7677
self.appdir = os.path.dirname(os.path.realpath(__file__))
77-
if self.appdir == "":
78+
if self.appdir == "" or self.appdir == "/":
79+
# launch path is blank; try extracting from argv
7880
self.appdir = os.path.dirname(os.path.realpath(sys.argv[0]))
7981

8082
executable = self.appdir + self.propeller_load_executables[platform.system()]

0 commit comments

Comments
 (0)