diff --git a/doorpi/__init__.py b/doorpi/__init__.py index 9b08b429..889da2ef 100644 --- a/doorpi/__init__.py +++ b/doorpi/__init__.py @@ -1,7 +1,6 @@ """provide intercomstation to the doorstation by VoIP""" -from .doorpi import metadata, DoorPi - +from .doorpi import DoorPi, metadata # noqa F401 __version__ = metadata.version __author__ = metadata.authors[0] diff --git a/doorpi/action/handler.py b/doorpi/action/handler.py index c83c33be..d69748ea 100644 --- a/doorpi/action/handler.py +++ b/doorpi/action/handler.py @@ -321,9 +321,7 @@ def register_action(self, event_name, action_object, *args, **kwargs): logger.error('action_object is None') return False - single_fire = kwargs['single_fire_action'] is True - if ('single_fire_action' in list(kwargs.keys()) and single_fire): - + if ('single_fire_action' in list(kwargs.keys()) and kwargs['single_fire_action'] is True): action_object.single_fire_action = True del kwargs['single_fire_action'] diff --git a/doorpi/conf/config_object.py b/doorpi/conf/config_object.py index 21d8a9f7..255f2739 100644 --- a/doorpi/conf/config_object.py +++ b/doorpi/conf/config_object.py @@ -55,7 +55,7 @@ def find_config(configfile=None): open(possible_default_file, 'r').close() return possible_default_file except Exception as exp: - logger.debug(possible_default_file+' failed with '+exp) + logger.debug(possible_default_file+' failed with %s' % exp) return None diff --git a/doorpi/doorpi.py b/doorpi/doorpi.py index 2f4a8757..435db9df 100644 --- a/doorpi/doorpi.py +++ b/doorpi/doorpi.py @@ -49,6 +49,9 @@ class DoorPi(object, metaclass=Singleton): __prepared = False __config = None + @property + def meta(self): return metadata + @property def config(self): return self.__config @@ -92,8 +95,7 @@ def epilog(self): return metadata.epilog def name(self): return str(metadata.package) @property - def name_and_version(self): return str( - metadata.package) + ' - version: ' + metadata.version + def name_and_version(self): return str(metadata.package) + ' - version: ' + metadata.version __shutdown = False @@ -106,10 +108,8 @@ def shutdown(self): return self.__shutdown def base_path(self): if self._base_path is None: try: - self._base_path = os.path.join( - os.path.expanduser('~'), metadata.package) - assert os.access( - self._base_path, os.W_OK), 'use fallback for base_path (see tmp path)' + self._base_path = os.path.join(os.path.expanduser('~'), metadata.package) + assert os.access(self._base_path, os.W_OK), 'use fallback for base_path (see tmp path)' except Exception as exp: logger.error(exp) import tempfile @@ -152,14 +152,12 @@ def prepare(self, parsed_arguments): self.__event_handler = EventHandler() if self.config.config_file is None: - self.event_handler.register_action( - 'AfterStartup', self.config.save_config) + self.event_handler.register_action('AfterStartup', self.config.save_config) self.config.get('EVENT_OnStartup', '10', 'sleep:1') if 'test' in parsed_arguments and parsed_arguments.test is True: logger.warning('using only test-mode and destroy after 5 seconds') - self.event_handler.register_action( - 'AfterStartup', DoorPiShutdownAction(self.doorpi_shutdown)) + self.event_handler.register_action('AfterStartup', DoorPiShutdownAction(self.doorpi_shutdown)) # register own events self.event_handler.register_event('BeforeStartup', __name__) diff --git a/doorpi/keyboard/KeyboardInterface.py b/doorpi/keyboard/KeyboardInterface.py index 8de9b6ac..5825b332 100644 --- a/doorpi/keyboard/KeyboardInterface.py +++ b/doorpi/keyboard/KeyboardInterface.py @@ -128,7 +128,7 @@ def __init__(self, config_keyboards): ) self.__OutputMappingTable[output_pin_name] = keyboard_name - if len(self.__keyboards) is 0: + if len(self.__keyboards) == 0: logger.error('No Keyboards loaded - load dummy!') self.__keyboards['dummy'] = load_single_keyboard('dummy') @@ -136,8 +136,8 @@ def destroy(self): try: for Keyboard in self.__keyboards: self.__keyboards[Keyboard].destroy() - except: - pass + except Exception as exp: + logger.info(exp) def set_output(self, pin, value, log_output=True): if pin not in self.__OutputMappingTable: diff --git a/doorpi/keyboard/from_filesystem.py b/doorpi/keyboard/from_filesystem.py index edf6a6f2..6e5fe457 100644 --- a/doorpi/keyboard/from_filesystem.py +++ b/doorpi/keyboard/from_filesystem.py @@ -2,7 +2,6 @@ from doorpi.keyboard.AbstractBaseClass import KeyboardAbstractBaseClass, HIGH_LEVEL, LOW_LEVEL import os -import ntpath from watchdog.observers import Observer from watchdog.events import FileModifiedEvent, FileSystemEventHandler @@ -12,8 +11,8 @@ def path_leaf(path): - head, tail = ntpath.split(path) - return tail or ntpath.basename(head) + head, tail = os.path.split(path) + return tail or os.path.basename(head) class MissingMandatoryParameter(Exception): diff --git a/doorpi/keyboard/from_gpio.py b/doorpi/keyboard/from_gpio.py index d276db1b..6fbf4f31 100644 --- a/doorpi/keyboard/from_gpio.py +++ b/doorpi/keyboard/from_gpio.py @@ -105,7 +105,7 @@ def event_detect(self, pin): self._fire_OnKeyPressed(pin, __name__) def status_input(self, pin): - if self._polarity is 0: + if self._polarity == 0: return str(RPiGPIO.input(int(pin))).lower() in HIGH_LEVEL else: return str(RPiGPIO.input(int(pin))).lower() in LOW_LEVEL @@ -117,7 +117,7 @@ def set_output(self, pin, value, log_output=True): pin = int(pin) value = str(value).lower() in HIGH_LEVEL - if self._polarity is 1: + if self._polarity == 1: value = not value log_output = str(log_output).lower() in HIGH_LEVEL diff --git a/doorpi/keyboard/from_piface.py b/doorpi/keyboard/from_piface.py index cb139c02..ef6939a0 100644 --- a/doorpi/keyboard/from_piface.py +++ b/doorpi/keyboard/from_piface.py @@ -74,7 +74,7 @@ def event_detect(self, event): self._fire_OnKeyPressed(event.pin_num, __name__) def status_input(self, pin): - if self._polarity is 0: + if self._polarity == 0: return str(p.digital_read(int(pin))).lower() in HIGH_LEVEL else: return str(p.digital_read(int(pin))).lower() in LOW_LEVEL @@ -86,7 +86,7 @@ def set_output(self, pin, value, log_output=True): pin = int(pin) value = str(value).lower() in HIGH_LEVEL - if self._polarity is 1: + if self._polarity == 1: value = not value log_output = str(log_output).lower() in HIGH_LEVEL diff --git a/doorpi/keyboard/from_pn532.py b/doorpi/keyboard/from_pn532.py index 406dbffe..80bf5704 100644 --- a/doorpi/keyboard/from_pn532.py +++ b/doorpi/keyboard/from_pn532.py @@ -71,7 +71,7 @@ # copy source-dir to pythons libdir: # sudo cp -r nfc /usr/local/lib/python2.7/dist-packages/nfc # /TODO -from doorpi.keyboard.AbstractBaseClass import KeyboardAbstractBaseClass, HIGH_LEVEL, LOW_LEVEL +from doorpi.keyboard.AbstractBaseClass import KeyboardAbstractBaseClass import doorpi import threading diff --git a/doorpi/keyboard/from_rdm6300.py b/doorpi/keyboard/from_rdm6300.py index 52924b9b..7aea4426 100644 --- a/doorpi/keyboard/from_rdm6300.py +++ b/doorpi/keyboard/from_rdm6300.py @@ -62,7 +62,7 @@ # # RFID data: http://kampis-elektroecke.de/?page_id=3248 import doorpi -from doorpi.keyboard.AbstractBaseClass import KeyboardAbstractBaseClass, HIGH_LEVEL, LOW_LEVEL +from doorpi.keyboard.AbstractBaseClass import KeyboardAbstractBaseClass import threading import serial diff --git a/doorpi/keyboard/from_usb_plain.py b/doorpi/keyboard/from_usb_plain.py index a5200696..5e3c03fb 100644 --- a/doorpi/keyboard/from_usb_plain.py +++ b/doorpi/keyboard/from_usb_plain.py @@ -1,9 +1,8 @@ -from doorpi.keyboard.AbstractBaseClass import KeyboardAbstractBaseClass, HIGH_LEVEL, LOW_LEVEL +from doorpi.keyboard.AbstractBaseClass import KeyboardAbstractBaseClass import doorpi import threading import serial -import time from os import linesep as OS_LINESEP import logging diff --git a/doorpi/keyboard/from_wiegand.py b/doorpi/keyboard/from_wiegand.py index 8b6c6bbf..2124edc9 100644 --- a/doorpi/keyboard/from_wiegand.py +++ b/doorpi/keyboard/from_wiegand.py @@ -1,4 +1,4 @@ -from doorpi.keyboard.AbstractBaseClass import KeyboardAbstractBaseClass, HIGH_LEVEL, LOW_LEVEL +from doorpi.keyboard.AbstractBaseClass import KeyboardAbstractBaseClass import doorpi import RPi.GPIO as RPiGPIO @@ -26,12 +26,9 @@ def __init__(self, input_pins, output_pins, keyboard_name, conf_pre, conf_post, # read config file section_name = conf_pre + 'keyboard' + conf_post - self._data0 = doorpi.DoorPi().config.get( - section_name, 'data0') # w0 - data signal - self._data1 = doorpi.DoorPi().config.get( - section_name, 'data1') # w1 - data signal - self._timeout = doorpi.DoorPi().config.get(section_name, 'timeout', - 0.25) # time for reading data signal + self._data0 = doorpi.DoorPi().config.get(section_name, 'data0') # w0 - data signal + self._data1 = doorpi.DoorPi().config.get(section_name, 'data1') # w1 - data signal + self._timeout = doorpi.DoorPi().config.get(section_name, 'timeout', 0.25) # time for reading data signal # init vars self._nextInput = '' # stores input until timeout @@ -122,7 +119,8 @@ def _processData(self): # reset input signal self._nextInput = '' - def _verifyParity(evenParity, oddParity): + @staticmethod + def verifyParity(evenParity, oddParity): bitsEven = evenParity.count('1') bitsOdd = oddParity.count('1') return (bitsEven % 2 == 0) and (bitsOdd % 2 == 1) @@ -130,23 +128,24 @@ def _verifyParity(evenParity, oddParity): def _verify37Bit(input): # even parity (start: 0, length: 19) # odd parity (start: 18, length: 19) - return _verifyParity(input[0:19], input[18:]) + return Wiegand.verifyParity(input[0:19], input[18:]) def _verify34Bit(input): # even parity (start 0, length: 17) # odd parity (start: 17, length: 17) - return _verifyParity(input[0:17], input[17:]) + return Wiegand.verifyParity(input[0:17], input[17:]) def _verify26Bit(input): # even parity (start: 0, length: 13) # odd parity (start: 13, length: 13) - return _verifyParity(input[0:13], input[13:]) + return Wiegand.verifyParity(input[0:13], input[13:]) def _verify8Bit(input): # first 4bits equal reverse last 4 bits return (int(input[0:4], 2) == ~int(input[4:], 2)) - def _removeParityBits(input): + @staticmethod + def removeParityBits(input): # remove parity bits input = input[1:-1] # dual to decimal @@ -154,12 +153,12 @@ def _removeParityBits(input): def _interpret8Bit(input): # IIIICCCC signal format (I = inverse) - value = int(intput, 2) & 0x0F + value = int(input, 2) & 0x0F return {'fc': -1, 'value': value} def _interpret26Bit(input): # PFFFFFFFFCCCCCCCCCCCCCCCCP signal format - temp = _removeParityBits(input) + temp = Wiegand.removeParityBits(input) # mask: 000000001111111111111111 cardNumber = temp & 0x00FFFF # mask: 111111110000000000000000 @@ -172,14 +171,14 @@ def _interpret32Bit(input): def _interpret34Bit(input): # PFFFFFFFFFFFFFFFFCCCCCCCCCCCCCCCCP signal format - temp = _removeParityBits(input) + temp = Wiegand.removeParityBits(input) cardNumber = temp & 0x000FFFF facilityCode = (temp & 0x7FFF80000) >> 16 return {'fc': facilityCode, 'value': cardNumber} def _interpret37Bit(input): # PFFFFFFFFFFFFFFFFCCCCCCCCCCCCCCCCCCCP signal format - temp = _removeParityBits(input) + temp = Wiegand.removeParityBits(input) cardNumber = temp & 0x0007FFFF facilityCode = (temp & 0x7FFF80000) >> 19 return {'fc': facilityCode, 'value': cardNumber} @@ -189,8 +188,8 @@ def destroy(self): return self._shutdown = True - GPIO.remove_event_detect(self._data0) - GPIO.remove_event_detect(self._data1) + RPiGPIO.remove_event_detect(self._data0) + RPiGPIO.remove_event_detect(self._data1) doorpi.DoorPi().event_handler.unregister_source(__name__, True) self.__destroyed = True diff --git a/doorpi/metadata.py b/doorpi/metadata.py index 12d2248f..1d9a5cbf 100755 --- a/doorpi/metadata.py +++ b/doorpi/metadata.py @@ -35,6 +35,7 @@ url = 'https://github.com/motom001/DoorPi' url_raw = 'https://raw.githubusercontent.com/motom001/DoorPi' +# flake8: noqa W605 # created with: http://patorjk.com/software/taag/#p=display&f=Ogre&t=DoorPi epilog = ''' ___ ___ _ diff --git a/doorpi/sipphone/AbstractBaseClass.py b/doorpi/sipphone/AbstractBaseClass.py index 8a404998..238311d5 100644 --- a/doorpi/sipphone/AbstractBaseClass.py +++ b/doorpi/sipphone/AbstractBaseClass.py @@ -31,65 +31,63 @@ def video_devices(self): return [] @property def current_call_dump(self): return {} - def __init__(self): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def __init__(self): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) - def config(self, **kwargs): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def config(self, **kwargs): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) - def start(self): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def start(self): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) - def stop(self): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def stop(self): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) - def destroy(self): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def destroy(self): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) - def call(self, number): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def call(self, number): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) - def hangup(self): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) - def is_admin_number(self, number): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def hangup(self): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) + + def is_admin_number(self, number): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) def __del__(self): self.destroy() class RecorderAbstractBaseClass(object): - def __init__(self): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def __init__(self): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) + + def config(self, **kwargs): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) - def config(self, **kwargs): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def start(self): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) - def start(self): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def stop(self): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) - def stop(self): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) - def destroy(self): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def destroy(self): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) def __del__(self): self.destroy() class PlayerAbstractBaseClass(object): - def __init__(self): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def __init__(self): raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) - def config(self, **kwargs): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def config(self, **kwargs): + raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) - def start(self): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def start(self): raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) - def stop(self): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) - def destroy(self): raise NotImplementedError( - "Subclass %s should implement this!" % self.__class__.__name__) + def stop(self): raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) + def destroy(self): raise NotImplementedError("Subclass %s should implement this!" % self.__class__.__name__) def __del__(self): self.destroy() diff --git a/doorpi/sipphone/SipphoneInterface.py b/doorpi/sipphone/SipphoneInterface.py index 56a4521d..f60a317c 100644 --- a/doorpi/sipphone/SipphoneInterface.py +++ b/doorpi/sipphone/SipphoneInterface.py @@ -15,8 +15,7 @@ def load_sipphone(): conf_post = '' # read selected sipphone from config file - sipphone_name = doorpi.DoorPi().config.get('SIP-Phone', 'sipphonetyp', - find_first_installed_sipphone()) + sipphone_name = doorpi.DoorPi().config.get('SIP-Phone', 'sipphonetyp', find_first_installed_sipphone()) # try to load selected sipphone or fall back to dummy try: diff --git a/doorpi/sipphone/from_dummy.py b/doorpi/sipphone/from_dummy.py index fb16144a..be1f3734 100644 --- a/doorpi/sipphone/from_dummy.py +++ b/doorpi/sipphone/from_dummy.py @@ -1,9 +1,6 @@ from doorpi import DoorPi from .AbstractBaseClass import SipphoneAbstractBaseClass, RecorderAbstractBaseClass, PlayerAbstractBaseClass -import datetime -from time import sleep - import logging logger = logging.getLogger(__name__) logger.debug('%s loaded', __name__) @@ -91,8 +88,8 @@ def stop(self): def destroy(self): try: self.stop() - except: - pass + except Exception as exp: + logger.info(exp) DoorPi().event_handler.unregister_source(__name__, True) @@ -120,11 +117,3 @@ def destroy(self): DoorPi().event_handler.register_event('OnPlayerStopped', __name__) DoorPi().event_handler.register_event('OnPlayerCreated', __name__) DoorPi().event_handler('OnPlayerCreated', __name__) - - def start(self): DoorPi().event_handler('OnPlayerStarted', __name__) - - def stop(self): DoorPi().event_handler('OnPlayerStopped', __name__) - - def destroy(self): - self.stop() - DoorPi().event_handler.unregister_source(__name__, True) diff --git a/doorpi/sipphone/from_linphone.py b/doorpi/sipphone/from_linphone.py index 00f5064d..a7c8d3e0 100644 --- a/doorpi/sipphone/from_linphone.py +++ b/doorpi/sipphone/from_linphone.py @@ -2,7 +2,6 @@ from doorpi.sipphone.linphone_lib.CallBacks import LinphoneCallbacks from doorpi.sipphone.linphone_lib.Player import LinphonePlayer from doorpi.sipphone.linphone_lib.Recorder import LinphoneRecorder -from doorpi.media.CreateDialTone import generate_dial_tone from .AbstractBaseClass import SipphoneAbstractBaseClass, SIPPHONE_SECTION import linphone as lin diff --git a/doorpi/status/status_class.py b/doorpi/status/status_class.py index 7a501dfd..17d88095 100644 --- a/doorpi/status/status_class.py +++ b/doorpi/status/status_class.py @@ -1,6 +1,5 @@ import importlib -from datetime import datetime import json import logging logger = logging.getLogger(__name__) diff --git a/doorpi/status/status_lib/environment.py b/doorpi/status/status_lib/environment.py index f98e8f08..a21be128 100644 --- a/doorpi/status/status_lib/environment.py +++ b/doorpi/status/status_lib/environment.py @@ -1,5 +1,4 @@ import importlib -import json import logging logger = logging.getLogger(__name__) diff --git a/doorpi/status/status_lib/event_handler.py b/doorpi/status/status_lib/event_handler.py index ee274bb2..9d1c255d 100644 --- a/doorpi/status/status_lib/event_handler.py +++ b/doorpi/status/status_lib/event_handler.py @@ -1,4 +1,3 @@ - import logging logger = logging.getLogger(__name__) logger.debug("%s loaded", __name__) diff --git a/doorpi/status/status_lib/history_event.py b/doorpi/status/status_lib/history_event.py index affa97d2..390987fb 100644 --- a/doorpi/status/status_lib/history_event.py +++ b/doorpi/status/status_lib/history_event.py @@ -1,4 +1,3 @@ - import logging logger = logging.getLogger(__name__) logger.debug("%s loaded", __name__) @@ -14,7 +13,7 @@ def get(*args, **kwargs): filter = kwargs['name'][0] try: max_count = int(kwargs['value'][0]) - except: + except: # noqa: E722 max_count = 100 return kwargs['DoorPiObject'].event_handler.db.get_event_log_entries(max_count, filter) diff --git a/doorpi/status/status_lib/keyboard.py b/doorpi/status/status_lib/keyboard.py index 71616b0f..e2837ab3 100644 --- a/doorpi/status/status_lib/keyboard.py +++ b/doorpi/status/status_lib/keyboard.py @@ -1,5 +1,3 @@ -from datetime import datetime - import logging logger = logging.getLogger(__name__) logger.debug("%s loaded", __name__) @@ -43,5 +41,5 @@ def get(*args, **kwargs): def is_active(doorpi_object): try: return True if doorpi_object.keyboard.name else False - except: + except: # noqa: E722 return False diff --git a/doorpi/status/webserver.py b/doorpi/status/webserver.py index a23b6c0b..ae4091b6 100755 --- a/doorpi/status/webserver.py +++ b/doorpi/status/webserver.py @@ -5,7 +5,6 @@ from http.server import HTTPServer from socketserver import ThreadingMixIn -from random import randrange import os import logging @@ -135,7 +134,7 @@ def config_status(self): return check_config(self.config) @property def own_url(self): - if self.server_port is 80: + if self.server_port == 80: return ('http://{0}/').format(self.server_name) else: return ('http://{0}:{1}/').format(self.server_name, self.server_port) @@ -187,9 +186,8 @@ def handle_while_not_shutdown(self): def fake_request(self): try: from urllib.request import urlopen as fake_request - fake_request( - ('http://{0}:{1}/').format(self.server_name, self.server_port), timeout=0) - except: + fake_request(('http://{0}:{1}/').format(self.server_name, self.server_port), timeout=0) + except: # noqa E722 pass def init_shutdown(self): diff --git a/doorpi/status/webserver_lib/request_handler.py b/doorpi/status/webserver_lib/request_handler.py index abee1cdf..6c441d09 100755 --- a/doorpi/status/webserver_lib/request_handler.py +++ b/doorpi/status/webserver_lib/request_handler.py @@ -4,13 +4,18 @@ import os from mimetypes import guess_type from http.server import BaseHTTPRequestHandler -import cgi # for parsing POST from urllib.parse import urlparse, parse_qs # parsing parameters and url import re # regex for area import json # for virtual resources from urllib.request import urlopen as load_online_fallback from urllib.parse import unquote_plus -from .request_handler_static_functions import * +from .request_handler_static_functions import ( + control_config_delete_key, + control_config_get_configfile, + control_config_get_value, + control_config_save, + control_config_set_value +) import logging logger = logging.getLogger(__name__) @@ -74,8 +79,6 @@ def do_GET(self): return parsed_path = urlparse(self.path) - # doorpi.DoorPi().event_handler('OnWebServerRequest', __name__, {'header': self.headers.items(), 'path': parsed_path}) - # doorpi.DoorPi().event_handler('OnWebServerRequestGet', __name__, {'header': self.headers.items(), 'path': parsed_path}) if parsed_path.path == '/': return self.return_redirection('dashboard/pages/index.html') @@ -188,9 +191,15 @@ def return_virtual_resource(self, prepared_object, return_type='json'): if return_type in ['json', 'default']: return self.return_message(json.dumps(prepared_object), 'application/json; charset=utf-8') if return_type in ["json_parsed", "json.parsed"]: - return self.return_message(self.parse_content(json.dumps(prepared_object)), 'application/json; charset=utf-8') + return self.return_message( + self.parse_content(json.dumps(prepared_object)), + 'application/json; charset=utf-8' + ) elif return_type in ['json_beautified', 'json.beautified', 'beautified.json']: - return self.return_message(json.dumps(prepared_object, sort_keys=True, indent=4), 'application/json; charset=utf-8') + return self.return_message( + json.dumps(prepared_object, sort_keys=True, indent=4), + 'application/json; charset=utf-8' + ) elif return_type in ['json_beautified_parsed', 'json.beautified.parsed', 'beautified.json.parsed', '']: return self.return_message(self.parse_content(json.dumps(prepared_object, sort_keys=True, indent=4)), 'application/json; charset=utf-8') @@ -198,12 +207,12 @@ def return_virtual_resource(self, prepared_object, return_type='json'): return self.return_message(str(prepared_object)) elif return_type in ['repr']: return self.return_message(repr(prepared_object)) - elif return_type is 'html': + elif return_type == 'html': return self.return_message(prepared_object, 'text/html; charset=utf-8') else: try: return self.return_message(repr(prepared_object)) - except: + except: # noqa E722 return self.return_message(str(prepared_object)) pass diff --git a/doorpi/status/webserver_lib/session_handler.py b/doorpi/status/webserver_lib/session_handler.py index 6a374955..c1e6da53 100755 --- a/doorpi/status/webserver_lib/session_handler.py +++ b/doorpi/status/webserver_lib/session_handler.py @@ -1,5 +1,4 @@ import doorpi -from doorpi.action.base import SingleAction import time # session timestamp diff --git a/tox.ini b/tox.ini index 6deafc26..f5258b6f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,2 +1,4 @@ [flake8] max-line-length = 120 +exclude = + doorpi/status/requirements_lib/req_*.py