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