PKó‹6™Ñáѽ½psshlib/color.pydef with_color(str, fg, bg=49): '''Given foreground/background ANSI color codes, return a string that, when printed, will format the supplied string using the supplied colors. ''' return "\x1b[%dm\x1b[%dm%s\x1b[39m\x1b[49m" % (fg,bg,str) def B(str): '''Returns a string that, when printed, will display the supplied string in ANSI bold. ''' return "\x1b[1m%s\x1b[22m" % str def r(str): return with_color(str, 31) # Red def g(str): return with_color(str, 32) # Green def y(str): return with_color(str, 33) # Yellow def b(str): return with_color(str, 34) # Blue def m(str): return with_color(str, 35) # Magenta def c(str): return with_color(str, 36) # Cyan def w(str): return with_color(str, 37) # White #following from Python cookbook, #475186 def has_colors(stream): '''Returns boolean indicating whether or not the supplied stream supports ANSI color. ''' if not hasattr(stream, "isatty"): return False if not stream.isatty(): return False # auto color only on TTYs try: import curses curses.setupterm() return curses.tigetnum("colors") > 2 except: # guess false in case of error return False PK…‹.8P6"’’psshlib/psshutil.pyimport os, signal, sys def read_hosts(pathname): """ Read hostfile with lines of the form: host[:port] [login]. Return three arrays: hosts, ports, and users. These can be used directly for all ssh-based commands (e.g., ssh, scp, rsync -e ssh, etc.) Empty lines and lines where the first non-blank character is a '#' character are ignored. """ import re if pathname == "-": f = open("/dev/stdin") else: f = open(pathname) lines = f.readlines() lines = map(lambda x: x.strip(), lines) addrs = [] hosts = [] ports = [] users = [] for line in lines: if re.match("^\s*(#|$)", line): continue fields = re.split("\s", line) if len(fields) == 1: addrs.append(line) users.append(None) elif len(fields) == 2: addrs.append(fields[0]) users.append(fields[1]) else: print "Bad line. Must be host[:port] [login]" sys.exit(3) f.close() for i in range(len(addrs)): addr = addrs[i] if re.search(":", addrs[i]): host, port = re.split(":", addr) hosts.append(host) ports.append(int(port)) else: hosts.append(addr) ports.append(22) return hosts, ports, users def patch_users(hosts, ports, users, user): """Fill in missing entries in users array with specified user""" for i in range(len(hosts)): if not users[i] and user: users[i] = user elif not users[i] and not user: print "User not specified for %s:%d" % (hosts[i], ports[i]) sys.exit(3) PKó‹6psshlib/__init__.pyPK‹.8ª•³þˆ ˆ psshlib/psshutil.pyc;ò ûá‹Gc@s1dkZdkZdkZd„Zd„ZdS(NcCsÐdk}|djotdƒ}n t|ƒ}|iƒ}td„|ƒ}g} g} g} g}x¶|D]®} |i d| ƒoqon|i d| ƒ}t|ƒdjo| i| ƒ|itƒqot|ƒdjo&| i|d ƒ|i|dƒqod GHtid ƒqoW|iƒx‘tt| ƒƒD]}}| |} |id | |ƒo<|i d | ƒ\}}| i|ƒ| it|ƒƒq>| i| ƒ| id ƒq>W| | |fSdS(s8 Read hostfile with lines of the form: host[:port] [login]. Return three arrays: hosts, ports, and users. These can be used directly for all ssh-based commands (e.g., ssh, scp, rsync -e ssh, etc.) Empty lines and lines where the first non-blank character is a '#' character are ignored. Ns-s /dev/stdincCs |iƒS(N(sxsstrip(sx((s4build/bdist.darwin-8.0.1-x86/egg/psshlib/psshutil.pysss ^\s*(#|$)s\siiis%Bad line. Must be host[:port] [login]is:i(srespathnamesopensfs readlinesslinessmapsaddrsshostssportssusersslinesmatchssplitsfieldsslensappendsNonessyssexitsclosesrangesisaddrssearchshostsportsint(spathnamesuserssfsisfieldsslinesshostsportsresaddrsshostsslinesportssaddr((s4build/bdist.darwin-8.0.1-x86/egg/psshlib/psshutil.pys read_hostssF         cCs~xwtt|ƒƒD]c}|| o|o|||ic Cs=tiƒd}ztiƒiƒd} tit i ƒovti dti |ƒƒ}tidti dƒƒ}tidti dƒƒ}titi t|ƒƒƒ}n#d|}d}d}t|ƒ}|tj o|G| G|G|G|GHn|G| G|G|GH|o|Gnt i iƒWdti|ƒXdS(Niis[%s]sSUCCESSsFAILUREs [SUCCESS]s [FAILURE](s completedsgetsnstimesasctimessplitststampscolors has_colorsssyssstdoutscsBsprogresssgssuccesssrsfailuresstrs exceptionsexcsNoneshostsoutputsflushsput( shostsportsoutputs exceptionsexcssuccesssnsfailuresprogressststamp((s6build/bdist.darwin-8.0.1-x86/egg/psshlib/basethread.pyslog_completionXs("   (scolors cStringIOserrnosfcntlsossselectssignalssyss threadingstimesQueues subprocesssPopensPIPEsThreads BaseThreads completedsputsNoneslog_completion(sfcntls cStringIOs BaseThreadscolorserrnossignalsQueuesPopenslog_completionssyss threadingstimesoss completedsselectsPIPE((s6build/bdist.darwin-8.0.1-x86/egg/psshlib/basethread.pys?s cR  PK…‹.8½`¦¦psshlib/basethread.pyimport color, cStringIO, errno, fcntl, os, select, signal, sys, threading, time, Queue from subprocess import Popen, PIPE class BaseThread(threading.Thread): def __init__(self, host, port, cmd, flags, sem, input=None): threading.Thread.__init__(self) self.host = host self.port = port self.cmd = cmd self.flags = flags self.sem = sem self.input = input self.outputbuffer = '' def run(self): done = None stdout = cStringIO.StringIO() stderr = cStringIO.StringIO() try: child = Popen([self.cmd], stderr=PIPE, stdin=PIPE, stdout=PIPE, close_fds=True, preexec_fn=os.setsid, shell=True) cstdout = child.stdout cstderr = child.stderr cstdin = child.stdin if self.input: cstdin.write(self.input) cstdin.close() del self.input # Throw away stdin's input, since we don't need it iomap = { cstdout : stdout, cstderr : stderr } fcntl.fcntl(cstdout.fileno(), fcntl.F_SETFL, os.O_NONBLOCK) fcntl.fcntl(cstderr.fileno(), fcntl.F_SETFL, os.O_NONBLOCK) start = time.time() status = -1 # Set status to -1 for other errors (timeout, etc.) while 1: timeout = self.flags["timeout"] - (time.time() - start) if timeout <= 0: raise Exception("Timeout") while True: try: r, w, e = select.select([ cstdout, cstderr ], [], [], timeout) break except select.error, v: if v[0] == errno.EINTR: continue else: raise try: for f in r: chunk = f.read() if len(chunk) == 0: done = 1 iomap[f].write(chunk) if self.flags.has_key("print") and self.flags["print"]: to_write = "%s: %s" % (self.host, chunk) sys.stdout.write(to_write) if self.flags.has_key("inline") and \ self.flags["inline"] and len(chunk) > 0: self.outputbuffer += chunk # Small output only if done: break except: os.kill(child.pid, signal.SIGKILL) raise status = child.wait() # Shouldn't block (just to get status) if status: raise Exception("Received error code of %d" % status) log_completion(self.host, self.port, self.outputbuffer) self.write_output(stdout, stderr) except Exception, e: log_completion(self.host, self.port, self.outputbuffer, e) self.write_output(stdout, stderr) try: os.kill(-child.pid, signal.SIGKILL) except: pass self.sem.release() def write_output(self, stdout, stderr): if self.flags["outdir"]: pathname = "%s/%s" % (self.flags["outdir"], self.host) open(pathname, "w").write(stdout.getvalue()) if self.flags["errdir"]: pathname = "%s/%s" % (self.flags["errdir"], self.host) open(pathname, "w").write(stderr.getvalue()) # Thread-safe queue with a single item: num completed threads completed = Queue.Queue() completed.put(0) def log_completion(host, port, output, exception=None): # Increment the count of complete ops. This will # drain the queue, causing subsequent calls of this # method to block. n = completed.get() + 1 try: tstamp = time.asctime().split()[3] # Current time if color.has_colors(sys.stdout): progress = color.c("[%s]" % color.B(n)) success = color.g("[%s]" % color.B("SUCCESS")) failure = color.r("[%s]" % color.B("FAILURE")) exc = color.r(color.B(str(exception))) else: progress = "[%s]" % n success = "[SUCCESS]" failure = "[FAILURE]" exc = str(exception) if exception is not None: print progress, tstamp, failure, host, exc else: print progress, tstamp, success, host if output: print output, sys.stdout.flush() finally: # Update the count of complete ops. This will re-fill # the queue, allowing other threads to continue with # output. completed.put(n) PK‹.8uöÙ„„psshlib/__init__.pyc;ò [xFc@sdS(N((((s4build/bdist.darwin-8.0.1-x86/egg/psshlib/__init__.pys?sPK‹.8ºêË\— — psshlib/color.pyc;ò [xFc@sadd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd „Zd „Z d S( i1cCsd|||fSdS(s•Given foreground/background ANSI color codes, return a string that, when printed, will format the supplied string using the supplied colors. s[%dm[%dm%sN(sfgsbgsstr(sstrsfgsbg((s1build/bdist.darwin-8.0.1-x86/egg/psshlib/color.pys with_colorscCs d|SdS(s\Returns a string that, when printed, will display the supplied string in ANSI bold. s %sN(sstr(sstr((s1build/bdist.darwin-8.0.1-x86/egg/psshlib/color.pysBscCst|dƒSdS(Ni(s with_colorsstr(sstr((s1build/bdist.darwin-8.0.1-x86/egg/psshlib/color.pysr scCst|dƒSdS(Ni (s with_colorsstr(sstr((s1build/bdist.darwin-8.0.1-x86/egg/psshlib/color.pysgscCst|dƒSdS(Ni!(s with_colorsstr(sstr((s1build/bdist.darwin-8.0.1-x86/egg/psshlib/color.pysyscCst|dƒSdS(Ni"(s with_colorsstr(sstr((s1build/bdist.darwin-8.0.1-x86/egg/psshlib/color.pysbscCst|dƒSdS(Ni#(s with_colorsstr(sstr((s1build/bdist.darwin-8.0.1-x86/egg/psshlib/color.pysmscCst|dƒSdS(Ni$(s with_colorsstr(sstr((s1build/bdist.darwin-8.0.1-x86/egg/psshlib/color.pyscscCst|dƒSdS(Ni%(s with_colorsstr(sstr((s1build/bdist.darwin-8.0.1-x86/egg/psshlib/color.pyswscCskt|dƒ otSn|iƒ otSny*dk}|iƒ|idƒdjSWn tSnXdS(s[Returns boolean indicating whether or not the supplied stream supports ANSI color. sisattyNscolorsi(shasattrsstreamsFalsesisattyscursess setuptermstigetnum(sstreamscurses((s1build/bdist.darwin-8.0.1-x86/egg/psshlib/color.pys has_colorss  N( s with_colorsBsrsgsysbsmscsws has_colors( s has_colorss with_colorsBsgsmscsrswsysb((s1build/bdist.darwin-8.0.1-x86/egg/psshlib/color.pys?s         PK•‹.8“×2EGG-INFO/zip-safe PKŽ‹.8<2Ÿ¯¯EGG-INFO/SOURCES.txtAUTHORS BUGS COPYING ChangeLog INSTALL Makefile TODO setup.cfg setup.py bin/pnuke bin/prsync bin/pscp bin/pslurp bin/pssh doc/index.html doc/pssh-HOWTO.html doc/pssh-HOWTO.pdf doc/pssh-HOWTO.ps doc/pssh-HOWTO.sgml pssh.egg-info/PKG-INFO pssh.egg-info/SOURCES.txt pssh.egg-info/dependency_links.txt pssh.egg-info/top_level.txt psshlib/__init__.py psshlib/basethread.py psshlib/color.py psshlib/psshutil.py test/ips.txt test/test.sh PKŽ‹.8“×2EGG-INFO/dependency_links.txt PKŽ‹.81$/CÊÊEGG-INFO/PKG-INFOMetadata-Version: 1.0 Name: pssh Version: 1.3.1 Summary: UNKNOWN Home-page: http://www.theether.org/pssh/ Author: Brent N. Chun Author-email: UNKNOWN License: BSD Description: UNKNOWN Platform: UNKNOWN PKŽ‹.8ƒŸî±EGG-INFO/top_level.txtpsshlib PK•‹.8!áN-  EGG-INFO/scripts/pslurp#!/usr/local/bin/python2.3 # -*- Mode: python -*- # # Usage: pslurp [OPTIONS] -h hosts.txt -o outdir remote local # # Parallel scp from the set of nodes in hosts.txt. For each node, we # essentially do a scp [-r] user@host:remote outdir//local. This # program also uses the -q (quiet) and -C (compression) options. Note # that remote must be an absolute path. # # Created: 18 November 2003 # # $Id: pslurp,v 1.1.1.1 2005/12/31 10:03:33 bnc Exp $ # import fcntl, os, popen2, pwd, select, signal, sys, threading, time basedir, bin = os.path.split(os.path.dirname(os.path.abspath(sys.argv[0]))) sys.path.append("%s" % basedir) import psshlib from psshlib.basethread import BaseThread _DEFAULT_PARALLELISM = 32 _DEFAULT_TIMEOUT = sys.maxint # "infinity" by default def print_usage(): print "Usage: pslurp [OPTIONS] -h hosts.txt -o outdir remote local" print print " -r --recursive recusively copy directories (OPTIONAL)" print " -L --localdir output directory for remote file copies" print " -h --hosts hosts file (each line \"host[:port] [login]\")" print " -l --user username (OPTIONAL)" print " -p --par max number of parallel threads (OPTIONAL)" print " -o --outdir output directory for stdout files (OPTIONAL)" print " -e --errdir output directory for stderr files (OPTIONAL)" print " -t --timeout timeout in seconds to do scp to a host (OPTIONAL)" print " -O --options SSH options (OPTIONAL)" print print "Example: pslurp -h hosts.txt -L /tmp/outdir -l irb2 \\" print " /home/irb2/foo.txt foo.txt" print def read_envvars(flags): if os.getenv("PSSH_LOCALDIR"): flags["localdir"] = os.getenv("PSSH_LOCALDIR") if os.getenv("PSSH_HOSTS"): flags["hosts"] = os.getenv("PSSH_HOSTS") if os.getenv("PSSH_USER"): flags["user"] = os.getenv("PSSH_USER") if os.getenv("PSSH_PAR"): flags["par"] = int(os.getenv("PSSH_PAR")) if os.getenv("PSSH_OUTDIR"): flags["outdir"] = os.getenv("PSSH_OUTDIR") if os.getenv("PSSH_ERRDIR"): flags["errdir"] = os.getenv("PSSH_ERRDIR") if os.getenv("PSSH_TIMEOUT"): flags["timeout"] = int(os.getenv("PSSH_TIMEOUT")) if os.getenv("PSSH_OPTIONS"): flags["options"] = os.getenv("PSSH_OPTIONS") def parsecmdline(argv): import getopt shortopts = "rL:h:l:p:o:e:t:O:" longopts = [ "recursive", "localdir", "hosts", "user", "par", "outdir", "errdir", "timeout", "options" ] flags = { "recursive" : None, "localdir" : None, "hosts" : None, "user" : None, "par" : _DEFAULT_PARALLELISM, "outdir" : None, "errdir" : None, "timeout" : _DEFAULT_TIMEOUT, "options" : None } read_envvars(flags) if not flags["user"]: flags["user"] = pwd.getpwuid(os.getuid())[0] # Default to current user opts, args = getopt.getopt(argv[1:], shortopts, longopts) for o, v in opts: if o in ("-r", "--recursive"): flags["recursive"] = 1 elif o in ("-L", "--localdir"): flags["localdir"] = v elif o in ("-h", "--hosts"): flags["hosts"] = v elif o in ("-l", "--user"): flags["user"] = v elif o in ("-p", "--par"): flags["par"] = int(v) elif o in ("-o", "--outdir"): flags["outdir"] = v elif o in ("-e", "--errdir"): flags["errdir"] = v elif o in ("-t", "--timeout"): flags["timeout"] = int(v) elif o in ("-O", "--options"): flags["options"] = v # Required flags if not flags["hosts"]: print_usage() sys.exit(3) return args, flags def do_pslurp(hosts, ports, users, remote, local, flags): import os if flags["localdir"] and not os.path.exists(flags["localdir"]): os.makedirs(flags["localdir"]) if flags["outdir"] and not os.path.exists(flags["outdir"]): os.makedirs(flags["outdir"]) if flags["errdir"] and not os.path.exists(flags["errdir"]): os.makedirs(flags["errdir"]) for host in hosts: dir = "%s/%s" % (flags["localdir"], host) if not os.path.exists(dir): os.mkdir(dir) sem = threading.Semaphore(flags["par"]) threads = [] for i in range(len(hosts)): sem.acquire() localpath = "%s/%s/%s" % (flags["localdir"], hosts[i], local) if flags["options"] and flags["recursive"]: cmd = "scp -o \"%s\" -qrC -P %d %s@%s:%s %s" % \ (flags["options"], ports[i], users[i], hosts[i], remote, localpath) elif flags["options"] and not flags["recursive"]: cmd = "scp -o \"%s\" -qC -P %d %s@%s:%s" % \ (flags["options"], ports[i], users[i], hosts[i], remote, localpath) elif not flags["options"] and flags["recursive"]: cmd = "scp -qrC -P %d %s@%s:%s %s" % \ (ports[i], users[i], hosts[i], remote, localpath) else: cmd = "scp -qC -P %d %s@%s:%s %s" % \ (ports[i], users[i], hosts[i], remote, localpath) t = BaseThread(hosts[i], ports[i], cmd, flags, sem) t.start() threads.append(t) for t in threads: t.join() if __name__ == "__main__": import os, pwd, re from psshlib import psshutil args, flags = parsecmdline(sys.argv) if len(args) != 2: print_usage() sys.exit(3) remote = args[0] local = args[1] if not re.match("^/", remote): print "Remote path %s must be an absolute path" % remote sys.exit(3) hosts, ports, users = psshutil.read_hosts(flags["hosts"]) psshutil.patch_users(hosts, ports, users, flags["user"]) os.setpgid(0, 0) do_pslurp(hosts, ports, users, remote, local, flags) PK”‹.8–µµEGG-INFO/scripts/pnuke#!/usr/local/bin/python2.3 # -*- Mode: python -*- # # Usage: pnuke [OPTIONS] -h hosts.txt pattern # # Nukes all processes that match pattern running as user # on the set of nodes in hosts.txt. # # Created: 16 August 2003 # # $Id: pnuke,v 1.1.1.1 2005/12/31 10:03:33 bnc Exp $ # import fcntl, os, popen2, pwd, select, signal, sys, threading, time basedir, bin = os.path.split(os.path.dirname(os.path.abspath(sys.argv[0]))) sys.path.append("%s" % basedir) import psshlib from psshlib.basethread import BaseThread _DEFAULT_PARALLELISM = 32 _DEFAULT_TIMEOUT = 60 def print_usage(): print "Usage: pnuke [OPTIONS] -h hosts.txt pattern" print print " -h --hosts hosts file (each line \"host[:port] [user]\")" print " -l --user username (OPTIONAL)" print " -p --par max number of parallel threads (OPTIONAL)" print " -o --outdir output directory for stdout files (OPTIONAL)" print " -e --errdir output directory for stderr files (OPTIONAL)" print " -t --timeout timeout in seconds to do ssh to a host (OPTIONAL)" print " -v --verbose turn on warning and diagnostic messages (OPTIONAL)" print " -O --options SSH options (OPTIONAL)" print print "Example: pnuke -h hosts.txt -l irb2 java" print def read_envvars(flags): if os.getenv("PSSH_HOSTS"): flags["hosts"] = os.getenv("PSSH_HOSTS") if os.getenv("PSSH_USER"): flags["user"] = os.getenv("PSSH_USER") if os.getenv("PSSH_PAR"): flags["par"] = int(os.getenv("PSSH_PAR")) if os.getenv("PSSH_OUTDIR"): flags["outdir"] = os.getenv("PSSH_OUTDIR") if os.getenv("PSSH_ERRDIR"): flags["errdir"] = os.getenv("PSSH_ERRDIR") if os.getenv("PSSH_TIMEOUT"): flags["timeout"] = int(os.getenv("PSSH_TIMEOUT")) if os.getenv("PSSH_VERBOSE"): # "0" or "1" flags["verbose"] = int(os.getenv("PSSH_VERBOSE")) if os.getenv("PSSH_OPTIONS"): flags["options"] = os.getenv("PSSH_OPTIONS") def parsecmdline(argv): import getopt shortopts = "h:l:p:o:e:t:vO:" longopts = [ "hosts", "user", "par", "outdir", "errdir", "timeout", "verbose", "options" ] flags = { "hosts" : None, "user" : None, "par" : _DEFAULT_PARALLELISM, "outdir" : None, "errdir" : None, "timeout" : _DEFAULT_TIMEOUT, "verbose" : None, "options" : None } read_envvars(flags) if not flags["user"]: flags["user"] = pwd.getpwuid(os.getuid())[0] # Default to current user opts, args = getopt.getopt(argv[1:], shortopts, longopts) for o, v in opts: if o in ("-h", "--hosts"): flags["hosts"] = v elif o in ("-l", "--user"): flags["user"] = v elif o in ("-p", "--par"): flags["par"] = int(v) elif o in ("-o", "--outdir"): flags["outdir"] = v elif o in ("-e", "--errdir"): flags["errdir"] = v elif o in ("-t", "--timeout"): flags["timeout"] = int(v) elif o in ("-v", "--verbose"): flags["verbose"] = 1 elif o in ("-O", "--options"): flags["options"] = v # Required flags if not flags["hosts"]: print_usage() sys.exit(3) return args, flags def do_pnuke(hosts, ports, users, pattern, flags): import os, re if flags["outdir"] and not os.path.exists(flags["outdir"]): os.makedirs(flags["outdir"]) if flags["errdir"] and not os.path.exists(flags["errdir"]): os.makedirs(flags["errdir"]) sem = threading.Semaphore(flags["par"]) threads = [] for i in range(len(hosts)): sem.acquire() if flags["verbose"]: quietswitch = "" else: quietswitch = "-q" if flags["options"]: cmd = 'ssh -o \"%s\" %s -p %s -l %s %s \"kill -9 \`ps -ef | grep %s | grep %s | grep -v grep | awk \'{print \$2}\'\` >& /dev/null"' % (flags["options"], hosts[i], ports[i], users[i], quietswitch, users[i], pattern) else: cmd = 'ssh %s -p %s -l %s %s \"kill -9 \`ps -ef | grep %s | grep %s | grep -v grep | awk \'{print \$2}\'\` >& /dev/null"' % \ (hosts[i], ports[i], users[i], quietswitch, users[i], pattern) t = BaseThread(hosts[i], ports[i], cmd, flags, sem) t.start() threads.append(t) for t in threads: t.join() if __name__ == "__main__": from psshlib import psshutil args, flags = parsecmdline(sys.argv) if len(args) == 0: print_usage() sys.exit(3) pattern = args[0] cmdline = " ".join(args) hosts, ports, users = psshutil.read_hosts(flags["hosts"]) psshutil.patch_users(hosts, ports, users, flags["user"]) os.setpgid(0, 0) do_pnuke(hosts, ports, users, pattern, flags) PK•‹.8‡7#º==EGG-INFO/scripts/pscp#!/usr/local/bin/python2.3 # -*- Mode: python -*- # # Usage: pscp [OPTIONS] -h hosts.txt local remote # # Parallel scp to the set of nodes in hosts.txt. For each node, # we essentially do a scp [-r] local user@host:remote. This program # also uses the -q (quiet) and -C (compression) options. Note # that remote must be an absolute path. # # Created: 16 August 2003 # # $Id: pscp,v 1.1.1.1 2005/12/31 10:03:33 bnc Exp $ # import fcntl, os, popen2, pwd, select, signal, sys, threading, time basedir, bin = os.path.split(os.path.dirname(os.path.abspath(sys.argv[0]))) sys.path.append("%s" % basedir) import psshlib from psshlib.basethread import BaseThread _DEFAULT_PARALLELISM = 32 _DEFAULT_TIMEOUT = sys.maxint # "infinity" by default def print_usage(): print "Usage: pscp [OPTIONS] -h hosts.txt local remote" print print " -r --recursive recusively copy directories (OPTIONAL)" print " -h --hosts hosts file (each line \"host[:port] [login]\")" print " -l --user username (OPTIONAL)" print " -p --par max number of parallel threads (OPTIONAL)" print " -o --outdir output directory for stdout files (OPTIONAL)" print " -e --errdir output directory for stderr files (OPTIONAL)" print " -t --timeout timeout in seconds to do scp to a host (OPTIONAL)" print " -O --options SSH options (OPTIONAL)" print print "Example: pscp -h hosts.txt -l irb2 foo.txt /home/irb2/foo.txt" print def read_envvars(flags): if os.getenv("PSSH_HOSTS"): flags["hosts"] = os.getenv("PSSH_HOSTS") if os.getenv("PSSH_USER"): flags["user"] = os.getenv("PSSH_USER") if os.getenv("PSSH_PAR"): flags["par"] = int(os.getenv("PSSH_PAR")) if os.getenv("PSSH_OUTDIR"): flags["outdir"] = os.getenv("PSSH_OUTDIR") if os.getenv("PSSH_ERRDIR"): flags["errdir"] = os.getenv("PSSH_ERRDIR") if os.getenv("PSSH_TIMEOUT"): flags["timeout"] = int(os.getenv("PSSH_TIMEOUT")) if os.getenv("PSSH_OPTIONS"): flags["options"] = os.getenv("PSSH_OPTIONS") def parsecmdline(argv): import getopt shortopts = "rh:l:p:o:e:t:O:" longopts = [ "recursive", "hosts" , "user", "par", "outdir", "errdir", "timeout", "options" ] flags = { "recursive" : None, "hosts" : None, "user" : None, "par" : _DEFAULT_PARALLELISM, "outdir" : None, "errdir" : None, "timeout" : _DEFAULT_TIMEOUT, "options" : None } read_envvars(flags) if not flags["user"]: flags["user"] = pwd.getpwuid(os.getuid())[0] # Default to current user opts, args = getopt.getopt(argv[1:], shortopts, longopts) for o, v in opts: if o in ("-r", "--recursive"): flags["recursive"] = 1 elif o in ("-h", "--hosts"): flags["hosts"] = v elif o in ("-l", "--user"): flags["user"] = v elif o in ("-p", "--par"): flags["par"] = int(v) elif o in ("-o", "--outdir"): flags["outdir"] = v elif o in ("-e", "--errdir"): flags["errdir"] = v elif o in ("-t", "--timeout"): flags["timeout"] = int(v) elif o in ("-O", "--options"): flags["options"] = v # Required flags if not flags["hosts"]: print_usage() sys.exit(3) return args, flags def do_pscp(hosts, ports, users, local, remote, flags): import os if flags["outdir"] and not os.path.exists(flags["outdir"]): os.makedirs(flags["outdir"]) if flags["errdir"] and not os.path.exists(flags["errdir"]): os.makedirs(flags["errdir"]) sem = threading.Semaphore(flags["par"]) threads = [] for i in range(len(hosts)): sem.acquire() if flags["options"] and flags["recursive"]: cmd = "scp -o \"%s\" -qrC -P %d %s %s@%s:%s" % \ (flags["options"], ports[i], local, users[i], hosts[i], remote) elif flags["options"] and not flags["recursive"]: cmd = "scp -o \"%s\" -qC -P %d %s %s@%s:%s" % \ (flags["options"], ports[i], local, users[i], hosts[i], remote) elif not flags["options"] and flags["recursive"]: cmd = "scp -qrC -P %d %s %s@%s:%s" % \ (ports[i], local, users[i], hosts[i], remote) else: cmd = "scp -qC -P %d %s %s@%s:%s" % \ (ports[i], local, users[i], hosts[i], remote) t = BaseThread(hosts[i], ports[i], cmd, flags, sem) t.start() threads.append(t) for t in threads: t.join() if __name__ == "__main__": import os, pwd, re from psshlib import psshutil args, flags = parsecmdline(sys.argv) if len(args) != 2: print_usage() sys.exit(3) local = args[0] remote = args[1] if not re.match("^/", remote): print "Remote path %s must be an absolute path" % remote sys.exit(3) hosts, ports, users = psshutil.read_hosts(flags["hosts"]) psshutil.patch_users(hosts, ports, users, flags["user"]) os.setpgid(0, 0) do_pscp(hosts, ports, users, local, remote, flags) PK•‹.8¯ãÐ;ooEGG-INFO/scripts/prsync#!/usr/local/bin/python2.3 # -*- Mode: python -*- # # Usage: prsync [OPTIONS] -h hosts.txt local remote # # Parallel rsync to the set of nodes in hosts.txt. For each node, # we essentially do a rsync -rv -e ssh local user@host:remote. # Note that remote must be an absolute path. # # Created: 16 August 2003 # # $Id: prsync,v 1.1.1.1 2005/12/31 10:03:33 bnc Exp $ # import fcntl, os, popen2, pwd, select, signal, sys, threading, time basedir, bin = os.path.split(os.path.dirname(os.path.abspath(sys.argv[0]))) sys.path.append("%s" % basedir) import psshlib from psshlib.basethread import BaseThread _DEFAULT_PARALLELISM = 32 _DEFAULT_TIMEOUT = sys.maxint # "infinity" by default def print_usage(): print "Usage: prsync [OPTIONS] -h hosts.txt local remote" print print " -r --recursive recusively copy directories (OPTIONAL)" print " -a --archive use rsync -a (archive mode) (OPTIONAL)" print " -z --compress use rsync compression (OPTIONAL)" print " -h --hosts hosts file (each line \"host[:port] [login]\")" print " -l --user username (OPTIONAL)" print " -p --par max number of parallel threads (OPTIONAL)" print " -o --outdir output directory for stdout files (OPTIONAL)" print " -e --errdir output directory for stderr files (OPTIONAL)" print " -t --timeout timeout in seconds to do rsync to a host (OPTIONAL)" print " -O --options SSH options (OPTIONAL)" print print "Example: prsync -r -h hosts.txt -l irb2 foo " + \ "/home/irb2/foo" print def read_envvars(flags): if os.getenv("PSSH_HOSTS"): flags["hosts"] = os.getenv("PSSH_HOSTS") if os.getenv("PSSH_USER"): flags["user"] = os.getenv("PSSH_USER") if os.getenv("PSSH_PAR"): flags["par"] = int(os.getenv("PSSH_PAR")) if os.getenv("PSSH_OUTDIR"): flags["outdir"] = os.getenv("PSSH_OUTDIR") if os.getenv("PSSH_ERRDIR"): flags["errdir"] = os.getenv("PSSH_ERRDIR") if os.getenv("PSSH_TIMEOUT"): flags["timeout"] = int(os.getenv("PSSH_TIMEOUT")) if os.getenv("PSSH_OPTIONS"): flags["options"] = os.getenv("PSSH_OPTIONS") def parsecmdline(argv): import getopt shortopts = "razh:l:p:o:e:t:O:" longopts = [ "recursive", "archive", "compress", "hosts", "user", "par", "outdir", "errdir", "timeout", "options" ] flags = { "recursive" : None, "archive" : None, "compress" : None, "hosts" : None, "user" : None, "par" : _DEFAULT_PARALLELISM, "outdir" : None, "errdir" : None, "timeout" : _DEFAULT_TIMEOUT, "options" : None } read_envvars(flags) if not flags["user"]: flags["user"] = pwd.getpwuid(os.getuid())[0] # Default to current user opts, args = getopt.getopt(argv[1:], shortopts, longopts) for o, v in opts: if o in ("-r", "--recursive"): flags["recursive"] = 1 elif o in ("-a", "--archive"): flags["archive"] = 1 elif o in ("-z", "--compress"): flags["compress"] = 1 elif o in ("-h", "--hosts"): flags["hosts"] = v elif o in ("-l", "--user"): flags["user"] = v elif o in ("-p", "--par"): flags["par"] = int(v) elif o in ("-o", "--outdir"): flags["outdir"] = v elif o in ("-e", "--errdir"): flags["errdir"] = v elif o in ("-t", "--timeout"): flags["timeout"] = int(v) elif o in ("-O", "--options"): flags["options"] = v # Required flags if not flags["hosts"]: print_usage() sys.exit(3) return args, flags def do_prsync(hosts, ports, users, local, remote, flags): import os if flags["outdir"] and not os.path.exists(flags["outdir"]): os.makedirs(flags["outdir"]) if flags["errdir"] and not os.path.exists(flags["errdir"]): os.makedirs(flags["errdir"]) sem = threading.Semaphore(flags["par"]) threads = [] for i in range(len(hosts)): sem.acquire() if flags["recursive"]: recursiveswitch = "-r" else: recursiveswitch = "" if flags["archive"]: archiveswitch = "-a" else: archiveswitch = "" if flags["compress"]: compressswitch = "-z" else: compressswitch = "" if flags["options"]: cmd = "rsync --port %d %s %s %s -v -e \"ssh -o %s\" %s %s@%s:%s" % (ports[i], archiveswitch, compressswitch, recursiveswitch, flags["options"], local, users[i], hosts[i], remote) else: cmd = "rsync --port %d %s %s %s -v -e ssh %s %s@%s:%s" % (ports[i], archiveswitch, compressswitch, recursiveswitch, local, users[i], hosts[i], remote) t = BaseThread(hosts[i], ports[i], cmd, flags, sem) t.start() threads.append(t) for t in threads: t.join() if __name__ == "__main__": import os, pwd, re from psshlib import psshutil args, flags = parsecmdline(sys.argv) if len(args) != 2: print_usage() sys.exit(3) local = args[0] remote = args[1] if not re.match("^/", remote): print "Remote path %s must be an absolute path" % remote sys.exit(3) hosts, ports, users = psshutil.read_hosts(flags["hosts"]) psshutil.patch_users(hosts, ports, users, flags["user"]) os.setpgid(0, 0) do_prsync(hosts, ports, users, local, remote, flags) PK”‹.8qgœnnEGG-INFO/scripts/pssh#!/usr/local/bin/python2.3 # -*- Mode: python -*- # # Usage: pssh [OPTIONS] -h hosts.txt prog [arg0] [arg1] .. # # Parallel ssh to the set of nodes in hosts.txt. For each node, this # essentially does an "ssh host -l user prog [arg0] [arg1] ...". The -o # option can be used to store stdout from each remote node in a # directory. Each output file in that directory will be named by the # corresponding remote node's hostname or IP address. # # Created: 16 August 2003 # # $Id: pssh,v 1.1.1.1 2005/12/31 10:03:33 bnc Exp $ # import fcntl, os, popen2, pwd, select, signal, sys, threading, time basedir, bin = os.path.split(os.path.dirname(os.path.abspath(sys.argv[0]))) sys.path.append("%s" % basedir) import psshlib from psshlib.basethread import BaseThread _DEFAULT_PARALLELISM = 32 _DEFAULT_TIMEOUT = 60 def print_usage(): print "Usage: pssh [OPTIONS] -h hosts.txt prog [arg0] .." print print " -h --hosts hosts file (each line \"host[:port] [user]\")" print " -l --user username (OPTIONAL)" print " -p --par max number of parallel threads (OPTIONAL)" print " -o --outdir output directory for stdout files (OPTIONAL)" print " -e --errdir output directory for stderr files (OPTIONAL)" print " -t --timeout timeout in seconds to do ssh to a host (OPTIONAL)" print " -v --verbose turn on warning and diagnostic messages (OPTIONAL)" print " -O --options SSH options (OPTIONAL)" print " -P --print print output as we get it (OPTIONAL)" print " -i --inline inline aggregated output for each server (OPTIONAL)" print print "Example: pssh -h nodes.txt -l irb2 -o /tmp/foo uptime" print def read_envvars(flags): if os.getenv("PSSH_HOSTS"): flags["hosts"] = os.getenv("PSSH_HOSTS") if os.getenv("PSSH_USER"): flags["user"] = os.getenv("PSSH_USER") if os.getenv("PSSH_PAR"): flags["par"] = int(os.getenv("PSSH_PAR")) if os.getenv("PSSH_OUTDIR"): flags["outdir"] = os.getenv("PSSH_OUTDIR") if os.getenv("PSSH_ERRDIR"): flags["errdir"] = os.getenv("PSSH_ERRDIR") if os.getenv("PSSH_TIMEOUT"): flags["timeout"] = int(os.getenv("PSSH_TIMEOUT")) if os.getenv("PSSH_VERBOSE"): # "0" or "1" flags["verbose"] = int(os.getenv("PSSH_VERBOSE")) if os.getenv("PSSH_OPTIONS"): flags["options"] = os.getenv("PSSH_OPTIONS") def parsecmdline(argv): import getopt shortopts = "h:l:p:o:e:t:vO:P:i" longopts = [ "hosts", "user", "par", "outdir", "errdir", "timeout", "verbose", "options", "print", "inline" ] flags = { "hosts" : None, "user" : None, "par" : _DEFAULT_PARALLELISM, "outdir" : None, "errdir" : None, "timeout" : _DEFAULT_TIMEOUT, "verbose" : None, "options" : None, "print" : None, "inline": None } read_envvars(flags) if not flags["user"]: flags["user"] = pwd.getpwuid(os.getuid())[0] # Default to current user opts, args = getopt.getopt(argv[1:], shortopts, longopts) for o, v in opts: if o in ("-h", "--hosts"): flags["hosts"] = v elif o in ("-l", "--user"): flags["user"] = v elif o in ("-p", "--par"): flags["par"] = int(v) elif o in ("-o", "--outdir"): flags["outdir"] = v elif o in ("-e", "--errdir"): flags["errdir"] = v elif o in ("-t", "--timeout"): flags["timeout"] = int(v) elif o in ("-v", "--verbose"): flags["verbose"] = 1 elif o in ("-O", "--options"): flags["options"] = v elif o in ("-P", "--print"): flags["print"] = 1 elif o in ("-i", "--inline"): flags["inline"] = 1 # Required flags if not flags["hosts"]: print_usage() sys.exit(3) return args, flags def buffer_input(): fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, os.O_NONBLOCK) try: return sys.stdin.read() except IOError: # Stdin contained no information return '' def do_pssh(hosts, ports, users, cmdline, flags): import os, re if flags["outdir"] and not os.path.exists(flags["outdir"]): os.makedirs(flags["outdir"]) if flags["errdir"] and not os.path.exists(flags["errdir"]): os.makedirs(flags["errdir"]) input = buffer_input() sem = threading.Semaphore(flags["par"]) threads = [] for i in range(len(hosts)): sem.acquire() if flags["verbose"]: quietswitch = "" else: quietswitch = "-q" if flags["options"]: cmd = "ssh -o \"%s\" %s -p %s -l %s %s \"%s\"" % \ (flags["options"], hosts[i], ports[i], users[i], quietswitch, cmdline) else: cmd = "ssh %s -p %s -l %s %s \"%s\"" % \ (hosts[i], ports[i], users[i], quietswitch, cmdline) t = BaseThread(hosts[i], ports[i], cmd, flags, sem, input) t.start() threads.append(t) for t in threads: t.join() def main(): from psshlib import psshutil args, flags = parsecmdline(sys.argv) if len(args) == 0: print_usage() sys.exit(3) cmdline = " ".join(args) hosts, ports, users = psshutil.read_hosts(flags["hosts"]) psshutil.patch_users(hosts, ports, users, flags["user"]) os.setpgid(0, 0) do_pssh(hosts, ports, users, cmdline, flags) if __name__ == "__main__": main() PKó‹6™Ñáѽ½¤psshlib/color.pyPK…‹.8P6"’’¤ëpsshlib/psshutil.pyPKó‹6¤® psshlib/__init__.pyPK‹.8ª•³þˆ ˆ ¤ß psshlib/psshutil.pycPK‹.8#4s7dd¤™psshlib/basethread.pycPK…‹.8½`¦¦¤1)psshlib/basethread.pyPK‹.8uöÙ„„¤ <psshlib/__init__.pycPK‹.8ºêË\— — ¤À<psshlib/color.pycPK•‹.8“×2¤†GEGG-INFO/zip-safePKŽ‹.8<2Ÿ¯¯¤¶GEGG-INFO/SOURCES.txtPKŽ‹.8“×2¤—IEGG-INFO/dependency_links.txtPKŽ‹.81$/CÊʤÓIEGG-INFO/PKG-INFOPKŽ‹.8ƒŸî±¤ÌJEGG-INFO/top_level.txtPK•‹.8!áN-  íKEGG-INFO/scripts/pslurpPK”‹.8–µµíIbEGG-INFO/scripts/pnukePK•‹.8‡7#º==í2uEGG-INFO/scripts/pscpPK•‹.8¯ãÐ;ooí¢‰EGG-INFO/scripts/prsyncPK”‹.8qgœnníFŸEGG-INFO/scripts/psshPK­ç´