def get_file_value(filename):
    try:
        with open(filename, 'r') as file_read:
            values = file_read.read()
        return values
    except:
        logerror("File:(%s) is not find" % (filename, ))
        return None
Beispiel #2
0
def kafka_auto_deploy(driver, logger, data):
    kafka = kafka_install(driver, logger, data["deploy_data"]["Kafka_data"])
    manager_url = data["manager_url"]
    #    login(driver,manager_url)
    try:
        login(driver, manager_url)
        kafka.start()
    except Exception, e:
        logerror("install fail:\n %s" % e)
Beispiel #3
0
def cluster_deploy(driver, logger, data):
    installer = cluster_install(driver, logger, data["deploy_data"])
    manager_url = data["manager_url"]
    #    login(driver,manager_url)
    try:
        login(driver, manager_url)
        installer.start()
    except Exception, e:
        logerror("install fail:\n %s" % e)
Beispiel #4
0
def get_element_text(driver,method,para):
    ele=find_elements(driver, method, para)
    if ele and len(ele)==1:
        try:
            loginfo(u'[%s]开始获取元素:%s中的文本'%(method,para))
            result=ele[0].text
            return result
        except Exception,e:
            logerror(u'[%s]获取元素:%s中的文本失败\n%s' %(method,para,e))
            return None
Beispiel #5
0
def click_element(driver,method,para):
    ele=find_elements(driver, method, para)
    if ele and len(ele)==1:
        try:
            loginfo(u'[%s]开始点击元素:%s' %(method,para))
            ele[0].click()
            return True
        except Exception,e:
            logerror(u'[%s]点击元素:%s失败\n%s' %(method,para,e))
            return False
Beispiel #6
0
def input_text(driver,method,para,text):
    ele=find_elements(driver, method, para)
    if ele and len(ele)==1:
        try:
            loginfo(u'[%s]开始向元素:%s中输入字符:%s' %(method,para,text))
            ele[0].clear()
            ele[0].send_keys(text)
            return True
        except Exception,e:
            logerror(u'[%s]向元素:%s输入字符失败\n%s' %(method,para,e))
            return False
Beispiel #7
0
def shell_command(command, info="", prin_t=True):
    loginfo(command)
    cm = subprocess.Popen(command,
                          stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE,
                          shell=True)
    _, err = cm.communicate()
    if cm.returncode != 0:
        logerror(err)
        logerror("Non zero exit code:%s executing: %s" % (cm.returncode, info))
        raise StandardError
def get_close_window_list(driver, not_close_window):
    handles = driver.window_handles
    window_list = []
    if type(not_close_window) is types.UnicodeType and type(
            not_close_window) is not types.ListType:
        not_close_window = not_close_window.split(" ")
    else:
        logerror("parameter is wrong")
    for handle in handles:
        if handle not in not_close_window:
            window_list.append(handle)
    return window_list
Beispiel #9
0
def run(case_name):
    logName = BASE_DIR + "/logs/install_log-%s.log" % (get_time())
    logger = Logger(filename=logName, loglevel=3)
    data = get_cluster_config()
    driver = driverInit()
    if case_name == u"kafka_deploy":
        kafka_auto_deploy(driver, logger, data)
    elif case_name == u"cluster_deploy":
        cluster_deploy(driver, logger, data)
    else:
        logerror("invalid option")
        dirverEnd(driver)
        os._exit(0)