Skip to main content

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

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

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

Metadata

Release files for python-atd 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-atd 0.2.2
File Size Uploaded Provenance
python-atd-0.2.2.linux-x86_64.tar.gz 15.7 kB Without provenance Details

Release files / python-atd-0.2.2.linux-x86_64.tar.gz

Download URL python-atd-0.2.2.linux-x86_64.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5cf1df4c5579a12fcaa86bec5f1b9e5fb327bbfc06c51d1296208874ecb05c0b
BLAKE2b-256 checksum
How to use checksums
6078a37c7344626212007ac0eac2fb9f8d2ab6942eab2f9ac7244bb95f47512e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Security for python-atd 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page