From 61a046d21ed039c8dfa439935fd267ae80ff0033 Mon Sep 17 00:00:00 2001 From: Aaron Lee Date: Sun, 28 Apr 2024 16:51:06 +0800 Subject: [PATCH] fixed requirements and upload encoding --- .python-version | 1 + Python.gitignore | 160 +++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | Bin 653 -> 1356 bytes temp/.gitkeep | 0 upload.py | 10 +-- 5 files changed, 166 insertions(+), 5 deletions(-) create mode 100644 .python-version create mode 100644 Python.gitignore create mode 100644 temp/.gitkeep diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..bd28b9c --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.9 diff --git a/Python.gitignore b/Python.gitignore new file mode 100644 index 0000000..6769e21 --- /dev/null +++ b/Python.gitignore @@ -0,0 +1,160 @@ +# 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 + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__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/ \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 993f5adc2cd07e3d69810220fce3d0d0e971fc1b..15ed56bb8eb88840cb9b34e24cae7b417ba2b018 100644 GIT binary patch literal 1356 zcmZ{kO>fg+5QO)P#7{AborabJ2aw=^;DCz65xK$npswS_HcIp3foFF8#uf-!ZXNIJ z?Ck8m{{8E%m3C*9)%KdJuosrw6@M4@+@2AsZEua;gE%@OCw6m*ul;=wX2Tr}3s}S; zuEJT?wxi0?I?%mk@E!Q|z&o*@FWkylaOami#n)69v#P54^~iZ3TRf#R387q7e(8v) zbs}23x|%vdi9>gE_?~EqvZygBQ1??Tvp4n~CV7!KR&d;Sr8#c$^PQa>D^;(!ul~W_ z+GqO+b4`ys)IHdfXGn$EbI;h)W5v~gQ%|bDBr4wJh!}{_drDb{Paq~=e~V&^x0$DkhCT0Q(N{()ymoD)0A70 z-=QeBI$W4XC~=JBON`HXnk+CY-2^e=t#9S<4~rI+`SHE z1NG{03QO-#yvgM_r(a#wy?=2AHaG2>PE$gB;nc_1De5Q|Owx8nL(7%6Bp<&@iv0nO CWyHY% literal 653 zcmaixv2KGf5QcX@g{7>>7!#5ZDFc<-sY}%dK*n6bs<9p0M4?Y#44E>J{rm3z`)`M< zF_?h|DY#M-?m&a%0b1NlxDUblbDDNC^kYMW8Pb*y8gAfHD?9E8LOWcA0J`N`K>9Ok z5v0+c*y)V3Bu5{L`(J#yU`8m(w(&AyG-285)Kxo39nFjsK1M2-AElNtV z-?XyR!}|XEtd!_snAV`htDprMCVy46Fj|8M#?^KTy;;(p<~!N(X))ZbabYPXN5+D- z(_O`7`AnBj@KcEtSw7e6*D5lSZ{zzJ_g=|n<&UpQ$kCd;Zq5A0TeRj!m4t4tDWdfk gVMf`@#~zS_>j*w9M=-(;aeOywDU4fMi!%uQ2OGQ2761SM diff --git a/temp/.gitkeep b/temp/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/upload.py b/upload.py index 414ec22..901dac6 100644 --- a/upload.py +++ b/upload.py @@ -14,7 +14,7 @@ def upload_users(): csv_file = request.files['csv'] filepath = os.path.join('./temp', csv_file.filename) csv_file.save(filepath) - with open(filepath) as file: + with open(filepath, encoding="utf-8") as file: csv_dict = csv.DictReader(file) for row in csv_dict: pwd = row['password'] @@ -56,7 +56,7 @@ def upload_homeroom(): filepath = os.path.join('./temp', csv_file.filename) csv_file.save(filepath) # allUsers = db.child("Users").get(session['token']).val() - with open(filepath) as file: + with open(filepath, encoding="utf-8") as file: csv_dict = csv.DictReader(file) db = refresh_db() cursor = db.cursor(buffered=True) @@ -155,7 +155,7 @@ def upload_stud_in_group(): csv_file = request.files['csv'] filepath = os.path.join('./temp', csv_file.filename) csv_file.save(filepath) - with open(filepath) as file: + with open(filepath, encoding="utf-8") as file: csv_dict = csv.DictReader(file) headers = csv_dict.fieldnames headers = headers[1:] @@ -270,7 +270,7 @@ def upload_dates(): csv_file = request.files['csv'] filepath = os.path.join('./temp', csv_file.filename) csv_file.save(filepath) - with open(filepath) as file: + with open(filepath, encoding="utf-8") as file: csv_dict = csv.DictReader(file) headers = csv_dict.fieldnames db = refresh_db() @@ -312,7 +312,7 @@ def upload_admin_acc(): csv_file = request.files['csv'] filepath = os.path.join('./temp', csv_file.filename) csv_file.save(filepath) - with open(filepath) as file: + with open(filepath, encoding="utf-8") as file: csv_dict = csv.DictReader(file) for row in csv_dict: pwd = row['password']