mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-12-04 12:38:19 +01:00
simplify log download
This commit is contained in:
parent
f5c242d7c8
commit
858c71856d
2 changed files with 17 additions and 41 deletions
|
@ -1,3 +1,3 @@
|
||||||
__version__ = "4.4.1.a5"
|
__version__ = "4.4.1.a6"
|
||||||
__codename__ = "Yeast Starter"
|
__codename__ = "Yeast Starter"
|
||||||
|
|
||||||
|
|
|
@ -144,53 +144,29 @@ class SystemController:
|
||||||
fullkettlename = pathlib.Path(os.path.join(".",kettlename))
|
fullkettlename = pathlib.Path(os.path.join(".",kettlename))
|
||||||
|
|
||||||
output_filename="cbpi4_log.zip"
|
output_filename="cbpi4_log.zip"
|
||||||
|
result=[]
|
||||||
if logtime == "b":
|
if systemd_available:
|
||||||
if systemd_available:
|
j = journal.Reader()
|
||||||
#os.system('journalctl -b -u craftbeerpi.service --output cat > {}'.format(fullname))
|
if logtime == "b":
|
||||||
b = journal.Reader()
|
j.this_boot()
|
||||||
b.add_match(_TRANSPORT="kernel")
|
else:
|
||||||
result=[]
|
|
||||||
for entry in b:
|
|
||||||
message=entry['MESSAGE']
|
|
||||||
if message.find("Booting") != -1:
|
|
||||||
result.append(entry['__REALTIME_TIMESTAMP'])
|
|
||||||
j = journal.Reader()
|
|
||||||
j.add_match(_SYSTEMD_UNIT="craftbeerpi.service")
|
|
||||||
j.seek_realtime(result[-1])
|
|
||||||
result=[]
|
|
||||||
for entry in j:
|
|
||||||
result.append(entry['MESSAGE'])
|
|
||||||
try:
|
|
||||||
with open(fullname, 'w') as f:
|
|
||||||
for line in result:
|
|
||||||
f.write(f"{line}\n")
|
|
||||||
except Exception as e:
|
|
||||||
logging.error(e)
|
|
||||||
|
|
||||||
else:
|
|
||||||
if systemd_available:
|
|
||||||
result=[]
|
|
||||||
#os.system('journalctl --since \"{} hours ago\" -u craftbeerpi.service --output cat > {}'.format(logtime, fullname))
|
|
||||||
j = journal.Reader()
|
|
||||||
j.add_match(_SYSTEMD_UNIT="craftbeerpi.service")
|
|
||||||
since = datetime.now() - timedelta(hours=int(logtime))
|
since = datetime.now() - timedelta(hours=int(logtime))
|
||||||
j.seek_realtime(since)
|
j.seek_realtime(since)
|
||||||
for entry in j:
|
j.add_match(_SYSTEMD_UNIT="craftbeerpi.service")
|
||||||
result.append(entry['MESSAGE'])
|
|
||||||
try:
|
for entry in j:
|
||||||
with open(fullname, 'w') as f:
|
result.append(entry['MESSAGE'])
|
||||||
for line in result:
|
try:
|
||||||
f.write(f"{line}\n")
|
with open(fullname, 'w') as f:
|
||||||
except Exception as e:
|
for line in result:
|
||||||
logging.error(e)
|
f.write(f"{line}\n")
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(e)
|
||||||
|
|
||||||
plugins = await self.plugins_list()
|
plugins = await self.plugins_list()
|
||||||
with open(fullpluginname, 'w') as f:
|
with open(fullpluginname, 'w') as f:
|
||||||
f.write(plugins)
|
f.write(plugins)
|
||||||
|
|
||||||
#os.system('echo "{}" >> {}'.format(plugins,fullpluginname))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
actors = self.cbpi.actor.get_state()
|
actors = self.cbpi.actor.get_state()
|
||||||
json.dump(actors['data'],open(fullactorname,'w'),indent=4, sort_keys=True)
|
json.dump(actors['data'],open(fullactorname,'w'),indent=4, sort_keys=True)
|
||||||
|
|
Loading…
Reference in a new issue