本文整理汇总了Python中ChorusGlobals类的典型用法代码示例。如果您正苦于以下问题:Python ChorusGlobals类的具体用法?Python ChorusGlobals怎么用?Python ChorusGlobals使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ChorusGlobals类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: close_connection
def close_connection(db_handler = None):
if not db_handler:
db_handler = default_handler
cursor = db_handler.cursor()
cursor.close()
db_handler.close()
ChorusGlobals.get_logger().info("close mysql connection")
示例2: set_output_folder
def set_output_folder(self):
'''Set output folder
Input: options.outputpath
Output: self.outputdir, ChorusGlobals.outputdir'''
self.outputdir = Utils.create_folder(self.options.outputpath, "Output", True)
ChorusGlobals.set_outputdir(self.outputdir)
print "Set output directory to %s" % self.outputdir
示例3: set_configfile
def set_configfile(self):
configfile = ConfigFile(self.options.configfile,self.options.configpath)
configfile.get_env(self.options.env)
self.parameters = configfile.parameters
self.config = configfile.config
ChorusGlobals.set_parameters(self.parameters)
ChorusGlobals.set_configinfo(self.config)
示例4: execute_sql_dict
def execute_sql_dict(sql, db_handler = None, keep_connection = True):
'''execute sql and return a dict format data'''
try:
data = []
datadict=[]
if db_handler:
conn = db_handler
else:
if "default_handler" in globals().keys():
conn = default_handler
else:
keep_connection = False
conn = __init_connection(db_info)
cursor = conn.cursor()
ChorusGlobals.get_logger().info("Execute SQL '%s'" % sql)
cursor.execute(sql)
for row in cursor:
data.append(row)
for row in data:
rid=data.index(row)
celldict={}
for i in range(len(row)):
celldict[cursor.column_names[i]]=row[i]
datadict.append(celldict)
conn.commit()
except Exception, e:
traceback.print_exc()
ChorusGlobals.get_logger().critical("Errors in sql execution: %s" % e)
raise Exception("Errors in sql execution: %s" % e)
示例5: set_baselinepath
def set_baselinepath(self):
self.baselinepath = self.BASELINE_PATH
if self.config.has_key("baseline"):
paths = self.config["baseline"].split(".")
for path in paths:
self.baselinepath.append(path)
ChorusGlobals.set_baselinepath(self.baselinepath)
示例6: generate_json
def generate_json(detail):
try:
finaldetail = Utils.parse_description(detail) if type(detail)==str else detail
jsdata = json.dumps(finaldetail)
except Exception,e:
message = "The input detail cannot be transfer into json type, error is %s" % str(e)
ChorusGlobals.get_logger().warning(message)
jsdata = json.dumps({"message":message})
示例7: __init__
def __init__(self):
self.logger = ChorusGlobals.get_logger()
self.suiteinfo = ChorusGlobals.get_suiteinfo()
self.set_baselinepath()
self.suite_dict = self.get_test_mapping()
self.filter_test_mapping()
self.set_scope()
self.get_testsuites()
示例8: get_knownissues
def get_knownissues(self):
if os.environ.has_key(CommonConstants.KNOWN_ISSUE_KEY):
known_issue_list = Utils.get_dict_from_json(os.environ[CommonConstants.KNOWN_ISSUE_KEY])
ChorusGlobals.set_knownissuelist(known_issue_list)
self.logger.info("Known issue list found in environment variables")
else:
ChorusGlobals.set_knownissuelist(None)
self.logger.debug("No known issue list found in environment variables")
示例9: add
def add(cls, name, detail, time_taken, timeout=30):
status = True if time_taken <= timeout else False
if not status:
cls.status = False
cls.failed += 1
else:
cls.passed += 1
js_detail = cls.generate_json(detail)
cls.data.append(Performance_Object(name, status, js_detail, time_taken, timeout))
ChorusGlobals.get_logger().info("Add Performance Result %s, status %s, time_taken %s" % (name, status, str(time_taken)))
cls.number += 1
示例10: set_xml_file
def set_xml_file(self):
if self.options.xml:
if os.path.isfile(self.options.xml):
if str(self.options.xml).endswith(".xml"):
ChorusGlobals.set_xml_file(self.options.xml)
print "Load test execution infomation from file %s"%(str(self.options.xml))
return
else:
print "The test execution configuration file should be an XML file"
else:
print "Can't find xml file %s" % (str(self.options.xml))
ChorusGlobals.set_xml_file(None)
示例11: __init_connection
def __init_connection(connection):
host = connection["host"]
port = connection["port"]
user = connection["username"]
passwd = connection["password"]
database = connection["database"]
db_handler = mysql.connector.connect(host = host,
port = int(port),
user = user,
passwd = passwd,
database = database)
ChorusGlobals.get_logger().info("start mysql connection")
return db_handler
示例12: setUpClass
def setUpClass(cls):
'''
setUpClass is executed every time before run a test suite
'''
cls.suite_starttime = time.time()
cls.logserver = ChorusGlobals.get_logserver()
cls.logserver.flush_console()
super(MyTestCase,cls).setUpClass()
cls.logger = ChorusGlobals.get_logger()
cls.suite_name = Utils.get_current_classname(cls)
from VerificationManagement import VerificationManagement
cls.vm = VerificationManagement()
cls.result = cls.vm.check_suitebaseline(cls.suite_name)
cls.timestamp = Utils.get_timestamp()
cls.config = ChorusGlobals.get_configinfo()
cls.parameters = ChorusGlobals.get_parameters()
示例13: execute_sql
def execute_sql(sql, db_info):
'''execute sql and return a list format data'''
try:
data = []
conn_info = __get_db_info(db_info)
print conn_info
conn = __init_connection(conn_info)
cursor = conn.cursor()
cursor.execute(sql)
for row in cursor:
data.append(row)
conn.commit()
except Exception, e:
ChorusGlobals.get_logger().critical("Errors in sql execution: %s" % e)
raise Exception("Errors in sql execution: %s" % e)
示例14: __get_db_info
def __get_db_info(db_info):
parameters = ChorusGlobals.get_parameters()
try:
db_config = parameters[db_info]
connection = {
"host": db_config['addr'],
"port": db_config['port'],
"username": db_config['username'],
"password": db_config['password'],
"database": db_config['database']
}
return connection
except Exception,e:
ChorusGlobals.get_logger().critical("The %s in config file is not correctly configured, errors: %s" % (db_info,str(e)))
raise Exception("The %s in config file is not correctly configured, errors: %s" % (db_info,str(e)))
示例15: get_parameters
def get_parameters(*args):
import ChorusGlobals
parameters = ChorusGlobals.get_parameters()
result = None
if parameters.has_key(args[0]):
result = parameters[args[0]]
if len(args)==1:
return result
for path in args[1:]:
if result:
if result.has_key(path):
result = result[path]
else:
result = None
if not result:
ChorusGlobals.get_logger().warning("No value retrieved for path %s" % str(args))
return result