plugin
parent
18b8ee5554
commit
9502ee247e
22
main.py
22
main.py
|
@ -10,12 +10,13 @@ import subprocess
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import ast
|
import ast
|
||||||
|
|
||||||
required = open("requirements.txt", 'r')
|
def installmodules(required, silent=False):
|
||||||
required = ast.literal_eval(required.read())
|
required = required
|
||||||
installed = {pkg.key for pkg in pkg_resources.working_set}
|
installed = {pkg.key for pkg in pkg_resources.working_set}
|
||||||
missing = required - installed
|
missing = required - installed
|
||||||
|
|
||||||
if missing:
|
if missing:
|
||||||
|
if silent == False:
|
||||||
while True:
|
while True:
|
||||||
ans = input(f"Einige benötigte Module sind nicht installiert ({missing}), installieren per pip? Y/N ")
|
ans = input(f"Einige benötigte Module sind nicht installiert ({missing}), installieren per pip? Y/N ")
|
||||||
if ans == "y":
|
if ans == "y":
|
||||||
|
@ -24,6 +25,12 @@ if missing:
|
||||||
break
|
break
|
||||||
elif ans == "n":
|
elif ans == "n":
|
||||||
exit()
|
exit()
|
||||||
|
else:
|
||||||
|
python = sys.executable
|
||||||
|
subprocess.check_call([python, '-m', 'pip', 'install', *missing], stdout=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
installmodules(ast.literal_eval(open("requirements.txt", 'r').read()))
|
||||||
|
|
||||||
import mtTkinter as tk
|
import mtTkinter as tk
|
||||||
from tkinter import ttk as tkk
|
from tkinter import ttk as tkk
|
||||||
from tkinter import messagebox
|
from tkinter import messagebox
|
||||||
|
@ -954,11 +961,15 @@ def ungridobjtrees():
|
||||||
|
|
||||||
def loadplugins(GUIe=True):
|
def loadplugins(GUIe=True):
|
||||||
global APIPLUG
|
global APIPLUG
|
||||||
|
print("loading plugins...")
|
||||||
for pluginname in os.listdir(plugindir):
|
for pluginname in os.listdir(plugindir):
|
||||||
if pluginname.split(".")[1] == "plg":
|
if pluginname.split(".")[1] == "plg":
|
||||||
file = open(plugindir+"/"+pluginname, 'r')
|
file = open(plugindir+"/"+pluginname, 'r')
|
||||||
plugindata = file.read()
|
plugindata = file.read()
|
||||||
plugindata = ast.literal_eval(plugindata)
|
plugindata = ast.literal_eval(plugindata)
|
||||||
|
print(plugindata["name"])
|
||||||
|
print("loading...")
|
||||||
|
installmodules(plugindata["modules"], True)
|
||||||
file.close()
|
file.close()
|
||||||
if "init" in plugindata and GUIe == True:
|
if "init" in plugindata and GUIe == True:
|
||||||
exec(plugindata["init"], globals())
|
exec(plugindata["init"], globals())
|
||||||
|
@ -966,6 +977,7 @@ def loadplugins(GUIe=True):
|
||||||
APIPLUG.append(plugindata["API"])
|
APIPLUG.append(plugindata["API"])
|
||||||
if "run" in plugindata:
|
if "run" in plugindata:
|
||||||
RUNPLUG.append(plugindata["run"])
|
RUNPLUG.append(plugindata["run"])
|
||||||
|
print("done.")
|
||||||
return [APIPLUG, RUNPLUG]
|
return [APIPLUG, RUNPLUG]
|
||||||
|
|
||||||
def GUIinit():
|
def GUIinit():
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "pluginname",
|
"name": "pluginname",
|
||||||
|
"modules": [],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
1,
|
1,
|
||||||
2,
|
2,
|
||||||
|
|
Loading…
Reference in New Issue