Correctly count number of installed pacakges in pacplot
This commit is contained in:
parent
a946b9a96e
commit
952106a805
15
pacplot
15
pacplot
|
@ -3,24 +3,33 @@
|
|||
from datetime import datetime
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
|
||||
with open('/var/log/pacman.log', 'r') as f:
|
||||
cnt = 0
|
||||
installed = 0
|
||||
removed = 0
|
||||
x = []
|
||||
y = []
|
||||
for line in f.readlines():
|
||||
if 'PACKAGEKIT' in line:
|
||||
# Ignore packagekit operations
|
||||
if '[ALPM]' not in line or 'warning' in line:
|
||||
# Ignore operations
|
||||
continue
|
||||
|
||||
if ' installed' in line:
|
||||
cnt += 1
|
||||
installed += 1
|
||||
elif 'removed' in line:
|
||||
cnt -= 1
|
||||
removed += 1
|
||||
else:
|
||||
continue
|
||||
|
||||
x.append(datetime.fromisoformat(line[1:23] + ':00'))
|
||||
y.append(cnt)
|
||||
|
||||
plt.scatter(x, y)
|
||||
|
||||
print('Currently installed packages:', cnt)
|
||||
print('Total installed packages:', installed)
|
||||
print('Total removed packages:', removed)
|
||||
plt.plot(x, y)
|
||||
plt.show()
|
||||
|
|
Loading…
Reference in a new issue