🕰 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
👻 Ghoul is an easy to use information service, allowing you to get/add information on someone or something directly from your terminal.

👻 Ghoul is an easy to use information service, allowing you to get/add information on someone or something directly from your terminal. It c

Billy 11 Nov 10, 2021
Ideas on how to quickly learn to build command-line tools

CLI-Bootcamp Ideas on how to quickly learn to build command-line tools Part 1-Bash Week1: Using Linux Lesson 1: Using Linux Shell Lab Lesson 2: How sh

Noah Gift 10 Apr 18, 2022
Package installer for python

This is a package that adds a JSON file to your project that records all of the packages used in it and allows people to install it with a single command.

Anmol Malik 1 May 23, 2022
DShell, a tool that combines with discord.py and Jishaku to present to you, shell channels.

Discord shell or dshell for short is a Python package that combines with discord.py and Jishaku to transform an ordinary Discord channel into one capable of running bash commands using a Discord bot.

11 Nov 15, 2022
GDBIGtools: A command line tools for GDBIG varaints browser

GDBIGtools: A command line tools for GDBIG varaints browser Introduction Born in Guangzhou Cohort Study Genome Research Database is based on thousands

广州市出生队列基因组学研究(The genomics study of BIGCS) 7 Sep 14, 2022
Code for "Salient Deconvolutional Networks, Aravindh Mahendran, Andrea Vedaldi, ECCV 2016"

deconvnet_analysis Code for "Salient Deconvolutional Networks, Aravindh Mahendran, Andrea Vedaldi, ECCV 2016" Parts of this code Generate figures in t

Aravindh Mahendran 12 Jan 25, 2021
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
A Command Line Error Parser Built using Python.

"Stalk Overflow with debuggy" Error Parser Everything is done in Python so it's extremely easy to install and use. Supports Python 3. Debuggy is used

Derhnyel 22 Nov 10, 2022
⌨ Toward a more useful keyboard

Toward a more useful keyboard Steve Losh's Modern Space Cadet is an inspiration. It opened my eyes to the fact that there's a more useful keyboard hid

Jason Rudolph 1.7k Jan 01, 2023
A Hikari command handler for people who love ducks.

duckari A Hikari command handler made with love by ducks. Currently Duckari is work in progress. Documentation is WIP. The wiki is no longer used as d

2 Oct 09, 2022
Simple subcommand CLIs with argparse

multicommand Simple subcommand CLIs with argparse. multicommand uses only the standard library and is ~150 lines of code (modulo comments and whitespa

Andrew Ross 10 Aug 01, 2022
A command line tool made in Python for the popular rhythm game

osr!name A command line tool made in Python for the popular rhythm game "osu!" that changes the player name of a .osr file (replay file). Example: Not

2 Dec 28, 2021
A simple python implementation of a reverse shell

llehs A python implementation of a reverse shell. Note for contributors The project is open for contributions and is hacktoberfest registered! llehs u

Archisman Ghosh 2 Jul 05, 2022
A Telegram Bot Written In Python To Upload Medias To telegra.ph

Telegraph-Uploader A Telegram Bot Written In Python To Upload Medias To telegra.ph DEPLOY YOU CAN SIMPLY DEPLOY ON HEROKU BY CLICKING THE BUTTON BELOW

Rithunand 31 Dec 03, 2022
A simple automation script that logs into your kra account and files your taxes with one command

EASY_TAX A simple automation script that logs into your kra account and files your taxes with one command Currently works for Chrome users. Will creat

leon koech 13 Sep 23, 2021
Todo - You could use terminal to set your todo

Python Tutorial You can learn how to build a terminal application(CLI applicatio

29 Jun 29, 2022
A simple command-line tracert implementation in Python 3 using ICMP packets

Traceroute A simple command-line tracert implementation in Python 3 using ICMP packets Details Traceroute is a networking tool designed for tracing th

James 3 Jul 16, 2022
Commandline Python app to Autodownload mediafire folders and files.

Commandline Python app to Autodownload mediafire folders and files.

Tharuk Renuja 3 May 12, 2022
Shazam is a Command Line Application that checks the integrity of the file by comparing it with a given hash.

SHAZAM - Check the file's integrity Shazam is a Command Line Application that checks the integrity of the file by comparing it with a given hash. Crea

Anaxímeno Brito 1 Aug 21, 2022
LSD (Linux Spotify Downloader) is a command line tool for downloading or rather recording content on Spotify.

LSD (Linux Spotify Downloader) is a command line tool for downloading or rather recording content on Spotify.

Jannis Zahn 7 Jun 21, 2022