From a6d815e855ad092cd186e3dfdd5e85621361287b Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Sat, 20 Jan 2024 22:07:12 +0100 Subject: [PATCH] several improvements --- .../about_upgrade_mightyscape.inx | 4 +- .../about_upgrade_mightyscape.py | 38 +++++++++++++------ .../chip_scratches/chip_scratches.inx | 24 ++++++------ .../nextgenerator/nextgenerator.inx | 1 - .../qcad_svg_to_modern_dxf.inx | 4 +- 5 files changed, 43 insertions(+), 28 deletions(-) diff --git a/extensions/fablabchemnitz/about_upgrade_mightyscape/about_upgrade_mightyscape.inx b/extensions/fablabchemnitz/about_upgrade_mightyscape/about_upgrade_mightyscape.inx index 3cca9f7..de1865b 100644 --- a/extensions/fablabchemnitz/about_upgrade_mightyscape/about_upgrade_mightyscape.inx +++ b/extensions/fablabchemnitz/about_upgrade_mightyscape/about_upgrade_mightyscape.inx @@ -6,6 +6,8 @@ + false + false false false @@ -17,7 +19,7 @@ - + diff --git a/extensions/fablabchemnitz/about_upgrade_mightyscape/about_upgrade_mightyscape.py b/extensions/fablabchemnitz/about_upgrade_mightyscape/about_upgrade_mightyscape.py index 06a6be6..d2675bc 100644 --- a/extensions/fablabchemnitz/about_upgrade_mightyscape/about_upgrade_mightyscape.py +++ b/extensions/fablabchemnitz/about_upgrade_mightyscape/about_upgrade_mightyscape.py @@ -16,6 +16,8 @@ ToDo import inkex import os +import subprocess +from subprocess import Popen, PIPE import warnings from datetime import datetime, timezone try: @@ -27,6 +29,19 @@ except: class AboutUpgradeMightyScape(inkex.EffectExtension): + def install_requirements(self): + requirements = inkex.utils.debug(os.path.abspath(os.path.join(self.ext_path()) + "/../../../requirements.txt")) + if not os.path.exists(requirements): + inkex.utils.debug("requirements.txt could not be found.") + exit(1) + command = ["python3 -m pip install --upgrade --quiet --no-cache-dir -r " + requirements] + inkex.utils.debug("Executing: {}".format(command)) + proc = subprocess.Popen(command, shell=True, stdout=PIPE, stderr=PIPE) + stdout, stderr = proc.communicate() + inkex.utils.debug(stdout.decode('UTF-8')) + inkex.utils.debug(stderr.decode('UTF-8')) + proc.wait() + def update(self, local_repo, remote, localCommitCount): inkex.utils.debug("Chosen remote is: {}".format(remote)) try: @@ -46,16 +61,8 @@ class AboutUpgradeMightyScape(inkex.EffectExtension): #origin.fetch() #fetch_info = origin.pull() #finally pull new data fetch_info = remote_repo.fetch() - try: - remote_repo.pull() #finally pull new data - except git.exc.GitCommandError as e: - if "Your local changes to the following files would be overwritten by merge" in str(e): - inkex.utils.debug("Please save or stash your local git changes first and try again. You can enable 'Stash untracked files' to continue.") - exit(1) - else: - inkex.utils.debug("Error: ") - inkex.utils.debug(e) - exit(1) + remote_repo.pull() #finally pull new data + for info in fetch_info: #should return only one line in total inkex.utils.debug("Updated {} to commit id {}. {} commits were pulled".format(info.ref, str(info.commit)[:7], remoteCommitCount - localCommitCount)) @@ -65,14 +72,18 @@ class AboutUpgradeMightyScape(inkex.EffectExtension): inkex.utils.debug("Nothing to do! MightyScape is already up to date!") except git.exc.GitCommandError as e: - inkex.utils.debug("Error: ") - inkex.utils.debug(e) + if "Your local changes to the following files would be overwritten by merge" in e: + inkex.utils.debug("Please save or stash your local git changes first and try again. You can enable 'Stash untracked files' to continue.") + else: + inkex.utils.debug("Error: ") + inkex.utils.debug(e) return False return True def add_arguments(self, pars): pars.add_argument("--tab") + pars.add_argument("--install_requirements", type=inkex.Boolean, default=False, help="Install python requirements") pars.add_argument("--convert_to_git", type=inkex.Boolean, default=False, help="If you downloaded MightyScape as .zip or .tar.gz you cannot upgrade using this extension. But you can convert your downloaded directory to a .git one by enabling this option") pars.add_argument("--recreate_remotes", type=inkex.Boolean, default=False, help="Update remotes in git config file (useful if you have an older version of MightyScape or if sth. changes)") pars.add_argument("--stash_untracked", type=inkex.Boolean, default=False, help="Stash untracked files and continue to upgrade") @@ -85,6 +96,9 @@ class AboutUpgradeMightyScape(inkex.EffectExtension): warnings.simplefilter('ignore', ResourceWarning) #suppress "enable tracemalloc to get the object allocation traceback" + if so.install_requirements is True: + self.install_requirements() + #get the directory of mightyscape extension_dir = os.path.abspath(os.path.join(os.path.abspath(os.path.dirname(__file__)), '../')) #go up to main dir /home//.config/inkscape/extensions/mightyscape-1.2/ main_dir = os.path.abspath(os.path.join(extension_dir, '../../')) #go up to main dir /home//.config/inkscape/extensions/mightyscape-1.2/ diff --git a/extensions/fablabchemnitz/chip_scratches/chip_scratches.inx b/extensions/fablabchemnitz/chip_scratches/chip_scratches.inx index b45d160..73bdb45 100644 --- a/extensions/fablabchemnitz/chip_scratches/chip_scratches.inx +++ b/extensions/fablabchemnitz/chip_scratches/chip_scratches.inx @@ -9,36 +9,36 @@ - 1000 - 1000 + 1000 + 1000 1.000 - 1 + 1 true true true - 2.000 - 0.000 - 10 + 2.000 + 0.000 + 10 false - 90.00 - 0.000 + 90.00 + 0.000 false true - 1.000 - 0.000 - 10 + 1.000 + 0.000 + 10 false true 1.000 0.000 - 10 + 10 false diff --git a/extensions/fablabchemnitz/nextgenerator/nextgenerator.inx b/extensions/fablabchemnitz/nextgenerator/nextgenerator.inx index 8713b84..4640063 100644 --- a/extensions/fablabchemnitz/nextgenerator/nextgenerator.inx +++ b/extensions/fablabchemnitz/nextgenerator/nextgenerator.inx @@ -60,7 +60,6 @@ This extension is a Python rewrite of the Generator bash script extension by Aur all - Automatically replace values and export the result. diff --git a/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad_svg_to_modern_dxf.inx b/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad_svg_to_modern_dxf.inx index 3c41b0c..f154dc7 100644 --- a/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad_svg_to_modern_dxf.inx +++ b/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad_svg_to_modern_dxf.inx @@ -20,9 +20,9 @@ true - 0.001 + 0.001 false - ~/opt/qcad-3.28.2-pro-linux-x86_64/qcadz + ~/opt/qcad-3.28.2-pro-linux-x86_64/qcad false false