...
Code Block |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<taskProperties xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/taskProperties.xsd" xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<description>ImportNOAAGFSdata_scheduled</description>
<userId>fews</userId>
<workflowId>Import_GFS_0.25_Schedule</workflowId>
<taskSelection>
<singleTask>
<time0>14-06-2021 11:20</time0>
</singleTask>
</taskSelection>
<forecastPriority>Normal</forecastPriority>
<makeForcastCurrent>true</makeForcastCurrent>
</taskProperties> |
Solution Python
The user opted for a Python script to update the systemtime.
Now my solution has been to include a Python script prior to the FEWS call within my batch file.
Code Block |
---|
language | bash |
---|
linenumbers | true |
---|
collapse | true |
---|
|
cd C:\FEWS\
python .\WindowsTaskScheduling\refreshT0.py C:/FEWS/WindowsTaskScheduling/TaskRun_Update_Daily_Met_Gob.xml UpdateDailyMetGob
.\bin\windows\Delft-FEWS.exe "runTask=C:\FEWS\WindowsTaskScheduling\TaskRun_Update_Daily_Met_Gob.xml" |
This is the Python script:
Code Block |
---|
language | py |
---|
linenumbers | true |
---|
collapse | true |
---|
|
import sys
import datetime
import pytz
XML_PATH = sys.argv[1]
WORKFLOW_ID = sys.argv[2]
s = '''<?xml version="1.0" encoding="UTF-8"?>
<taskProperties xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/taskProperties.xsd" xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<description>Update daily gobs (scheduled task)</description>
<userId>mm</userId>
<workflowId>{}</workflowId>
<taskSelection>
<singleTask>
<time0>{}</time0>
</singleTask>
</taskSelection>
<forecastPriority>Normal</forecastPriority>
<makeForcastCurrent>true</makeForcastCurrent>
</taskProperties>
'''
cur = datetime.datetime.now(tz=pytz.timezone("EST"))
with open(XML_PATH, "w") as f:
f.write(s.format(WORKFLOW_ID, cur.isoformat())) |
...