GodotPythonJSONRPC/TestPythonInExport.gd
2024-07-15 07:39:58 -07:00

68 lines
1.7 KiB
GDScript

extends Node
var pw : KiriPythonWrapperInstance
func _ready():
#pw = KiriPythonWrapperInstance.new(
#"/storage/git2/GodotJSONRPCTest/addons/KiriPythonRPCWrapper/KiriPythonRPCWrapper/test_module/__init__.py")
#pw.setup_python()
#pw.start_process()
#var ret = pw.call_rpc_sync("func_to_call", ["test string whatever blah"])
#print(ret)
#print("Calling the thing")
#butt("nkc sckccsd scaskcmasklcms")
#print("Done calling the thing:" )
#asdfblah.emit()
#pw.stop_process()
#
pw = KiriPythonWrapperInstance.new(
"res://SomePythonThingy/test_a_thing.py")
pw.setup_python()
#print("running command...")
#var utility_script_path = pw.convert_cache_item_to_real_path(
#"res://SomePythonThingy/some_utility_script.py")
#var r1 = pw.run_python_command([utility_script_path], [], true)
#print("done running command... ", r1)
print("running command...")
var requirements_txt_path = pw.convert_cache_item_to_real_path(
"res://SomePythonThingy/requirements.txt")
var output_array = []
var r1 = pw.run_python_command(
["-m", "pip", "install", "-r", requirements_txt_path],
output_array, true, true)
print("done running command... ", r1)
print("OUTPUT WAS:", output_array[0])
pw.start_process(true)
print("Call thingy...")
var ret = await pw.call_rpc_async("some_function_to_call", [])
print("Done thingy...")
print(ret)
func _process(delta):
#if pw.get_status() == \
#KiriPythonWrapperInstance.KiriPythonWrapperStatus.STATUS_RUNNING:
#print("poll")
pw.poll()
#if pw.get_status() == \
#KiriPythonWrapperInstance.KiriPythonWrapperStatus.STATUS_STOPPED:
#print("IT STOPPED")
signal asdfblah
func butt(asdf):
print("Butt1: ", asdf)
await asdfblah
print("Butt2: ", asdf)