Logging and code cleanup
This commit is contained in:
32
bin/delpkg
32
bin/delpkg
@ -9,7 +9,6 @@ Functions:
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import packaging_scripts.pacmanconf as pacmanconf
|
||||
import packaging_scripts.pkgfiles as pkgfiles
|
||||
@ -24,20 +23,14 @@ E_REPO_REMOVEERR = 2
|
||||
|
||||
# ========== Logging setup ==========
|
||||
console_formatter = logging.Formatter('==> %(levelname)s %(message)s')
|
||||
#logging = logging.getLogger(__name__)
|
||||
logging.basicConfig(format='==> %(levelname)s %(message)s',
|
||||
level=logging.DEBUG)
|
||||
syslog = logging.getLogger('packaging_scripts')
|
||||
syslog.setLevel(logging.DEBUG)
|
||||
|
||||
#stdout_handler = logging.StreamHandler(sys.stdout)
|
||||
#stdout_handler.setLevel(logging.INFO)
|
||||
#stdout_handler.setFormatter(console_formatter)
|
||||
#
|
||||
#stderr_handler = logging.StreamHandler()
|
||||
#stderr_handler.setLevel(logging.ERROR)
|
||||
#stderr_handler.setFormatter(console_formatter)
|
||||
#
|
||||
#logging.addHandler(stdout_handler)
|
||||
#logging.addHandler(stderr_handler)
|
||||
console_handler = logging.StreamHandler()
|
||||
console_handler.setLevel(logging.ERROR)
|
||||
console_handler.setFormatter(console_formatter)
|
||||
|
||||
syslog.addHandler(console_handler)
|
||||
|
||||
|
||||
# ========== Functions ==========
|
||||
@ -48,7 +41,7 @@ def del_pkgfile(pkg):
|
||||
:type pkg: pathlib.Path object
|
||||
"""
|
||||
pkg.unlink()
|
||||
logging.info(f"Removed {pkg}")
|
||||
syslog.info(f"Removed {pkg}")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -79,10 +72,8 @@ if __name__ == '__main__':
|
||||
# has the same name as that repo
|
||||
db = f"{cachedir}/{repo}.{DB_EXT}"
|
||||
|
||||
# if args.verbose:
|
||||
# stdout_handler.setLevel(logging.DEBUG)
|
||||
|
||||
logging.debug(f"Packages: {pkgs}")
|
||||
if args.verbose:
|
||||
stdout_handler.setLevel(logging.DEBUG)
|
||||
|
||||
for pkg in pkgs:
|
||||
pkg_tarballs = pkgfiles.get_pkgfiles(query=pkg,
|
||||
@ -100,5 +91,4 @@ if __name__ == '__main__':
|
||||
try:
|
||||
repos.repo_add('remove', db, pkg, opts=opts)
|
||||
except repos.RepoAddError as e:
|
||||
logging.error(e)
|
||||
pass
|
||||
syslog.error(e)
|
||||
|
Reference in New Issue
Block a user