示例#1
0
def test():
    log_debug('install', 'start testing ')
    login_cnt = 0
    install_cnt = 0
    for i in range(TEST_ROUNDS):
        if SHOW_TIME:
            start_time = datetime.utcnow()
        username = USER + str(USER_START + i)
        uid, key = login(username, PASSWORD)
        if not uid or not key:
            log_err('install->login', 'failed to login %s.' % str(username))
            return False
        login_cnt += 1
        log_debug('install->login', 'login_cnt=%d' % login_cnt)
        if SHOW_TIME:
            log_debug('install->login',
                      'time=%d sec' % (datetime.utcnow() - start_time).seconds)
            start_time = datetime.utcnow()

        if RANDOM_DRIVER:
            driver_num = randint(40, DRIVER_NUM)
            package = DRIVER_PACKAGE + str(driver_num)
        else:
            package = DRIVER_PACKAGE + str(DRIVER_START + i)

        if not install_driver(uid, package, VERSION):
            log_err('instll', 'failed to install driver %s' % str(package))
            return False
        if SHOW_TIME:
            log_debug('install',
                      'time=%d sec' % (datetime.utcnow() - start_time).seconds)
        install_cnt += 1
        log_debug('install', 'install_cnt=%d' % install_cnt)
示例#2
0
文件: install.py 项目: tx626/dpmtest
def test():
    log_debug('install', 'start testing ')
    login_cnt = 0
    install_cnt = 0
    for i in range(TEST_ROUNDS):
        if SHOW_TIME:
            start_time = datetime.utcnow()
        username = USER + str(USER_START + i)
        uid, key = login(username, PASSWORD)
        if not uid or not key:
            log_err('install->login', 'failed to login %s.' % str(username))
            return False
        login_cnt += 1
        log_debug('install->login', 'login_cnt=%d' % login_cnt)
        if SHOW_TIME:
            log_debug('install->login', 'time=%d sec' % (datetime.utcnow() - start_time).seconds)
            start_time = datetime.utcnow()
        
        if RANDOM_DRIVER:
            driver_num = randint(0, DRIVER_NUM - 1)
            package = DRIVER_PACKAGE + str(driver_num)
        else:
            package = DRIVER_PACKAGE + str(DRIVER_START + i)
        
        if not install_driver(uid, package, VERSION):
            log_err('instll', 'failed to install driver %s' % str(package))
            return False
        if SHOW_TIME:
            log_debug('install', 'time=%d sec' % (datetime.utcnow() - start_time).seconds)
        install_cnt += 1
        log_debug('install', 'install_cnt=%d' % install_cnt)
示例#3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-d', '--driver', action='store_true')
    parser.add_argument('-a', '--app', action='store_true')
    parser.add_argument('-i', dest='uid', default=None)
    parser.add_argument('-u', dest='username', default=None)
    parser.add_argument('-p', dest='password', default=None)
    parser.add_argument('-v', dest='version', default=None)
    parser.add_argument('-s', dest='source', default=None)

    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit()

    cmd = sys.argv[1]
    if cmd == 'login':
        args = parser.parse_args(sys.argv[2:])
        uid, key = login(args.username, args.password)
        log_debug('dpm',
                  'finished login, uid=%s, key=%s' % (str(uid), str(key)))
        sys.exit()
    else:
        package = sys.argv[2]
        args = parser.parse_args(sys.argv[3:])
        user = args.username
        password = args.password
        version = args.version
        path = args.source
        uid = args.uid

    if len(package.split('==')) > 1:
        package, version = get_version(package)

    if args.app:
        if cmd == 'upload':
            uid, key = login(user, password)
            if upload_app(path, uid, package, version, key):
                log_debug('dpm', 'finished uploading app %s' % package)
        elif cmd == 'install':
            uid, key = login(user, password)
            if install_app(uid, package, version):
                log_debug('dpm', 'finished installing app %s' % package)
        elif cmd == 'uninstall':
            uid, key = login(user, password)
            if uninstall_app(uid, package):
                log_debug('dpm', 'finished removing app %s' % package)

    elif args.driver:
        if cmd == 'upload':
            uid, key = login(user, password)
            if upload_driver(path, uid, package, version):
                log_debug('dpm', 'finished uploading driver %s' % package)
        elif cmd == 'install':
            uid, key = login(user, password)
            if install_driver(uid, package, version):
                log_debug('dpm', 'finished installing driver %s' % package)
示例#4
0
文件: dpm.py 项目: tx626/dpm
def main(): 
    parser = argparse.ArgumentParser()
    parser.add_argument('-d', '--driver', action='store_true')
    parser.add_argument('-a', '--app', action='store_true')
    parser.add_argument('-i',  dest='uid', default=None)
    parser.add_argument('-u',  dest='username', default=None)
    parser.add_argument('-p',  dest='password', default=None)
    parser.add_argument('-v',  dest='version', default=None)
    parser.add_argument('-s',  dest='source', default=None)
    
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit()
    
    cmd = sys.argv[1]
    if cmd == 'login':
        args = parser.parse_args(sys.argv[2:])
        uid, key = login(args.username, args.password)
        log_debug('dpm', 'finished login, uid=%s, key=%s' % (str(uid), str(key)))
        sys.exit()
    else:
        package = sys.argv[2]
        args = parser.parse_args(sys.argv[3:])
        user = args.username
        password = args.password
        version = args.version
        path = args.source
        uid = args.uid
        
    if len(package.split('==')) > 1:
        package, version = get_version(package)
    
    if args.app:
        if cmd == 'upload':
            uid, key = login(user, password)
            if upload_app(path, uid, package, version, key):
                log_debug('dpm', 'finished uploading app %s' % package)
        elif cmd == 'install':
            uid, key = login(user, password)
            if install_app(uid, package, version):
                log_debug('dpm', 'finished installing app %s' % package)
        elif cmd == 'uninstall':
            uid, key = login(user, password)
            if uninstall_app(uid, package):
                log_debug('dpm', 'finished removing app %s' % package) 
    
    elif args.driver:
        if cmd == 'upload':
            uid, key = login(user, password)
            if upload_driver(path, uid, package, version):
                log_debug('dpm', 'finished uploading driver %s' % package)
        elif cmd == 'install':
            uid, key = login(user, password)
            if install_driver(uid, package, version):
                log_debug('dpm', 'finished installing driver %s' % package)