用pexpect实现的任务分发工具,可用于pexpect学习

最近忙着看书,都没什么时间和大家分享些什么,分享一下前段时间写的分发工具吧,希望对大家有帮助, 主要用于学习pexpect。水平有限,希望大家多多指点,言辞激烈点也没关系,楼主内心强大。

下载地址:

https://github.com/gbwllx/dispatch_server/tree/master

http://download.csdn.net/detail/gbwllx/7923891

主要实现了服务器集群内的文件分发,任务分发,文件下载等功能。

功能初步实现,当然还有很多地方可以改进,主要适用于初学者学习pexpect

需要配置的地方比较少,只要给一个用户名,配置一下机器列表就可以了微笑


主要函数

ssh_cmd()  file_upload()  download()等


使用方法

usage = "dispatch_server.py [-u][-f][-d][-p][-U]|[-c]|[-s]"
optParser = OptionParser(usage)
group = OptionGroup(optParser,"Auxiliary Funciton Options")
group.add_option("-c","--command",action = "store",type="str",dest = "cmd",
help='''status for process status
kill for kill process 
clresult for clear result directory 
other string for you can input cmd yourself''')
group.add_option("-s","--slice",action = "store",type="str",dest = "slicefile",nargs=2, help="file to slice")
optParser.add_option_group(group)
optParser.add_option("-d","--download",action = "store_true",dest = "downdir",help="input which directory you want to download")
optParser.add_option("-f","--file",action = "store",type="str",dest = "filename", help="file to check")
optParser.add_option("-p","--print",action = "store_true",dest = "outputinfo", help="if on, output the process infomation")
optParser.add_option("-u","--upload",action = "store_false",dest = "uploaddir", help="if update")
optParser.add_option("-U","--user",action = "store",type="str",dest = "username", default="ffff", help="username")


需配置的机器列表

maclistfile ='%s/dispatch/ffff_maclistfile.txt' %dir





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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值