MCPcopy Create free account
hub / github.com/ActiveState/code / printProgramStatus

Function printProgramStatus

recipes/Python/576807_Send_Email/recipe-576807.py:136–148  ·  view source on GitHub ↗

Print program duration information.

(started, stream=sys.stdout)

Source from the content-addressed store, hash-verified

134 return ['st', 'nd', 'rd'][day % 10 - 1]
135
136def printProgramStatus(started, stream=sys.stdout):
137 """Print program duration information."""
138
139 NEW_LINE = '\n'
140 DATE_TIME_FORMAT = '%Y-%m-%d %H:%M:%S.%f (%a %d{0} %b %Y)'
141 finished = datetime.datetime.now()
142 delta = finished - started
143 dateTimeStr = started.strftime(DATE_TIME_FORMAT.format(getDaySuffix(started.day)))
144 msg = '{1}Started: {0}{1}'.format(dateTimeStr, NEW_LINE)
145 dateTimeStr = finished.strftime(DATE_TIME_FORMAT.format(getDaySuffix(finished.day)))
146 msg += 'Finished: {0}{1}'.format(dateTimeStr, NEW_LINE)
147 msg += 'Duration: {0} (days hh:mm:ss:ms)'.format(delta)
148 print(msg, file=stream)
149
150def getFileContentsOrParameterValue(filePathOrValue):
151 """Return list of file contents if parameter is file path, otherwise

Callers 1

mainFunction · 0.85

Calls 3

getDaySuffixFunction · 0.85
printFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected