From d73beb9be404c0485edefd56c1cf639adba93a51 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Tue, 8 Dec 2020 17:17:24 +0100 Subject: [PATCH] Add pylint flake8 --- .drone.yml | 5 +++++ pynyaata/__init__.py | 13 ++++++------- pynyaata/config.py | 3 +-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.drone.yml b/.drone.yml index 6b982e2..79c1d0d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,6 +3,11 @@ name: default type: docker steps: + - name: flake8 + image: python + commands: + - pip install flake8 + - flake8 pynyaata --ignore=E501 - name: docker image: plugins/docker settings: diff --git a/pynyaata/__init__.py b/pynyaata/__init__.py index 0e89f7b..0c05cb6 100644 --- a/pynyaata/__init__.py +++ b/pynyaata/__init__.py @@ -2,13 +2,12 @@ from functools import wraps from operator import attrgetter, itemgetter from flask import redirect, render_template, request, url_for, abort -from werkzeug.security import check_password_hash +import utils from .config import app, auth, ADMIN_USERNAME, ADMIN_PASSWORD, MYSQL_ENABLED, APP_PORT, IS_DEBUG -from .connectors import * -from .connectors.core import ConnectorCore, ConnectorLang, ConnectorReturn +from .connectors import get_instance, run_all +from .connectors.core import ConnectorLang, ConnectorReturn from .forms import SearchForm, DeleteForm, EditForm -from .utils import boldify, clean_model if MYSQL_ENABLED: from .config import db @@ -27,7 +26,7 @@ def mysql_required(f): @auth.verify_password def verify_password(username, password): - return username == ADMIN_USERNAME and check_password_hash(ADMIN_PASSWORD, password) + return username == ADMIN_USERNAME and ADMIN_PASSWORD == password @app.template_filter('boldify') @@ -179,8 +178,8 @@ def admin_edit(link_id=None): link = AnimeLink.query.filter_by(id=link_id).first() form.folder.data = link.title.folder.id else: - link = clean_model(AnimeLink()) - link.title = clean_model(AnimeTitle()) + link = utils.clean_model(AnimeLink()) + link.title = utils.clean_model(AnimeTitle()) link.vf = False return render_template('admin/edit.html', search_form=SearchForm(), link=link, folders=folders, action_form=form) diff --git a/pynyaata/config.py b/pynyaata/config.py index a9f4a36..00a9f4f 100644 --- a/pynyaata/config.py +++ b/pynyaata/config.py @@ -4,13 +4,12 @@ from flask import Flask from flask.cli import load_dotenv from flask_httpauth import HTTPBasicAuth from flask_sqlalchemy import SQLAlchemy -from werkzeug.security import generate_password_hash load_dotenv() IS_DEBUG = environ.get('FLASK_ENV', 'production') == 'development' ADMIN_USERNAME = environ.get('ADMIN_USERNAME', 'admin') -ADMIN_PASSWORD = generate_password_hash(environ.get('ADMIN_PASSWORD', 'secret')) +ADMIN_PASSWORD = environ.get('ADMIN_PASSWORD', 'secret') APP_PORT = int(environ.get('FLASK_PORT', 5000)) CACHE_TIMEOUT = int(environ.get('CACHE_TIMEOUT', 60 * 60)) REQUESTS_TIMEOUT = int(environ.get('REQUESTS_TIMEOUT', 5))