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

Feat/pyinstaller #19

Merged
merged 33 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9c6e747
feat: pyinstaller
zzjc1234 Sep 1, 2023
a46ea16
Merge branch 'fix/codeQuality' into feat/pyinstaller
zzjc1234 Sep 1, 2023
f0f25ad
Merge branch 'main' into feat/pyinstaller
zzjc1234 Sep 2, 2023
de425ff
fix:update
zzjc1234 Sep 2, 2023
e96e3dc
feat: modifed for pyinstaller
zzjc1234 Sep 2, 2023
1480008
fix: rm wrong file
zzjc1234 Sep 2, 2023
235e8dc
chore: build executables in action
linsyking Sep 2, 2023
38f6896
Merge branch 'main' into feat/pyinstaller
linsyking Sep 2, 2023
7cadc18
chore: action file format
linsyking Sep 2, 2023
ce9ab85
chore: format code
linsyking Sep 2, 2023
bab0a2f
fix: pyinstaller dependencies
zzjc1234 Sep 2, 2023
6688b37
Merge branch 'feat/pyinstaller' of github.com:linsyking/CanvasHelper2…
zzjc1234 Sep 2, 2023
d6c7c1b
fix: pyinstaller
zzjc1234 Sep 2, 2023
006b7b5
fix: add spec file
zzjc1234 Sep 3, 2023
fc26113
fix: format the code
zzjc1234 Sep 3, 2023
80adf71
chore: add makefile
zzjc1234 Sep 3, 2023
cfbb33d
fix: remove git dependency
zzjc1234 Sep 3, 2023
df7a8d8
fix: pyinstaller
linsyking Sep 3, 2023
12f97ee
fix: log level changed to error
linsyking Sep 3, 2023
f0a096e
fix: use makedirs instead of mkdir
linsyking Sep 3, 2023
ae3263f
chore: make windows exe
linsyking Sep 3, 2023
c4cc836
feat: read net_config
zzjc1234 Sep 6, 2023
a27b195
feat: add default host and port
zzjc1234 Sep 6, 2023
1f41821
fix: condition without net_config
zzjc1234 Sep 7, 2023
8afa721
Merge branch 'dev' into feat/pyinstaller
linsyking Sep 7, 2023
30082c6
Merge branch 'main' into feat/pyinstaller
linsyking Sep 7, 2023
93becdb
Merge branch 'dev' into feat/pyinstaller
linsyking Jan 9, 2024
080f12b
fix: duplicate code
zzjc1234 Jan 16, 2024
25a7d11
fix: fail to upload figures
zzjc1234 Jan 17, 2024
2d3469f
Merge branch 'fix/security_win' into feat/pyinstaller
zzjc1234 Jan 17, 2024
ac79a06
Merge branch 'dev' into feat/pyinstaller
linsyking Feb 4, 2024
f165496
Merge branch 'dev' into feat/pyinstaller
linsyking Feb 4, 2024
787f6b8
Merge branch 'dev' into feat/pyinstaller
zzjc1234 Feb 12, 2024
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
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ jobs:
- name: Test run
run: |
timeout 3 uvicorn canvas_app:app --port 9283 || [ $? -eq 124 ]
- name: Build executables
run: |
pip install pyinstaller
pyinstaller -F start.py
timeout 3 dist/start --port 9283 || [ $? -eq 124 ]
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
START_SRC=start.py

all:
pyinstaller -F $(START_SRC)

windows:
wine pyinstaller -F $(START_SRC)

clean:
rm -r build dist *.spec *.log

format:
black .

run:
./dist/start
11 changes: 4 additions & 7 deletions canvas_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import urllib.parse
from models import Position, Check, Course, URL
from fastapi.responses import JSONResponse
from os import path, listdir, remove, mkdir
from updater import update
from os import path, listdir, remove, makedirs

import json
import logging
from typing import List
Expand Down Expand Up @@ -76,9 +76,6 @@ def check_file(filename):

conf = ConfigMGR()

# Self Update
update()


@app.get(
"/config",
Expand Down Expand Up @@ -376,7 +373,7 @@ async def set_check(name: str, check: Check):
"""
Check

Only 1,2,3 is available
Only 1, 2, 3 is available
"""
if check.type < 0 or check.type > 3:
return JSONResponse(status_code=400, content={"message": "Invalid check type"})
Expand Down Expand Up @@ -475,7 +472,7 @@ async def get_file_list():
if path.exists("./public/res"):
return {"files": listdir("./public/res")}
else:
mkdir("./public/res")
makedirs("./public/res", exist_ok=True)
return {"files": []}


Expand Down
5 changes: 0 additions & 5 deletions models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#!/usr/bin/env python3
"""
@Author: King
@Date: 2023-01-04 21:24:24
@Email: [email protected]
"""

from pydantic import BaseModel, Field
from typing import Union
Expand Down
4 changes: 4 additions & 0 deletions net_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"host": "localhost",
"port": 9283
}
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ requests
fastapi
uvicorn
python-multipart
GitPython
46 changes: 46 additions & 0 deletions start.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3

import uvicorn
from canvas_app import app
import json
from os import path

"""
Start script
"""


if __name__ == "__main__":
net_config = {}

log_config = {
"version": 1,
"disable_existing_loggers": True,
"handlers": {
"file_handler": {
"class": "logging.FileHandler",
"filename": "error.log",
},
},
"root": {
"handlers": ["file_handler"],
"level": "ERROR",
},
}

if path.exists("net_config.json"):
with open("net_config.json", "r", encoding="utf-8", errors="ignore") as f:
net_config = json.load(f)

if "host" not in net_config:
raise Exception("no host")
elif "port" not in net_config:
raise Exception("no port")

usr_host = net_config["host"]
zzjc1234 marked this conversation as resolved.
Show resolved Hide resolved
usr_port = net_config["port"]
else:
usr_host = "localhost"
usr_port = 9283

uvicorn.run(app, port=usr_port, host=usr_host, reload=False, log_config=log_config)
33 changes: 0 additions & 33 deletions updater.py

This file was deleted.

Loading