log file
This commit is contained in:
2
msw.py
2
msw.py
@@ -27,7 +27,7 @@ for name in plugins_list:
|
|||||||
with open('plugins/__init__.py', 'w') as f:
|
with open('plugins/__init__.py', 'w') as f:
|
||||||
f.write(plugins_import_script)
|
f.write(plugins_import_script)
|
||||||
print('%s plugins will be import' % (len(plugins_realname_list)))
|
print('%s plugins will be import' % (len(plugins_realname_list)))
|
||||||
print('They are: %s' % str(plugins_realname_list))
|
print('Plugins list: %s' % str(plugins_realname_list))
|
||||||
|
|
||||||
|
|
||||||
global_config['plugins_realname_list'] = plugins_realname_list
|
global_config['plugins_realname_list'] = plugins_realname_list
|
||||||
|
|||||||
@@ -1,12 +1,19 @@
|
|||||||
import threading
|
import threading
|
||||||
from mswp import Datapack
|
from mswp import Datapack
|
||||||
from forwarder import receive_queues
|
from forwarder import receive_queues
|
||||||
|
from config import dprint as print
|
||||||
receive_queue = receive_queues[__name__]
|
receive_queue = receive_queues[__name__]
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
while True:
|
while True:
|
||||||
dp = receive_queue.get()
|
dp = receive_queue.get()
|
||||||
print('Writedown log: %s' % dp.body.decode())
|
|
||||||
|
if dp.method == 'file':
|
||||||
|
word = dp.head.get('filename')
|
||||||
|
else:
|
||||||
|
word = dp.body.decode()
|
||||||
|
|
||||||
|
print('Writedown log: %s' % (word), dp)
|
||||||
with open('logger.log', 'a') as f:
|
with open('logger.log', 'a') as f:
|
||||||
if dp.head.get('from'):
|
if dp.head.get('from'):
|
||||||
from_app_name = dp.head.get('from')
|
from_app_name = dp.head.get('from')
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class Network_controller: # manage id and connection
|
|||||||
|
|
||||||
def process_command(self, dp):
|
def process_command(self, dp):
|
||||||
if dp.body == b'status':
|
if dp.body == b'status':
|
||||||
print('Online %s' % self.id_dict)
|
print('Online %s' % str(list(self.id_dict.keys())))
|
||||||
|
|
||||||
|
|
||||||
def start_sending_dp(self):
|
def start_sending_dp(self):
|
||||||
@@ -145,7 +145,7 @@ class Network_controller: # manage id and connection
|
|||||||
self.id_dict[id] = []
|
self.id_dict[id] = []
|
||||||
self.id_dict[id].append(connection)
|
self.id_dict[id].append(connection)
|
||||||
self.all_connection_list.append(connection)
|
self.all_connection_list.append(connection)
|
||||||
print('%s has connected' % id)
|
print('%s connected' % id)
|
||||||
|
|
||||||
|
|
||||||
def del_connection(self, id, connection):
|
def del_connection(self, id, connection):
|
||||||
@@ -172,7 +172,6 @@ class Connection:
|
|||||||
self.thread_recv.start()
|
self.thread_recv.start()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _init(self): # init to check connection id, threading
|
def _init(self): # init to check connection id, threading
|
||||||
err_code, flag = self.check_id()
|
err_code, flag = self.check_id()
|
||||||
if err_code:
|
if err_code:
|
||||||
@@ -264,8 +263,11 @@ class Connection:
|
|||||||
'''
|
'''
|
||||||
if self.positive:
|
if self.positive:
|
||||||
self.send_id()
|
self.send_id()
|
||||||
|
try:
|
||||||
|
data = self.conn.recv(BUFFSIZE)
|
||||||
|
except ConnectionResetError:
|
||||||
|
print('One connection failed before ID check')
|
||||||
|
|
||||||
data = self.conn.recv(BUFFSIZE)
|
|
||||||
if not data:
|
if not data:
|
||||||
return 2, ''
|
return 2, ''
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user