mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-04-02 08:58:27 +02:00
fixes for venv
This commit is contained in:
parent
9d00d5a7a1
commit
f0b320bdf8
@ -628,6 +628,27 @@ class DVM:
|
||||
|
||||
return reaction_event.as_json()
|
||||
|
||||
async def run_subprocess(python_bin, dvm_config, request_form):
|
||||
process = await asyncio.create_subprocess_exec(
|
||||
python_bin, dvm_config.SCRIPT,
|
||||
'--request', json.dumps(request_form),
|
||||
'--identifier', dvm_config.IDENTIFIER,
|
||||
'--output', 'output.txt',
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE
|
||||
)
|
||||
|
||||
stdout, stderr = await process.communicate()
|
||||
|
||||
retcode = process.returncode
|
||||
|
||||
if retcode != 0:
|
||||
print(f"Error: {stderr.decode()}")
|
||||
else:
|
||||
print(f"Output: {stdout.decode()}")
|
||||
|
||||
return retcode
|
||||
|
||||
async def do_work(job_event, amount):
|
||||
if ((
|
||||
EventDefinitions.KIND_NIP90_EXTRACT_TEXT.as_u64() <= job_event.kind().as_u64() <= EventDefinitions.KIND_NIP90_GENERIC.as_u64())
|
||||
@ -648,10 +669,11 @@ class DVM:
|
||||
python_location = "/Scripts/python"
|
||||
python_bin = (r'cache/venvs/' + os.path.basename(dvm_config.SCRIPT).split(".py")[0]
|
||||
+ python_location)
|
||||
retcode = subprocess.call([python_bin, dvm_config.SCRIPT,
|
||||
'--request', json.dumps(request_form),
|
||||
'--identifier', dvm_config.IDENTIFIER,
|
||||
'--output', 'output.txt'])
|
||||
#retcode = subprocess.call([python_bin, dvm_config.SCRIPT,
|
||||
# '--request', json.dumps(request_form),
|
||||
# '--identifier', dvm_config.IDENTIFIER,
|
||||
# '--output', 'output.txt'])
|
||||
await run_subprocess(python_bin, dvm_config, request_form)
|
||||
print("Finished processing, loading data..")
|
||||
|
||||
with open(os.path.abspath('output.txt')) as f:
|
||||
|
@ -163,7 +163,7 @@ class DVMTaskInterface:
|
||||
# f.close()
|
||||
|
||||
|
||||
async def process_venv(identifier):
|
||||
def process_venv(identifier):
|
||||
args = DVMTaskInterface.process_args()
|
||||
dvm_config = build_default_config(args.identifier)
|
||||
dvm = identifier(name="", dvm_config=dvm_config, nip89config=NIP89Config(), admin_config=None)
|
||||
@ -172,3 +172,4 @@ async def process_venv(identifier):
|
||||
DVMTaskInterface.write_output(result, args.output)
|
||||
except Exception as e:
|
||||
DVMTaskInterface.write_output("Error: " + str(e), args.output)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user