Skip to content

Commit 8d4146c

Browse files
author
Developer
committed
Updated self.appdir code to try one or two methods of finding working folder, with .realpath in each case.
1 parent 45ac7bd commit 8d4146c

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

BlocklyPropClient.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ def __init__(self, *args, **kwargs):
6565
self.connected = False
6666

6767
# Path to where application was launched
68-
# self.appdir = os.path.dirname(sys.argv[0])
69-
# self.appdir = os.getcwd() #works
68+
# realpath expands to full path if __file__ or sys.argv[0] contains just a filename
7069
self.appdir = os.path.dirname(os.path.realpath(__file__))
70+
if self.appdir == "":
71+
self.appdir = os.path.dirname(os.path.realpath(sys.argv[0]))
7172
self.logger.info('Logging is enabled')
7273
self.logger.info('Application launched from %s', self.appdir)
7374

BlocklyServer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ def __init__(self, version, queue):
2727

2828
self.version = version
2929
self.queue = queue
30-
# self.appdir = os.path.dirname(sys.argv[0])
30+
# realpath expands to full path if __file__ or sys.argv[0] contains just a filename
3131
self.appdir = os.path.dirname(os.path.realpath(__file__))
32+
if self.appdir == "":
33+
self.appdir = os.path.dirname(os.path.realpath(sys.argv[0]))
3234
self.logger.debug("Application started from: %s", self.appdir)
3335

3436
queue.put((10, 'INFO', 'Server started'))

PropellerLoad.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ def __init__(self):
1919
self.logger.info('Creating loader logger.')
2020

2121
# Find the path to the application launch directory
22-
# self.appdir = os.path.dirname(sys.argv[0])
23-
# self.appdir = os.getcwd() # works
22+
# realpath expands to full path if __file__ or sys.argv[0] contains just a filename
2423
self.appdir = os.path.dirname(os.path.realpath(__file__))
24+
if self.appdir == "":
25+
self.appdir = os.path.dirname(os.path.realpath(sys.argv[0]))
2526
self.logger.debug("Application running from: %s", self.appdir)
2627

27-
# if not self.appdir:
28-
# self.appdir = os.getcwd()
29-
3028
self.propeller_load_executables = {
3129
"Windows": "/propeller-tools/windows/propeller-load.exe",
3230
"Linux": "/propeller-tools/linux/propeller-load",
@@ -73,9 +71,11 @@ def load(self, action, file_to_load, com_port):
7371
self.loading = True
7472

7573
# Patch until we figure out why the __init__ is not getting called
76-
if not self.appdir or self.appdir == '':
77-
# self.appdir = os.path.dirname(sys.argv[0])
74+
if not self.appdir or self.appdir == '':
75+
# realpath expands to full path if __file__ or sys.argv[0] contains just a filename
7876
self.appdir = os.path.dirname(os.path.realpath(__file__))
77+
if self.appdir == "":
78+
self.appdir = os.path.dirname(os.path.realpath(sys.argv[0]))
7979

8080
executable = self.appdir + self.propeller_load_executables[platform.system()]
8181
self.logger.debug('Loader executable path is: %s)', executable)

0 commit comments

Comments
 (0)