python-atd


Namepython-atd JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttp://github.com/ctrlcctrlv/python-atd
SummaryUnix `at` scheduler, for Python 3 and Python 2. Supports atq, atd, & atrm
upload_time2022-12-16 09:07:39
maintainer
docs_urlNone
authorFredrick Brennan
requires_python
licenseMIT
keywords atq atrm atd at
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            atd package (v0.2.2)
====================

at is the companion of cron. While cron says "execute command every 5 minutes",
at says, "execute command once at exactly 2:00 PM". at is the original Unix
scheduler.

This Python module aims to support all at operations in a safe way.

Installation
============

```bash
pip install atd
```

Tests
=====

If installing from repository with `python setup.py install`, it's recommended
to run the tests to make sure at is configured properly.

Supports Python 2 and Python 3.

Simple usage example
====================

```python3
from atd import atd
import datetime

print('Create some jobs...')
job1 = atd.at("echo lol >> /tmp/lolol", datetime.datetime.now() + 
	datetime.timedelta(minutes = 2))
job2 = atd.at("rm /tmp/lolol", datetime.timedelta(minutes=5))

print("Job 1: {0}".format(job1))
print("Job 2: {0}".format(job2))

print('All right, free up those vars...')
del job1; del job2

print('Check our atd queue for our jobs (`atq`)')
atq = atd.AtQueue()
print [str(job) for job in atq.jobs]

print('Cancel all our jobs.')
print [atd.atrm(job) for job in atq.jobs]

print('Refresh the AtQueue...')
atq.refresh()

print('Poof!')
print [str(job) for job in atq.jobs]
```

Submodules
==========

atd module
==========

at(command, when, queue='a')

> Execute command at when.
>
> command may be anything interpreble by /bin/sh. If you need features specific
> to another shell, create a script and then make the command <path to
> shell> <path to script>.
>
> when may be a datetime.timedelta, a datetime.datetime or a timespec str. If a
> string is provided, it is assumed that it's a valid timespec. See *timespec*
> doc in at's documentation.
> 
> python-atd also has good support for named queues. Both GNU and BSD at
> support the concept of named queues, which allow you to easily separate
> different types of jobs based on type.For example, if you owned a bank, you'd
> have different types of jobs. Check clearing might go in queue "c" 24 hours
> after request, while international wire clearing would go in queue "i" 48
> hours after request. An unfortunate limitation of at is that all jobs can
> only be one letter, A-Z or a-z. This means there are only 52 available queues
> in both BSD at and GNU at.

atrm(\*atjobs)

> Cancel one or more AtJobs. Takes an AtJob instance returned by at(). You may
> also choose to save the at job ID in a database, and pass its ID to cancel().

clear(queue = False)

> Cancel all atjobs. You may also specify a queue.

convert\_datetime(dt)

> Convert a datetime object to a POSIX timestamp usable by at. It returns a
> string.
>
> From the at manual: -t Specify the job time using the POSIX time format. The
> argument should be in the form \[\[CC\]YY\]MMDDhhmm\[.SS\].

convert\_timedelta(td)

> Convert a timedelta object to a timespec usable by at. Note that at does not
> understand seconds, so extra seconds are rounded down.

get\_allowed\_users()

> Get a list() of all users allowed to use at, or raise an OSError if we can't
> determine it for some reason.

get\_denied\_users()

> Get a list() of all users disallowed from at, or raise an OSError if we can't
> determine it for some reason.

atq module
==========

class class atq.AtJob(jobid=0, load=False)

> Bases: "object"
>
> from\_at\_stderr(stderr)
>
> > Called by at(), it creates an AtJob from at's stderr.
>
> load()
>
> > For performance reasons, information about atjobs is lazy-loaded on request
> > (see \_\_get\_\_()). However, you can force load all of it with this
> > function, for example for pretty instantaneous JSON output from
> > \_\_repr\_\_().

class class atq.AtQueue(queue=False)

> Bases: "object"
>
> The AtQueue class represents the state of the at queue at the time when it
> was initialized. Jobs are stored as a list in AtQueue.jobs.
>
> find\_job\_by\_id(id)
>
> > Simply iterate through AtQueue.jobs and return the job with the given id.
> > Raise ValueError if no job in AtQueue.
>
> refresh()
>
> > Refresh this AtQueue, reading from atq again. This is automatically called
> > on instantiation. self.jobs becomes a list of AtJob objects.

config module
=============

tests module
============

class class tests.NoNullAtJobComparisonTest(methodName='runTest')

> Bases: "unittest.case.TestCase"
>
> test\_null\_atjob\_comparison()

class class tests.ScheduleTests(methodName='runTest')

> Bases: "unittest.case.TestCase"
>
> test\_at\_cancel()

class class tests.TimeConversionTests(methodName='runTest')

> Bases: "unittest.case.TestCase"
>
> test\_datetime()
>
> test\_timedelta()

Module contents
===============




            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/ctrlcctrlv/python-atd",
    "name": "python-atd",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "atq atrm atd at",
    "author": "Fredrick Brennan",
    "author_email": "copypaste@kittens.ph",
    "download_url": "https://files.pythonhosted.org/packages/60/78/a37c7344626212007ac0eac2fb9f8d2ab6942eab2f9ac7244bb95f47512e/python-atd-0.2.2.linux-x86_64.tar.gz",
    "platform": null,
    "description": "atd package (v0.2.2)\n====================\n\nat is the companion of cron. While cron says \"execute command every 5 minutes\",\nat says, \"execute command once at exactly 2:00 PM\". at is the original Unix\nscheduler.\n\nThis Python module aims to support all at operations in a safe way.\n\nInstallation\n============\n\n```bash\npip install atd\n```\n\nTests\n=====\n\nIf installing from repository with `python setup.py install`, it's recommended\nto run the tests to make sure at is configured properly.\n\nSupports Python 2 and Python 3.\n\nSimple usage example\n====================\n\n```python3\nfrom atd import atd\nimport datetime\n\nprint('Create some jobs...')\njob1 = atd.at(\"echo lol >> /tmp/lolol\", datetime.datetime.now() + \n\tdatetime.timedelta(minutes = 2))\njob2 = atd.at(\"rm /tmp/lolol\", datetime.timedelta(minutes=5))\n\nprint(\"Job 1: {0}\".format(job1))\nprint(\"Job 2: {0}\".format(job2))\n\nprint('All right, free up those vars...')\ndel job1; del job2\n\nprint('Check our atd queue for our jobs (`atq`)')\natq = atd.AtQueue()\nprint [str(job) for job in atq.jobs]\n\nprint('Cancel all our jobs.')\nprint [atd.atrm(job) for job in atq.jobs]\n\nprint('Refresh the AtQueue...')\natq.refresh()\n\nprint('Poof!')\nprint [str(job) for job in atq.jobs]\n```\n\nSubmodules\n==========\n\natd module\n==========\n\nat(command, when, queue='a')\n\n> Execute command at when.\n>\n> command may be anything interpreble by /bin/sh. If you need features specific\n> to another shell, create a script and then make the command <path to\n> shell> <path to script>.\n>\n> when may be a datetime.timedelta, a datetime.datetime or a timespec str. If a\n> string is provided, it is assumed that it's a valid timespec. See *timespec*\n> doc in at's documentation.\n> \n> python-atd also has good support for named queues. Both GNU and BSD at\n> support the concept of named queues, which allow you to easily separate\n> different types of jobs based on type.For example, if you owned a bank, you'd\n> have different types of jobs. Check clearing might go in queue \"c\" 24 hours\n> after request, while international wire clearing would go in queue \"i\" 48\n> hours after request. An unfortunate limitation of at is that all jobs can\n> only be one letter, A-Z or a-z. This means there are only 52 available queues\n> in both BSD at and GNU at.\n\natrm(\\*atjobs)\n\n> Cancel one or more AtJobs. Takes an AtJob instance returned by at(). You may\n> also choose to save the at job ID in a database, and pass its ID to cancel().\n\nclear(queue = False)\n\n> Cancel all atjobs. You may also specify a queue.\n\nconvert\\_datetime(dt)\n\n> Convert a datetime object to a POSIX timestamp usable by at. It returns a\n> string.\n>\n> From the at manual: -t Specify the job time using the POSIX time format. The\n> argument should be in the form \\[\\[CC\\]YY\\]MMDDhhmm\\[.SS\\].\n\nconvert\\_timedelta(td)\n\n> Convert a timedelta object to a timespec usable by at. Note that at does not\n> understand seconds, so extra seconds are rounded down.\n\nget\\_allowed\\_users()\n\n> Get a list() of all users allowed to use at, or raise an OSError if we can't\n> determine it for some reason.\n\nget\\_denied\\_users()\n\n> Get a list() of all users disallowed from at, or raise an OSError if we can't\n> determine it for some reason.\n\natq module\n==========\n\nclass class atq.AtJob(jobid=0, load=False)\n\n> Bases: \"object\"\n>\n> from\\_at\\_stderr(stderr)\n>\n> > Called by at(), it creates an AtJob from at's stderr.\n>\n> load()\n>\n> > For performance reasons, information about atjobs is lazy-loaded on request\n> > (see \\_\\_get\\_\\_()). However, you can force load all of it with this\n> > function, for example for pretty instantaneous JSON output from\n> > \\_\\_repr\\_\\_().\n\nclass class atq.AtQueue(queue=False)\n\n> Bases: \"object\"\n>\n> The AtQueue class represents the state of the at queue at the time when it\n> was initialized. Jobs are stored as a list in AtQueue.jobs.\n>\n> find\\_job\\_by\\_id(id)\n>\n> > Simply iterate through AtQueue.jobs and return the job with the given id.\n> > Raise ValueError if no job in AtQueue.\n>\n> refresh()\n>\n> > Refresh this AtQueue, reading from atq again. This is automatically called\n> > on instantiation. self.jobs becomes a list of AtJob objects.\n\nconfig module\n=============\n\ntests module\n============\n\nclass class tests.NoNullAtJobComparisonTest(methodName='runTest')\n\n> Bases: \"unittest.case.TestCase\"\n>\n> test\\_null\\_atjob\\_comparison()\n\nclass class tests.ScheduleTests(methodName='runTest')\n\n> Bases: \"unittest.case.TestCase\"\n>\n> test\\_at\\_cancel()\n\nclass class tests.TimeConversionTests(methodName='runTest')\n\n> Bases: \"unittest.case.TestCase\"\n>\n> test\\_datetime()\n>\n> test\\_timedelta()\n\nModule contents\n===============\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Unix `at` scheduler, for Python 3 and Python 2. Supports atq, atd, & atrm",
    "version": "0.2.2",
    "split_keywords": [
        "atq",
        "atrm",
        "atd",
        "at"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "fba4584f37754720d222a32afb03dac7",
                "sha256": "5cf1df4c5579a12fcaa86bec5f1b9e5fb327bbfc06c51d1296208874ecb05c0b"
            },
            "downloads": -1,
            "filename": "python-atd-0.2.2.linux-x86_64.tar.gz",
            "has_sig": false,
            "md5_digest": "fba4584f37754720d222a32afb03dac7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15724,
            "upload_time": "2022-12-16T09:07:39",
            "upload_time_iso_8601": "2022-12-16T09:07:39.066960Z",
            "url": "https://files.pythonhosted.org/packages/60/78/a37c7344626212007ac0eac2fb9f8d2ab6942eab2f9ac7244bb95f47512e/python-atd-0.2.2.linux-x86_64.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-16 09:07:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ctrlcctrlv",
    "github_project": "python-atd",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "python-atd"
}
        
Elapsed time: 0.02034s