Add time in message
This commit is contained in:
@@ -4,6 +4,7 @@ import argparse
|
||||
import asyncio
|
||||
import json
|
||||
import time
|
||||
import datetime
|
||||
|
||||
from kasa import Discover
|
||||
from kasa.exceptions import KasaException
|
||||
@@ -95,7 +96,11 @@ def getSecrets(fileanme):
|
||||
return None
|
||||
|
||||
|
||||
def getDatetime():
|
||||
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
async def main(configs):
|
||||
print(f"Start: {getDatetime()}")
|
||||
secrect = getSecrets(configs.get("secret_filepath", DEFAULT_POLLING_INTERVAL))
|
||||
if secrect is None:
|
||||
print(f'Cannot read secret file({configs.get("secret_filepath", DEFAULT_POLLING_INTERVAL)})')
|
||||
@@ -141,7 +146,7 @@ async def main(configs):
|
||||
if ENABLE_EXPORTER:
|
||||
gaugeDict[gaugeName].set(value)
|
||||
|
||||
pp(f"Set {gaugeName}: {value}")
|
||||
pp(f"[{getDatetime()}] Set {gaugeName}: {value}")
|
||||
|
||||
time.sleep(pollingInterval)
|
||||
except KeyboardInterrupt:
|
||||
@@ -149,6 +154,7 @@ async def main(configs):
|
||||
break
|
||||
|
||||
await t315.disconnect()
|
||||
print(f"End: {getDatetime()}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user