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

来源:互联网 发布:淘宝假冒伪劣被处罚 编辑:程序博客网 时间:2024/06/01 10:39

最近忙着看书,都没什么时间和大家分享些什么,分享一下前段时间写的分发工具吧,希望对大家有帮助, 主要用于学习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