Lint fixes
parent
dbad59b012
commit
a1cd039d4f
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# pylint: disable=locally-disabled, line-too-long, logging-fstring-interpolation, too-many-lines
|
||||
|
||||
### NOTES:
|
||||
# Install:
|
||||
# python3-git
|
||||
|
@ -33,7 +35,7 @@ from enum import Enum
|
|||
|
||||
|
||||
class OgProgressPrinter(git.RemoteProgress):
|
||||
def __init(self, logger):
|
||||
def __init__(self, logger):
|
||||
self.logger = logger
|
||||
|
||||
def update(self, op_code, cur_count, max_count=None, message=""):
|
||||
|
@ -102,7 +104,6 @@ class NTFSLibrary:
|
|||
self.implementation = implementation
|
||||
|
||||
self.logger.debug("Initializing")
|
||||
None
|
||||
|
||||
def create_filesystem(self, device, label):
|
||||
"""
|
||||
|
@ -321,7 +322,7 @@ class OpengnsysGitLibrary:
|
|||
|
||||
self.logger.debug("Parsing /proc/mounts")
|
||||
|
||||
with open("/proc/mounts", 'r') as mounts:
|
||||
with open("/proc/mounts", 'r', encoding='utf-8') as mounts:
|
||||
for line in mounts:
|
||||
parts = line.split()
|
||||
data = {}
|
||||
|
@ -422,7 +423,7 @@ class OpengnsysGitLibrary:
|
|||
ignore_file = base_path + "/.gitignore"
|
||||
|
||||
self.logger.debug("Creating ignore list: " + ignore_file)
|
||||
with open(ignore_file, 'w') as f:
|
||||
with open(ignore_file, 'w', encoding='utf-8') as f:
|
||||
f.write("\n".join(self.default_ignore_list))
|
||||
f.write("\n")
|
||||
|
||||
|
@ -438,7 +439,7 @@ class OpengnsysGitLibrary:
|
|||
params = {}
|
||||
self.logger.debug("Parsing kernel parameters")
|
||||
|
||||
with open("/proc/cmdline") as cmdline:
|
||||
with open("/proc/cmdline", encoding='utf-8') as cmdline:
|
||||
line = cmdline.readline()
|
||||
parts = line.split()
|
||||
for part in parts:
|
||||
|
@ -446,7 +447,7 @@ class OpengnsysGitLibrary:
|
|||
key, value = part.split("=")
|
||||
params[key] = value
|
||||
|
||||
self.logger.debug("%i parameters found" % len(params))
|
||||
self.logger.debug("%i parameters found", len(params))
|
||||
return params
|
||||
|
||||
def _is_filesystem(self, path):
|
||||
|
@ -462,7 +463,7 @@ class OpengnsysGitLibrary:
|
|||
Returns:
|
||||
bool: True if the path is a filesystem root, False otherwise.
|
||||
"""
|
||||
with open('/proc/mounts', 'r') as mounts:
|
||||
with open('/proc/mounts', 'r', encoding='utf-8') as mounts:
|
||||
for mount in mounts:
|
||||
parts = mount.split()
|
||||
self.logger.debug(f"Parts: {parts}")
|
||||
|
@ -636,7 +637,7 @@ class OpengnsysGitLibrary:
|
|||
disks = []
|
||||
|
||||
self.logger.debug("Looking for EFI partition")
|
||||
with open("/proc/partitions", "r") as partitions_file:
|
||||
with open("/proc/partitions", "r", encoding='utf-8') as partitions_file:
|
||||
line_num=0
|
||||
for line in partitions_file:
|
||||
if line_num >=2:
|
||||
|
@ -675,7 +676,7 @@ class OpengnsysGitLibrary:
|
|||
elif os.path.isdir(file_path):
|
||||
shutil.rmtree(file_path)
|
||||
except Exception as e:
|
||||
self.logger.warning('Failed to delete %s. Error: %s' % (file_path, e))
|
||||
self.logger.warning('Failed to delete %s. Error: %s', file_path, e)
|
||||
|
||||
|
||||
def _runBashFunction(self, function, arguments):
|
||||
|
@ -832,7 +833,7 @@ class OpengnsysGitLibrary:
|
|||
|
||||
# https://jsonlines.org/
|
||||
|
||||
metadata_file = open(os.path.join(meta_dir, "metadata.json.new"), "w")
|
||||
metadata_file = open(os.path.join(meta_dir, "metadata.json.new"), "w", encoding='utf-8')
|
||||
metadata = {}
|
||||
metadata["efi_boot"] = self._is_efi()
|
||||
|
||||
|
@ -848,13 +849,13 @@ class OpengnsysGitLibrary:
|
|||
|
||||
|
||||
|
||||
empties_file = open(os.path.join(meta_dir, "empty_directories.jsonl.new"), "w")
|
||||
specials_file = open(os.path.join(meta_dir, "special_files.jsonl.new"), "w")
|
||||
acls_file = open(os.path.join(meta_dir, "acls.jsonl.new"), "w")
|
||||
perms_file = open(os.path.join(meta_dir, "unix_permissions.jsonl.new"), "w")
|
||||
xattrs_file = open(os.path.join(meta_dir, "xattrs.jsonl.new"), "w")
|
||||
renamed_file = open(os.path.join(meta_dir, "renamed.jsonl.new"), "w")
|
||||
filesystems_file = open(os.path.join(meta_dir, "filesystems.json.new"), "w")
|
||||
empties_file = open(os.path.join(meta_dir, "empty_directories.jsonl.new"), "w", encoding='utf-8')
|
||||
specials_file = open(os.path.join(meta_dir, "special_files.jsonl.new"), "w", encoding='utf-8')
|
||||
acls_file = open(os.path.join(meta_dir, "acls.jsonl.new"), "w", encoding='utf-8')
|
||||
perms_file = open(os.path.join(meta_dir, "unix_permissions.jsonl.new"), "w", encoding='utf-8')
|
||||
xattrs_file = open(os.path.join(meta_dir, "xattrs.jsonl.new"), "w", encoding='utf-8')
|
||||
renamed_file = open(os.path.join(meta_dir, "renamed.jsonl.new"), "w", encoding='utf-8')
|
||||
filesystems_file = open(os.path.join(meta_dir, "filesystems.json.new"), "w", encoding='utf-8')
|
||||
|
||||
ntfs = False
|
||||
|
||||
|
@ -1123,7 +1124,7 @@ class OpengnsysGitLibrary:
|
|||
# Process renames first so that all the filenames are as they should be
|
||||
# for the following steps.
|
||||
self.logger.debug("Processing renamed.jsonl")
|
||||
with open(os.path.join(meta_dir, "renamed.jsonl"), "r") as gitignores_file:
|
||||
with open(os.path.join(meta_dir, "renamed.jsonl"), "r", encoding='utf-8') as gitignores_file:
|
||||
for line in gitignores_file:
|
||||
#self.logger.debug(f"Line: {line}")
|
||||
renamed_data = json.loads(line)
|
||||
|
@ -1148,7 +1149,7 @@ class OpengnsysGitLibrary:
|
|||
|
||||
if not destructive_only:
|
||||
self.logger.debug("Processing empty_directories.jsonl")
|
||||
with open(os.path.join(meta_dir, "empty_directories.jsonl"), "r") as empties_file:
|
||||
with open(os.path.join(meta_dir, "empty_directories.jsonl"), "r", encoding='utf-8') as empties_file:
|
||||
for line in empties_file:
|
||||
empties_data = json.loads(line)
|
||||
empty_dir = empties_data['dir']
|
||||
|
@ -1169,7 +1170,7 @@ class OpengnsysGitLibrary:
|
|||
|
||||
if not destructive_only:
|
||||
self.logger.debug("Processing unix_permissions.jsonl")
|
||||
with open(os.path.join(meta_dir, "unix_permissions.jsonl"), "r") as acls_file:
|
||||
with open(os.path.join(meta_dir, "unix_permissions.jsonl"), "r", encoding='utf-8') as acls_file:
|
||||
for line in acls_file:
|
||||
perms_data = json.loads(line)
|
||||
#self.logger.debug(f"Data: {acls_data}")
|
||||
|
@ -1195,7 +1196,7 @@ class OpengnsysGitLibrary:
|
|||
|
||||
if not destructive_only:
|
||||
self.logger.debug("Processing acls.jsonl")
|
||||
with open(os.path.join(meta_dir, "acls.jsonl"), "r") as acls_file:
|
||||
with open(os.path.join(meta_dir, "acls.jsonl"), "r", encoding='utf-8') as acls_file:
|
||||
for line in acls_file:
|
||||
|
||||
# docs: https://pylibacl.k1024.org/module.html#posix1e.ACL.to_any_text
|
||||
|
@ -1219,7 +1220,7 @@ class OpengnsysGitLibrary:
|
|||
|
||||
if not destructive_only:
|
||||
self.logger.debug("Processing xattrs.jsonl")
|
||||
with open(os.path.join(meta_dir, "xattrs.jsonl"), "r") as xattrs_file:
|
||||
with open(os.path.join(meta_dir, "xattrs.jsonl"), "r", encoding='utf-8') as xattrs_file:
|
||||
for line in xattrs_file:
|
||||
xattrs_data = json.loads(line)
|
||||
xattrs_file = xattrs_data['file']
|
||||
|
@ -1232,7 +1233,7 @@ class OpengnsysGitLibrary:
|
|||
#self.logger.debug(f"Line: {line}")
|
||||
|
||||
self.logger.debug("Processing special_files.jsonl")
|
||||
with open(os.path.join(meta_dir, "special_files.jsonl"), "r") as specials_file:
|
||||
with open(os.path.join(meta_dir, "special_files.jsonl"), "r", encoding='utf-8') as specials_file:
|
||||
for line in specials_file:
|
||||
#self.logger.debug(f"Line: {line}")
|
||||
data = json.loads(line)
|
||||
|
|
Loading…
Reference in New Issue