Import JSON
From lib.core.path import Confpath
class Configtype (object):
mysql = ' mysql '
Redis = ' Redis '
class Config (object):
def __init__ (self):
self.config = {}
def make (self):
# mysql configuration information
Self.config[configtype.mysql] = {}
self.config[configtype.mysql][' host '] = ' 127.0.0.1 '
self.config[configtype.mysql][' port ' = 3306
self.config[configtype.mysql][' user '] = ' sky '
self.config[configtype.mysql][' passwd '] = ' 123456 '
self.config[configtype.mysql][' db '] = ' SSJ '
self.config[configtype.mysql][' charset '] = ' UTF8 '
# Redis configuration information
Self.config[configtype.mysql] = {}
self.config[configtype.mysql][' host '] = ' 127.0.0.1 '
self.config[configtype.mysql][' port ' = 3306
self.config[configtype.mysql][' user '] = ' sky '
self.config[configtype.mysql][' passwd '] = ' 123456 '
self.config[configtype.mysql][' db '] = ' SSJ '
self.config[configtype.mysql][' charset '] = ' UTF8 '
FW = open (Confpath, ' W ')
Fw.write (Json.dumps (self.config))
Fw.flush ()
fw.close ()
def read (self,config):
FR = Open (Confpath)
data = Json.load (FR)
if config = = Configtype.mysql:
return Data[configtype.mysql]
elif config = = Configtype.redis:
return Data[configtype.redis]
if __name__ = = ' __main__ ':
Config (). make ()
print (Config (). Read (Configtype.mysql))
UI Automation Web-side Framework config.py code