🕰 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 --every=@10:10
Every Monday at 10:10 AM --every=monday@10:10am
Every 10th day of the month at 10:10 AM --every=10th@10:10am
Every last day of the month at 10:10 AM --every=eom@10:10am
Every 10th and last day of the month at 10 AM and 10 PM --every=10,eom@10,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
PyArmor is a command line tool used to obfuscate python scripts

PyArmor is a command line tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.

Dashingsoft 2k Jan 7, 2023
AML Command Transfer. A lightweight tool to transfer any command line to Azure Machine Learning Services

AML Command Transfer (ACT) ACT is a lightweight tool to transfer any command from the local machine to AML or ITP, both of which are Azure Machine Lea

Microsoft 11 Aug 10, 2022
A cd command that learns - easily navigate directories from the command line

NAME autojump - a faster way to navigate your filesystem DESCRIPTION autojump is a faster way to navigate your filesystem. It works by maintaining a d

William Ting 14.5k Jan 3, 2023
Ros command - Unifying the ROS command line tools

Unifying the ROS command line tools One impairment to ROS 2 adoption is that all

null 37 Dec 15, 2022
Python command line tool and python engine to label table fields and fields in data files.

Python command line tool and python engine to label table fields and fields in data files. It could help to find meaningful data in your tables and data files or to find Personal identifable information (PII).

APICrafter 22 Dec 5, 2022
PwnWiki command line searching tool & bindings written in Python

pwsearch PwnWiki 数据库搜索命令行工具。 安装 您可以直接用 pip 命令从 PyPI 安装 pwsearch: pip3 install -U pwsearch 您也可以 clone 该仓库并直接从源码启动

PwnWiki 20 Jun 21, 2021
A command line tool (and Python library) for archiving Twitter JSON

A command line tool (and Python library) for archiving Twitter JSON

Documenting the Now 1.3k Dec 28, 2022
Unofficial Open Corporates CLI: OpenCorporates is a website that shares data on corporations under the copyleft Open Database License. This is an unofficial open corporates python command line tool.

Unofficial Open Corporates CLI OpenCorporates is a website that shares data on corporations under the copyleft Open Database License. This is an unoff

Richard Mwewa 30 Sep 8, 2022
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 possibilities.

オークO A K Z E H オーク 1 Oct 28, 2021
A simple command line tool written in python to manage a to-do list

A simple command line tool written in python to manage a to-do list Dependencies: python Commands: todolist (-a | --add) [(-p | --priority)] [(-l | --

edwloef 0 Nov 2, 2021
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

null 2 Dec 28, 2021
spotifytools is a Python command line tool

spotifytools spotifytools is a Python command line tool Documentation The documentation is available on the following link Releases Instalation instru

null 0 Sep 28, 2021
A command line tool to query source code from your current Python env

wxc wxc (pronounced "which") allows you to inspect source code in your Python environment from the command line. It is based on the inspect module fro

Clément Robert 13 Nov 8, 2022
MsfMania is a command line tool developed in Python that is designed to bypass antivirus software on Windows and Linux/Mac in the future

MsfMania MsfMania is a command line tool developed in Python that is designed to bypass antivirus software on Windows and Linux/Mac in the future. Sum

null 446 Dec 21, 2022
Bonjour Software pypahe is a Python Package Helper command-line tool.

pypahe Bonjour Software pypahe is a Python Package Helper command-line tool. Requirements Docker runtime Usage print the latest available version of a

Bonjour Software 0 Aug 10, 2021
Python library and command line tool for interacting with Bugzilla

python-bugzilla This package provides two bits: bugzilla python module for talking to a Bugzilla instance over XMLRPC or REST /usr/bin/bugzilla comman

Python Bugzilla Project 112 Nov 5, 2022
A python based command line tool to compare Github Users or Repositories

gitcomp A simple python package with a CLI to compare GitHub users and repositories by associating a git_score to each entry which is a weighted sum o

Anirudh Vaish 5 Mar 26, 2022
💻VIEN is a command-line tool for managing Python Virtual Environments.

vien VIEN is a command-line tool for managing Python Virtual Environments. It provides one-line shortcuts for: creating and deleting environments runn

Artёm IG 5 Mar 19, 2022
A lightweight Python module and command-line tool for generating NATO APP-6(D) compliant military symbols from both ID codes and natural language names

Python military symbols This is a lightweight Python module, including a command-line script, to generate NATO APP-6(D) compliant military symbol icon

Nick Royer 5 Dec 27, 2022