Lint fixes

ticket-769
Vadim vtroshchinskiy 2024-10-08 13:43:27 +02:00
parent ebef0dc565
commit 2d40e2fb93
1 changed files with 11 additions and 17 deletions

View File

@ -16,9 +16,6 @@ import tempfile
import logging import logging
import subprocess import subprocess
import pwd
import grp
import datetime
import json import json
import sys import sys
@ -126,7 +123,7 @@ class NTFSLibrary:
""" """
self.logger.info(f"Creating NTFS in {device} with label {label}") self.logger.info(f"Creating NTFS in {device} with label {label}")
subprocess.run(["/usr/sbin/mkntfs", device, "-Q", "-L", label]) subprocess.run(["/usr/sbin/mkntfs", device, "-Q", "-L", label], check=True)
def mount_filesystem(self, device, mountpoint): def mount_filesystem(self, device, mountpoint):
@ -1114,7 +1111,7 @@ class OpengnsysGitLibrary:
self.logger.debug("Initializing") self.logger.debug("Initializing")
mounts = self._parse_mounts() mounts = self._parse_mounts()
self.logger.debug(f"Restoring metadata in {path}") self.logger.info(f"Restoring metadata in {path}")
meta_dir = os.path.join(path, ".opengnsys-metadata") meta_dir = os.path.join(path, ".opengnsys-metadata")
if not os.path.exists(meta_dir): if not os.path.exists(meta_dir):
@ -1123,7 +1120,7 @@ class OpengnsysGitLibrary:
# Process renames first so that all the filenames are as they should be # Process renames first so that all the filenames are as they should be
# for the following steps. # for the following steps.
self.logger.debug("Processing renamed.jsonl") self.logger.info("Processing renamed.jsonl")
with open(os.path.join(meta_dir, "renamed.jsonl"), "r", encoding='utf-8') as gitignores_file: with open(os.path.join(meta_dir, "renamed.jsonl"), "r", encoding='utf-8') as gitignores_file:
for line in gitignores_file: for line in gitignores_file:
#self.logger.debug(f"Line: {line}") #self.logger.debug(f"Line: {line}")
@ -1148,7 +1145,7 @@ class OpengnsysGitLibrary:
self.logger.warning(f"Can't rename {renamed_file_path} => {orig_file_path}: Source file not found") self.logger.warning(f"Can't rename {renamed_file_path} => {orig_file_path}: Source file not found")
if not destructive_only: if not destructive_only:
self.logger.debug("Processing empty_directories.jsonl") self.logger.info("Processing empty_directories.jsonl")
with open(os.path.join(meta_dir, "empty_directories.jsonl"), "r", encoding='utf-8') 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: for line in empties_file:
empties_data = json.loads(line) empties_data = json.loads(line)
@ -1169,7 +1166,7 @@ class OpengnsysGitLibrary:
os.unlink(empty_dir_keep) os.unlink(empty_dir_keep)
if not destructive_only: if not destructive_only:
self.logger.debug("Processing unix_permissions.jsonl") self.logger.info("Processing unix_permissions.jsonl")
with open(os.path.join(meta_dir, "unix_permissions.jsonl"), "r", encoding='utf-8') 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: for line in acls_file:
perms_data = json.loads(line) perms_data = json.loads(line)
@ -1195,7 +1192,7 @@ class OpengnsysGitLibrary:
if not destructive_only: if not destructive_only:
self.logger.debug("Processing acls.jsonl") self.logger.info("Processing acls.jsonl")
with open(os.path.join(meta_dir, "acls.jsonl"), "r", encoding='utf-8') as acls_file: with open(os.path.join(meta_dir, "acls.jsonl"), "r", encoding='utf-8') as acls_file:
for line in acls_file: for line in acls_file:
@ -1216,10 +1213,11 @@ class OpengnsysGitLibrary:
#self.logger.debug(f"ACL: {acl_text}" ) #self.logger.debug(f"ACL: {acl_text}" )
self.logger.debug(f"Applying ACL to {acl_file_path}") self.logger.debug(f"Applying ACL to {acl_file_path}")
#acl.applyto(acl_file_path) if os.path.exists(acl_file_path):
acl.applyto(acl_file_path)
if not destructive_only: if not destructive_only:
self.logger.debug("Processing xattrs.jsonl") self.logger.info("Processing xattrs.jsonl")
with open(os.path.join(meta_dir, "xattrs.jsonl"), "r", encoding='utf-8') as xattrs_file: with open(os.path.join(meta_dir, "xattrs.jsonl"), "r", encoding='utf-8') as xattrs_file:
for line in xattrs_file: for line in xattrs_file:
xattrs_data = json.loads(line) xattrs_data = json.loads(line)
@ -1232,7 +1230,7 @@ class OpengnsysGitLibrary:
#self.logger.debug(f"Line: {line}") #self.logger.debug(f"Line: {line}")
self.logger.debug("Processing special_files.jsonl") self.logger.info("Processing special_files.jsonl")
with open(os.path.join(meta_dir, "special_files.jsonl"), "r", encoding='utf-8') 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: for line in specials_file:
#self.logger.debug(f"Line: {line}") #self.logger.debug(f"Line: {line}")
@ -1264,7 +1262,7 @@ class OpengnsysGitLibrary:
os.chown(full_path, data['uid'], data['gid']) os.chown(full_path, data['uid'], data['gid'])
os.chmod(full_path, file_mode) os.chmod(full_path, file_mode)
self.logger.debug("Metadata restoration completed.") self.logger.info("Metadata restoration completed.")
def _configure_repo(self, repo): def _configure_repo(self, repo):
""" """
@ -1675,7 +1673,3 @@ if __name__ == '__main__':
else: else:
print("Debe especificar una acción") print("Debe especificar una acción")
# #