🕰 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
CLI/library to control FNIRSI DC Power Supply (DC-6006L, etc)

dc6006l - CLI/library to control FNIRSI DC Power Supply (DC-6006L, etc) What is this? FNIRSI DC6006L is a programmable DC power supply that is quite c

Taisuke Yamada 7 Sep 25, 2022
pypyr task-runner cli & api for automation pipelines.

pypyr task-runner cli & api for automation pipelines. Automate anything by combining commands, different scripts in different languages & applications into one pipeline process.

pypyr 471 Dec 15, 2022
Wappalyzer CLI tool to find Web Technologies

Wappalyzer CLI tool to find Web Technologies

GOKUL A.P 17 Dec 15, 2022
🦎 A NeoVim plugin for highlighting visual selections like in a normal document editor!

🦎 HighStr.nvim A NeoVim plugin for highlighting visual selections like in a normal document editor! Demo TL;DR HighStr.nvim is a NeoVim plugin writte

Pocco81 222 Jan 03, 2023
cmdpxl: a totally practical command-line image editor

cmdpxl: a totally practical command-line image editor

Jieruei Chang 476 Jan 07, 2023
CLI based diff viewer

Rich Diff CLI based diff viewer

Suresh Kumar 24 Nov 15, 2022
This is a Command Line program to interact with your NFTs, Cryptocurrencies etc

This is a Command Line program to interact with your NFTs, Cryptocurrencies etc. via the ThirdWeb Platform. This is just a fun little project that I made to be able to connect to blockchains and Web3

Arpan Pandey 5 Oct 02, 2022
term2048 is a terminal-based version of 2048.

term2048 is a terminal-based version of 2048.

Baptiste Fontaine 798 Nov 21, 2022
MiShell is a multi-platform, multi-architecture project based on the first version (MiShell32)

MiShell is a multi-platform, multi-architecture project based on the first version (MiShell32), which offers super super small reverse shell payloads great for injection in buffer overflow vulnerabil

Kamyar Hatamnezhad 0 Oct 27, 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
CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM

AWS SAM The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications. It provides shorthand syntax to e

Amazon Web Services 6.2k Jan 08, 2023
triggercmd is a CLI client for the TRIGGERcmd cloud service.

TriggerCMD CLI client triggercmd is a CLI client for the TRIGGERcmd cloud service. installation the triggercmd package is available in PyPI. to instal

Gustavo Soares 7 Oct 18, 2022
🕰 The command line tool for scheduling Python scripts

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

Max Humber 146 Dec 07, 2022
A handy command-line utility for generating and sending iCalendar events

A handy command-line utility for generating and sending iCalendar events This simple command-line utility is designed to generate an iCalendar event,

Baochun Li 17 Nov 21, 2022
spid-sp-test is a SAML2 SPID/CIE Service Provider validation tool that can be executed from the command line.

spid-sp-test spid-sp-test is a SAML2 SPID/CIE Service Provider validation tool that can be executed from the command line. This tool was born by separ

Developers Italia 30 Nov 08, 2022
This is my fetch, with ascii arts from neofetch and internet

deadfetch This is my fetch, with ascii arts from neofetch and internet Installation First what you need its python Fedora sudo dnf install python3 sud

DedSec 8 Jan 20, 2022
CLI translator based on Google translate API

Translate-CLI CLI переводчик основанный на Google translate API как пользоваться ? запустить в консоли скомпилированный скрипт (exe - windows, bin - l

7 Aug 13, 2022
A CLI tool for searching and watching videos on youtube with no spyware and MPV and yt-dlp

A CLI tool for searching and watching videos on youtube with no spyware and MPV and yt-dlp

TruncatedDinosour 3 Feb 22, 2022
Kattis shell for getting examples, testing and submitting.

Kattis shell for getting examples, testing and submitting.

Simon Green Kristensen 15 Sep 30, 2022
Get latest astronomy job and rumor news in your command line

astrojobs Tired of checking the AAS job register and astro rumor mill for job news? Get the latest updates in the command line! astrojobs automaticall

Philip Mocz 19 Jul 20, 2022