From 35bac6bfcf27eefcb992388bb33f6ae6a7787595 Mon Sep 17 00:00:00 2001 From: LittleCoder Date: Wed, 8 Feb 2017 16:43:27 +0800 Subject: [PATCH] Clear useless loggings --- itchat/components/messages.py | 1 - itchat/components/register.py | 17 ++++++++++------- itchat/config.py | 2 +- itchat/utils.py | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/itchat/components/messages.py b/itchat/components/messages.py index 46e36f2f..260d16b6 100644 --- a/itchat/components/messages.py +++ b/itchat/components/messages.py @@ -207,7 +207,6 @@ def produce_group_chat(core, msg): member = utils.search_dict_list((chatroom or {}).get( 'MemberList') or [], 'UserName', actualUserName) if member is None: - print(chatroom['MemberList']) logger.debug('chatroom member fetch failed with %s' % actualUserName) else: msg['ActualUserName'] = actualUserName diff --git a/itchat/components/register.py b/itchat/components/register.py index b8b62ff4..a07c1111 100644 --- a/itchat/components/register.py +++ b/itchat/components/register.py @@ -64,15 +64,16 @@ def configured_reply(self): else: try: r = replyFn(msg) - if r is not None: self.send(r, msg.get('FromUserName')) + if r is not None: + self.send(r, msg.get('FromUserName')) except: - logger.warning('An error occurred in registered function, use `itchat.run(debug=True)` to show detailed information') - logger.debug(traceback.format_exc()) + logger.warning(traceback.format_exc()) def msg_register(self, msgType, isFriendChat=False, isGroupChat=False, isMpChat=False): ''' a decorator constructor return a specific decorator based on information given ''' - if not isinstance(msgType, list): msgType = [msgType] + if not isinstance(msgType, list): + msgType = [msgType] def _msg_register(fn): for _msgType in msgType: if isFriendChat: @@ -91,12 +92,14 @@ def run(self, debug=False, blockThread=True): set_logging(loggingLevel=logging.DEBUG) def reply_fn(): try: - while self.alive: self.configured_reply() + while self.alive: + self.configured_reply() except KeyboardInterrupt: - if self.useHotReload: self.dump_login_status() + if self.useHotReload: + self.dump_login_status() self.alive = False logger.debug('itchat received an ^C and exit.') - print('Bye~') + logger.info('Bye~') if blockThread: reply_fn() else: diff --git a/itchat/config.py b/itchat/config.py index a48acb4a..1c205023 100644 --- a/itchat/config.py +++ b/itchat/config.py @@ -1,6 +1,6 @@ import os, platform -VERSION = '1.2.21' +VERSION = '1.2.22' BASE_URL = 'https://login.weixin.qq.com' OS = platform.system() #Windows, Linux, Darwin DIR = os.getcwd() diff --git a/itchat/utils.py b/itchat/utils.py index ca797f81..68aac9a9 100644 --- a/itchat/utils.py +++ b/itchat/utils.py @@ -105,7 +105,7 @@ def print_cmd_qr(fileDir, size = 37, padding = 3, except ImportError: def print_cmd_qr(fileDir, size = 37, padding = 3, white = BLOCK, black = ' ', enableCmdQR = True): - print('pillow should be installed to use command line QRCode: pip install pillow') + logger.warning('pillow should be installed to use command line QRCode: pip install pillow') print_qr(fileDir) def struct_friend_info(knownInfo): member = copy.deepcopy(friendInfoTemplate)