Skip to content

Commit

Permalink
camply 0.1.4 (#17)
Browse files Browse the repository at this point in the history
* update pypi secrets

* YML Integration

* YML update

* TOC Entry

* pushbullet

* CHANGELOG.md + README.docker.md

* YAML example update

* Docker README Update

* clickable logo

* autoformat
  • Loading branch information
juftin authored Jun 2, 2021
1 parent aec4c6b commit 0071fea
Show file tree
Hide file tree
Showing 20 changed files with 934 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/camply-publishing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ jobs:
poetry update
cd ${GITHUB_WORKSPACE} && poetry install
cd ${GITHUB_WORKSPACE} && poetry build
cd ${GITHUB_WORKSPACE} && poetry publish --username ${PYPI_USERNAME} --password ${PYPI_PASSWORD}
cd ${GITHUB_WORKSPACE} && poetry publish --username ${{ secrets.PYPI_USERNAME }} --password ${{ secrets.PYPI_PASSWORD }}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ versioning.

## [Unreleased]

## [0.1.4] - 2021-06-01

### Added

- Pushbullet Notifications
- YAML Search Configuration Files

### Fixed

- PyPi Publishing CI on Release

## [0.1.3] - 2021-05-25

### Added
Expand Down Expand Up @@ -49,6 +60,8 @@ versioning.

[unreleased]: https://github.com/juftin/camply/compare/main...integration

[0.1.4]: https://github.com/juftin/camply/compare/v0.1.3...v0.1.4

[0.1.3]: https://github.com/juftin/camply/compare/v0.1.2...v0.1.3

[0.1.2]: https://github.com/juftin/camply/compare/v0.1.1...v0.1.2
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.8-slim

MAINTAINER Justin Flannery <[email protected]>
LABEL version="0.1.3"
LABEL version="0.1.4"
LABEL description="camply, the campsite finder"

COPY . /tmp/camply
Expand Down
87 changes: 69 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<div align="center">
<a href="https://github.com/juftin/camply">
<img src="https://raw.githubusercontent.com/juftin/camply/main/docs/static/camply.svg"
width="400" height="400" alt="camply">
</a>
</div>

`camply`, the campsite finder ⛺️, is a tool to help you book a campground online. Finding
Expand Down Expand Up @@ -37,6 +39,7 @@ ___________
+ [Look for Weekend Campsite Availabilities](#look-for-weekend-campsite-availabilities)
+ [Look for a Campsite Inside of Yellowstone](#look-for-a-campsite-inside-of-yellowstone)
+ [Look for a Campsite Across Multiple Recreation areas](#look-for-a-campsite-across-multiple-recreation-areas)
+ [Using a YML Configuration file to search for campsites](#using-a-yml-configuration-file-to-search-for-campsites)
+ [Search for Recreation Areas by Query String](#search-for-recreation-areas-by-query-string)
+ [Look for Specific Campgrounds Within a Recreation Area](#look-for-specific-campgrounds-within-a-recreation-area)
+ [Look for Specific Campgrounds by Query String](#look-for-specific-campgrounds-by-query-string)
Expand Down Expand Up @@ -115,7 +118,8 @@ Search for a campsite within camply. Campsites are returned based on the search
Campsites contain properties like booking date, site type (tent, RV, cabin, etc), capacity, price,
and a link to make the booking. Required parameters include `--start-date`, `--end-date`,
`--rec-area` / `--campground`. Constant searching functionality can be enabled with
`--continuous` and notifications via Email and Pushover can be enabled using `--notifications`.
`--continuous` and notifications via Email, Pushover, and Pushbullet can be enabled using
`--notifications`.

#### Arguments:

Expand All @@ -140,16 +144,20 @@ and a link to make the booking. Required parameters include `--start-date`, `--e
10, cannot be less than 5. [**_example_](#look-for-weekend-campsite-availabilities)
* `--notifications`: `NOTIFICATIONS`
+ If `--continuous` is activated, types of notifications to receive. Options available are
`email`, `pushover`, or `silent`. Defaults to `silent` - which just logs messages to
console. [**_example_](#continuously-searching-for-a-campsite)
`email`, `pushover`, `pushbullet`, or `silent`. Defaults to `silent` - which just logs
messages to console. [**_example_](#continuously-searching-for-a-campsite)
* `--notify-first-try`
+ If `--continuous` is activated, whether to send all non-silent notifications if more than 5
matching campsites are found on the first try. Defaults to false which only sends the
first 5. [**_example_](#continuously-searching-for-a-campsite)
matching campsites are found on the first try. Defaults to false which only sends the first
5. [**_example_](#continuously-searching-for-a-campsite)
* `--search-forever`
+ If `--continuous` is activated, this method continues to search after the first availability
has been found. The one caveat is that it will never notify about the same identical campsite
for the same booking date. [**_example_](#continue-looking-after-the-first-match-is-found)
* `--yml-config`
+ Rather than provide arguments to the command line utility, instead pass a file path to a YAML
configuration file. See the documentation for more information on how to structure your
configuration file. [**_example_](#using-a-yml-configuration-file-to-search-for-campsites)

```text
camply campsites \
Expand Down Expand Up @@ -204,11 +212,12 @@ camply campgrounds --search "Fire Tower Lookout" --state CA
Set up `camply` configuration file with an interactive console

In order to send notifications through `camply` you must set up some authorization values. Whether
you need to set up pushover notifications (push notifications on your phone, your pushover account
can be set up at https://pushover.net) or Email messages, everything can be done through the
`configure` command. The end result is a file called [`.camply`](example.camply) in your home
folder. See the [Running in Docker](#running-in-docker) section to see how you can use environment
variables instead of a config file.
you need to set up [Pushover notifications](https://pushover.net)
, [PushBullet](https://www.pushbullet.com/#settings/account) or Email messages, everything can be
done through the `configure` command. The end result is a file called
[`.camply`](docs/examples/example.camply) in your home folder. See
the [Running in Docker](#running-in-docker) section to see how you can use environment variables
instead of a config file.

```text
camply configure
Expand Down Expand Up @@ -253,7 +262,8 @@ camply campsites \

Sometimes you want to look for campgrounds until an eventual match is found. The below snippet will
search for matching campsites until it finds a match. It also sends a notification via `pushover`
once matches are found. Alternate notification methods are `email` and `silent` (default).
once matches are found. Alternate notification methods are `email`, `pushbullet`, and `silent` (
default).

__Important Note__: When `camply` is told to run `--continuous` with non-silent notifications set up
and it finds more than 5 matching campsites on the first try, it will only send notifications for
Expand Down Expand Up @@ -335,6 +345,31 @@ camply campsites \
--end-date 2021-07-16
```

#### Using a YML Configuration file to search for campsites

Sometimes, using a YAML configuration file is easier to manage all of your search options. See the
below [YML example file](docs/examples/example_search.yml) and corresponding camply command:

```yaml
provider: RecreationDotGov # RecreationDotGov IF NOT PROVIDED
recreation_area: # (LIST OR SINGLE ENTRY)
- 2991 # Yosemite National Park, CA (All Campgrounds)
- 1074 # Sierra National Forest, CA (All Campgrounds)
campgrounds: null # ENTIRE FIELD CAN BE OMITTED IF NOT USED. # (LIST OR SINGLE ENTRY)
start_date: 2021-09-12 # YYYY-MM-DD
end_date: 2021-09-12 # YYYY-MM-DD
weekends: False # FALSE BY DEFAULT
continuous: True # DEFAULTS TO TRUE
polling_interval: 5 # DEFAULTS TO 10 , CAN'T BE LESS THAN 5
notifications: email # (silent, email, pushover, pushbullet), DEFAULTS TO `silent`
search_forever: True # FALSE BY DEFAULT
notify_first_try: False # FALSE BY DEFAULT
```
```text
camply campsites --yml-config example_search.yml
```

#### Search for Recreation Areas by Query String

Just need to find what your local Recreation Area ID number is? This simple command allows you to
Expand Down Expand Up @@ -457,12 +492,12 @@ camping_finder.get_matching_campsites(log=True, verbose=True,

## Running in Docker

Here's an example of a detached container searching in the background (notice the `--rm` flag, the
container will disappear after `camply` exits).
Here's an example of a detached container searching in the background (notice the `-d` flag, the
container will run detached).

```text
docker run -d --rm \
--name camply \
docker run -d \
--name camply-detached-example \
--env PUSHOVER_PUSH_TOKEN=${PUSHOVER_PUSH_TOKEN} \
--env PUSHOVER_PUSH_USER=${PUSHOVER_PUSH_USER} \
--env TZ="America/Denver" \
Expand Down Expand Up @@ -496,11 +531,11 @@ The docker image accepts the following environment variables:
logging, defaults to UTC)

Alternatively, if you have already run `camply configure` locally, you can share
your [`.camply`](example.camply) file inside the docker container.
your [`.camply`](docs/examples/example.camply) file inside the docker container.

```text
docker run -d --rm \
--name camply \
docker run \
--name camply-file-share-example \
--env TZ="America/Denver" \
--volume ${HOME}/.camply:/home/camply/.camply \
juftin/camply \
Expand All @@ -512,6 +547,22 @@ docker run -d --rm \
--notifications email
```

To manage multiple searches (with different notification preferences) I like to use YML
configuration files:

```text
docker run -d \
--name camply-email-example \
--env TZ="America/Denver" \
--env EMAIL_TO_ADDRESS=${EMAIL_TO_ADDRESS} \
--env EMAIL_USERNAME=${EMAIL_USERNAME} \
--env EMAIL_PASSWORD=${EMAIL_PASSWORD} \
--volume example_search.yml:/home/camply/example_search.yml \
juftin/camply:latest \
camply campsites \
--yml-config /home/camply/example_search.yml
```

## Dependencies

`camply` is compatible with any Python version >= `3.6`. Currently, there are four required
Expand Down
2 changes: 1 addition & 1 deletion camply/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
camply __init__ file
"""

__version__ = "0.1.3"
__version__ = "0.1.4"
2 changes: 1 addition & 1 deletion camply/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
from .cli_config import CommandLineConfig
from .data_columns import DataColumns
from .file_config import FileConfig
from .notification_config import EmailConfig, PushoverConfig
from .notification_config import EmailConfig, PushbulletConfig, PushoverConfig
from .search_config import SearchConfig
from .yellowstone_config import YellowstoneConfig
2 changes: 1 addition & 1 deletion camply/config/api_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from camply.config.file_config import FileConfig

load_dotenv(FileConfig.DOT_CAMPLY_FILE, override=True)
load_dotenv(FileConfig.DOT_CAMPLY_FILE, override=False)

USER_AGENTS: List[dict] = [
{"User-Agent": ("Mozilla/5.0 (X11; Linux x86_64; rv:10.0) "
Expand Down
16 changes: 11 additions & 5 deletions camply/config/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from camply.config.file_config import FileConfig
from camply.config.search_config import SearchConfig

load_dotenv(FileConfig.DOT_CAMPLY_FILE, override=True)
load_dotenv(FileConfig.DOT_CAMPLY_FILE, override=False)


class CommandLineActions:
Expand Down Expand Up @@ -84,8 +84,8 @@ class CommandLineArguments:
NOTIFICATIONS_DEFAULT: str = "silent"
NOTIFICATIONS_HELP: str = ("If --continuous is activated, types of notifications to receive. "
"Options available are 'email', "
"'pushover', or 'silent'. Defaults to 'silent' - which just logs "
"messages to console.")
"'pushover', 'pushbullet', or 'silent'. Defaults to 'silent' - "
"which just logs messages to console.")

NOTIFY_FIRST_TRY_ARGUMENT: str = "--notify-first-try"
NOTIFY_FIRST_TRY_DESTINATION: str = "notify_first_try"
Expand All @@ -101,6 +101,12 @@ class CommandLineArguments:
"that it will never notify about the same identical campsite for "
"the same booking date.")

YAML_SEARCH_ARGUMENT: str = "--yml-config"
YAML_SEARCH_DESTINATION: str = "yml_config"
YAML_SEARCH_HELP: str = ("Rather than provide arguments to the command line utility, instead "
"pass a file path to a YAML configuration file. See the documentation "
"for more information on how to structure your configuration file.")


class CommandLineValidation:
"""
Expand Down Expand Up @@ -168,8 +174,8 @@ class CommandLineConfig(CommandLineActions, CommandLineArguments, CommandLineVal
"Required parameters include `--start-date`, "
"`--end-date`, `--rec-area` / `--campground`. "
"Constant searching functionality can be enabled with "
" `--continuous` and notifications via Email and "
"Pushover can be enabled using `--notifications`.")
" `--continuous` and notifications "
"can be enabled using `--notifications`.")

COMMAND_CONFIGURE: str = "configure"
COMMAND_CONFIGURE_HELP: str = "Set up camply configuration file with an interactive console"
Expand Down
1 change: 1 addition & 0 deletions camply/config/file_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class FileConfig:
DOT_CAMPLY_FIELDS: List[str] = OrderedDict(
PUSHOVER_PUSH_TOKEN=dict(default="", notes="Enables Pushover Notifications"),
PUSHOVER_PUSH_USER=dict(default="", notes="Enables Pushover Notifications"),
PUSHBULLET_API_TOKEN=dict(default="", notes="Enables Pushbullet Notifications"),
EMAIL_TO_ADDRESS=dict(default="", notes="Email Notifications will be sent here"),
EMAIL_USERNAME=dict(default="", notes="Email Authorization Login Username"),
EMAIL_PASSWORD=dict(default="", notes="Email Authorization Login Password"),
Expand Down
16 changes: 15 additions & 1 deletion camply/config/notification_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from camply.config.file_config import FileConfig

logger = logging.getLogger(__name__)
load_dotenv(FileConfig.DOT_CAMPLY_FILE, override=True)
load_dotenv(FileConfig.DOT_CAMPLY_FILE, override=False)


class PushoverConfig:
Expand Down Expand Up @@ -58,3 +58,17 @@ class EmailConfig:
f"EMAIL_FROM_ADDRESS (default: {DEFAULT_FROM_ADDRESS})",
f'EMAIL_SUBJECT_LINE (default: "{DEFAULT_SUBJECT_LINE}")',
f"EMAIL_SMTP_PORT (default: {DEFAULT_SMTP_PORT})"]


class PushbulletConfig:
"""
Pushbullet Notification Config Class
"""

PUSHBULLET_API_ENDPOINT: str = "https://api.pushbullet.com/v2/pushes"
API_HEADERS: dict = {"Content-Type": "application/json"}

try:
API_TOKEN: str = environ["PUSHBULLET_API_TOKEN"]
except KeyError:
API_TOKEN = None
4 changes: 3 additions & 1 deletion camply/notifications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"""

from .email_notifications import EmailNotifications
from .pushbullet import PushbulletNotifications
from .pushover import PushoverNotifications
from .silent_notifications import SilentNotifications

CAMPSITE_NOTIFICATIONS: dict = {
"pushover": PushoverNotifications,
"email": EmailNotifications,
"silent": SilentNotifications
"silent": SilentNotifications,
"pushbullet": PushbulletNotifications
}
Loading

0 comments on commit 0071fea

Please sign in to comment.