report errors separately

This commit is contained in:
Christian Zangl 2020-09-07 19:02:12 +02:00
parent 619c45a420
commit 68eebc28a6
2 changed files with 14 additions and 5 deletions

View File

@ -22,6 +22,7 @@ Status codes:
class Main: class Main:
def __init__(self): def __init__(self):
self.stdscr = None self.stdscr = None
self.bitrot_list = []
self.err_list = [] self.err_list = []
self.modified = False self.modified = False
self.verbose = False self.verbose = False
@ -33,9 +34,11 @@ class Main:
if stat == Stat.FLAG_MOD: if stat == Stat.FLAG_MOD:
self.modified = True self.modified = True
else: else:
if stat in [Stat.ERR_BITROT, Stat.INTERNALEXCEPTION]: if stat == Stat.ERR_BITROT:
self.bitrot_list.append(path)
elif stat == Stat.INTERNALEXCEPTION:
self.err_list.append(path) self.err_list.append(path)
if stat in [Stat.OK, Stat.UPDATE, Stat.NEW]: elif stat in [Stat.OK, Stat.UPDATE, Stat.NEW]:
self.total += 1 self.total += 1
if self.verbose or not stat in [Stat.OK, Stat.SKIP]: if self.verbose or not stat in [Stat.OK, Stat.SKIP]:
print(stat.value, path) print(stat.value, path)
@ -107,11 +110,17 @@ class Main:
if self.modified: if self.modified:
print("Indices were updated.") print("Indices were updated.")
if self.err_list: if self.bitrot_list:
print("chkbit detected bitrot in these files:", file=sys.stderr) print("chkbit detected bitrot in these files:", file=sys.stderr)
for err in self.bitrot_list:
print(err, file=sys.stderr)
print(f"error: detected {len(self.bitrot_list)} file(s) with bitrot!", file=sys.stderr)
if self.err_list:
print("chkbit ran into errors:", file=sys.stderr)
for err in self.err_list: for err in self.err_list:
print(err, file=sys.stderr) print(err, file=sys.stderr)
print(f"error: detected {len(self.err_list)} file(s) with bitrot!", file=sys.stderr)
if self.bitrot_list or self.err_list:
sys.exit(1) sys.exit(1)

View File

@ -11,7 +11,7 @@ with open(os.path.join(os.path.dirname(__file__), "README.md"), encoding="utf-8"
setup( setup(
name="chkbit", name="chkbit",
version="2.0.0", version="2.0.2",
url="https://github.com/laktak/chkbit-py", url="https://github.com/laktak/chkbit-py",
author="Christian Zangl", author="Christian Zangl",
author_email="laktak@cdak.net", author_email="laktak@cdak.net",