2016-12-15 39 views
2

我有一箇舊的python腳本,它使用了我剛剛通過添加pywinauto進行更新的日誌記錄。導入Pywinauto導致調試消息出現兩次

任何日誌行都按照預期寫入日誌文件,但一旦導入了pywinauto,我將獲得寫入控制檯的行的2個副本。

註釋掉進口pywinauto線即可解決問題(但不是一個真正的解決方案,我需要利用圖書館)

import logging 
import pywinauto 

# Set up a script_logger. 
script_logger = logging.getLogger('test') 
script_logger.setLevel(logging.DEBUG) 

ch = logging.StreamHandler() 
ch.setLevel(logging.DEBUG) 

formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') 
ch.setFormatter(formatter) 

script_logger.addHandler(ch) 

logFilename = "debug.log" 
fh = logging.FileHandler(logFilename) 
fh.setLevel(logging.DEBUG) 
ch.setFormatter(formatter) 
script_logger.addHandler(fh) 
script_logger.debug("Hello world") 

典型輸出(第一行預計,第二行不)

2016-12-15 17:43:09,056 - test - DEBUG - Hello world 
2016-12-15 17:43:09,056 DEBUG: Hello world 

我可以看到第二行內

庫\站點包\ pywinauto \ actionlogger創建.py

有什麼想法?

謝謝

+0

這可能是pywinauto中的一個錯誤。感謝您報告這一點。不幸的是,在新年之後會看到這個。 –

+0

任何想法,當這可能會看?我應該在pywinauto上打一張票嗎? – KermitG

+0

剛從假期旅行回來。將盡快看看。導入pywinauto時,comtypes警告也存在另一個問題。 –

回答

0

現在它應該在主分支中修復。你可以試試pip install https://github.com/pywinauto/pywinauto/archive/master.zip