several improvements
This commit is contained in:
@ -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>
|
||||
|
@ -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/
|
||||
|
Reference in New Issue
Block a user