Skip to content
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

Reserved keywords are mapped to wrong expressions #394

Open
bynr opened this issue Jan 24, 2020 · 0 comments
Open

Reserved keywords are mapped to wrong expressions #394

bynr opened this issue Jan 24, 2020 · 0 comments

Comments

@bynr
Copy link

bynr commented Jan 24, 2020

Description of bug

Documentation in README mismatch for weekly cronjob expression.

# Fire once a week.

@crython.job(expr='0 0 0 * * 0 *')
def foo():
print "Back in line, maggot! - Kearny"

and

@Weekly | Run once a week at midnight in the morning of Sunday | 0 0 0 0 * 0 *

Looking in details of the expression in the code for @weekly keyword, we can see the actual expression used:

'@weekly': '0 0 0 0 * 0 *',

As shown in below section, the expression is not correct.

According to the crython docstring, this is how an expression is constructed:

    Represents an entire cron expression.
    An expression consists of seven, space delimited fields that represent the following values::
        +------------- second (0 - 59)
        | +------------- minute (0 - 59)
        | | +------------- hour (0 - 23)
        | | | +------------- day (1 - 31)
        | | | | +------------- month (1 - 12)
        | | | | | +------------- weekday (0 - 6) (Sunday to Saturday; 7 is also Sunday)
        | | | | | | +------------- year (1970 - 2099)
        | | | | | | |
        | | | | | | |
        * * * * * * *

I believe all keywords using incorrectly the day_in_month part of expressions set to 0 should fail?
I only tested it for the weekly keyword as shown below.

How to reproduce

Python 3.6.9 (default, Nov  7 2019, 10:44:02) 

In [1]: import pandas as pd
In [2]: import crython
In [3]: crython.__version__
Out[3]: '0.2.0'

In [5]: crython.expression.CronExpression.new('0 0 0 * * 0 *').matches(pd.Timestamp('2020-01-26 00:00:00'))
Out[5]: True

In [6]: crython.expression.CronExpression.new('0 0 0 0 * 0 *').matches(pd.Timestamp('2020-01-26 00:00:00'))
Out[6]: False

In [7]: crython.expression.CronExpression.new('@weekly').matches(pd.Timestamp('2020-01-26 00:00:00'))
Out[7]: False
@bynr bynr changed the title Some reserved keywords define wrong expressions Reserved keywords are mapped to wrong expressions Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant