Skip to content

Commit

Permalink
🔥 revert repository
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrsxx committed Mar 23, 2022
1 parent e307fdc commit 282feac
Show file tree
Hide file tree
Showing 15 changed files with 372 additions and 100 deletions.
170 changes: 162 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,173 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# vscode config
.vscode

# python cache
__pycache__
.mypy_cache

# logs and screenshots
src/logs
src/screenshots
# bin, logs, and screenshots files
bin/*
logs/*
screenshots/*

# virtual environment
webdriver

# private key
secret

# tests
# local and cloud functions
start.py
server.py

# .gitkeep
!.gitkeep
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worker: python cloud.py && python server.py
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Auto Attend MyBest BSI

![Build](https://github.com/ccrsxx/autobsi/actions/workflows/codeql-analysis.yml/badge.svg)
[![Heroku](https://pyheroku-badge.herokuapp.com/?app=ccrsxx)](https://autobsi.herokuapp.com)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

Expand Down
Empty file added bin/.gitkeep
Empty file.
67 changes: 67 additions & 0 deletions cloud.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from src import get_from_heroku

source = (
lambda x: f'''
import schedule
from src import (
os,
time,
logging,
get_from_heroku,
attend_class,
job,
)
def main():
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(message)s',
datefmt='%H:%M:%S',
handlers=[
logging.FileHandler(os.path.join('logs', 'temp.txt')),
logging.StreamHandler(),
],
)
attend_class(get=get_from_heroku, mail=True, verbose=False, cloud=True)
{x}
while True:
schedule.run_pending()
time.sleep(1)
if __name__ == '__main__':
main()
'''
)


def main():
timetable = get_from_heroku('timetable')

class_schedule = []

for day in timetable:
item = timetable[day]
start_time, _ = item['time']

if isinstance(start_time, list):
for i, (start_time, _) in enumerate(item['time']):
class_schedule.append(
f'schedule.every().{day}.at(\'{start_time}\').do(job, \'{day}\', {i})'
)
else:
class_schedule.append(
f'schedule.every().{day}.at(\'{start_time}\').do(job, \'{day}\')'
)

with open('server.py', 'w') as f:
f.write(source(';'.join(class_schedule)))


if __name__ == '__main__':
main()
Empty file added logs/.gitkeep
Empty file.
11 changes: 2 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,23 @@
os,
time,
logging,
datetime,
get_from_config,
get_from_dotenv,
attend_class,
job,
)


def main():
os.chdir(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'src'))

logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(message)s',
datefmt='%H:%M:%S',
handlers=[
logging.FileHandler(
os.path.join('logs', f'{datetime.now().strftime("%d %b")}.txt')
),
logging.FileHandler(os.path.join('logs', 'temp.txt')),
logging.StreamHandler(),
],
)

attend_class(get=get_from_config, mail=False, verbose=False)
attend_class(get=get_from_config, mail=False, verbose=False, cloud=False)

'''
schedule.every().monday.at('12:30').do(job, 'monday')
Expand Down
Binary file modified requirements.txt
Binary file not shown.
1 change: 1 addition & 0 deletions runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-3.8.13
Empty file added screenshots/.gitkeep
Empty file.
13 changes: 2 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import sys

from win32api import GetFileVersionInfo, HIWORD
from urllib.request import urlopen
from zipfile import ZipFile
Expand Down Expand Up @@ -28,17 +28,8 @@


def main():
os.chdir(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'src'))

no_chrome = True

print('Checking needed folder...')
for folder in ['logs', 'screenshots']:
if not os.path.exists(folder):
os.makedirs(folder)
print(f'Created {folder}')
print('Checking folder done.')

print('Checking If Google Chrome is installed...')
for chrome_path in CHROME_PATHS:
if os.path.exists(chrome_path):
Expand All @@ -54,7 +45,7 @@ def main():
else:
print(f'Google Chrome version {chrome_version} detected.')

os.chdir(os.path.join(os.path.dirname(sys.executable), 'Scripts'))
os.chdir('bin')

print(f'Downloading webdriver for Google Chrome version {chrome_version}...')

Expand Down
11 changes: 9 additions & 2 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
"""Automated Attendance script for MyBest BSI"""

__author__ = """ccrsxx"""
__version__ = '1.0'
__version__ = '2.0'

from .autobsi import *
from .autobsi import (
os,
time,
logging,
attend_class,
job,
)
from .environment import *
Loading

0 comments on commit 282feac

Please sign in to comment.