作者 lemon

增加检查必须库是否安装的启动入口

@@ -46,15 +46,14 @@ class Monitor(callback.CallBack): @@ -46,15 +46,14 @@ class Monitor(callback.CallBack):
46 Config.set('host', self._socket.ws_url) 46 Config.set('host', self._socket.ws_url)
47 47
48 def go_login(self): 48 def go_login(self):
49 - threading.Thread(target=self._auto_login,args=()).start() 49 + threading.Thread(target=self._auto_login, args=(), name='auto_login_thread').start()
50 50
51 def _auto_login(self): 51 def _auto_login(self):
52 user_list = UserList.query(status=Status.ONLINE) 52 user_list = UserList.query(status=Status.ONLINE)
53 for user in user_list: 53 for user in user_list:
54 print("自动登录->", user) 54 print("自动登录->", user)
55 self.login(user.email, user.password, user.format_cookie(), user.user_agent) 55 self.login(user.email, user.password, user.format_cookie(), user.user_agent)
56 - time.sleep(0.2)  
57 - 56 + time.sleep(0.3)
58 57
59 def _replace_call(self, client): 58 def _replace_call(self, client):
60 funcs = [x for x in dir(self) if x.startswith("on")] 59 funcs = [x for x in dir(self) if x.startswith("on")]
@@ -4,3 +4,23 @@ @@ -4,3 +4,23 @@
4 # @Author : Lemon 4 # @Author : Lemon
5 # @File : setup.py.py 5 # @File : setup.py.py
6 # @Software: PyCharm 6 # @Software: PyCharm
  7 +
  8 +from bin import start
  9 +import os
  10 +
  11 +with os.popen('pip3 freeze') as p:
  12 + all = p.read().lower()
  13 +
  14 +current = [x.split('==')[0] for x in all.split('\n')]
  15 +
  16 +with open('requirements.txt', 'r') as f:
  17 + need = f.read().lower()
  18 +
  19 +li = [(x.split('==')[0], x.split('==')[1],) for x in need.split('\n')]
  20 +for name, ver in li:
  21 + if not name in current:
  22 + print('正在安装缺少的库: %s==%s' % (name, ver))
  23 + res = os.popen('pip3 install %s==%s' % (name, ver)).read()
  24 + print(res)
  25 +
  26 +start.core.run()