ericpruitt / cronex Goto Github PK
View Code? Open in Web Editor NEWHeavily unit tested cron expression evaluation
License: MIT License
Heavily unit tested cron expression evaluation
License: MIT License
I'd like to add an extra seconds
field into this. I'm pretty happy with the ability to use cron-like syntax for scheduling, but I'm running into an environment with required resolution of ~10 seconds. I'd like to keep using cron-like syntax while saving compatibility with old tasks at the same time, instead of running once a minute and sleeping within this minute (I think that's ugly).
If I try to add this by myself, would you be interested in maintaining that code? What would you recommend doing (e.g. add seconds field to date_tuple
and implement length checks, add an extra seconds = '*'
kind of opt. argument, add a function wrapper, etc?).
from cronex import CronExpression
ce = CronExpression(u'* * * * *')
Code should run without issue
Raises error as
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/.python-virtualenvs/codebase/local/lib/python2.7/site-packages/cronex/__init__.py", line 107, in __init__
self.string_tab = map(str.upper, [minutes, hours, dom, months, dow])
TypeError: descriptor 'upper' requires a 'str' object but received a 'unicode'
Simply convert your unicode
to str
for the time being
from cronex import CronExpression
ce = CronExpression(u'* * * * *'.encode('utf-8))
If you are unsure if the object is of type unicode
or str
, you can still use the same method
# `my_string` is defined elsewhere, it is possibly a <unicode> or <str> object
from cronex import CronExpression
ce = CronExpression(my_string.encode('utf-8'))
When I exec this command, I got the error:
cp: 无法获取'cronex.py' 的文件状态(stat): 没有那个文件或目录
How to resolve it?
Hello @ericpruitt,
Thanks so much for making this little library. It's very helpful.
I was working on a small missing feature needed to implement support for time jump tracking for the Vixie cron style local time tracking event loop algorithm, where non-wildcard and wildcard job execution changes intelligently in the presence of DST, transitions and most forward and reverse clock skew occurrences.
While I was testing my own changes, I noticed an original UT is failing in the unchanged code. I wanted to see if you could check it for a second so I could be sure the change I'd like to contribute will work properly for everyone.
Thanks,
@megahall
$ ./tests.py
...................F....
======================================================================
FAIL: test_periodics_month (__main__.test_testedmodule)
----------------------------------------------------------------------
Traceback (most recent call last):
File "./tests.py", line 116, in test_periodics_month
self.assertFalse(testex.check_trigger(now_tuple[:5]))
AssertionError: True is not false
----------------------------------------------------------------------
Ran 24 tests in 0.035s
FAILED (failures=1)
How can I consider index for day of week [1-7]
, instead of [0-6]
as I am working with Quartz Syntax of cron expression where index of day of week is consider from 1 and in code it is considered from 0. Due to that I am getting wrong output from check_trigger()
method.
http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.