Commit ac774ccf authored by carlosperate's avatar carlosperate

Allow any file to be used selected for the Arduino compiler.

This is to be able to select the right file in all operating systems.
parent a2202345
...@@ -287,8 +287,6 @@ def browse_file(): ...@@ -287,8 +287,6 @@ def browse_file():
Opens a file browser and selects executable files Opens a file browser and selects executable files
:return: Full path to selected file :return: Full path to selected file
""" """
#TODO: Filter has been manually set for .exe files, still need to make it
# compatible with other OSes
root = Tkinter.Tk() root = Tkinter.Tk()
# Make window almost invisible to focus it and ensure directory browser # Make window almost invisible to focus it and ensure directory browser
# doesn't end up loading in the background behind main window. # doesn't end up loading in the background behind main window.
...@@ -298,7 +296,7 @@ def browse_file(): ...@@ -298,7 +296,7 @@ def browse_file():
root.deiconify() root.deiconify()
root.lift() root.lift()
root.focus_force() root.focus_force()
types = [('Executable', '.exe'), ('All Files', '*')] types = [('All Files', '*')]
file_path = tkFileDialog.askopenfilename(filetypes=types) file_path = tkFileDialog.askopenfilename(filetypes=types)
root.destroy() root.destroy()
return file_path return file_path
...@@ -348,7 +346,7 @@ def get_compiler_path(): ...@@ -348,7 +346,7 @@ def get_compiler_path():
""" """
compiler_directory = ServerCompilerSettings().compiler_dir compiler_directory = ServerCompilerSettings().compiler_dir
if not compiler_directory: if not compiler_directory:
compiler_directory = 'Please select a valid Arduino compiler directory.' compiler_directory = 'Please select a valid Arduino compiler directory'
json_data = {'setting_type': 'compiler', json_data = {'setting_type': 'compiler',
'element': 'text_input', 'element': 'text_input',
'display_text': compiler_directory} 'display_text': compiler_directory}
......
...@@ -88,10 +88,7 @@ class ServerCompilerSettings(object): ...@@ -88,10 +88,7 @@ class ServerCompilerSettings(object):
def set_compiler_dir(self, new_compiler_dir): def set_compiler_dir(self, new_compiler_dir):
""" The compiler dir must be full path to an .exe file. """ """ The compiler dir must be full path to an .exe file. """
# FIXME: this is a windows only check (.exe), needs to be if os.path.isfile(new_compiler_dir):
# updated to be compatible with linux and MacOS
if os.path.exists(new_compiler_dir) and\
new_compiler_dir.endswith('.exe'):
self.__compiler_dir__ = new_compiler_dir self.__compiler_dir__ = new_compiler_dir
print('\nCompiler directory set to:\n\t%s' % self.__compiler_dir__) print('\nCompiler directory set to:\n\t%s' % self.__compiler_dir__)
self.save_settings() self.save_settings()
...@@ -114,9 +111,7 @@ class ServerCompilerSettings(object): ...@@ -114,9 +111,7 @@ class ServerCompilerSettings(object):
def set_compiler_dir_from_file(self, new_compiler_dir): def set_compiler_dir_from_file(self, new_compiler_dir):
""" The compiler dir must be full path to an existing file. """ """ The compiler dir must be full path to an existing file. """
# FIXME: this is a windows only check (.exe), needs to be if os.path.isfile(new_compiler_dir):
# updated to be compatible with linux and MacOS
if os.path.exists(new_compiler_dir):
self.__compiler_dir__ = new_compiler_dir self.__compiler_dir__ = new_compiler_dir
else: else:
print('\nThe provided compiler path in the settings file is not ' + print('\nThe provided compiler path in the settings file is not ' +
......
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