Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change ./checkin.py into an entrypoint #71

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*.pyc
Dockerfile
README.md
htmlcov/
*.xml
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
.cache/
.coverage
htmlcov/
coverage.xml
coverage.xml
.DS_Store
*.egg-info/
dist/
*venv
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ language: python
env:
global:
- CC_TEST_REPORTER_ID=3d0abe23b60c405d5de7e038f366649a8002c4ccedccabad3da0e3b3e9b5049b
install:
pip install .[dev]
python:
- "2.7.15"
- "3.7.1"
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
FROM python:3.7
WORKDIR /usr/src/app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
RUN pip install .[dev] --no-cache-dir

ENTRYPOINT ["./entrypoint.sh"]
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include README.md
include LICENSE
include southwest/VERSION
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
all: init test lint
init:
pip install -r requirements.txt
pip install -e .[dev]

test:
pytest --cov=southwest/ --cov=checkin
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ This script can either be ran directly on your host or within Docker.
#### Install Base Package Requirements

```bash
$ pip install -r requirements.txt
$ pip install .
```

#### Usage

```bash
$ python ./checkin.py CONFIRMATION_NUMBER FIRST_NAME LAST_NAME
$ checkin CONFIRMATION_NUMBER FIRST_NAME LAST_NAME
```

### Docker
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

if [ "$1" != "/bin/sh" ]; then
python -u ./checkin.py "$@"
checkin "$@"
else
exec "$@"
fi
46 changes: 46 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""setup.py

Packaging for direct pypi distribution and cli entrypoints

"""
from setuptools import setup, find_packages
from os import path
from codecs import open

__library_name__ = "southwest"
__here__ = path.dirname(__file__)

with open(path.join(__here__,"README.md"), "r", "utf-8") as f:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing whitespace after ','

__readme__ = f.read()

with open(path.join(__here__, __library_name__ , "VERSION"), "r") as f:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace before ','

__version__ = f.read().strip()


setup(
name="SouthwestCheckin",
description="Python script to checkin to a Southwest Flight",
long_description=__readme__,
long_description_content_type="text/markdown",
url="https://github.com/pyro2927/SouthwestCheckin",
license="GPL-3.0",
packages=find_packages(exclude=["tests"]),
version=__version__,
install_requires=[
"datetime",
"docopts",
"python-dateutil",
"pytz",
"requests",
"uuid",
"vcrpy",
],
extras_require={
"dev": ["pycodestyle", "pytest", "pytest-cov", "pytest-mock", "requests_mock",]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing whitespace after ','

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
entry_points={
"console_scripts": ["checkin={}.checkin:checkin".format(__library_name__)]
},
package_data={"": ["README.md", "LICENSE"], __library_name__: ["VERSION"]},
include_package_data=True,
)
1 change: 1 addition & 0 deletions southwest/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
5 changes: 5 additions & 0 deletions southwest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
import pkgutil

from .southwest import Reservation
from .openflights import timezone_for_airport

__library_name__ = "southwest"
__version__ = pkgutil.get_data(__library_name__, "VERSION").decode("utf-8")
10 changes: 7 additions & 3 deletions checkin.py → southwest/checkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from docopt import docopt
from math import trunc
from pytz import utc
from southwest import Reservation, openflights
from . import Reservation, openflights
from threading import Thread
import sys
import time
Expand Down Expand Up @@ -85,8 +85,8 @@ def auto_checkin(reservation_number, first_name, last_name, verbose=False):
break


if __name__ == '__main__':

def checkin():
"""main function: for entry_point"""
arguments = docopt(__doc__, version='Southwest Checkin 3')
reservation_number = arguments['CONFIRMATION_NUMBER']
first_name = arguments['FIRST_NAME']
Expand All @@ -102,3 +102,7 @@ def auto_checkin(reservation_number, first_name, last_name, verbose=False):
except KeyboardInterrupt:
print("Ctrl+C detected, canceling checkin")
sys.exit()


if __name__ == '__main__':
checkin()
2 changes: 1 addition & 1 deletion tests/checkin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
import requests
import southwest
import checkin
from southwest import checkin
from datetime import datetime, timedelta
from .my_vcr import custom_vcr
from pytz import timezone
Expand Down