Ejemplo n.º 1
0
 def rename(self, argv):
     if len(argv) < 2:
         print
         print "fileutils rename [-v] <pattern> <repl> [root]"
         sys.exit(-1)
     argsparser = CustomArgsParser(optFlags=['-v'])
     argsparser.parse(argv)
     verbose = argsparser.getOption('-v')
     posArgs = argsparser.getPosArgs()
     pattern = posArgs[0]
     repl = posArgs[1]
     if len(posArgs) == 3:
         root = normalizeName(posArgs[2])
     else:
         root = normalizeName(os.curdir)
     renameFiles(root, pattern, repl, verbose)
Ejemplo n.º 2
0
 def scatter(self, argv):
     parser = CustomArgsParser(optKeys=['--np', '--outsize', '--errsize'])
     parser.parse(argv)
     if (len(parser.getPosArgs()) < 2):
         print
         print 'ssh scatter <src> [<user>@]<host-file>:<range>:<dst> [options]'
         print '    options:'
         print '         --np <num procs>'
         print '         --outsize <num stdout lines>'
         print '         --errsize <num stderr lines>'
         sys.exit(-1)
     nprocs = int(parser.getOption('--np', 4))
     outBufSize = int(parser.getOption('--outsize', 10))
     errBufSize = int(parser.getOption('--errsize', 50))
     runSSHScatter(parser.getPosArgs(), nprocs, outBufSize, errBufSize)
Ejemplo n.º 3
0
 def gather(self, argv):
     parser = CustomArgsParser(optKeys=['--np', '--outsize', '--errsize'],
                               optFlags=['--no-merge'])
     parser.parse(argv)
     if (len(parser.getPosArgs()) < 2):
         print
         print 'ssh gather [<user>@]<host-file>:<range>:<src> <dst>'
         print '    options:'
         print '         --np <num procs>'
         print '         --outsize <num stdout lines>'
         print '         --errsize <num stderr lines>'
         print '         --no-merge'
         sys.exit(-1)
     nomerge = bool(parser.getOption('--no-merge', True))
     nprocs = int(parser.getOption('--np', 4))
     outBufSize = int(parser.getOption('--outsize', 10))
     errBufSize = int(parser.getOption('--errsize', 50))
     runSSHGather(parser.getPosArgs(), not nomerge,
                  nprocs, outBufSize, errBufSize)