diff --git a/UIserver/static/js/settings.js b/UIserver/static/js/settings.js index 36fb0c3d..147dd778 100644 --- a/UIserver/static/js/settings.js +++ b/UIserver/static/js/settings.js @@ -20,7 +20,7 @@ function save(connect = false){ port : $("#serial_ports").val(), baud : $("#serial_baud").val() }, - dimensions : { + device : { width: $("#device_width").val(), height : $("#device_height").val() }, diff --git a/UIserver/templates/preferences/manual_control.html b/UIserver/templates/preferences/manual_control.html index 8a81ae50..9e359c2a 100644 --- a/UIserver/templates/preferences/manual_control.html +++ b/UIserver/templates/preferences/manual_control.html @@ -22,8 +22,8 @@

Gcode command:

-
{{settings.dimensions.width}}
-
{{settings.dimensions.height}}
+
{{settings.device.width}}
+
{{settings.device.height}}
@@ -33,6 +33,9 @@

Gcode command:

+
+ +
{%endblock%} \ No newline at end of file diff --git a/UIserver/templates/preferences/settings.html b/UIserver/templates/preferences/settings.html index f6cba51c..6757f7f8 100644 --- a/UIserver/templates/preferences/settings.html +++ b/UIserver/templates/preferences/settings.html @@ -36,13 +36,13 @@

Dimensions

diff --git a/readme.md b/readme.md index a54791d4..82ce26de 100755 --- a/readme.md +++ b/readme.md @@ -114,12 +114,33 @@ It may happen that the serial port is not working correctly. In this case activate the environment, uninstall the "serial" and the "pyserial" modules and install again the "pyserial": ``` $> source env/bin/activate -python3 -m pip uninstall serial pyserial -python3 -m pip install pyserial +(env) $> python3 -m pip uninstall serial pyserial +(env) $> python3 -m pip install pyserial ``` If you find any bug or problem please open an issue in the dedicated page. +# Updates + +To update to the last available version of the software in linux you can run the following commands: + +``` +$> source env/bin/activate +(env) $> git pull +(env) $> sh install.sh +``` + +If you are working on Windows you should use instead: + +``` +$> source env/bin/activate +(env) $> git pull +(env) $> install.bat +``` + +Some browser may cache the scripts. If you get any error try to clean the cache of your browser related to the sandipy site. + + # Development and testing Any help in the app development is accepted. diff --git a/setup.py b/setup.py index 6ad1381a..4811c0e6 100755 --- a/setup.py +++ b/setup.py @@ -4,17 +4,19 @@ import time import platform import os - +from utils import settings_utils class PostDevelopCommand(develop): def run(self): develop.run(self) print("Running post develop script") + settings_utils.update_settings_file_version() class PostInstallCommand(install): def run(self): install.run(self) print("Running post install script") + settings_utils.update_settings_file_version() setup( name='UIserver', diff --git a/utils/settings_utils.py b/utils/settings_utils.py index ae897b4d..fb7e1d3a 100644 --- a/utils/settings_utils.py +++ b/utils/settings_utils.py @@ -3,6 +3,7 @@ import json settings_path = "./UIserver/saves/saved_settings.json" +defaults_path = "UIserver/saves/default_settings.json" def save_settings(settings): dataj = json.dumps(settings) @@ -10,10 +11,38 @@ def save_settings(settings): f.write(dataj) def load_settings(): - if(not os.path.exists(settings_path)): - shutil.copyfile("UIserver/saves/default_settings.json", settings_path) settings = "" with open(settings_path) as f: settings = json.load(f) return settings - \ No newline at end of file + +def update_settings_file_version(): + print("Updating settings save files") + if(not os.path.exists(settings_path)): + shutil.copyfile(defaults_path, settings_path) + else: + old_settings = load_settings() + def_settings = "" + with open(defaults_path) as f: + def_settings = json.load(f) + + new_settings = match_dict(old_settings, def_settings) + save_settings(new_settings) + +def match_dict(mod_dict, ref_dict): + new_dict = {} + for k in ref_dict.keys(): + if k in mod_dict: + if type(mod_dict[k]) is dict: + new_dict[k] = match_dict(mod_dict[k], ref_dict[k]) + else: + new_dict[k] = mod_dict[k] + else: + new_dict[k] = ref_dict[k] + return new_dict + +if __name__ == "__main__": + # testing update_settings_file_version + settings_path = "../"+settings_path + defaults_path = "../"+defaults_path + update_settings_file_version() \ No newline at end of file