Code Monkey home page Code Monkey logo

hackjohn's Introduction

Bot to monitor for southbound permit spaces on the John Muir Trail

This repository contains a Python script for monitoring Yosemite's Donohue Exit Quota and Trailhead Space Available online table. Vacancies in this table indicate the availability of a southbound John Muir Trail permit, available for immediate reservation by calling the Yosemite Wilderness Permit Reservations at 1-209-372-0740. This strategy enables securing a soutbound JMT permit after the lottery drawing for a given date.

Learn more about using hackjohn and its history of success in the blog post titled Introducing the hackjohn bot for southbound John Muir Trail permits and The Mercury News article titled Here’s how to get a coveted reservation to hike the John Muir Trail.

Usage

Modify hackjohn.py with the parameters of your permit search. To receive Telegram notfications, set your token for the MiddleManBot. Then simply run the hackjohn Python script in the hackjohn appropriate environment (described below) with:

python hackjohn.py

The script with print the table of available spaces via stdout. An example of the output is:

Spaces available as of 2019-04-22:

      Date                                        Trailhead  Spaces
2019-09-19  Happy Isles->Sunrise/Merced Lake (pass through)       3
2019-09-22              Happy Isles->Little Yosemite Valley       5
2019-09-23              Happy Isles->Little Yosemite Valley       4
2019-09-28              Happy Isles->Little Yosemite Valley       3
2019-10-02  Happy Isles->Sunrise/Merced Lake (pass through)       4
2019-10-03  Happy Isles->Sunrise/Merced Lake (pass through)       4
2019-10-04  Happy Isles->Sunrise/Merced Lake (pass through)       3
2019-10-05  Happy Isles->Sunrise/Merced Lake (pass through)       3

According to https://www.nps.gov/yose/planyourvisit/fulltrailheads.htm
Yosemite Reservations: 209-372-0740 (Monday–Friday 9:00am–4:30pm)

By default, Hackjohn writes the output to the file hackjohn-output.txt (as specified by output_path). To avoid repeated notification, Hackjohn skips Telegram notification if its output matches the pre-existing output.

Notifications

Hackjohn can send notifications via the Telegram messaging app. Configure enable_middleman and token in hackjohn.py to use this feature.

Environment

The environment can be installed using either Virtual Environments or Conda.

Virtual Environment

To insall a virtual environment, run the following:

# Create a virtual environment in the env directory
python3 -m venv env

# Activate the virtual environment
source env/bin/activate

# Install the required dependencies into the virtual env
pip install --requirement requirements.txt

Conda

The conda environment for this repository is specified in environment.yml. Install this environment with:

conda env create --file environment.yml

Then use conda activate hackjohn and conda deactivate to activate or deactivate the environment.

Automation

You can automate the running of hackjohn.py at scheduled times every day. According to the Yosemite permit office, the trailhead quotas are often updated around 11 AM Pacific Time.

I used cron, which despite its awful interface got the job done. Therefore, I added the following lines to my crontab configuration (replacing ABOSOLUTE_REPO_PATH with the absolute path to the directory containing hackjohn.py):

# hackjohn bot scheduling (configured for a system on Eastern Time)
0 13 * * * ABOSOLUTE_REPO_PATH/hackjohn.py >> ABOSOLUTE_REPO_PATH/hackjohn.log
44 13 * * * ABOSOLUTE_REPO_PATH/hackjohn.py >> ABOSOLUTE_REPO_PATH/hackjohn.log
59 13 * * * ABOSOLUTE_REPO_PATH/hackjohn.py >> ABOSOLUTE_REPO_PATH/hackjohn.log
14 14 * * * ABOSOLUTE_REPO_PATH/hackjohn.py >> ABOSOLUTE_REPO_PATH/hackjohn.log
30 14 * * * ABOSOLUTE_REPO_PATH/hackjohn.py >> ABOSOLUTE_REPO_PATH/hackjohn.log
40 14 * * * ABOSOLUTE_REPO_PATH/hackjohn.py >> ABOSOLUTE_REPO_PATH/hackjohn.log
00 15 * * * ABOSOLUTE_REPO_PATH/hackjohn.py >> ABOSOLUTE_REPO_PATH/hackjohn.log
19 15 * * * ABOSOLUTE_REPO_PATH/hackjohn.py >> ABOSOLUTE_REPO_PATH/hackjohn.log
00 19 * * * ABOSOLUTE_REPO_PATH/hackjohn.py >> ABOSOLUTE_REPO_PATH/hackjohn.log

Run crontab -e to edit your cron configuration. In order to for the cron-scheduled script to run in the proper environment, you must add a shebang pointing to which Python to use. For example, the following but substituting your username:

#!/home/dhimmel/anaconda3/envs/hackjohn/bin/python

hackjohn's People

Contributors

dhimmel avatar 3max9 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.