本文整理汇总了Python中CommonUtils.openLogFile方法的典型用法代码示例。如果您正苦于以下问题:Python CommonUtils.openLogFile方法的具体用法?Python CommonUtils.openLogFile怎么用?Python CommonUtils.openLogFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonUtils
的用法示例。
在下文中一共展示了CommonUtils.openLogFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: JDProductSpider
# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import openLogFile [as 别名]
db=JDConstants.MYSQL_DATABASE
spider = JDProductSpider(host, user, passwd, db)
spider.start()
# product = JDProductInfo()
# product.setProductId("1453838631")
# product.setProductBuyUrl("http://item.jd.com/1453838631.html")
# spider.getProductDetail(product)
if __name__=="__main__":
reload(sys)
sys.setdefaultencoding('utf-8')
workDir = os.path.dirname(os.path.realpath(sys.argv[0]))
os.chdir(os.path.dirname(workDir)) # 保证spider cache目录一致
logFile = CommonUtils.openLogFile(mode="w")
oldStdout = sys.stdout
sys.stdout = logFile
print "============================================"
print "change work direcotory to workDir", workDir
print "Start Baidu Product Spider:", time.asctime()
main()
logFile.close()
if oldStdout:
sys.stdout = oldStdout
示例2: AWSBaiduNewsDeploy
# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import openLogFile [as 别名]
if platform.system() == 'Windows':
host="localhost"
user="root"
passwd="123456"
db="test"
deploy = AWSBaiduNewsDeploy(host, user, passwd, db)
deploy.start()
if __name__ == "__main__":
reload(sys)
sys.setdefaultencoding('utf-8')
workDir = os.path.dirname(os.path.realpath(sys.argv[0]))
os.chdir(os.path.dirname(workDir))
logFile = CommonUtils.openLogFile()
oldStdout = sys.stdout
sys.stdout = logFile
print "============================================"
print "change work direcotory to workDir", workDir
print "Start AWS Baidu News Deploy:", time.asctime()
main()
logFile.close()
if oldStdout:
sys.stdout = oldStdout
示例3: AppStoreSpider
# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import openLogFile [as 别名]
spider = AppStoreSpider(host, user, passwd, db)
spider.addPriceTrackViewUrlBundleId()
if __name__=="__main__":
reload(sys)
sys.setdefaultencoding('utf-8')
workDir = os.path.dirname(os.path.realpath(sys.argv[0]))
os.chdir(os.path.dirname(workDir)) # 保证spider cache目录一致
import MyEncrypt
logFile = None
oldStdout = sys.stdout
if "generate" in sys.argv:
logFile = CommonUtils.openLogFile(filename="generate", mode="w")
elif "parse" in sys.argv:
pass
elif "clear" in sys.argv:
pass
elif "update" in sys.argv:
logFile = CommonUtils.openLogFile(filename="update", mode="w")
elif "price" in sys.argv:
logFile = CommonUtils.openLogFile(filename="price", mode="w")
else:
logFile = CommonUtils.openLogFile(mode="w")
if logFile is not None:
sys.stdout = logFile
print "============================================"