Closed amir-khamis closed 2 years ago
Just handle raised exceptions in your code to allow it to continue
for result in r:
cron_expression = result[expressionField]
try:
descripter = ExpressionDescriptor(cron_expression, options)
result[humanReadableField] = str(descripter.get_description(DescriptionTypeEnum.FULL))
except Exception:
result[humanReadableField] = '???'
w.writerow(result)
Hello, I was wondering if you can possibly help me figure out the best way to avoid bad cron entries like this one:"3-59/10 * 1-7" the code bombs out and it does not continue processing. is there a way for me to improve the code on my side to avoid this issue? perhaps I can improve the for loop to avoid processing a bad entry like the example I provided? any help is greatly appreciated and thank you so much for this amazing library, it is so important!
here is the code I using:
!/usr/bin/env python
import csv import sys
from cron_descriptor import ExpressionDescriptor, Options, DescriptionTypeEnum, CasingTypeEnum
expressionField = "cron_expression" humanReadableField = "cron_human_readable"
def main(): infile = sys.stdin outfile = sys.stdout
main()