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