tooliload eb09dbd72b
Add plugin Adulttime Interactive Downloader (#240)
* Create requirements.txt

* Add files via upload

* Create empty

* Yarned Files

	modified:   plugins/AdulttimeInteractiveDL/AdulttimeInteractiveDL.py
	modified:   plugins/AdulttimeInteractiveDL/AdulttimeInteractiveDL.yml
	deleted:    plugins/AdulttimeInteractiveDL/cache/empty
	modified:   plugins/AdulttimeInteractiveDL/requirements.txt

* - Added Return on Error with stashapi
modified:   plugins/AdulttimeInteractiveDL/AdulttimeInteractiveDL.py

- Add new Plugin "PythonToolsInstaller" for Docker ENV, to create VENV with stashtools to use with other Plugins
new file:   plugins/PythonToolsInstaller/PythonToolsInstaller.py
new file:   plugins/PythonToolsInstaller/PythonToolsInstaller.yml
new file:   plugins/PythonToolsInstaller/packages/stashtools.txt

Files yarned.
2024-06-24 21:47:10 +03:00

71 lines
1.6 KiB
Python

import requests, os, shutil
import re, sys, json, time, sysconfig
from inspect import getmembers, isfunction
from venv import create
from os.path import join, expanduser, abspath
import subprocess
import shutil
def main():
input = None
if len(sys.argv) < 2:
input = readJSONInput()
output = {}
run(input, output)
out = json.dumps(output)
print(out + "\n")
def readJSONInput():
input = sys.stdin.read()
return json.loads(input)
def run(input, output):
if input == "None" or input == "":
return
PLUGIN_DIR = input["server_connection"]["PluginDir"]
modeArg = input['args']["mode"]
try:
if modeArg == "" or modeArg == "add":
return
elif modeArg == "process_py_stashapi_tools":
get_download_py_stashapp_tools(PLUGIN_DIR)
except Exception as e:
raise
output["error"] = str(e)
return
output["output"] = "ok"
def get_download_py_stashapp_tools(PLUGIN_DIR):
org_packagedir = sysconfig.get_paths()["purelib"] # /usr/lib/python3.11/site-packages/usr/lib/python3.11/site-packages
used_dir = f"{PLUGIN_DIR}"
create(f"{used_dir}/venv/", with_pip=True)
# where requirements.txt is in same dir as this script
subprocess.run([f"{used_dir}/venv/bin/pip", "install", "-r", abspath(f"{used_dir}/packages/stashtools.txt")],stdout=None)
# venv/lib/python3.11/site-packages/stashapp_tools-
src = f"{used_dir}/venv/lib/python3.11/site-packages"
destination = shutil.copytree(src, org_packagedir,ignore_func,None,shutil.copy2,False,True)
fp = open(f'{used_dir}/copydo.txt', 'w+')
fp.write("%s\n" % print(destination))
def ignore_func(src, names):
return ['env'] if 'env' in names else []
main()