mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-01-01 12:26:13 +00:00
Bendover for PyLint
This commit is contained in:
parent
e784ca3011
commit
b426a6f6c4
|
@ -13,12 +13,13 @@ from flask_caching import Cache
|
|||
from flask_assets import Environment, Bundle
|
||||
from flask import Flask, render_template
|
||||
|
||||
from gallery.utils import theme_manager
|
||||
|
||||
# Configuration
|
||||
from dotenv import load_dotenv
|
||||
import platformdirs
|
||||
from yaml import FullLoader, load
|
||||
from dotenv import load_dotenv
|
||||
from yaml import FullLoader, safe_load
|
||||
|
||||
# Utils
|
||||
from gallery.utils import theme_manager
|
||||
|
||||
|
||||
USER_DIR = platformdirs.user_config_dir('onlylegs')
|
||||
|
@ -38,8 +39,8 @@ def create_app(test_config=None):
|
|||
print("Loaded environment variables")
|
||||
|
||||
# Get config file
|
||||
with open(os.path.join(USER_DIR, 'conf.yml'), encoding='utf-8') as f:
|
||||
conf = load(f, Loader=FullLoader)
|
||||
with open(os.path.join(USER_DIR, 'conf.yml'), encoding='utf-8') as file:
|
||||
conf = safe_load(file, loader=FullLoader)
|
||||
print("Loaded gallery config")
|
||||
|
||||
# App configuration
|
||||
|
@ -66,8 +67,8 @@ def create_app(test_config=None):
|
|||
theme_manager.CompileTheme('default', app.root_path)
|
||||
|
||||
# Bundle JS files
|
||||
js = Bundle('js/*.js', output='gen/packed.js')
|
||||
assets.register('js_all', js)
|
||||
js_scripts = Bundle('js/*.js', output='gen/packed.js')
|
||||
assets.register('js_all', js_scripts)
|
||||
|
||||
# Error handlers
|
||||
@app.errorhandler(403)
|
||||
|
|
|
@ -4,7 +4,8 @@ OnlyLegs - Database models and functions for SQLAlchemy
|
|||
import os
|
||||
import platformdirs
|
||||
|
||||
from sqlalchemy import create_engine, Column, Integer, String, Boolean, DateTime, ForeignKey, PickleType
|
||||
from sqlalchemy import (
|
||||
create_engine, Column, Integer, String, Boolean, DateTime, ForeignKey, PickleType)
|
||||
from sqlalchemy.orm import declarative_base, relationship
|
||||
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ def lens_specification(value):
|
|||
"""
|
||||
try:
|
||||
return str(value[0] / value[1]) + 'mm - ' + str(value[2] / value[3]) + 'mm'
|
||||
except Exception as err:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
|
|
13
run.py
13
run.py
|
@ -1,3 +1,10 @@
|
|||
"""
|
||||
Run script for OnlyLegs
|
||||
"""
|
||||
from setup.args import PORT, ADDRESS, WORKERS, DEBUG
|
||||
from setup.configuration import Configuration
|
||||
|
||||
|
||||
print("""
|
||||
___ _ _
|
||||
/ _ \ _ __ | |_ _| | ___ __ _ ___
|
||||
|
@ -9,10 +16,6 @@ Created by Fluffy Bean - Version 23.03.20
|
|||
""")
|
||||
|
||||
|
||||
from setup.args import PORT, ADDRESS, WORKERS, DEBUG
|
||||
from setup.configuration import Configuration
|
||||
|
||||
|
||||
Configuration() # Run pre-checks
|
||||
|
||||
|
||||
|
@ -25,7 +28,7 @@ if DEBUG:
|
|||
|
||||
create_app().run(host=ADDRESS, port=PORT, debug=True, threaded=True)
|
||||
else:
|
||||
from setup.runner import OnlyLegs
|
||||
from setup.runner import OnlyLegs # pylint: disable=C0412
|
||||
|
||||
# If no address is specified, bind the server to all interfaces
|
||||
if not ADDRESS:
|
||||
|
|
|
@ -4,10 +4,10 @@ Runs when the app detects that there is no user directory
|
|||
"""
|
||||
import os
|
||||
import sys
|
||||
import platformdirs
|
||||
import logging
|
||||
import yaml
|
||||
import re
|
||||
import platformdirs
|
||||
import yaml
|
||||
|
||||
|
||||
USER_DIR = platformdirs.user_config_dir('onlylegs')
|
||||
|
@ -145,6 +145,9 @@ class Configuration:
|
|||
|
||||
@staticmethod
|
||||
def logging_config():
|
||||
"""
|
||||
Set the logging config
|
||||
"""
|
||||
logs_path = os.path.join(platformdirs.user_config_dir('onlylegs'), 'logs')
|
||||
|
||||
if not os.path.isdir(logs_path):
|
||||
|
|
|
@ -1,22 +1,31 @@
|
|||
"""
|
||||
Gunicorn configuration file
|
||||
"""
|
||||
from gunicorn.app.base import Application
|
||||
from gunicorn import util
|
||||
|
||||
|
||||
class OnlyLegs(Application):
|
||||
def __init__(self, options={}):
|
||||
"""
|
||||
Gunicorn application
|
||||
"""
|
||||
def __init__(self, options={}): # pylint: disable=W0102, W0231
|
||||
self.usage = None
|
||||
self.callable = None
|
||||
self.options = options
|
||||
self.do_load_config()
|
||||
|
||||
def init(self, *args):
|
||||
"""
|
||||
Initialize the application
|
||||
"""
|
||||
cfg = {}
|
||||
for k, v in self.options.items():
|
||||
if k.lower() in self.cfg.settings and v is not None:
|
||||
cfg[k.lower()] = v
|
||||
for setting, value in self.options.items():
|
||||
if setting.lower() in self.cfg.settings and value is not None:
|
||||
cfg[setting.lower()] = value
|
||||
return cfg
|
||||
|
||||
def prog(self):
|
||||
def prog(self): # pylint: disable=C0116, E0202
|
||||
return 'OnlyLegs'
|
||||
|
||||
def load(self):
|
||||
|
|
Loading…
Reference in a new issue