🕰 The command line tool for scheduling Python scripts

Overview

hickory

PyPI Downloads

About

hickory is a simple command line tool for scheduling Python scripts.

Support

Operating System Scheduler
macOS launchd
Linux systemd
Windows

Install

pip install hickory

Quickstart

Create a file called foo.py:

import datetime
import time

stamp = datetime.datetime.now().strftime("%H:%M:%S")
time.sleep(5)

print(f"Foo - {stamp} + 5 seconds")

Schedule foo.py to execute every ten minutes:

hickory schedule foo.py --every=10minutes

Check the status of all queued schedules:

hickory status

Stop and delete the schedule for foo.py:

hickory kill foo.py

Logs

macOS - logs are stored in the same directory as the scheduled script:

tail -f hickory.log

Linux - logs are written to the journal:

journalctl -f

--every Examples

Repeat
Every ten minutes --every=10minutes
Every day at 10:10 AM [email protected]:10
Every Monday at 10:10 AM [email protected]:10am
Every 10th day of the month at 10:10 AM [email protected]:10am
Every last day of the month at 10:10 AM [email protected]:10am
Every 10th and last day of the month at 10 AM and 10 PM --every=10,[email protected],10pm

--every Table

Interval
10 seconds 10, 10s, 10sec, 10secs, 10seconds
10 minutes 10m, 10min, 10mins, 10minutes
10 hours 10h, 10hr, 10hrs, 10hours
Time
10:00 AM @10, @10am
10:00 PM @22, @10pm
10:10 AM @10:10, @10:10am
10:10 PM @22:10, @10:10pm
Weekday
Monday m@, mon@, monday@
Tuesday t@, tue@, tues@, tuesday@
Wednesday w@, wed@, weds@, wednesday@
Thursday th@, thu@, thur@, thurs@, thursday@
Friday f@, fri@, friday@
Saturday s@, sat@, saturday@
Sunday su@, sun@, sunday@
Calendar Day
1st 1@, 1st@
2nd 2@, 2nd@
3rd 3@, 3rd@
4th 4@, 4th@
15th 15@, 15th@
31st 31@, 31st@
Other Day
Every Day day@
Every Weekday weekday@
End of Month eom@
Comments
  • Add colors to cli messages

    Add colors to cli messages

    Related issue: #5

    Here's what this PR brings:

    • when an action is successful, print in green (Killed X, Scheduled X);
    • when an exception is raised, print in red + hide traceback for commonplace errors (file not found, unsupported platform, hickory specific errors);
    • the output of status isn't colored because as a table-like output, it's likely to be passed through a pipe for other purposes (although you could always detect when this happens using os.isatty and not add any colors).
    • added hickory/__main__.py to be able to run the package against a specific python runtime: python -m hickory targeting the folder or the installed package.

    Coloring is done using colorama, a popular terminal coloring package. It also brings cross-compatibility with Windows since coloring is done through API calls rather than escape sequences in there.

    opened by Zebralt 3
  • Feature Request: --retry

    Feature Request: --retry

    I like the philosophy behind hickory but I'm wondering if it makes sense to add a retry mechanic.

    One of the main reasons some of my old clients resorted to airflow was because of the retry mechanics in them. It feels like API-wise we could add two extra flags. One for how often we should attempt a retry and another one for how long to wait between retries.

    opened by koaning 1
  • Cannot show status and it does not schedule either

    Cannot show status and it does not schedule either

    Describe the bug I followed the readme, but did not succeed. To Reproduce Create a foo.py

    import datetime
    import time
    
    stamp = datetime.datetime.now().strftime("%H:%M:%S")
    time.sleep(5)
    
    print(f"Foo - {stamp} + 5 seconds")
    
    

    Then schedule with hickory schedule foo.py --every=10s

    Then check the status using hickory status

    Expected behavior Expect the schedule will work and the show the status of all scheduled jobs

    Environment:

    • OS: [Linux] (Windows subsystem linux 2)
    • Version: [Ubuntu 20.04.1 LTS]

    Additional context When I check status, it shows

    Traceback (most recent call last):
      File "/home/jake/anaconda3/bin/hickory", line 8, in <module>
        sys.exit(main())
      File "/home/jake/anaconda3/lib/python3.8/site-packages/hickory/cli.py", line 86, in main
        return status()
      File "/home/jake/anaconda3/lib/python3.8/site-packages/hickory/cli.py", line 71, in status
        return status_systemd()
      File "/home/jake/anaconda3/lib/python3.8/site-packages/hickory/systemd.py", line 126, in status_systemd
        info_dicts = [_service_info(s) for s in services]
      File "/home/jake/anaconda3/lib/python3.8/site-packages/hickory/systemd.py", line 126, in <listcomp>
        info_dicts = [_service_info(s) for s in services]
      File "/home/jake/anaconda3/lib/python3.8/site-packages/hickory/systemd.py", line 118, in _service_info
        state = _find_state(short)
      File "/home/jake/anaconda3/lib/python3.8/site-packages/hickory/systemd.py", line 105, in _find_state
        state = re.findall("Active: (.*?)\n", status)[0]
    IndexError: list index out of range
    
    opened by hainingpan 0
  • Cannot run Hickory on specific ubuntu variants.

    Cannot run Hickory on specific ubuntu variants.

    I am trying to run hickory on PopOS (which I think is a variant of ubuntu) and it seems to complain about the folder structure.

    hickory schedule scripts/grab_issues.py --every 2hours
    Traceback (most recent call last):
      File "/home/vincent/Development/gh-dashb/venv/bin/hickory", line 8, in <module>
        sys.exit(main())
      File "/home/vincent/Development/gh-dashb/venv/lib/python3.7/site-packages/hickory/cli.py", line 83, in main
        schedule(args.script, args.every)
      File "/home/vincent/Development/gh-dashb/venv/lib/python3.7/site-packages/hickory/cli.py", line 35, in schedule
        schedule_systemd(label, working_directory, which_python, script, every)
      File "/home/vincent/Development/gh-dashb/venv/lib/python3.7/site-packages/hickory/systemd.py", line 74, in schedule_systemd
        dump_string(service, f"{SYSTEMD_PATH}/{label}.service")
      File "/home/vincent/Development/gh-dashb/venv/lib/python3.7/site-packages/hickory/systemd.py", line 66, in dump_string
        with open(path, "w") as f:
    FileNotFoundError: [Errno 2] No such file or directory: '/home/vincent/.config/systemd/user/hickory.3825d9.scripts/grab_issues.py.service'
    

    I can confirm that the /home/vincent/.config/systemd/user path exists, so maybe this is a file that didn't get created?

    Environment:

    > pip freeze | grep hickory
    hickory==1.0.0
    
    > cat /etc/os-release
    NAME="Pop!_OS"
    VERSION="20.04 LTS"
    ID=pop
    ID_LIKE="ubuntu debian"
    PRETTY_NAME="Pop!_OS 20.04 LTS"
    VERSION_ID="20.04"
    HOME_URL="https://pop.system76.com"
    SUPPORT_URL="https://support.system76.com"
    BUG_REPORT_URL="https://github.com/pop-os/pop/issues"
    PRIVACY_POLICY_URL="https://system76.com/privacy"
    VERSION_CODENAME=focal
    UBUNTU_CODENAME=focal
    LOGO=distributor-logo-pop-os
    
    opened by koaning 1
  • Added logging system and .env file setup

    Added logging system and .env file setup

    Hey @maxhumber Please validate my work, I have added .env file for replacing ur constants and then added logging system. Check them and let me know !!

    opened by rexdivakar 1
  • Feature Request: allow for command line input

    Feature Request: allow for command line input

    At the moment the command line only allows you to pass a python file. The merit to this is that things remain simple. But one might wonder, could we also run anything that the command line could run?

    That way hickory could also be used to run;

    • scripts from non-python languages
    • jupyter notebooks
    • docker containers

    The API might still allow it via something like;

    hickory schedule "docker run ..." --every=1hour
    hickory schedule "jupyter nbconvert notebook.ipynb" --every=1hour
    

    If this is out of scope of the library I understand. There's merit to keeping a tool small.

    opened by koaning 3
Releases(v1.0.0)
Owner
Max Humber
Human
Max Humber
Darkdump - Search The Deep Web Straight From Your Terminal

Darkdump - Search The Deep Web Straight From Your Terminal About Darkdump Darkdump is a simple script written in Python3.9 in which it allows users to

Josh Schiavone 264 Dec 30, 2022
term2048 is a terminal-based version of 2048.

term2048 is a terminal-based version of 2048.

Baptiste Fontaine 798 Nov 21, 2022
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie

HTTPie: human-friendly CLI HTTP client for the API era HTTPie (pronounced aitch-tee-tee-pie) is a command-line HTTP client. Its goal is to make CLI in

HTTPie 25.4k Dec 30, 2022
uploadgram uses your Telegram account to upload files up to 2GiB, from the Terminal.

uploadgram uploadgram uses your Telegram account to upload files up to 2GiB, from the Terminal. Heavily inspired by the telegram-upload Installing: pi

Shrimadhav U K 97 Jan 06, 2023
pyNPS - A cli Linux and Windows Nopaystation client made with python 3 and wget

Currently, all the work is being done inside the refactoring branch. pyNPS - A cli Linux and Windows Nopaystation client made with python 3 and wget P

Everton Correia 45 Dec 11, 2022
🌌 A Python script to generate blog banners from command line.

Auto Blog Banner Generator A Python script to generate blog banners. This script is used at RavSam. The following image is an example of the blog bann

RavSam 10 Sep 20, 2022
Official AIdea command line tool

AIdea CLI Official AIdea command line tool for https://aidea-web.tw. Installation Make sure you have installed both Python 3 and pip package manager.

AIdea 5 Dec 15, 2021
A dilligent command line tool to publish ads on ebay-kleinanzeigen.de

kleinanzeigen-bot Feedback and high-quality pull requests are highly welcome! About Installation Usage Development Notes License About kleinanzeigen-b

83 Dec 26, 2022
Command line tool to automate transforming the effects of one color profile to another, possibly more standard one.

Finished rendering the frames of that animation, and now the colors look washed out and ugly? This terminal program will solve exactly that.

Eric Xue 1 Jan 26, 2022
An anime command-line system information tool written in python.

Animefetch - v0.0.3 An anime command-line system information tool written in python. Description Animefetch is an anime command-line system informatio

Thadeuks 6 Jun 17, 2022
CLI to show end-of-life dates for tools and technologies.

Python 3.9+ interface to endoflife.date to show end-of-life dates for tools and technologies.

Hugo van Kemenade 32 Jan 06, 2023
gget is a free and open-source command-line tool and Python package that enables efficient querying of genomic databases.

gget is a free and open-source command-line tool and Python package that enables efficient querying of genomic databases. gget consists of a collection of separate but interoperable modules, each des

Pachter Lab 570 Dec 29, 2022
Skiller - With this payload you can control the target computer with (cmd)

Skiller - With this payload you can control the target computer with (cmd)

1 Jan 02, 2022
A simple Python CLI tool that draws routes/paths on a given map.

Map Router A simple Python CLI tool that draws routes/paths on a given map. Index Installation Usage Docs Why? License Support Installation Coming soo

Pedro Morim 1 Nov 07, 2021
Just a shell writed on Python

HIGHSHELL (also hSH or HS) Just a shell writed on Python Send bug report • How to use the shell • Broked features • Licenses How to use the shell Inst

0LungSkill0 2 Jan 04, 2022
A minimal and ridiculously good looking command-line-interface toolkit.

Pyceo Pyceo is a Python package for creating beautiful, composable, and ridiculously good looking command-line-user-interfaces without having to write

Juan-Pablo Scaletti 21 Mar 25, 2022
A collection of command-line interface games written in python

Command Line Interface Python Games Collection of some starter python game projects for beginners How to play these games Clone this repository git cl

Paras Gupta 7 Jun 06, 2022
Gitfetch is a simple tool to get github user details

Gitfetch Just a (cli?) tool to get github user details 🙂 Installation 📂 Install Gitfetch via pypi pip install gitfetch or pip install git+https://g

I'm Not A Bot #Left_TG 7 Jan 23, 2022
Generate folder trees directly from the terminal.

Dir Tree Artist 🎨 🌲 Intro Easily view folder structure, with parameters to sieve out what you want. Choose to exclude files from being viewed (.git,

Glenda T 0 May 17, 2022
A super simple terminal command shortener 🐟

pcmd A super simple terminal command shortener 🐟 Source code : https://github.com/j0fiN/pcmd Documentation : https://j0fin.github.io/pcmd About Durin

9 Mar 02, 2022