diff --git a/aperisolve/analyzers/pngcheck.py b/aperisolve/analyzers/pngcheck.py index d62fca6..6e04559 100644 --- a/aperisolve/analyzers/pngcheck.py +++ b/aperisolve/analyzers/pngcheck.py @@ -24,6 +24,7 @@ class PngcheckAnalyzer(SubprocessAnalyzer): return "The file format of the file is not supported (PNG or JNG only)." return stdout + def analyze_pngcheck(input_img: Path, output_dir: Path) -> None: """Analyze an image submission using pngcheck.""" analyzer = PngcheckAnalyzer(input_img, output_dir) diff --git a/aperisolve/analyzers/steghide.py b/aperisolve/analyzers/steghide.py index 8bd26dd..fec8f5d 100644 --- a/aperisolve/analyzers/steghide.py +++ b/aperisolve/analyzers/steghide.py @@ -49,8 +49,8 @@ class SteghideAnalyzer(SubprocessAnalyzer): def process_output(self, stdout: str, stderr: str) -> str | list[str] | dict[str, str]: """Process the stdout into a list of lines.""" out = [] - for line in (stdout + '\n' + stderr).split("\n"): - if 'wrote extracted data to' in line: + for line in (stdout + "\n" + stderr).split("\n"): + if "wrote extracted data to" in line: out.append(line) return out diff --git a/aperisolve/app.py b/aperisolve/app.py index 734097c..ae869ea 100644 --- a/aperisolve/app.py +++ b/aperisolve/app.py @@ -28,9 +28,7 @@ app: Flask = Flask(__name__) app.json.sort_keys = False # type: ignore app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get("DB_URI") app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False -app.config["MAX_CONTENT_LENGTH"] = int( - os.environ.get("MAX_CONTENT_LENGTH", 1024 * 1024) -) +app.config["MAX_CONTENT_LENGTH"] = int(os.environ.get("MAX_CONTENT_LENGTH", 1024 * 1024)) RESULT_FOLDER.mkdir(parents=True, exist_ok=True) db.init_app(app) @@ -112,10 +110,7 @@ def upload_image() -> tuple[Response, int]: if image.filename is None or image.filename == "": return jsonify({"error": "No image provided"}), 400 - if ( - "." not in image.filename - or Path(image.filename).suffix.lower() not in IMAGE_EXTENSIONS - ): + if "." not in image.filename or Path(image.filename).suffix.lower() not in IMAGE_EXTENSIONS: return jsonify({"error": "Unsupported file type"}), 400 # Compute hashes and prepare submission @@ -230,9 +225,7 @@ def get_result(hash_val: str) -> tuple[Response, int]: submission = Submission.query.get_or_404(hash_val) image = Image.query.get_or_404(submission.image_hash) # type: ignore - result_path = ( - RESULT_FOLDER / str(image.hash) / str(submission.hash) / "results.json" - ) + result_path = RESULT_FOLDER / str(image.hash) / str(submission.hash) / "results.json" if not result_path.exists(): return jsonify({"error": "Results not ready yet..."}), 425 @@ -261,9 +254,7 @@ def download_output(hash_val: str, tool: str) -> Response: @app.route("/image/") @app.route("/image//") -def get_image( - hash_val: Optional[str] = None, img_name: Optional[str] = None -) -> Response: +def get_image(hash_val: Optional[str] = None, img_name: Optional[str] = None) -> Response: """ Download the image with a specific name (usually ones generated with decomposer) for a given submission hash. @@ -283,9 +274,7 @@ def get_image( image = Image.query.filter_by(hash=hash_val).first_or_404() output_file = Path(image.file) # type: ignore - if (not output_file.exists()) or ( - output_file.suffix.lower() not in IMAGE_EXTENSIONS - ): + if (not output_file.exists()) or (output_file.suffix.lower() not in IMAGE_EXTENSIONS): return abort(404, description="Image not found or unsupported format") return send_file(output_file, as_attachment=True) diff --git a/aperisolve/cleanup.py b/aperisolve/cleanup.py index 5a63f96..032a7b6 100644 --- a/aperisolve/cleanup.py +++ b/aperisolve/cleanup.py @@ -49,9 +49,7 @@ def cleanup_old_entries() -> None: db.session.delete(submission) # pylint: disable=no-member elif submission.status == "done": # type: ignore # Search for buggy results, delete - result_path = ( - RESULT_FOLDER / str(submission.image_hash) / str(submission.hash) - ) + result_path = RESULT_FOLDER / str(submission.image_hash) / str(submission.hash) result_file = result_path / "results.json" if not result_file.exists(): db.session.delete(submission) # pylint: disable=no-member diff --git a/aperisolve/models.py b/aperisolve/models.py index dc47053..22d6d34 100644 --- a/aperisolve/models.py +++ b/aperisolve/models.py @@ -97,9 +97,7 @@ def fill_ihdr_db() -> None: if exists: # Skip if already present continue - db.session.add( # pylint: disable=no-member - IHDR(packed=p.packed, crc=p.crc) - ) + db.session.add(IHDR(packed=p.packed, crc=p.crc)) # pylint: disable=no-member count += 1 if count % 5000 == 0: diff --git a/aperisolve/sentry.py b/aperisolve/sentry.py index 13b5871..c0307a5 100644 --- a/aperisolve/sentry.py +++ b/aperisolve/sentry.py @@ -14,9 +14,7 @@ from sentry_sdk.integrations.threading import ThreadingIntegration SENTRY_DSN = os.environ.get("SENTRY_DSN") SENTRY_ENVIRONMENT = os.environ.get("SENTRY_ENVIRONMENT", "development") SENTRY_TRACES_SAMPLE_RATE = float(os.environ.get("SENTRY_TRACES_SAMPLE_RATE", "0.1")) -SENTRY_PROFILES_SAMPLE_RATE = float( - os.environ.get("SENTRY_PROFILES_SAMPLE_RATE", "0.1") -) +SENTRY_PROFILES_SAMPLE_RATE = float(os.environ.get("SENTRY_PROFILES_SAMPLE_RATE", "0.1")) SENTRY_RELEASE = os.environ.get("SENTRY_RELEASE", "1.0.0")