Renamed for process

This commit is contained in:
Dimitris Zlatanidis 2023-06-29 12:34:06 +03:00
parent 302119fb8b
commit 7673f054ee
6 changed files with 20 additions and 20 deletions

View file

@ -6,8 +6,8 @@
* Logging path to /var/log/slpkg/
- Added:
* Build log file under /var/log/slpkg/build/prgnam.SlackBuild_date_time.log
* Setting of build log file in the config file
* Process log file under /var/log/slpkg/filename_date_time.log
* Setting of process log file in the config file
### 4.9.0 - 21/06/2023
- Updated:

View file

@ -65,9 +65,9 @@ BORDER_COLOR = "bold_green"
# Default is true. [true/false]
CASE_SENSITIVE = true
# Keep build log file on /var/log/slpkg/build/ folder.
# Keep process log file on /var/log/slpkg/ folder.
# Default is true. [true/false]
BUILD_LOG = true
PROCESS_LOG = true
# Slackware command for install packages, instead, you can use 'installpkg'.
# Normally upgradepkg only upgrades packages that are already installed

View file

@ -56,18 +56,18 @@ class Cleanings(Configs):
else:
print('\nNothing to clean.\n')
if any(Path(self.build_log_path).iterdir()):
self.delete_build_logs()
if any(Path(self.slpkg_log_path).iterdir()):
self.delete_process_logs()
def delete_logs_of_dependencies(self) -> None:
self.session.query(LogsDependencies).delete()
self.session.commit()
def delete_build_logs(self) -> None:
def delete_process_logs(self) -> None:
""" Deletes of build log files. """
print('\nDeleting of build log files:\n')
for file in self.build_log_path.glob('*'):
for file in self.slpkg_log_path.glob('*'):
print(f" {self.bred}>{self.endc} '{file}'")
print(f"\n{self.prog_name}: {self.blink}{self.bold}{self.bred}WARNING!{self.endc}: All the files "
@ -75,8 +75,8 @@ class Cleanings(Configs):
self.view.question()
for file in self.build_log_path.glob('*'):
self.utils.remove_file_if_exists(self.build_log_path, str(file))
for file in self.slpkg_log_path.glob('*'):
self.utils.remove_file_if_exists(self.slpkg_log_path, str(file))
print(f'{self.byellow}Successfully cleared!{self.endc}\n')

View file

@ -25,7 +25,7 @@ class Configs:
etc_path: Path = Path('/etc', prog_name)
db_path: Path = Path(lib_path, 'database')
log_packages: Path = Path('/var', 'log', 'packages')
build_log_path: Path = Path('/var/log/slpkg/logs/build/')
slpkg_log_path: Path = Path('/var/log/slpkg/')
database_name: str = f'database.{prog_name}'
file_list_suffix: str = '.pkgs'
@ -49,7 +49,7 @@ class Configs:
spinner_color: str = 'green'
border_color: str = 'bgreen'
case_sensitive: bool = True
build_log: bool = True
process_log: bool = True
proxy_address: str = ''
proxy_username: str = ''
@ -88,7 +88,7 @@ class Configs:
spinner_color: str = config['SPINNER_COLOR']
border_color: str = config['BORDER_COLOR']
case_sensitive: bool = config['CASE_SENSITIVE']
build_log: bool = config['BUILD_LOG']
process_log: bool = config['PROCESS_LOG']
proxy_address: str = config['PROXY_ADDRESS']
proxy_username: str = config['PROXY_USERNAME']
proxy_password: str = config['PROXY_PASSWORD']
@ -136,7 +136,7 @@ class Configs:
etc_path,
build_path,
tmp_slpkg,
build_log_path,
slpkg_log_path,
download_only_path,
LoggingConfig.log_path
]

View file

@ -11,7 +11,7 @@ class LoggingConfig:
level = logging.INFO
filemode: str = 'w'
encoding: str = 'utf-8'
log_path: Path = Path('/var/log/slpkg/logs')
log_path: Path = Path('/var/log/slpkg/')
log_file: Path = Path(log_path, 'slpkg.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}'

View file

@ -149,9 +149,9 @@ class Utilities(Configs):
def process(self, command: str, stderr=None, stdout=None, filename=None) -> None:
""" Handle the processes. """
output = tee = ''
if filename and self.build_log:
self.header_build_log(filename)
tee: str = f'| tee -a {self.build_log_path}/{filename}_{self.log_date}_{self.log_time}.log'
if filename and self.process_log:
self.header_process_log(filename)
tee: str = f'| tee -a {self.slpkg_log_path}/{filename}_{self.log_date}_{self.log_time}.log'
try:
output = subprocess.run(f'{command} {tee}', shell=True, stderr=stderr, stdout=stdout)
except subprocess.CalledProcessError as error:
@ -165,9 +165,9 @@ class Utilities(Configs):
if output.returncode != 0:
raise SystemExit(1)
def header_build_log(self, filename: str) -> None:
def header_process_log(self, filename: str) -> None:
""" Creates the build log file and the header. """
with open(f'{self.build_log_path}/{filename}_{self.log_date}_{self.log_time}.log', 'w') as f:
with open(f'{self.slpkg_log_path}/{filename}_{self.log_date}_{self.log_time}.log', 'w') as f:
f.write(f'{LoggingConfig.date_time}: {filename}: Version: {self.prog_name} {self.prog_version.version}\n')
def get_file_size(self, file: Path) -> str: