当前位置: 首页>>代码示例>>Python>>正文


Python CommonUtils.openLogFile方法代码示例

本文整理汇总了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
开发者ID:doomchocolate,项目名称:spider,代码行数:32,代码来源:JDProductsSpider.py

示例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
开发者ID:doomchocolate,项目名称:spider,代码行数:32,代码来源:AWSBaiduNewsDeploy.py

示例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 "============================================"
开发者ID:doomchocolate,项目名称:spider,代码行数:33,代码来源:AppStoreSpider.py


注:本文中的CommonUtils.openLogFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。