Compare commits
3 Commits
4fd2d55cbd
...
6888a69ee7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6888a69ee7 | ||
|
|
0f9135707a | ||
|
|
9bdd1b4569 |
12
README.md
12
README.md
@@ -67,6 +67,18 @@ Your contributions are very much welcome ! You can either request an account on
|
|||||||
|
|
||||||
Please also say if you had a printer to test your code, and which printer you've been using.
|
Please also say if you had a printer to test your code, and which printer you've been using.
|
||||||
|
|
||||||
|
### Linting
|
||||||
|
|
||||||
|
If you want to contribute code, please make sure to lint the project before commiting. This helps the code keep a general structure, and avoids some commons erros and mistakes.
|
||||||
|
|
||||||
|
To do so, you can run the following command :
|
||||||
|
|
||||||
|
```
|
||||||
|
black src/
|
||||||
|
```
|
||||||
|
|
||||||
|
Beware that this command *will* re-write files, so doing `git add <file>` and then `black src/` and then `git diff` to see what the linter has done is a good idea.
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
# Configuration file the LittlePrynter
|
# Configuration file the LittlePrynter
|
||||||
|
|
||||||
|
[defaults]
|
||||||
|
signature = "Anonymous"
|
||||||
|
|
||||||
# Printer settings
|
# Printer settings
|
||||||
[printer]
|
[printer]
|
||||||
vendor_id = 0x04b8
|
vendor_id = 0x04b8
|
||||||
|
|||||||
25
src/main.py
25
src/main.py
@@ -82,6 +82,7 @@ except FileExistsError:
|
|||||||
app.logger.debug("Directory %s already exists.", UPLOAD_FOLDER)
|
app.logger.debug("Directory %s already exists.", UPLOAD_FOLDER)
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
app.logger.error("Permission denied: Unable to create %s", UPLOAD_FOLDER)
|
app.logger.error("Permission denied: Unable to create %s", UPLOAD_FOLDER)
|
||||||
|
exit(77)
|
||||||
|
|
||||||
# Output the config file
|
# Output the config file
|
||||||
if os.getenv("LIPY_DEBUG") is True:
|
if os.getenv("LIPY_DEBUG") is True:
|
||||||
@@ -165,14 +166,20 @@ def api_print_sms():
|
|||||||
app.logger.debug("Printing an sms")
|
app.logger.debug("Printing an sms")
|
||||||
try:
|
try:
|
||||||
txt = request.form["txt"]
|
txt = request.form["txt"]
|
||||||
sign = request.form["signature"]
|
|
||||||
except werkzeug.exceptions.BadRequestKeyError as e:
|
except werkzeug.exceptions.BadRequestKeyError as e:
|
||||||
app.logger.error(
|
app.logger.error("Whoops, we are missing the txt input field. : %s ", str(e))
|
||||||
"Whoops, no forms submitted or missing signature : %s ", str(e)
|
|
||||||
)
|
|
||||||
flash("Whoops, no forms submitted or missing signature : %s", str(e))
|
flash("Whoops, no forms submitted or missing signature : %s", str(e))
|
||||||
return redirect(url_for("index"))
|
return redirect(url_for("index"))
|
||||||
|
|
||||||
|
try:
|
||||||
|
# comment: We try to get a signature
|
||||||
|
sign = request.form["signature"]
|
||||||
|
except werkzeug.exceptions.BadRequestKeyError as e:
|
||||||
|
app.logger.warning(
|
||||||
|
"No signature found for this print, using default signature.", str(e)
|
||||||
|
)
|
||||||
|
sign = configuration_file["defaults"]["signature"]
|
||||||
|
|
||||||
web.print_sms(txt, sign)
|
web.print_sms(txt, sign)
|
||||||
return redirect(url_for("index"))
|
return redirect(url_for("index"))
|
||||||
|
|
||||||
@@ -184,11 +191,13 @@ def api_print_image():
|
|||||||
app.logger.debug("Printing an image")
|
app.logger.debug("Printing an image")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# comment: We try to get a signature
|
||||||
sign = request.form["signature"]
|
sign = request.form["signature"]
|
||||||
except Exception as e:
|
except werkzeug.exceptions.BadRequestKeyError as e:
|
||||||
app.logger.error("Whoops, no forms submitted or missing signature : %s", str(e))
|
app.logger.warning(
|
||||||
flash("Whoops, no forms submitted or missing signature : %s ", str(e))
|
"No signature found for this print, using default signature.", str(e)
|
||||||
return redirect(url_for("index"))
|
)
|
||||||
|
sign = configuration_file["defaults"]["signature"]
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
# check if the post request has the file part
|
# check if the post request has the file part
|
||||||
|
|||||||
Reference in New Issue
Block a user