Forum

Author Topic: RunScript to execute external script version 1.5.1  (Read 215 times)

eastonmbio

  • Newbie
  • *
  • Posts: 2
    • View Profile
RunScript to execute external script version 1.5.1
« on: April 12, 2021, 12:47:57 PM »
I'm looking to execute an external script as a network task using the following tester code:

Code: [Select]
import Metashape

path = Metashape.app.getOpenFileName("Specify path to the PSX document:")
root = Metashape.app.getExistingDirectory("Specify network root path:")

doc = Metashape.Document()
doc.open(path)
chunk = doc.chunk

client=Metashape.NetworkClient()

network_tasks = list()

task = Metashape.Tasks.RunScript()
task.path = "C:/path/to/myscript.py"

n_task = Metashape.NetworkTask()
n_task.name = task.name
n_task.params = task.encode()
n_task.frames.append((chunk.key, 0))
network_tasks.append(n_task)


client.connect('my.server.name')
batch_id = client.createBatch(path[len(root):], [network_tasks] )
client.resumeBatch(batch_id)
print("Job Started...")


The code referred to in the path just imports Metashape. However, when running the script, I get the error message " TypeError: Task object expected". Clearly what I am passing in to the server is not recognised as a task. I am using version 1.5.1. I'm not sure if my code structure needs to change to accommodate network processing of the external script.