Skip to content

Commit

Permalink
The basics are worked out for the repo status plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
ianpaul committed May 26, 2022
1 parent d6b001d commit 801cf77
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/flashbake/plugins/lastlog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flashbake.plugins import AbstractMessagePlugin
import subprocess
import datetime

class LastLog(AbstractMessagePlugin):
def __init__(self, plugin_spec):
Expand All @@ -12,9 +13,20 @@ def addcontext(self, message_file, config):
colon to the variable x.'''
x = [s for s in llog for i in s if target in i]

for i in range(len(x)):
message_file.write("{0} {1} {2} {3} {4} {5}\n".format(x[i][0], x[i][3], x[i][4], x[i][5], x[i][8], x[i][6]))

#for i in range(len(x)):
# message_file.write("{0} {1} {2} {3} {4} {5}\n".format(x[i][0], x[i][3], x[i][4], x[i][5], x[i][8], x[i][6]))
#for i in x:
# print(i[8])
for i in x:
date_placement = [i[3], i[4], i[5], i[6], i[8]]
y = ' '.join(date_placement)
#print(date_placement)
past24 = datetime.datetime.now() - datetime.timedelta(hours=24)
#if datetime.datetime(*date_placement[2:4]) <= past24:
# print(i)
if datetime.datetime.strptime(y, "%a %b %d %H:%M:%S %Y") >= past24:
# print(i)
message_file.write(f'Most recent lastlog entries: \n{i[0]} {i[3]} {i[4]} {i[5]} {i[6]} {i[8]}')
def checklog(self):
last = subprocess.run(["lastlog"], capture_output=True,
text=True).stdout.strip("\n")
Expand Down

0 comments on commit 801cf77

Please sign in to comment.