shell python自定义模块安装_实现Python shell脚本调用已经安装好的upload模块应运

upload egg的执行方法是 upload -m 参数1 -v /home/log/1.log -c /home/config/1.config -e 0 -p 11111

因为Home的log文件夹下有每一天的log文件需要上传,我现在需要自己写一个python或者shell脚本去调用这个已经安装好的upload模块,去上传这些log文件。

要求:

遍历log 文件夹下的文件,Log文件夹目录:

Log--

----config

----1.config

----2.config

----vlog----

-----2015-01-01

1-1-1-1.log

1-2-1-1.log

....

-----2015-01-02

1-1-1-1.log

1-2-1-1.log

....

拿到对应的config文件

遍历这些文件,然后自动不停的上传,上传的py文件已经有了。直到log目录下的文件上传完毕。

import os

path = "~/log"

def enumeratepaths(path=path):

configs = []

for dirpath, dirnames, filenames in os.walk(path):

for file in filenames:

if "config" in file:

fullpath = os.path.join(dirpath, file)

configs.append(fullpath)

# 看你的`upload`的参数还可能需要`log`文件

# basename = os.path.basename(fullpath)

# log_path = os.path.join(dirpath, basename.split('.')[0] + '.log'

return configs

拿到路径之后可以用os.system或者subprocess来调用upload.

这里的code仅作参考. 具体可以看看OReily 的 Python for Unix and Linux System Administration (2008) 的第六章 Working with Paths, Directories, and Files

玩蛇网文章,转载请注明出处和文章网址:https://www.iplaypy.com/wenda/wd18790.html

相关文章 Recommend

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值