Skip to main content

A Celery schedule corntab which is work with jalali calendar

Project description

PyPI Code style: black

JalaliCrontab is a Celery schedule that works with Jalali Calendar.

Getting Started

Install with pip:

pip install celery-jalalicrontab

You can use JalaliCrontab just like celery crontab. In the example bellow, task will be run every minutes in “30” of “dey” month:

@app.on_after_configure.connect
def setup_periodic_tasks(sender, **kwargs):
    sender.add_periodic_task(
        JalaliCrontab(day_of_month=30, month_of_year=10),
        test.s('Happy my birthday!'),
    )

And also you can use it alongside RedisBeater by extending JalaliCrontab and jalalidatetime then define encode_beater method for them:

class Myjalalidatetime(jalalidatetime):
    def encode_beater(self):
        if self.tzinfo is None:
            timezone = 'UTC'
        elif self.tzinfo.zone is None:
            timezone = self.tzinfo.utcoffset(None).total_seconds()
        else:
            timezone = self.tzinfo.zone

        datetime_obj = self.togregorian()
        return {
            'year': datetime_obj.year,
            'month': datetime_obj.month,
            'day': datetime_obj.day,
            'hour': datetime_obj.hour,
            'minute': datetime_obj.minute,
            'second': datetime_obj.second,
            'microsecond': datetime_obj.microsecond,
            'timezone': timezone,
        }

class MyJalaliCrontab(JalaliCrontab):
    def encode_beater(self):
        return {
            'minute': self._orig_minute,
            'hour': self._orig_hour,
            'day_of_week': self._orig_day_of_week,
            'day_of_month': self._orig_day_of_month,
            'month_of_year': self._orig_month_of_year,
        }

Development

JalaliCrontab is available on GitHub

Once you have the source you can run the tests with the following commands:

pip install -r requirements.dev.txt
py.test tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

celery-jalalicrontab-1.0.3.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

celery_jalalicrontab-1.0.3-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page