Execute a waiting graph with dispatch library and publish if needed

Post Reply
Message
Author
arnaud
Posts: 5
Joined: Thu Jun 01, 2017 1:19 pm

Execute a waiting graph with dispatch library and publish if needed

#1 Post by arnaud » Thu Jun 22, 2017 11:51 am

Code: Select all

from kurtis import logInfo
from kurtis import dispatch
from kurtis import api
from kurtis.graph import getPythonCommand

# if your code is outside of Kurtis you need to open the project first by uncomenting the next line and replace your workingcopy path. please refere to the api for more details
# api.openProject("path to your workingcopy")

block = api.findBlockByNodeID(4011)
KD = dispatch.KurtisDispatch('Local Render', '')
if block.hasGraph():
    with block.openGraph() as graph:
        if graph.isValid():
            variables = block.getVarValues()
            graph_id = block.getGraphID()
            path=r'f:\toot.py'
            with open (path,'w') as f:
                graph.exportPython(f)
                kurtis_cmd = getPythonCommand( variables['environment'], block.getDepartment() )
                KD.processGraph(kurtis_cmd,path,'',graph_id,{},{})
    		if block.doesGraphNeedPublish():
        		logInfo("need update")
        		block.publishGraph("Published by api script",ignore_warnings=True)
        

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest