mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-09-30 19:33:42 +08:00
Make pylint more strict (#1626)
* make pylint more strict * cleanup in progress * done cleaning up * no opendbc
This commit is contained in:
+12
-5
@@ -30,6 +30,7 @@ import threading
|
||||
from enum import Enum
|
||||
from common.basedir import PARAMS
|
||||
|
||||
|
||||
def mkdirs_exists_ok(path):
|
||||
try:
|
||||
os.makedirs(path)
|
||||
@@ -143,6 +144,10 @@ class DBAccessor():
|
||||
|
||||
def get(self, key):
|
||||
self._check_entered()
|
||||
|
||||
if self._vals is None:
|
||||
return None
|
||||
|
||||
try:
|
||||
return self._vals[key]
|
||||
except KeyError:
|
||||
@@ -195,7 +200,7 @@ class DBReader(DBAccessor):
|
||||
finally:
|
||||
lock.release()
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
pass
|
||||
|
||||
|
||||
@@ -221,14 +226,14 @@ class DBWriter(DBAccessor):
|
||||
os.chmod(self._path, 0o777)
|
||||
self._lock = self._get_lock(True)
|
||||
self._vals = self._read_values_locked()
|
||||
except:
|
||||
except Exception:
|
||||
os.umask(self._prev_umask)
|
||||
self._prev_umask = None
|
||||
raise
|
||||
|
||||
return self
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self._check_entered()
|
||||
|
||||
try:
|
||||
@@ -302,12 +307,13 @@ def read_db(params_path, key):
|
||||
except IOError:
|
||||
return None
|
||||
|
||||
|
||||
def write_db(params_path, key, value):
|
||||
if isinstance(value, str):
|
||||
value = value.encode('utf8')
|
||||
|
||||
prev_umask = os.umask(0)
|
||||
lock = FileLock(params_path+"/.lock", True)
|
||||
lock = FileLock(params_path + "/.lock", True)
|
||||
lock.acquire()
|
||||
|
||||
try:
|
||||
@@ -324,12 +330,13 @@ def write_db(params_path, key, value):
|
||||
os.umask(prev_umask)
|
||||
lock.release()
|
||||
|
||||
|
||||
class Params():
|
||||
def __init__(self, db=PARAMS):
|
||||
self.db = db
|
||||
|
||||
# create the database if it doesn't exist...
|
||||
if not os.path.exists(self.db+"/d"):
|
||||
if not os.path.exists(self.db + "/d"):
|
||||
with self.transaction(write=True):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user