several improvements

This commit is contained in:
Mario Voigt 2024-01-20 22:07:12 +01:00
parent 704bfaebf0
commit a6d815e855
5 changed files with 43 additions and 28 deletions

View File

@ -6,6 +6,8 @@
<param name="tab" type="notebook">
<page name="tab_settings" gui-text="Upgrade Options">
<label appearance="header">Install Updates / Options</label>
<param name="install_requirements" type="bool" gui-text="Install python requirements" gui-description="Installs all python requirements from requirements.txt. This may take up to 10 minutes or may. There will be no visible console output until finished. Please wait until completed.">false</param>
<param name="convert_to_git" type="bool" gui-text="Convert to .git" gui-description="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">false</param>
<param name="recreate_remotes" type="bool" gui-text="Recreate remotes" gui-description="Update remotes in git config file (useful if you have an older version of MightyScape or if something changes). Warning: might drop passwords/auth tokens!">false</param>
<param name="stash_untracked" type="bool" gui-text="Stash untracked files" gui-description="Enable to drop your local changes">false</param>
@ -17,7 +19,7 @@
</page>
<page name="tab_about" gui-text="About">
<label appearance="header">MightyScape Extension Collection</label>
<label>2019 - 2023 / written by Mario Voigt (Stadtfabrikanten e.V. / FabLab Chemnitz)</label>
<label>2019 - 2024 / written by Mario Voigt (Stadtfabrikanten e.V. / FabLab Chemnitz)</label>
<spacer />
<label appearance="header">Online Documentation</label>
<label appearance="url">https://y.stadtfabrikanten.org/mightyscape-overview</label>

View File

@ -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/<user>/.config/inkscape/extensions/mightyscape-1.2/
main_dir = os.path.abspath(os.path.join(extension_dir, '../../')) #go up to main dir /home/<user>/.config/inkscape/extensions/mightyscape-1.2/

View File

@ -9,36 +9,36 @@
<option value="rect_from_xy">Rectangle from width and height</option>
<option value="rect_from_selection">Rectangle from selection</option>
</param>
<param name="rx" type="int" max="10000" gui-text="Width">1000</param>
<param name="ry" type="int" max="10000" gui-text="Height">1000</param>
<param name="rx" type="int" min="0" max="10000" gui-text="Width">1000</param>
<param name="ry" type="int" min="0" max="10000" gui-text="Height">1000</param>
<separator/>
<param name="mainSize" type="float" max="100.0" precision="3" gui-text="Size of objects (scale factor)">1.000</param>
<param name="mainNum" type="int" max="5000" gui-text="Number of objects (acts as multiplicator)">1</param>
<param name="mainNum" type="int" min="0" max="5000" gui-text="Number of objects (acts as multiplicator)">1</param>
<param name="randomize" type="bool" gui-text="Randomize number of objects">true</param>
<param name="allInOneGroup" type="bool" gui-text="Put all items into one group">true</param>
</page>
<page name="Scratches" gui-text="Scratches">
<param name="honp" type="bool" gui-text="Enable scratches">true</param>
<param name="hsize" type="float" max="100.0" min="-100.0" precision="3" gui-text="Size of scratches">2.000</param>
<param name="hgrow" type="float" max="100.0" min="-100.0" precision="3" gui-text="Grow scratches with distance">0.000</param>
<param name="hnum" type="int" max="100.0" gui-text="Number of scratches">10</param>
<param name="hsize" type="float" min="-100.0" max="100.0" precision="3" gui-text="Size of scratches">2.000</param>
<param name="hgrow" type="float" min="-100.0" max="100.0" precision="3" gui-text="Grow scratches with distance">0.000</param>
<param name="hnum" type="int" min="0" max="100" gui-text="Number of scratches">10</param>
<param name="hrad" type="bool" gui-text="Angle scratches toward center">false</param>
<param name="hang" type="float" max="180.0" min="-180.0" precision="3" gui-text="Angle from radius">90.00</param>
<param name="hcurve" type="float" max="100.0" min="-100.0" precision="3" gui-text="Change angle with distance">0.000</param>
<param name="hang" type="float" min="-180.0" max="180.0" precision="3" gui-text="Angle from radius">90.00</param>
<param name="hcurve" type="float" min="-100.0" max="100.0" precision="3" gui-text="Change angle with distance">0.000</param>
<param name="hgrad" type="bool" gui-text="Use density gradient">false</param>
</page>
<page name="Chips" gui-text="Chips">
<param name="conp" type="bool" gui-text="Enable chips">true</param>
<param name="csize" type="float" max="100.0" min="-100.0" precision="3" gui-text="Size of chips">1.000</param>
<param name="cgrow" type="float" max="100.0" min="-100.0" precision="3" gui-text="Grow chips with distance">0.000</param>
<param name="cnum" type="int" max="100.0" gui-text="Number of chips">10</param>
<param name="csize" type="float" min="-100.0" max="100.0" precision="3" gui-text="Size of chips">1.000</param>
<param name="cgrow" type="float" min="-100.0" max="100.0" precision="3" gui-text="Grow chips with distance">0.000</param>
<param name="cnum" type="int" min="0" max="100" gui-text="Number of chips">10</param>
<param name="cgrad" type="bool" gui-text="Use density gradient">false</param>
</page>
<page name="Specks" gui-text="Specks">
<param name="sonp" type="bool" gui-text="Enable specks">true</param>
<param name="ssize" type="float" max="100.0" min="-100.0" precision="3" gui-text="Size of specks">1.000</param>
<param name="sgrow" type="float" max="100.0" min="-100.0" precision="3" gui-text="Grow specks with distance">0.000</param>
<param name="snum" type="int" max="100.0" gui-text="Number of specks">10</param>
<param name="snum" type="int" min="0" max="100" gui-text="Number of specks">10</param>
<param name="sgrad" type="bool" gui-text="Use density gradient">false</param>
</page>
</param>

View File

@ -60,7 +60,6 @@ This extension is a Python rewrite of the Generator bash script extension by Aur
</param>
<effect needs-live-preview="false">
<object-type>all</object-type>
<menu-tip>Automatically replace values and export the result.</menu-tip>
<effects-menu>
<submenu name="FabLab Chemnitz">
<submenu name="Import/Export/Transfer" />

View File

@ -20,9 +20,9 @@
<option value="R9 DXF">R9 (OpenDesign)</option>
</param>
<param name="qcad_join_polylines" type="bool" gui-text="Join Polylines">true</param>
<param name="qcad_tolerance" type="float" min="0.0000001" max="999999" precision="3" gui-text="Polyline tolerance" gui-description="">0.001</param>
<param name="qcad_tolerance" type="float" min="0.0000001" max="999999" precision="3" gui-text="Polyline tolerance">0.001</param>
<param name="qcad_purge_duplicates" type="bool" gui-text="Purge duplicate lines">false</param>
<param name="qcad_pro_path" type="path" mode="file" gui-text="QCAD Pro executable path" gui-description="Do not use Community Edition, as it will not work.">~/opt/qcad-3.28.2-pro-linux-x86_64/qcad</param>z
<param name="qcad_pro_path" type="path" mode="file" gui-text="QCAD Pro executable path" gui-description="Do not use Community Edition, as it will not work.">~/opt/qcad-3.28.2-pro-linux-x86_64/qcad</param>
<param name="debug" type="bool" gui-text="Show debug info">false</param>
<param name="open_in_qcad" type="bool" gui-text="Open export file in QCAD">false</param>
</page>