概述
logging.conf
[loggers]
keys=root
[handlers]
keys=rotateFileHandler
[formatters]
keys=logformat
[formatter_logformat]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
[logger_root]
level=DEBUG
handlers=rotateFileHandler
[handler_rotateFileHandler]
class=handlers.RotatingFileHandler
level=NOTSET
formatter=logformat
args=('ExecuteOraSql.log', 'a', 10*1024*1024, 10)
ExecuteOraSql.py
import subprocess
import logging
import logging.config
if __name__ == '__main__':
log_filename = "logging.conf"
logging.config.fileConfig(log_filename)
logger = logging.getLogger("ExecuteOraSql")
cmd = "sqlplus -S user/pwd @"
for x in 1,2:
sql = str(x) + ".sql"
p = subprocess.Popen(cmd+sql, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
o = p.stdout.readlines()
e = p.stderr.readlines()
for i in o:
logger.debug(i)
if e:
logger.error(e)
参考:
http://www.cnblogs.com/dkblog/archive/2011/08/26/2155018.html
http://blog.csdn.net/dyx1024/article/details/7250828
最后
以上就是幸福热狗为你收集整理的python shell怎么打开测试_Python执行Shell命令测试脚本的全部内容,希望文章能够帮你解决python shell怎么打开测试_Python执行Shell命令测试脚本所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复