예제 #1
0
파일: task.py 프로젝트: zhanghonged/0911
def exect(minfo,ccc):
  if len(sys.argv) > 1:
    if sys.argv[1] == '--help' and len(sys.argv) == 2:
      print help.help()
    if sys.argv[1] == '--version' and len(sys.argv) == 2:
      ver=help.version()
      print "version is %s" %ver
    for j,k in minfo.items():
      user=j.split(':')[0]
      host=j.split(':')[1]
      port=int(j.split(':')[2])
      password=k
      if sys.argv[1] in ['--help','--version'] and len(sys.argv) == 2:
        pass
      elif sys.argv[1] == 'run' and len(sys.argv) == 3:
        print 'exec host is                                                %s ' %host
        print sys.argv[1:]
        date=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
        log='%s %s start run command:' %(date,host)
        addlog.wlog(log)
        r=run_cmd(user,password,host,port,sys.argv[2])
        r.run()
      elif sys.argv[1] == 'put' and len(sys.argv) == 4:
        print 'exec host is                                                %s ' %host
        print sys.argv[1:]
        date=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
        log='%s %s start put' %(date,host)
        addlog.wlog(log)
        addlog.wlog(sys.argv[1:])
        p=uad(user,password,host,port,sys.argv[2],sys.argv[3])
        p.tran_put()
      elif sys.argv[1] == 'get' and len(sys.argv) == 4:
        print 'exec host is                                                %s ' %host
        print sys.argv[1:]
        date=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
        log='%s %s start get' %(date,host)
        addlog.wlog(log)
        addlog.wlog(sys.argv[1:])
        p=uad(user,password,host,port,sys.argv[2],sys.argv[3])
        p.tran_get()
      else:
        print 'Is Wrong,Please input again'
  else:
    for j,k in minfo.items():
      user=j.split(':')[0]
      host=j.split(':')[1]
      port=int(j.split(':')[2])
      password=k
      print 'exec host is                                                %s ' %host
      date=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
      log='%s %s start:' %(date,host)
      addlog.wlog(log)
      r=run_cmd(user,password,host,port,ccc)
      r.run()
예제 #2
0
def exect(minfo,ccc):
  if len(sys.argv) > 1:
    if sys.argv[1] == '--help' and len(sys.argv) == 2:
      print help.help()
    if sys.argv[1] == '--version' and len(sys.argv) == 2:
      ver=help.version()
      print "version is %s" %ver
    for j,k in minfo.items():
      user=j.split(':')[0]
      host=j.split(':')[1]
      port=int(j.split(':')[2])
      password=k
      if sys.argv[1] in ['--help','--version'] and len(sys.argv) == 2:
        pass
      elif sys.argv[1] == 'run' and len(sys.argv) == 3:
        print 'exec host is                                                %s ' %host
        print sys.argv[1:]
        r=run_cmd(user,password,host,port,sys.argv[2])
        r.start()
      elif sys.argv[1] == 'put' and len(sys.argv) == 4:
        print 'exec host is                                                %s ' %host
        print sys.argv[1:]
        p=tran_put(user,password,host,port,sys.argv[2],sys.argv[3])
        p.start()
      elif sys.argv[1] == 'get' and len(sys.argv) == 4:
        print 'exec host is                                                %s ' %host
        print sys.argv[1:]
        p=tran_get(user,password,host,port,sys.argv[2],sys.argv[3])
        p.start()
      else:
        print 'Is Wrong,Please input again'
  else:
    for j,k in minfo.items():
      user=j.split(':')[0]
      host=j.split(':')[1]
      port=int(j.split(':')[2])
      password=k
      print 'exec host is                                                %s ' %host
      r=run_cmd(user,password,host,port,ccc)
      r.start()
예제 #3
0
파일: swup.py 프로젝트: thwarted/swup
        sys.exit(2)

    # Setup the configuration and get the mode in which we are supposed to
    # run.
    try:
        mode, args, config = setup(argdict)
    except SetupException, errmsg:
        sys.stderr.write('%s\n' % errmsg)
        sys.exit(2)

    # Check for the simpler modes that does not involve the upgrade module.
    if mode == 'help':
        help.helpme()
        sys.exit(0)
    elif mode == 'version':
        help.version()
        sys.exit(0)
    elif mode == 'import_key':
        try:
            import_key(args, config['gnupgdir'])
            sys.exit(0)
        except ImportKeyException, errmsg:
            sys.stderr.write('%s\n' % errmsg)
            sys.exit(2)
    elif mode == 'list_keys':
        try:
            list_keys(config['gnupgdir'])
            sys.exit(0)
        except ListKeysException, errmsg:
            sys.stderr.write('%s\n' % errmsg)
            sys.exit(1)
예제 #4
0
파일: swup.py 프로젝트: thwarted/swup
        sys.exit(2)

    # Setup the configuration and get the mode in which we are supposed to
    # run.
    try:
        mode, args, config = setup(argdict)
    except SetupException, errmsg:
        sys.stderr.write("%s\n" % errmsg)
        sys.exit(2)

    # Check for the simpler modes that does not involve the upgrade module.
    if mode == "help":
        help.helpme()
        sys.exit(0)
    elif mode == "version":
        help.version()
        sys.exit(0)
    elif mode == "import_key":
        try:
            import_key(args, config["gnupgdir"])
            sys.exit(0)
        except ImportKeyException, errmsg:
            sys.stderr.write("%s\n" % errmsg)
            sys.exit(2)
    elif mode == "list_keys":
        try:
            list_keys(config["gnupgdir"])
            sys.exit(0)
        except ListKeysException, errmsg:
            sys.stderr.write("%s\n" % errmsg)
            sys.exit(1)