Hi everyone
I’m trying to calculate the render time for a task using Task.TaskRenderTime, I have no idea how to convert it to seconds or format it. When I try to format to any format it I get this error: time data ‘10675199.02:48:05.4775807’ does not match format ‘%H:%M:%S.%f0’
The issue is that you’re getting given a TimeSpan object from .NET. And 10675199.02:48:05.4775807 is the maximum size of a TimeSpan, so whatever task you’re reading likely doesn’t have a TaskRenderTime as we’re likely using the max value to indicate no data.
Keep in mind it’s not a string you’re formatting into a datetime. You may be able to get away with using something like formatted_time = task.TaskRenderTime.ToString("c") to get a workable string with the time data.
Here’s the little script I wrote poking at the data types to see what I could get back, as it’s been a while since I used TimeSpan formatting. test_task_time.py (540 Bytes)
Do you know a way to calculate the total task time from within a Post Task script using just the task properties or any internal method? I tried but it looks like the data isn’t populated when the Post Task script it’s called, the only way I can do it is querying the web service api.
That tracks, I imagine at the time the post-task script is running the Task object hasn’t actually finished up yet and had its metrics calculated.
Maybe the task report is ready though? I wrote a script to shovel out the task info for everything in a database years ago that used the report objects instead of the tasks themselves. The bits you care about are around lines 8-25. extract_aws_data.py (2.6 KB)
Great script, but sadly the task report it’s only ready after executing the Post Task script. Looks like I have to keep using the REST API for now. Thanks for the help, it helped me a lot to understand a few things I had no idea how to achieve.