start.py 1012 B

1234567891011121314151617181920212223242526272829303132333435
  1. from Utils.DingTalk import *
  2. from Utils.Hik import *
  3. import datetime
  4. import os
  5. def datetime_now():
  6. datetime_now = datetime.datetime.now().strftime("%Y-%m-%d")
  7. return datetime_now
  8. def endDate():
  9. endDate = int(datetime.datetime.now().strftime("%Y")) +10
  10. endDate = str(endDate) +"-01-01"
  11. return endDate
  12. with open("config.json","r") as f:
  13. data = json.load(f)
  14. mobile = data["mobile"]
  15. appkey = "dinglmkgry6mibab7tgs"
  16. appsecret = "DiJEEMHDt7Mk9X1eb_oFT4Vh-OIeRqN36HtIAbxD8M5Q6VGUvgsfzGRayRkpWO1t"
  17. # mobile = "15727360513"
  18. Ding_Talk = DingTalk(appkey, appsecret, mobile)
  19. userid = Ding_Talk.getuserid_bymobile()
  20. username = Ding_Talk.username(userid)
  21. if username:
  22. host = "https://192.168.64.44:443"
  23. appKey = "25227103"
  24. appSecret = "LMGm1LNhAE7zF6Alzqdz"
  25. Hik_iSecure = Hik_iSecure(host, appKey, appSecret)
  26. add_user = Hik_iSecure.add_user(username, userid)
  27. if add_user == "success":
  28. Hik_iSecure.create_card(datetime_now(),endDate(),userid)
  29. os.system("pause")