update some json; add back updater extension

This commit is contained in:
Mario Voigt 2022-11-07 23:48:48 +01:00
parent c13e2e2cff
commit a4d367e4fb
9 changed files with 261 additions and 14 deletions

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>About/Upgrade MightyScape</name>
<id>fablabchemnitz.de.about_upgrade_mightyscape</id>
<param name="tab" type="notebook">
<page name="tab_settings" gui-text="Upgrade Options">
<label appearance="header">Install Updates / Options</label>
<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>
<label>Click "Apply" to upgrade MightyScape to recent version!</label>
<spacer />
<label appearance="header">Hint: Zip File Mirror</label>
<label>There's also a zip file mirror of all MightyScape extensions. This was made for the lazy or picky one's!</label>
<label appearance="url">https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2-zipmirror</label>
</page>
<page name="tab_about" gui-text="About">
<label appearance="header">MightyScape Extension Collection</label>
<label>2019 - 2022 / 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>
<spacer />
<label appearance="header">Contributing</label>
<label appearance="url">https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2</label>
<label appearance="url">mailto:mario.voigt@stadtfabrikanten.org</label>
</page>
<page name="tab_donate" gui-text="Donate">
<label appearance="header">Coffee + Pizza</label>
<label>We are the Stadtfabrikanten, running the FabLab Chemnitz since 2016. A FabLab is an open workshop that gives people access to machines and digital tools like 3D printers, laser cutters and CNC milling machines.</label>
<spacer />
<label>You like our work and want to support us? You can donate to our non-profit organization by different ways:</label>
<label appearance="url">https://y.stadtfabrikanten.org/donate</label>
<spacer />
<label>Thanks for using our extension and helping us!</label>
<image>../000_about_fablabchemnitz.svg</image>
</page>
</param>
<effect needs-live-preview="false">
<object-type>all</object-type>
<effects-menu>
<submenu name="FabLab Chemnitz"/>
</effects-menu>
</effect>
<script>
<command location="inx" interpreter="python">about_upgrade_mightyscape.py</command>
</script>
</inkscape-extension>

View File

@ -0,0 +1,179 @@
#!/usr/bin/env python3
"""
Upgrade MightyScape from Inkscape Extension Dialog. Made for end users
Extension for InkScape 1.2.1
Author: Mario Voigt / FabLab Chemnitz
Mail: mario.voigt@stadtfabrikanten.org
Date: 14.05.2021
Last patch: 07.11.2022
License: GNU GPL v3
ToDo
- add routine to check for differences between remotes (unequal commits)
"""
import inkex
import os
import warnings
from datetime import datetime
try:
import git
from git import Repo #requires GitPython lib
except:
inkex.utils.debug("Error. GitPython was not installed but is required to run the upgrade process!")
exit(1)
class AboutUpgradeMightyScape(inkex.EffectExtension):
def update(self, local_repo, remote, localCommitCount):
inkex.utils.debug("Chosen remote is: {}".format(remote))
try:
localCommit = local_repo.head.commit
remote_repo = git.remote.Remote(local_repo, remote)
remoteCommit = remote_repo.fetch()[0].commit
inkex.utils.debug("Latest remote commit is: " + str(remoteCommit)[:7])
remoteCommitCount = 0
for c in remote_repo.repo.iter_commits('origin/master'):
remoteCommitCount += 1
inkex.utils.debug("Commits at remote: {}".format(remoteCommitCount))
if localCommit.hexsha != remoteCommit.hexsha:
ssh_executable = 'git'
with local_repo.git.custom_environment(GIT_SSH=ssh_executable):
#origin = local_repo.remotes.origin
#origin.fetch()
#fetch_info = origin.pull() #finally pull new data
fetch_info = remote_repo.fetch()
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))
inkex.utils.debug("Please restart Inkscape to let the changes take effect.")
else:
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)
return False
return True
def add_arguments(self, pars):
pars.add_argument("--tab")
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")
def effect(self):
global so
so = self.options
warnings.simplefilter('ignore', ResourceWarning) #suppress "enable tracemalloc to get the object allocation traceback"
#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/
#create some statistics
totalFolders = 0
for root, folders, files in os.walk(extension_dir):
totalFolders += len(folders)
break #prevent descending into subfolders
totalInx = 0
for root, folders, files in os.walk(extension_dir):
for file in files:
if file.endswith('.inx'):
totalInx += 1
inkex.utils.debug("Locally there are {} extension folders with {} .inx files!\n".format(totalFolders, totalInx))
remotes = []
remotes.append(["https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2.git", "origin"]) #main
remotes.append(["https://github.com/eridur-de/mightyscape-1.2.git", "github"]) #copy/second remote
gitDir = os.path.join(main_dir, ".git")
if not os.path.exists(gitDir):
if so.convert_to_git is True:
local_repo = Repo.init(main_dir)
local_repo.git.add(all=True)
localRemotes = []
for remote in remotes:
localRemotes.append(local_repo.create_remote(remote[1], url=remote[0]))
localRemotes[0].update()
local_repo.index.commit('.')
local_repo.git.checkout('origin/master')
else:
inkex.utils.debug("MightyScape .git directory was not found. It seems you installed MightyScape the traditional way (by downloading and extracting from archive). Please install MightyScape using the git clone method if you want to use the upgrade function. More details can be found in the official README.")
exit(1)
local_repo = Repo(gitDir)
#drop local changed. update might fail if file changes are present
if so.stash_untracked is True:
local_repo.git.stash('save')
existingRemotes = [] #check for existing remotes. if one is missing, add it (or delete and recreate)
for r in local_repo.remotes:
existingRemotes.append(str(r))
for remote in remotes:
if remote[1] not in existingRemotes:
local_repo.create_remote(remote[1], url=remote[0])
if so.recreate_remotes is True: #delete and then recreate
local_repo.delete_remote(remote[1])
local_repo.create_remote(remote[1], url=remote[0])
#check if it is a non-empty git repository
if local_repo.bare is False:
if local_repo.is_dirty(untracked_files=True) is False:
if len(local_repo.untracked_files) > 0:
if so.stash_untracked is True:
local_repo.git.stash('save')
else:
inkex.utils.debug("There are some untracked files in your MightyScape directory. Still trying to pull recent files from git...")
localLatestCommit = local_repo.head.commit
localCommits = list(local_repo.iter_commits("origin/master", skip=0))
localCommitCount = len(localCommits)
inkex.utils.debug("Local commit id is: " + str(localLatestCommit)[:7])
inkex.utils.debug("There are {} local commits at the moment.".format(localCommitCount))
localCommits = localCommits[:10] #get only last ten commits
localCommitList = []
for localCommit in localCommits:
localCommitList.append(localCommit)
#localCommitList.reverse()
inkex.utils.debug("*"*40)
inkex.utils.debug("Latest {} local commits are:".format(len(localCommits)))
for i in range(0, len(localCommits)):
inkex.utils.debug("{} | {} : {}".format(
datetime.utcfromtimestamp(localCommitList[i].committed_date).strftime('%Y-%m-%d %H:%M:%S'),
localCommitList[i].name_rev[:7],
localCommitList[i].message.strip())
)
#inkex.utils.debug(" - {}: {}".format(localCommitList[i].newhexsha[:7], localCommitList[i].message))
inkex.utils.debug("*"*40)
#finally run the update
success = self.update(local_repo, remotes[0][1], localCommitCount)
if success is False: #try the second remote if first failed
inkex.utils.debug("Error receiving latest remote commit from main git remote {}. Trying second remote ...".format(remotes[0][0]))
success = self.update(local_repo, remotes[1][1], localCommitCount)
if success is False: #if still false:
inkex.utils.debug("Error receiving latest remote commit from second git remote {}.\nAre you offline? Cannot continue!".format(remotes[0][0]))
exit(1)
else:
inkex.utils.debug("No \".git\" directory found. Seems your MightyScape was not installed with git clone. Please see documentation on how to do that.")
exit(1)
if __name__ == '__main__':
AboutUpgradeMightyScape().run()

View File

@ -0,0 +1,20 @@
[
{
"name": "About/Upgrade MightyScape",
"id": "fablabchemnitz.de.about_upgrade_mightyscape",
"path": "about_upgrade_mightyscape",
"dependent_extensions": null,
"original_name": "About/Upgrade MightyScape",
"original_id": "fablabchemnitz.de.about_upgrade_mightyscape",
"license": "GNU GPL v3",
"license_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/LICENSE",
"comment": "",
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/about_upgrade_mightyscape",
"fork_url": null,
"documentation_url": "https://stadtfabrikanten.org/display/IFM/MightyScape+1.X+-+Introduction+and+Installation",
"inkscape_gallery_url": null,
"main_authors": [
"github.com/eridur-de"
]
}
]

View File

@ -9,13 +9,13 @@
"license": "MIT License", "license": "MIT License",
"license_url": "https://github.com/tzunghaor/inkscape-eps-export/blob/master/aieps_output.py", "license_url": "https://github.com/tzunghaor/inkscape-eps-export/blob/master/aieps_output.py",
"comment": "", "comment": "",
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/ai_compatible_eps_output", "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/ai_compatible_eps_output",
"fork_url": "https://github.com/tzunghaor/inkscape-eps-export", "fork_url": "https://github.com/tzunghaor/inkscape-eps-export",
"documentation_url": "https://stadtfabrikanten.org/pages/viewpage.action?pageId=55018922&searchId=UF0RDT9E0", "documentation_url": "https://stadtfabrikanten.org/pages/viewpage.action?pageId=55018922&searchId=UF0RDT9E0",
"inkscape_gallery_url": null, "inkscape_gallery_url": null,
"main_authors": [ "main_authors": [
"github.com/tzunghaor", "github.com/tzunghaor",
"github.com/vmario89" "github.com/eridur-de"
] ]
} }
] ]

View File

@ -7,14 +7,14 @@
"original_name": "Contour Scanner And Trimmer", "original_name": "Contour Scanner And Trimmer",
"original_id": "fablabchemnitz.de.contour_scanner_and_trimmer", "original_id": "fablabchemnitz.de.contour_scanner_and_trimmer",
"license": "GNU GPL v3", "license": "GNU GPL v3",
"license_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/LICENSE", "license_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/LICENSE",
"comment": "Written by Mario Voigt from scratch with a lot of help using other extensions as template", "comment": "Written by Mario Voigt from scratch with a lot of help using other extensions as template",
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/contour_scanner_and_trimmer", "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/contour_scanner_and_trimmer",
"fork_url": null, "fork_url": null,
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Contour+Scanner+And+Trimmer", "documentation_url": "https://stadtfabrikanten.org/display/IFM/Contour+Scanner+And+Trimmer",
"inkscape_gallery_url": "https://inkscape.org/de/~MarioVoigt/%E2%98%85contour-scanner-and-trimmer", "inkscape_gallery_url": "https://inkscape.org/de/~MarioVoigt/%E2%98%85contour-scanner-and-trimmer",
"main_authors": [ "main_authors": [
"github.com/vmario89" "github.com/eridur-de"
] ]
} }
] ]

View File

@ -7,14 +7,14 @@
"original_name": "DXF/DWG Importer", "original_name": "DXF/DWG Importer",
"original_id": "fablabchemnitz.de.dxf_dwg_importer", "original_id": "fablabchemnitz.de.dxf_dwg_importer",
"license": "GNU GPL v3", "license": "GNU GPL v3",
"license_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/LICENSE", "license_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/LICENSE",
"comment": "Written by Mario Voigt", "comment": "Written by Mario Voigt",
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/dxf_dwg_importer", "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/dxf_dwg_importer",
"fork_url": null, "fork_url": null,
"documentation_url": "https://stadtfabrikanten.org/pages/viewpage.action?pageId=78807535", "documentation_url": "https://stadtfabrikanten.org/pages/viewpage.action?pageId=78807535",
"inkscape_gallery_url": "https://inkscape.org/~MarioVoigt/%E2%98%85dxfdwg-importer", "inkscape_gallery_url": "https://inkscape.org/~MarioVoigt/%E2%98%85dxfdwg-importer",
"main_authors": [ "main_authors": [
"github.com/vmario89" "github.com/eridur-de"
] ]
} }
] ]

View File

@ -9,12 +9,12 @@
"license": "GNU GPL v3", "license": "GNU GPL v3",
"license_url": "", "license_url": "",
"comment": "", "comment": "",
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/laser_check", "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/laser_check",
"fork_url": null, "fork_url": null,
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Laser+Check", "documentation_url": "https://stadtfabrikanten.org/display/IFM/Laser+Check",
"inkscape_gallery_url": null, "inkscape_gallery_url": null,
"main_authors": [ "main_authors": [
"github.com/vmario89" "github.com/eridur-de"
] ]
} }
] ]

View File

@ -9,13 +9,13 @@
"license": "GNU GPL v2", "license": "GNU GPL v2",
"license_url": "https://github.com/Shriinivas/inkscapestrokefont/blob/master/LICENSE", "license_url": "https://github.com/Shriinivas/inkscapestrokefont/blob/master/LICENSE",
"comment": "", "comment": "",
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/stroke_font_creator", "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/stroke_font_creator",
"fork_url": "https://github.com/Shriinivas/inkscapestrokefont", "fork_url": "https://github.com/Shriinivas/inkscapestrokefont",
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Stroke+Font+Creator", "documentation_url": "https://stadtfabrikanten.org/display/IFM/Stroke+Font+Creator",
"inkscape_gallery_url": null, "inkscape_gallery_url": null,
"main_authors": [ "main_authors": [
"github.com/Shriinivas", "github.com/Shriinivas",
"github.com/vmario89" "github.com/eridur-de"
] ]
} }
] ]

View File

@ -9,13 +9,13 @@
"license": "MIT License", "license": "MIT License",
"license_url": "https://github.com/juanfran/svgo-inkscape/blob/master/LICENSE", "license_url": "https://github.com/juanfran/svgo-inkscape/blob/master/LICENSE",
"comment": "", "comment": "",
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/svgo_output", "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/svgo_output",
"fork_url": "https://github.com/juanfran/svgo-inkscape/", "fork_url": "https://github.com/juanfran/svgo-inkscape/",
"documentation_url": "https://stadtfabrikanten.org/pages/viewpage.action?pageId=55019653", "documentation_url": "https://stadtfabrikanten.org/pages/viewpage.action?pageId=55019653",
"inkscape_gallery_url": null, "inkscape_gallery_url": null,
"main_authors": [ "main_authors": [
"github.com/juanfran", "github.com/juanfran",
"github.com/vmario89" "github.com/eridur-de"
] ]
} }
] ]