mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
Clean from logging
This commit is contained in:
parent
9c566be3d1
commit
e79e1e6fda
12 changed files with 10 additions and 87 deletions
|
@ -2,7 +2,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import hashlib
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
from urllib.parse import unquote
|
||||
|
@ -11,7 +10,6 @@ from slpkg.utilities import Utilities
|
|||
from slpkg.error_messages import Errors
|
||||
from slpkg.views.views import View
|
||||
from slpkg.views.asciibox import AsciiBox
|
||||
from slpkg.logging_config import LoggingConfig
|
||||
|
||||
|
||||
class Md5sum:
|
||||
|
@ -23,11 +21,6 @@ class Md5sum:
|
|||
self.utils = Utilities()
|
||||
self.view = View(flags)
|
||||
|
||||
logging.basicConfig(filename=LoggingConfig.log_file,
|
||||
filemode=LoggingConfig.filemode,
|
||||
encoding=LoggingConfig.encoding,
|
||||
level=LoggingConfig.level)
|
||||
|
||||
def md5sum(self, path: Union[str, Path], source: str, checksum: str) -> None:
|
||||
""" Checksum the source. """
|
||||
source_file = unquote(source)
|
||||
|
@ -47,7 +40,4 @@ class Md5sum:
|
|||
with open(filename, 'rb') as file:
|
||||
return file.read()
|
||||
except FileNotFoundError:
|
||||
logger = logging.getLogger(LoggingConfig.date_time)
|
||||
logger.exception(f'{self.__class__.__name__}: '
|
||||
f'{self.__class__.read_binary_file.__name__}')
|
||||
self.errors.raise_error_message(f"No such file or directory: '{filename}'", exit_status=20)
|
||||
|
|
|
@ -7,7 +7,6 @@ from typing import Any
|
|||
from pathlib import Path
|
||||
from dataclasses import dataclass
|
||||
|
||||
from slpkg.logging_config import LoggingConfig
|
||||
from slpkg.toml_error_message import TomlErrors
|
||||
|
||||
|
||||
|
@ -148,7 +147,6 @@ class Configs:
|
|||
tmp_slpkg,
|
||||
slpkg_log_path,
|
||||
download_only_path,
|
||||
LoggingConfig.log_path
|
||||
]
|
||||
|
||||
for path in paths:
|
||||
|
|
|
@ -10,7 +10,7 @@ from slpkg.views.asciibox import AsciiBox
|
|||
class Dependees(Configs):
|
||||
""" Prints the packages that depend on. """
|
||||
|
||||
def __init__(self, data: dict, packages: list, flags: list, repository: str):
|
||||
def __init__(self, data: dict, packages: list, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
self.data: dict = data
|
||||
self.packages: list = packages
|
||||
|
@ -24,8 +24,6 @@ class Dependees(Configs):
|
|||
self.var: str = self.ascii.vertical_and_right
|
||||
self.package_version: str = ''
|
||||
|
||||
self.is_binary: bool = self.utils.is_binary_repo(repository)
|
||||
|
||||
self.option_for_full_reverse: bool = self.utils.is_option(
|
||||
('-E', '--full-reverse'), flags)
|
||||
|
||||
|
@ -48,7 +46,7 @@ class Dependees(Configs):
|
|||
def find_requires(self, package: str) -> Generator:
|
||||
""" Find requires that package dependees. """
|
||||
for name, data in self.data.items():
|
||||
if package in data['requires'].split():
|
||||
if package in data['requires']:
|
||||
yield name, data['requires']
|
||||
|
||||
def view_the_title(self) -> None:
|
||||
|
|
|
@ -36,7 +36,6 @@ class DownloadOnly(Configs):
|
|||
self.repos.ponce_repo_name: self.repos.ponce_repo_path
|
||||
}
|
||||
|
||||
self.is_binary: bool = self.utils.is_binary_repo(repository)
|
||||
self.option_for_directory: bool = self.utils.is_option(
|
||||
('-z', '--directory='), flags)
|
||||
|
||||
|
@ -48,7 +47,7 @@ class DownloadOnly(Configs):
|
|||
start: float = time.time()
|
||||
|
||||
for pkg in packages:
|
||||
if self.is_binary:
|
||||
if self.repository not in [self.repos.sbo_repo_name, self.repos.ponce_repo_name]:
|
||||
self.save_binary_sources(pkg)
|
||||
else:
|
||||
self.save_slackbuild_sources(pkg)
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class LoggingConfig:
|
||||
date_now = datetime.now()
|
||||
level = logging.INFO
|
||||
filemode: str = 'w'
|
||||
encoding: str = 'utf-8'
|
||||
log_path: Path = Path('/var/log/slpkg/')
|
||||
log_file: Path = Path(log_path, 'slpkg_runtime.log')
|
||||
date: str = f'{date_now.day}/{date_now.month}/{date_now.year}'
|
||||
time: str = f'{date_now.hour}:{date_now.minute}:{date_now.second}'
|
||||
date_time: str = f'{date} {time}'
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
import sys
|
||||
import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from slpkg.checks import Check
|
||||
|
@ -26,7 +25,6 @@ from slpkg.dialog_configs import FormConfigs
|
|||
from slpkg.check_updates import CheckUpdates
|
||||
from slpkg.download_only import DownloadOnly
|
||||
from slpkg.sbos.slackbuild import Slackbuilds
|
||||
from slpkg.logging_config import LoggingConfig
|
||||
from slpkg.find_installed import FindInstalled
|
||||
from slpkg.views.view_package import ViewPackage
|
||||
from slpkg.remove_packages import RemovePackages
|
||||
|
@ -302,16 +300,6 @@ class Menu(Configs):
|
|||
self.check = Check(self.repository)
|
||||
self.choose = Choose(self.repository)
|
||||
|
||||
logging.basicConfig(filename=LoggingConfig.log_file,
|
||||
filemode=LoggingConfig.filemode,
|
||||
encoding=LoggingConfig.encoding,
|
||||
level=LoggingConfig.level)
|
||||
|
||||
logger = logging.getLogger(LoggingConfig.date_time)
|
||||
logger.info(f'{self.__class__.__name__}: '
|
||||
f'{self.__class__.__init__.__name__}: '
|
||||
f'{args=}, {self.flags=}, {self.repository=}')
|
||||
|
||||
def load_database(self):
|
||||
if self.repository != '*' and not self.data:
|
||||
print('\rDatabase loading... ', end='')
|
||||
|
@ -690,9 +678,6 @@ class Menu(Configs):
|
|||
flags: list = self.commands[self.args[1]]
|
||||
Help(self.args[1], flags).view()
|
||||
except KeyError:
|
||||
logger = logging.getLogger(LoggingConfig.date_time)
|
||||
logger.exception(f'{self.__class__.__name__}: '
|
||||
f'{self.__class__.help_for_commands.__name__}')
|
||||
self.usage.help_minimal(f"{self.prog_name}: invalid argument '{''.join(self.args[1])}'")
|
||||
else:
|
||||
self.usage.help_short(1)
|
||||
|
|
|
@ -34,7 +34,7 @@ class MultiProcess(Configs):
|
|||
failed: str = f'{self.red}{self.ascii.failed}{self.endc}'
|
||||
|
||||
# Starting multiprocessing
|
||||
process_1 = Process(target=self.utils.process, args=(command, self.stderr, self.stdout, filename))
|
||||
process_1 = Process(target=self.utils.process, args=(command, self.stderr, self.stdout,))
|
||||
process_2 = Process(target=self.progress.progress_bar, args=(progress_message, filename))
|
||||
|
||||
process_1.start()
|
||||
|
@ -54,4 +54,4 @@ class MultiProcess(Configs):
|
|||
# Restore the terminal cursor
|
||||
print('\x1b[?25h', self.endc)
|
||||
else:
|
||||
self.utils.process(command, self.stderr, self.stdout, filename)
|
||||
self.utils.process(command, self.stderr, self.stdout)
|
||||
|
|
|
@ -41,7 +41,6 @@ class RemovePackages(Configs):
|
|||
('-y', '--yes'), flags)
|
||||
|
||||
def remove(self) -> None:
|
||||
self.query_logs_dependencies()
|
||||
self.add_packages_for_remove()
|
||||
self.save_dependencies_for_remove()
|
||||
self.remove_doubles_dependencies()
|
||||
|
@ -104,7 +103,6 @@ class RemovePackages(Configs):
|
|||
continue
|
||||
|
||||
self.multi_proc.process(command, package, progress_message)
|
||||
self.delete_package_from_logs(name)
|
||||
|
||||
def is_dependency(self, name: str) -> list:
|
||||
dependencies: list = []
|
||||
|
@ -132,18 +130,6 @@ class RemovePackages(Configs):
|
|||
if i > 1:
|
||||
print(f"{'':>8}{self.cyan}{dependency}{self.endc}")
|
||||
|
||||
def query_logs_dependencies(self) -> None:
|
||||
package_requires: tuple = self.session.query(
|
||||
LogsDependencies.name, LogsDependencies.requires).all()
|
||||
for package in package_requires:
|
||||
self.logs_dependencies[package[0]] = package[1].split()
|
||||
|
||||
def delete_package_from_logs(self, package) -> None:
|
||||
if not self.option_for_resolve_off:
|
||||
self.session.query(LogsDependencies).filter(
|
||||
LogsDependencies.name == package).delete()
|
||||
self.session.commit()
|
||||
|
||||
def choose_dependencies_for_remove(self) -> None:
|
||||
if self.dependencies and self.dialog:
|
||||
height: int = 10
|
||||
|
|
|
@ -23,8 +23,6 @@ class SearchPackage(Configs):
|
|||
self.repo_data: dict = {}
|
||||
self.data_dict: dict = {}
|
||||
|
||||
self.is_binary: bool = self.utils.is_binary_repo(repository)
|
||||
|
||||
self.option_for_no_case: bool = self.utils.is_option(
|
||||
('-m', '--no-case'), flags)
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ from slpkg.utilities import Utilities
|
|||
from slpkg.views.asciibox import AsciiBox
|
||||
from slpkg.sbos.dependencies import Requires
|
||||
from slpkg.binaries.required import Required
|
||||
from slpkg.repositories import Repositories
|
||||
|
||||
|
||||
class Tracking(Configs):
|
||||
|
@ -16,9 +17,11 @@ class Tracking(Configs):
|
|||
self.data: dict = data
|
||||
self.packages: list = packages
|
||||
self.flags: list = flags
|
||||
self.repository: str = repository
|
||||
|
||||
self.ascii = AsciiBox()
|
||||
self.utils = Utilities()
|
||||
self.repos = Repositories()
|
||||
|
||||
self.llc: str = self.ascii.lower_left_corner
|
||||
self.hl: str = self.ascii.horizontal_line
|
||||
|
@ -31,8 +34,6 @@ class Tracking(Configs):
|
|||
self.count_requires: int = 0
|
||||
self.require_length: int = 0
|
||||
|
||||
self.is_binary: bool = self.utils.is_binary_repo(repository)
|
||||
|
||||
self.option_for_pkg_version: bool = self.utils.is_option(
|
||||
('-p', '--pkg-version'), flags)
|
||||
|
||||
|
@ -98,7 +99,7 @@ class Tracking(Configs):
|
|||
self.package_version: str = self.data[package]['version']
|
||||
|
||||
def set_package_requires(self, package: str) -> None:
|
||||
if self.is_binary:
|
||||
if self.repository not in [self.repos.sbo_repo_name, self.repos.ponce_repo_name]:
|
||||
self.package_requires: tuple = Required(self.data, package).resolve()
|
||||
else:
|
||||
self.package_requires: tuple = Requires(self.data, package).resolve()
|
||||
|
|
|
@ -38,8 +38,6 @@ class UpdateRepositories(Configs):
|
|||
|
||||
self.repos_for_update: dict = {}
|
||||
|
||||
self.is_binary: bool = self.utils.is_binary_repo(repository)
|
||||
|
||||
self.option_for_repository: bool = self.utils.is_option(
|
||||
('-o', '--repository='), flags)
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
from typing import Generator
|
||||
from pkg_resources import parse_version
|
||||
|
||||
|
@ -9,7 +8,6 @@ from slpkg.rules import Rules
|
|||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.repositories import Repositories
|
||||
from slpkg.logging_config import LoggingConfig
|
||||
|
||||
|
||||
class Upgrade(Configs):
|
||||
|
@ -24,11 +22,6 @@ class Upgrade(Configs):
|
|||
self.repos = Repositories()
|
||||
self.rules = Rules()
|
||||
|
||||
logging.basicConfig(filename=LoggingConfig.log_file,
|
||||
filemode=LoggingConfig.filemode,
|
||||
encoding=LoggingConfig.encoding,
|
||||
level=LoggingConfig.level)
|
||||
|
||||
def packages(self) -> Generator:
|
||||
""" Returns the upgradable packages. """
|
||||
|
||||
|
@ -76,12 +69,7 @@ class Upgrade(Configs):
|
|||
return True
|
||||
|
||||
except ValueError:
|
||||
logger = logging.getLogger(LoggingConfig.date_time)
|
||||
logger.exception(f"{self.__class__.__name__}: "
|
||||
f"{self.__class__.is_package_upgradeable.__name__}: "
|
||||
f"{self.repos.repositories[self.repository]['repo_tag']}, "
|
||||
f"{repository_package=}, {installed_package=}, {repository_package > installed_package}, "
|
||||
f"{repository_package == installed_package and repo_package_build > inst_package_build}")
|
||||
pass
|
||||
|
||||
if repository_package > installed_package:
|
||||
return True
|
||||
|
|
Loading…
Reference in a new issue