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

"0 8-21/3,21 * * *" raises Exception #86

Open
pheanex opened this issue Sep 26, 2024 · 2 comments
Open

"0 8-21/3,21 * * *" raises Exception #86

pheanex opened this issue Sep 26, 2024 · 2 comments

Comments

@pheanex
Copy link

pheanex commented Sep 26, 2024

I guess the following should not raise and needs fixing?

~ $python -m venv venv
~ $. venv/bin/activate
(venv) ~ $pip install cron-descriptor
Collecting cron-descriptor
  Downloading cron_descriptor-1.4.5-py3-none-any.whl (50 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 50.4/50.4 kB 1.0 MB/s eta 0:00:00
Installing collected packages: cron-descriptor
Successfully installed cron-descriptor-1.4.5

[notice] A new release of pip available: 22.2.1 -> 24.2
[notice] To update, run: pip install --upgrade pip
(venv) ~ $python3
Python 3.10.6 (main, Aug 15 2022, 10:11:08) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cron_descriptor import get_description
>>> print(get_description("0 8-21/3,21 * * *"))
Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/cron_descriptor/ExpressionDescriptor.py", line 117, in get_full_description
    time_segment = self.get_time_of_day_description()
  File "/venv/lib/python3.10/site-packages/cron_descriptor/ExpressionDescriptor.py", line 189, in get_time_of_day_description
    hours_description = self.get_hours_description()
  File "/venv/lib/python3.10/site-packages/cron_descriptor/ExpressionDescriptor.py", line 273, in get_hours_description
    return self.get_segment_description(
  File "/venv/lib/python3.10/site-packages/cron_descriptor/ExpressionDescriptor.py", line 458, in get_segment_description
    description = get_interval_description_format(segments[1]).format(get_single_item_description(segments[1]))
  File "/venv/lib/python3.10/site-packages/cron_descriptor/ExpressionDescriptor.py", line 276, in <lambda>
    lambda s: self.format_time(s, "0"),
  File "/venv/lib/python3.10/site-packages/cron_descriptor/ExpressionDescriptor.py", line 554, in format_time
    hour = int(hour_expression)
ValueError: invalid literal for int() with base 10: '3,21'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/venv/lib/python3.10/site-packages/cron_descriptor/ExpressionDescriptor.py", line 652, in get_description
    return descriptor.get_description(DescriptionTypeEnum.FULL)
  File "/venv/lib/python3.10/site-packages/cron_descriptor/ExpressionDescriptor.py", line 104, in get_description
    return choices.get(description_type, self.get_seconds_description)()
  File "/venv/lib/python3.10/site-packages/cron_descriptor/ExpressionDescriptor.py", line 136, in get_full_description
    raise FormatException(description)
cron_descriptor.Exception.FormatException

Syntax seems legit, see i.e. here

@pheanex
Copy link
Author

pheanex commented Sep 26, 2024

And also "0 10 * * [1,2,3,4]"

@pheanex
Copy link
Author

pheanex commented Sep 26, 2024

Coming from the django-celery-beat issue btw

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