-
Notifications
You must be signed in to change notification settings - Fork 713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export crontab line from CronTrigger #945
Comments
And what will it do with the |
My original idea was to have it crontab compatible, but I can add an optional parameter I did not saw any standard that APScheduler uses in reading the |
The point I was trying to make is that since APScheduler's cron trigger has more options than the original cron spec, the reverse conversion doesn't work, so I'm not going to provide such a method. I took a look at the |
I was poking around and ended up with a small piece of code that could retrieve all the information into a dictionary: trigger = CronTrigger.from_crontab("20 04 25 12 *")
cron_dict = { k:str(v) for (k,v) in zip(trigger.FIELD_NAMES, trigger.fields)} It is not the most convenient, or straightforward way of getting the information, but it seems to work as expected. Are you planning to change the code to have something like this? If I could export as a dict, it could be possible to format the string as well |
Did you mean trigger = CronTrigger.from_crontab("20 04 25 12 *")
cron_dict = {f.name: str(f) in trigger._fields} |
yes, |
If the feature to export the crontab line won't be implemented, should I close this issue already, or is this going to be related to any other changes you will do in the code? |
Things to check first
Feature description
I've been looking for a way to export crontab line from the trigger and it seems this feature does not exist. In the CronTrigger class, there is a from_crontab method that receives a crontab string. It would be good to have a
to_crontab()
method that would return a crontab line.Here are some examples in how I would assume this would work:
In case this feature gets approve, I would like to contribute to the project and work on it.
Thanks :)
Use case
Example of usage
The text was updated successfully, but these errors were encountered: