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