File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -307,6 +307,19 @@ callbacks:
307307 value : " %_exec.pluginDir%/server/export/error.js"
308308 - type : " value"
309309 value : " %info.json%"
310+ sleep :
311+ exec :
312+ timeoutSec : 120
313+ service : " python3"
314+ commands :
315+ - prog : " python3"
316+ stdout :
317+ type : body
318+ args :
319+ - type : " value"
320+ value : " %_exec.pluginDir%/server/export/sleep.py"
321+ - type : " value"
322+ value : " %info.json%"
310323
311324 transition_db_pre_save :
312325 set_comment :
Original file line number Diff line number Diff line change 1+ import sys
2+ import json
3+ import time
4+
5+ def main ():
6+ # Check if enough arguments are provided
7+ if len (sys .argv ) < 2 :
8+ print (f'Wrong number of parameters. Usage: "python3 export_demo.py <info>"' , file = sys .stderr )
9+ sys .exit (1 )
10+
11+ # Parse the JSON string passed as the second argument (sys.argv[1])
12+ info_json_str = sys .argv [1 ]
13+
14+ try :
15+ info = json .loads (info_json_str )
16+ except json .JSONDecodeError as e :
17+ print (f"Unable to parse argument <info>: { e } " , file = sys .stderr )
18+ sys .exit (1 )
19+
20+ sec = float (info ["export" ]["export" ]["produce_options" ].get ("seconds" , 1 ))
21+ # print(f"Sleeping {sec} seconds")
22+ time .sleep (sec )
23+
24+ info ["export" ]["_plugin_log" ] = [
25+ f"sleeping for { sec } ..." ,
26+ f"slept for { sec } ."
27+ ]
28+
29+ # Mark export as done and clean up log
30+ info ["export" ]["_state" ] = "done"
31+ info ["export" ].pop ("_log" , None ) # Remove _log if it exists
32+
33+ # Output the modified export object as pretty-printed JSON
34+ print (json .dumps (info ["export" ], indent = 2 ))
35+
36+ if __name__ == "__main__" :
37+ main ()
You can’t perform that action at this time.
0 commit comments