Compare commits

..

No commits in common. "efae37ad88d2327f461d9e7b0c489885e58d148a" and "792b32fb1c3415a2781f45fb64d16e1a330273c6" have entirely different histories.

8 changed files with 16 additions and 97 deletions

View file

@ -64,8 +64,6 @@ def manipulate_files():
os.unlink(file.path)
ctx.db.delete_file(uid=ctx.uid, fid=file.id)
ctx.db.delete_file_analysis_by_fid(fid=file.id)
ctx.db.delete_jobs_by_fid(uid=ctx.uid, fid=file.id)
flash("File deleted", category="info")
case _:

View file

@ -43,23 +43,22 @@ WHERE
user_id = :uid
;
-- name: delete-file!
DELETE FROM files
-- name: delete-file*!
DELETE FROM jobs
WHERE
user_id = :uid
AND id = :fid
AND file_id = :fid
;
-- name: delete-file-analysis-by-fid!
DELETE FROM file_analysis
WHERE
file_id = :fid
;
-- name: delete-file-analysis!
DELETE FROM file_analysis
DELETE FROM files
WHERE
id = :aid
user_id = :uid
AND id = :fid
;
-- name: fetch-file^

View file

@ -192,10 +192,3 @@ WHERE
user_id = :uid
AND id = :jid
;
-- name: delete-jobs-by-fid!
DELETE FROM jobs
WHERE
user_id = :uid
AND file_id = :fid
;

View file

@ -1,45 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<html lang="en">
<head>
<link rel="stylesheet" href="https://tentacles.tirefireind.us/static/css/style.css" />
</head>
<body>
<nav class="container navbar">
<span class="logo">
<a class="row" href="https://tentacles.tirefireind.us/">
<img src="https://tentacles.tirefireind.us/static/tentacles.svg" alt="Tentacles">
<span class="name color-yellow">Tentacles</span>
</a>
</span>
</nav>
<div class="container content">
<div class="row">
<p>
Dear {{ username }},
</p>
<p>
We're sorry to inform you that the file <code>{{ filename }}</code> you attempted to print has been rejected.
</p>
<p>
At this time, Tentacles requires that all submitted Gcode be generated by PrusaSlicer 2.0.0 or later, and
contain the PrusaSlicer emitted configuration metadata. This allows us to verify that the Gcode you've
submitted fits within the constraints of the printers we have available and choose an appropriately printer
for running the job. This protects our printers from damage and ensures that you get usable results.
</p>
<p>
Please re-slice the object using <a href="https://www.prusa3d.com/page/prusaslicer_424/">PrusaSlicer</a> and
re-submit the resulting Gcode.
</p>
<p>
Thank you for your understanding
</p>
</div>
</div>
</body>
<footer>
</footer>
</html>

View file

@ -3,13 +3,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<html lang="en">
<head>
<link rel="stylesheet" href="https://tentacles.tirefireind.us/static/css/style.css" />
<link rel="stylesheet" href="{{ base_url }}/static/css/style.css" />
</head>
<body>
<nav class="container navbar">
<span class="logo">
<a class="row" href="https://tentacles.tirefireind.us/">
<img src="https://tentacles.tirefireind.us/static/tentacles.svg" alt="Tentacles">
<a class="row" href="/">
<img src="{{ base_url }}/static/tentacles.svg" alt="Tentacles">
<span class="name color-yellow">Tentacles</span>
</a>
</span>

View file

@ -6,8 +6,8 @@
<div class="file row u-flex">
<div class="details six columns u-flex u-flex-wrap">
<span class="file-name">{{ file.filename }}</span>
<span class="file-sucesses"><label>Successes</label>{{ file.print_successes }}</span>
<span class="file-failures"><label>Failures</label>{{ file.print_failures }}</span>
<span class="file-sucesses">{{ file.print_successes }} successes</span>
<span class="file-failures">{{ file.print_failures }} errors</span>
</div>
<div class="controls u-flex u-ml-auto">
{{ macros.start_job(file.id) }}

View file

@ -8,7 +8,7 @@
<body>
<nav class="container navbar">
<span class="logo">
<a class="row" href="{{ base_url }}">
<a class="row" href="/">
<img src="{{ base_url }}/static/tentacles.svg" alt="Tentacles">
<span class="name color-yellow">Tentacles</span>
</a>

View file

@ -7,7 +7,6 @@ Supporting the core app with asynchronous maintenance tasks.
Mostly related to monitoring and managing Printer state.
"""
import os
from contextlib import closing
from functools import cache
import logging
@ -20,7 +19,6 @@ from cherrypy.process.plugins import Monitor
from fastmail import FastMailSMTP
from gcode import analyze_gcode_file
from flask import Flask as App
from flask import render_template
from octorest import OctoRest as _OR
from requests import Response
from requests.exceptions import (
@ -304,40 +302,16 @@ def send_emails(app, db: Db):
def analyze_files(app: App, db: Db):
for file in db.list_unanalyzed_files():
p = Path(file.path)
if not p.is_file():
log.error(f"Invalid file {file.id}!")
continue
record = analyze_gcode_file(p)
for unanalyzed in db.list_unanalyzed_files():
record = analyze_gcode_file(Path(unanalyzed.path))
if not record:
log.error(
f"Unable to analyze {file.path} ({file.filename} owned by {file.user_id})!"
f"Unable to analyze {unanalyzed.path} ({unanalyzed.filename} owned by {unanalyzed.user_id})!"
)
db.delete_file(uid=file.user_id, fid=file.id)
db.delete_file_analysis_by_fid(fid=file.id)
db.delete_jobs_by_fid(uid=file.user_id, fid=file.id)
if os.path.exists(file.path):
os.unlink(file.path)
with app.app_context():
db.create_email(
uid=file.user_id,
subject=f"Failure to print: {file.filename}",
body=render_template(
"analysis_failure_email.html.j2",
username=db.fetch_user(uid=file.user_id).name,
filename=file.filename,
),
)
continue
db.create_analysis(
file_id=file.id,
file_id=unanalyzed.id,
max_x=record.max_x,
max_y=record.max_y,
max_z=record.max_z,