Commit d8c03033 authored by carlosperate's avatar carlosperate

More robust path management. Useful for py2exe packaging.

parent f80e1b4b
...@@ -565,8 +565,9 @@ class ServerCompilerSettings(object): ...@@ -565,8 +565,9 @@ class ServerCompilerSettings(object):
:return: path to the settings file :return: path to the settings file
""" """
if not self.__settings_path__: if not self.__settings_path__:
self.__settings_path__ = os.path.join( this_package_dir = os.path.dirname(os.path.realpath(__file__))
os.path.dirname(__file__), self.__settings_filename__) self.__settings_path__ = os.path.normpath(
os.path.join(this_package_dir, self.__settings_filename__))
return self.__settings_path__ return self.__settings_path__
def get_board_value_from_key(self, string_key): def get_board_value_from_key(self, string_key):
......
...@@ -94,22 +94,26 @@ def main(argv): ...@@ -94,22 +94,26 @@ def main(argv):
# with the parent folder of where this script is executed, done to be able # with the parent folder of where this script is executed, done to be able
# to find the closure lib directory on the same level as the project folder # to find the closure lib directory on the same level as the project folder
print("\n======= Starting Server =======") print("\n======= Starting Server =======")
this_file_dir = os.path.dirname(os.path.realpath(sys.argv[0])) this_file_parent_dir =\
os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0])))
try: try:
server_root server_root
except NameError: except NameError:
server_root = os.path.dirname(this_file_dir) server_root = this_file_parent_dir
# Opening the browser to the web-app # Opening the browser to the web-app
paths = [server_root, this_file_dir] paths = [server_root, this_file_parent_dir]
common_path = os.path.commonprefix(paths) common_path = os.path.commonprefix(paths)
if not common_path: if not common_path:
print('The server working directory and Ardublockly project need to ' + print('The server working directory and Ardublockly project need to ' +
'be in the same root directory!') 'be in the same root directory.!' +
'The server root also needs to be at least one directory up ' +
'from the Ardublockly folder!')
sys.exit(1) sys.exit(1)
relative_path = [os.path.relpath(this_file_dir, common_path)] relative_path = [os.path.relpath(this_file_parent_dir, common_path)]
app_index = os.path.join(relative_path[0], 'apps', 'arduino_material') app_index = os.path.normpath(os.path.join(
#print('Root & this file: %s\nCommon & relative path: %s; %s\nIndex: %s' % relative_path[0], 'ardublockly', 'apps', 'arduino_material'))
# (paths, common_path, relative_path, app_index)) print('Root & script parent: %s\nCommon & relative path: %s; %s\nIndex: %s'
% (paths, common_path, relative_path, app_index))
open_browser(app_index) open_browser(app_index)
ArduinoServerCompiler.BlocklyHTTPServer.start_server(server_root) ArduinoServerCompiler.BlocklyHTTPServer.start_server(server_root)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment