LGTM fixes. Remove unused import and variables

This commit is contained in:
Khanh Ngo 2019-12-07 20:20:40 +07:00
parent 53a7545ccc
commit 6af94df00a
No known key found for this signature in database
GPG Key ID: D5FAA6A16150E49E
13 changed files with 29 additions and 29 deletions

View File

@ -49,7 +49,7 @@ def create_app(config=None):
# HSTS # HSTS
if app.config.get('HSTS_ENABLED'): if app.config.get('HSTS_ENABLED'):
from flask_sslify import SSLify from flask_sslify import SSLify
_sslify = SSLify(app) _sslify = SSLify(app) # lgtm [py/unused-import]
# Load app's components # Load app's components
assets.init_app(app) assets.init_app(app)

View File

@ -1,7 +1,7 @@
import base64 import base64
import binascii import binascii
from functools import wraps from functools import wraps
from flask import g, redirect, url_for, request, abort, current_app, render_template from flask import g, request, abort, current_app, render_template
from flask_login import current_user from flask_login import current_user
from .models import User, ApiKey, Setting, Domain from .models import User, ApiKey, Setting, Domain

View File

@ -9,7 +9,6 @@ import os
from distutils.version import StrictVersion from distutils.version import StrictVersion
from urllib.parse import urlparse from urllib.parse import urlparse
from datetime import datetime, timedelta from datetime import datetime, timedelta
from threading import Thread
from .certutil import KEY_FILE, CERT_FILE from .certutil import KEY_FILE, CERT_FILE
@ -58,12 +57,18 @@ def fetch_remote(remote_url,
r.raise_for_status() r.raise_for_status()
except Exception as e: except Exception as e:
msg = "Returned status {0} and content {1}" msg = "Returned status {0} and content {1}"
raise RuntimeError('Error while fetching {0}'.format(remote_url)) raise RuntimeError('Error while fetching {0}. {1}'.format(
remote_url, msg))
return r return r
def fetch_json(remote_url, method='GET', data=None, params=None, headers=None, timeout=None): def fetch_json(remote_url,
method='GET',
data=None,
params=None,
headers=None,
timeout=None):
r = fetch_remote(remote_url, r = fetch_remote(remote_url,
method=method, method=method,
data=data, data=data,
@ -78,7 +83,10 @@ def fetch_json(remote_url, method='GET', data=None, params=None, headers=None, t
if r.status_code == 204: if r.status_code == 204:
return {} return {}
elif r.status_code == 409: elif r.status_code == 409:
return {'error': 'Resource already exists or conflict', 'http_code': r.status_code} return {
'error': 'Resource already exists or conflict',
'http_code': r.status_code
}
try: try:
assert ('json' in r.headers['content-type']) assert ('json' in r.headers['content-type'])

View File

@ -20,4 +20,4 @@ from .record_entry import RecordEntry
def init_app(app): def init_app(app):
db.init_app(app) db.init_app(app)
_migrate = Migrate(app, db) _migrate = Migrate(app, db) # lgtm [py/unused-import]

View File

@ -287,7 +287,8 @@ class Domain(db.Model):
account_id = None account_id = None
# add new domain # add new domain
d = Domain() d = Domain()
d.name = domain['name'].rstrip('.') d.name = domain['name'].rstrip(
'.') # lgtm [py/modification-of-default-value]
d.master = str(domain['masters']) d.master = str(domain['masters'])
d.type = domain['kind'] d.type = domain['kind']
d.serial = domain['serial'] d.serial = domain['serial']

View File

@ -3,7 +3,6 @@ from flask import current_app
from urllib.parse import urljoin from urllib.parse import urljoin
from ..lib import utils from ..lib import utils
from .base import db
from .setting import Setting from .setting import Setting

View File

@ -2,7 +2,6 @@ import sys
import pytimeparse import pytimeparse
from ast import literal_eval from ast import literal_eval
from distutils.util import strtobool from distutils.util import strtobool
from distutils.version import StrictVersion
from .base import db from .base import db

View File

@ -1,15 +1,13 @@
import re import re
import json import json
import traceback import traceback
import datetime
from ast import literal_eval from ast import literal_eval
from distutils.version import StrictVersion from distutils.version import StrictVersion
from flask import Blueprint, render_template, make_response, url_for, current_app, g, session, request, redirect, jsonify, abort from flask import Blueprint, render_template, make_response, url_for, current_app, request, redirect, jsonify, abort
from flask_login import login_user, login_required, current_user from flask_login import login_required, current_user
from .base import login_manager
from ..decorators import operator_role_required, admin_role_required from ..decorators import operator_role_required, admin_role_required
from ..models.user import User, Anonymous from ..models.user import User
from ..models.account import Account from ..models.account import Account
from ..models.account_user import AccountUser from ..models.account_user import AccountUser
from ..models.role import Role from ..models.role import Role

View File

@ -1,6 +1,6 @@
import base64 import base64
from flask import render_template, url_for, redirect, session, request, current_app from flask import render_template, url_for, redirect, session, request, current_app
from flask_login import LoginManager, login_user from flask_login import LoginManager
from ..models.user import User from ..models.user import User

View File

@ -1,6 +1,6 @@
from flask import Blueprint, render_template, make_response, url_for, current_app, request, jsonify, redirect from flask import Blueprint, render_template, url_for, current_app, request, jsonify, redirect
from flask_login import login_required, current_user from flask_login import login_required, current_user
from sqlalchemy import not_, or_ from sqlalchemy import not_
from ..lib.utils import customBoxes from ..lib.utils import customBoxes
from ..models.user import User from ..models.user import User
@ -33,7 +33,7 @@ def domains_custom(boxId):
.outerjoin(Account, Domain.account_id == Account.id) \ .outerjoin(Account, Domain.account_id == Account.id) \
.outerjoin(AccountUser, Account.id == AccountUser.account_id) \ .outerjoin(AccountUser, Account.id == AccountUser.account_id) \
.filter( .filter(
db.or_( d(
DomainUser.user_id == current_user.id, DomainUser.user_id == current_user.id,
AccountUser.user_id == current_user.id AccountUser.user_id == current_user.id
)) ))

View File

@ -1,14 +1,12 @@
import re import re
import json import json
import traceback import traceback
import datetime
from distutils.version import StrictVersion from distutils.version import StrictVersion
from flask import Blueprint, render_template, make_response, url_for, current_app, g, session, request, redirect, abort, jsonify from flask import Blueprint, render_template, make_response, url_for, current_app, request, redirect, abort, jsonify
from flask_login import login_user, login_required, current_user from flask_login import login_required, current_user
from .base import login_manager
from ..decorators import can_create_domain, operator_role_required, can_access_domain, can_configure_dnssec from ..decorators import can_create_domain, operator_role_required, can_access_domain, can_configure_dnssec
from ..models.user import User, Anonymous from ..models.user import User
from ..models.account import Account from ..models.account import Account
from ..models.setting import Setting from ..models.setting import Setting
from ..models.history import History from ..models.history import History

View File

@ -1,12 +1,10 @@
import qrcode as qrc import qrcode as qrc
import qrcode.image.svg as qrc_svg import qrcode.image.svg as qrc_svg
from io import BytesIO from io import BytesIO
from flask import Blueprint, request, render_template, make_response, jsonify, redirect, url_for, current_app, session, g from flask import Blueprint, request, render_template, make_response, jsonify, redirect, url_for, session
from flask_login import current_user, login_user, logout_user, login_required from flask_login import current_user, login_required
from .base import login_manager
from ..models.user import User from ..models.user import User
from ..models.role import Role
user_bp = Blueprint('user', user_bp = Blueprint('user',
__name__, __name__,

View File

@ -13,7 +13,6 @@
import sys import sys
import logging import logging
from flask import current_app
from powerdnsadmin import create_app from powerdnsadmin import create_app
from powerdnsadmin.models.domain import Domain from powerdnsadmin.models.domain import Domain
from powerdnsadmin.models.setting import Setting from powerdnsadmin.models.setting import Setting