utils.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # This Python file uses the following encoding: utf-8
  2. # @author runhey
  3. # github https://github.com/runhey
  4. import re
  5. from pathlib import Path
  6. from datetime import datetime
  7. from PySide6.QtCore import QObject, Slot, Signal
  8. from module.logger import logger
  9. class Utils(QObject):
  10. def __init__(self) -> None:
  11. super(Utils, self).__init__()
  12. @Slot(result="QString")
  13. def current_datetime(self) -> str:
  14. """
  15. 获取当前的时间
  16. :return:
  17. """
  18. return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
  19. @Slot(str, str, str, result="QString")
  20. def test_notify(self, _config: str, title: str, content: str) -> bool:
  21. from module.notify.notify import Notifier
  22. try:
  23. notifier = Notifier(_config)
  24. if notifier.push(title=title, content=content):
  25. return "true"
  26. else:
  27. return "false"
  28. except Exception as e:
  29. logger.exception(e)
  30. return "false"
  31. if __name__ == "__main__":
  32. u = Utils()
  33. print(u.current_datetime())