-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from stivenramireza/release/0.0.1
Release 0.0.1
- Loading branch information
Showing
16 changed files
with
451 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
DRIVER_PATH=<DRIVER_PATH> | ||
OUTPUT_PATH=<OUTPUT_PATH> | ||
WEBSITE_URL=<WEBSITE_URL> | ||
IDENTIFICATION=<IDENTIFICATION> | ||
PASSWORD=<PASSWORD> | ||
HEADQUARTER_NAME=<HEADQUARTER_NAME> | ||
DESIRED_TIME=<DESIRED_TIME> | ||
WHATSAPP_URL=<WHATSAPP_URL> | ||
CHAT_NAME=<CHAT_NAME> | ||
PERSON_NAME=<PERSON_NAME> | ||
CHROME_PROFILE_PATH=<CHROME_PROFILE_PATH> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
DRIVER_PATH=<DRIVER_PATH> | ||
OUTPUT_PATH=<OUTPUT_PATH> | ||
WEBSITE_URL=<WEBSITE_URL> | ||
IDENTIFICATION=<IDENTIFICATION> | ||
PASSWORD=<PASSWORD> | ||
HEADQUARTER_NAME=<HEADQUARTER_NAME> | ||
DESIRED_TIME=<DESIRED_TIME> | ||
WHATSAPP_URL=<WHATSAPP_URL> | ||
CHAT_NAME=<CHAT_NAME> | ||
PERSON_NAME=<PERSON_NAME> | ||
CHROME_PROFILE_PATH=<CHROME_PROFILE_PATH> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Upload Python Package | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@main | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: v0.0.1 | ||
release_name: v0.0.1 | ||
body: | | ||
First version | ||
draft: false | ||
prerelease: false | ||
|
||
deploy: | ||
needs: release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine | ||
- name: Build and publish | ||
env: | ||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
run: | | ||
python setup.py sdist bdist_wheel | ||
twine upload dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = '0.0.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from secrets import ( | ||
DRIVER_PATH, | ||
OUTPUT_PATH, | ||
WEBSITE_URL, | ||
IDENTIFICATION, | ||
PASSWORD, | ||
HEADQUARTER_NAME, | ||
DESIRED_TIME, | ||
WHATSAPP_URL, | ||
CHAT_NAME, | ||
PERSON_NAME, | ||
CHROME_PROFILE_PATH | ||
) | ||
|
||
from smartfit_booking.website_bot import ( | ||
initialize, | ||
login_to_website, | ||
answer_questionnaire, | ||
search_headquarter, | ||
book_hour, | ||
get_qr_code, | ||
login_to_whatsapp, | ||
search_chat, | ||
send_message | ||
) | ||
|
||
from smartfit_booking.storage import ( | ||
save_file, | ||
remove_file | ||
) | ||
|
||
from smartfit_booking.data_access_api import get_data | ||
|
||
import os | ||
|
||
def main(): | ||
""" book_an_hour """ | ||
driver = initialize(DRIVER_PATH, OUTPUT_PATH, CHROME_PROFILE_PATH) | ||
login_to_website(driver, WEBSITE_URL, IDENTIFICATION, PASSWORD) | ||
answer_questionnaire(driver) | ||
search_headquarter(driver, HEADQUARTER_NAME) | ||
book_hour(driver, DESIRED_TIME) | ||
qr_code_url = get_qr_code(driver) | ||
|
||
""" download_qr_code """ | ||
response = get_data(qr_code_url) | ||
image_path = os.path.join(OUTPUT_PATH, 'code.jpg') | ||
save_file(image_path, response) | ||
|
||
""" send_whatsapp_message """ | ||
login_to_whatsapp(driver, WHATSAPP_URL) | ||
search_chat(driver, CHAT_NAME) | ||
send_message(driver, image_path, PERSON_NAME, DESIRED_TIME) | ||
remove_file(image_path) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
selenium==3.141.0 | ||
requests==2.25.1 | ||
python-dotenv==0.15.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from dotenv import load_dotenv | ||
|
||
from smartfit_booking.logger import logger | ||
|
||
import os | ||
|
||
ENV = os.environ.get('ENV') | ||
if ENV == 'production': | ||
dotenv_path = '.env' | ||
logger.info('Using production environment variables') | ||
else: | ||
dotenv_path = '.env.dev' | ||
logger.info('Using development environment variables') | ||
|
||
exists = os.path.exists(dotenv_path) | ||
|
||
if not exists: | ||
raise Exception('env files do not exist') | ||
|
||
load_dotenv(dotenv_path) | ||
|
||
DRIVER_PATH = os.environ.get('DRIVER_PATH') | ||
OUTPUT_PATH = os.environ.get('OUTPUT_PATH') | ||
WEBSITE_URL = os.environ.get('WEBSITE_URL') | ||
IDENTIFICATION = os.environ.get('IDENTIFICATION') | ||
PASSWORD = os.environ.get('PASSWORD') | ||
HEADQUARTER_NAME = os.environ.get('HEADQUARTER_NAME') | ||
DESIRED_TIME = os.environ.get('DESIRED_TIME') | ||
WHATSAPP_URL = os.environ.get('WHATSAPP_URL') | ||
CHAT_NAME = os.environ.get('CHAT_NAME') | ||
PERSON_NAME = os.environ.get('PERSON_NAME') | ||
CHROME_PROFILE_PATH = os.environ.get('CHROME_PROFILE_PATH') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from __version__ import __version__ | ||
|
||
import setuptools | ||
|
||
with open('requirements.txt') as f: | ||
required = f.read().splitlines() | ||
|
||
setuptools.setup( | ||
name="smartfit_booking", | ||
version=__version__, | ||
author="Stiven Ramírez Arango", | ||
author_email="[email protected]", | ||
description="Smart Fit gym booking package", | ||
packages=setuptools.find_packages(), | ||
python_requires=">=3.6", | ||
install_requires=required | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from . import data_access_api, formatter, logger, storage, website_bot | ||
|
||
__all__ = [ | ||
'data_access_api', | ||
'formatter', | ||
'logger', | ||
'storage', | ||
'website_bot' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import requests | ||
|
||
from smartfit_booking.logger import logger | ||
|
||
def get_data(url: str) -> object: | ||
try: | ||
response = requests.get(url) | ||
if response.status_code == 200: | ||
logger.info(f'Data has been gotten successfully') | ||
return response | ||
except Exception as error: | ||
logger.error(f'Error to get data from url {url}: {error}') | ||
raise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from datetime import datetime | ||
|
||
import time | ||
|
||
def get_current_date() -> str: | ||
return datetime.now().strftime("%d/%m/%Y") | ||
|
||
def search_current_date() -> str: | ||
return datetime.now().strftime("%d%m%Y") | ||
|
||
def convert_24_to_12_hour(time_value: str) -> str: | ||
t = time.strptime(time_value, "%H:%M") | ||
return time.strftime("%I:%M %p", t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import logging as logger | ||
|
||
logger.basicConfig(level=logger.INFO) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
|
||
from smartfit_booking.logger import logger | ||
|
||
def save_file(path: str, response: object) -> None: | ||
try: | ||
file = open(path, "wb") | ||
file.write(response.content) | ||
file.close() | ||
logger.info(f'File {path} has been saved successfully') | ||
except Exception as error: | ||
logger.error(f'Error to save image: {error}') | ||
raise | ||
|
||
def remove_file(path: str) -> None: | ||
try: | ||
if os.path.exists(path): | ||
os.remove(path) | ||
logger.info(f'File {path} has been removed successfully') | ||
except Exception as error: | ||
logger.error(f'Error to remove file {path}: {error}') | ||
raise |
Oops, something went wrong.