🕰 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
Professor Wordlist is a free open source command line tool written in python

Professor Wordlist is a free open source command line tool written in python, With the aim of generating custom wordlists with a variety of unique parameters and functions providing many possibilitie

オークO A K Z E H オーク 1 Oct 28, 2021
CLI tool to develop StarkNet projects written in Cairo

⛵ Nile Navigate your StarkNet projects written in Cairo. Installation pip install cairo-nile Usage Install Cairo Use nile to install a given version o

Martín Triay 305 Dec 30, 2022
Analyzing the most strategic words to guess on Wordle, based on letter frequency distributions

wordle-analysis Evaluating different heuristics to determine the most effective solving strategy and building an AI-powered assistant tool to help you

Sejal Dua 9 Feb 27, 2022
AWS Interactive CLI - Allows you to execute a complex AWS commands by chaining one or more other AWS CLI dependency

AWS Interactive CLI - Allows you to execute a complex AWS commands by chaining one or more other AWS CLI dependency

Rafael Torres 2 Dec 10, 2021
[WIP]An ani-cli like cli tool for movies and webseries

mov-cli A cli to browse and watch movies. Installation This project is a work in progress. However, you can try it out python git clone https://github

166 Dec 30, 2022
Terminal epub reader with inline images

nuber Inspired by epy, nuber is an Epub terminal reader with inline images written with Rust and Python using Überzug. Features Display images in term

Moshe Sherman 73 Oct 12, 2022
Simple CLI tool to track your cryptocurrency portfolio in real time.

Simple tool to track your crypto portfolio in realtime. It can be used to track any coin on the BNB network, even obscure coins that are not listed or trackable by major portfolio tracking applicatio

Trevor White 69 Oct 24, 2022
Code for the Open Data Day 2022 publicbodies.org Nepal data scraping activities.

Open Data Day Publicbodies.org Nepal We've gathered on Saturday, 5th March 2022 with Open Knowledge Nepal in order to try and automate the collection

Augusto Herrmann 2 Mar 12, 2022
Output Analyzer for you terminal commands

Output analyzer (OZER) You can specify a few words inside config.yaml file and specify the color you want to be used. installing: Install command usin

Ehsan Shirzadi 1 Oct 21, 2021
Themes for the kitty terminal emulator

Themes for the kitty terminal This is a collection of themes for the kitty terminal emulator. The themes were initially imported from dexpota/kitty-th

Kovid Goyal 190 Jan 05, 2023
Find your broken links, so users don't.

PyAnchor Dead links are an annoyance for websites with an extensive amount of content. A side from the negative impact on SEO, dead links are an annoy

Ricky White 61 Dec 14, 2022
Command line tool to keep track of your favorite playlists on YouTube and many other places.

Command line tool to keep track of your favorite playlists on YouTube and many other places.

Wolfgang Popp 144 Jan 05, 2023
Run an FFmpeg command and see the percentage progress and ETA.

Run an FFmpeg command and see the percentage progress and ETA.

25 Dec 22, 2022
CLI/GUI Math commands based on python 3

PyMath Commands Syntax Installation Commands: pymath add: usage: pymath add 12.5 12.5 sub: usage: pymath sub 25 12.5 div: usage: pymath div 144 12 mul

eggsnham07 0 Nov 22, 2021
A clone of the popular online game Wordle

wordle_clone A CLI application for wordle. Description A clone of the popular online game Wordle.

0 Jan 29, 2022
Borderless-Window-Utility - Modifies window style to force most applications into a borderless windowed mode

Borderless-Window-Utility Modifies window style to force most applications into

8 Oct 22, 2022
🖥️ A cross-platform modern shell.

Ergonomica WARNING: master on this repository is not the same as a stable release! Currently, this software is purely experimental, as I am cleaning i

813 Dec 27, 2022
📦 A command line utility to put text in a box.

boxie A command line utility to put text in a box. Installation pip install boxie If you are on Linux you may need to use sudo to access this globally

Eliaz Bobadilla 10 Jun 30, 2022
Project scoped command execution to just do your work

Judoka is a command line utility that lets you define project scoped commands and call them through their alias. It lets you just do (= judo) your work.

Eelke van den Bos 2 Dec 17, 2021
My dotfiles -My configuration, with installations steps.

.dotfiles My configuration, with installations steps. Installation Oh My ZSH Install with this command: sh -c "$(curl -fsSL https://raw.githubusercont

Luca Angioloni 4 Dec 14, 2022