From 0ecc05a50817910c46e299606ba0892aaa9b87d6 Mon Sep 17 00:00:00 2001 From: rupozzi Date: Fri, 20 May 2022 13:42:00 +0200 Subject: [PATCH] fix: Updating to new TimeUtilities module --- src/COMDIRAC/Interfaces/scripts/dinput.py | 6 ++++-- src/COMDIRAC/Interfaces/scripts/doutput.py | 5 +++-- src/COMDIRAC/Interfaces/scripts/dstat.py | 8 +++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/COMDIRAC/Interfaces/scripts/dinput.py b/src/COMDIRAC/Interfaces/scripts/dinput.py index b75ce79..739c280 100644 --- a/src/COMDIRAC/Interfaces/scripts/dinput.py +++ b/src/COMDIRAC/Interfaces/scripts/dinput.py @@ -1,11 +1,13 @@ """ Retrieve input sandbox for a DIRAC job """ + import DIRAC from DIRAC.Core.Utilities.DIRACScript import DIRACScript as Script import os import pprint +import datetime class Params(object): @@ -100,7 +102,7 @@ def main(): args = Script.getPositionalArgs() from DIRAC.Interfaces.API.Dirac import Dirac - from DIRAC.Core.Utilities.Time import toString, date, day + from DIRAC.Core.Utilities.TimeUtilities import toString, day dirac = Dirac() exitCode = 0 @@ -118,7 +120,7 @@ def main(): args += l.split(",") for jobGroup in params.getJobGroup(): - jobDate = toString(date() - 30 * day) + jobDate = toString(datetime.datetime.utcnow().date - 30 * day) # Choose jobs no more than 30 days old result = dirac.selectJobs(jobGroup=jobGroup, date=jobDate) diff --git a/src/COMDIRAC/Interfaces/scripts/doutput.py b/src/COMDIRAC/Interfaces/scripts/doutput.py index 83ca3fa..cadd931 100644 --- a/src/COMDIRAC/Interfaces/scripts/doutput.py +++ b/src/COMDIRAC/Interfaces/scripts/doutput.py @@ -7,6 +7,7 @@ from DIRAC.Core.Utilities.DIRACScript import DIRACScript as Script import os +import datetime class Params(object): @@ -118,7 +119,7 @@ def main(): args = Script.getPositionalArgs() from DIRAC.Interfaces.API.Dirac import Dirac - from DIRAC.Core.Utilities.Time import toString, date, day + from DIRAC.Core.Utilities.TimeUtilities import toString, day dirac = Dirac() exitCode = 0 @@ -136,7 +137,7 @@ def main(): args += l.split(",") for jobGroup in params.getJobGroup(): - jobDate = toString(date() - 30 * day) + jobDate = toString(datetime.datetime.utcnow().date() - 30 * day) # Choose jobs in final state, no more than 30 days old for s in ["Done", "Failed"]: diff --git a/src/COMDIRAC/Interfaces/scripts/dstat.py b/src/COMDIRAC/Interfaces/scripts/dstat.py index 176acf1..06dfb74 100644 --- a/src/COMDIRAC/Interfaces/scripts/dstat.py +++ b/src/COMDIRAC/Interfaces/scripts/dstat.py @@ -1,15 +1,15 @@ #! /usr/bin/env python - """ Retrieve status of DIRAC jobs """ +import datetime from signal import signal, SIGPIPE, SIG_DFL from DIRAC import exit as DIRACExit, S_OK, S_ERROR from COMDIRAC.Interfaces import DSession from COMDIRAC.Interfaces import ConfigCache from DIRAC.Core.Utilities.DIRACScript import DIRACScript as Script -from DIRAC.Core.Utilities.Time import toString, date, day +from DIRAC.Core.Utilities.TimeUtilities import toString, day from DIRAC.WorkloadManagementSystem.Client.JobMonitoringClient import ( JobMonitoringClient, ) @@ -242,7 +242,9 @@ def main(): if not jobs: # time interval - jobDate = toString(date() - params.getJobDate() * day) + jobDate = toString( + datetime.datetime.utcnow().date() - params.getJobDate() * day + ) # job owner userName = params.getUser()