changed upgrader

This commit is contained in:
Mario Voigt 2021-05-17 11:56:17 +02:00
parent c78c5d5cc2
commit 9b8e91c5a6
2 changed files with 44 additions and 3 deletions

View File

@ -1,8 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>Upgrade MightyScape</name>
<name>About/Upgrade MightyScape</name>
<id>fablabchemnitz.de.upgrade_mightyscape</id>
<param name="stash_untracked" type="bool" gui-hidden="true" gui-text="Stash untracked files and continue to upgrade">false</param>
<param name="tab" type="notebook">
<page name="tab_about" gui-text="About">
<label appearance="header">MightyScape Extension Collection</label>
<label>2019 - 2021 / 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/MarioVoigt/mightyscape-1.X</label>
<label appearance="url">mailto:mario.voigt@stadtfabrikanten.org</label>
<spacer />
<label appearance="header">Click "Apply" to upgrade MightyScape to recent version!</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>

View File

@ -19,15 +19,31 @@ from git import Repo #requires GitPython lib
class Upgrade(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument("--tab")
pars.add_argument("--stash_untracked", type=inkex.Boolean, default=False, help="Stash untracked files and continue to upgrade")
def effect(self):
warnings.simplefilter('ignore', ResourceWarning) #suppress "enable tracemalloc to get the object allocation traceback"
#get the directory of mightyscape
extension_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../', '../../') #go up to main dir /home/<user>/.config/inkscape/extensions/mightyscape-1.X/
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.X/
main_dir = os.path.abspath(os.path.join(extension_dir, '../../')) #go up to main dir /home/<user>/.config/inkscape/extensions/mightyscape-1.X/
repo = Repo(os.path.join(extension_dir, ".git"))
#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("There are {} extension folders with {} .inx files!".format(totalFolders, totalInx))
repo = Repo(os.path.join(main_dir, ".git"))
#check if it is a non-empty git repository
if repo.bare is False: