notifytest2.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import redis
  2. import time
  3. import json
  4. from selenium import webdriver
  5. from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  6. import time
  7. import os
  8. import urllib.parse
  9. from selenium.webdriver.support.ui import WebDriverWait
  10. from selenium.webdriver.common.by import By
  11. from selenium.webdriver.support import expected_conditions as EC
  12. import codecs
  13. import random
  14. from bs4 import BeautifulSoup
  15. import requests
  16. import dataset
  17. import time
  18. import rpyc
  19. import sys
  20. import docker
  21. headers = {
  22. "Authorization": "Bearer " + "eEVYaouu4zJUWdfCwRn8e0G9bnsbemmUNnIJY8LL1Lw",
  23. "Content-Type": "application/x-www-form-urlencoded"
  24. }
  25. import subprocess
  26. batcmd="dir"
  27. import rpyc
  28. import os
  29. conn = rpyc.classic.connect("192.168.192.139",18812)
  30. conn.execute('import subprocess')
  31. rsub = conn.modules.subprocess
  32. result = rsub.check_output('docker ps |grep alpine-poi | wc -l', shell=True)
  33. alston1="alston1:"+result.decode('utf-8').strip()
  34. conn = rpyc.classic.connect("192.168.192.43",18812)
  35. conn.execute('import subprocess')
  36. rsub = conn.modules.subprocess
  37. result = rsub.check_output('docker ps |grep alpine-poi | wc -l', shell=True)
  38. alston2="alston2:"+result.decode('utf-8').strip()
  39. #sys.exit()
  40. #ros.system('docker restart 62eab82f7759')
  41. #print('after restart')
  42. #time.sleep(11)
  43. #print('after wait')
  44. def send_msg(kw):
  45. params = {"message": kw}
  46. r = requests.post("https://notify-api.line.me/api/notify",headers=headers, params=params)
  47. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/google_poi?charset=utf8mb4')
  48. cursor=db.query('SELECT count(*) as cnt FROM google_poi.shop_list3;')
  49. cnt=''
  50. for c in cursor:
  51. cnt=str(c['cnt'])
  52. #result="\n"
  53. #idx=0
  54. #for c in cursor:
  55. # idx+=1
  56. # if idx<=3:
  57. # elmt=c['kw'].split(' ')[0]
  58. # result+="["+str(c['ranking'])+"]:"+elmt+"\n"
  59. #msg="\n機器人執行次數:"+str(idx)
  60. msg="shop_list3: "+cnt+"\n"
  61. msg+=alston1+"\n"
  62. msg+=alston2
  63. send_msg(msg)