1from astconfigparser 
import MultiOrderedConfigParser
 
    4    import pymysql 
as MySQLdb
 
    5    MySQLdb.install_as_MySQLdb()
 
   15    _tablename = 
"sippeers" 
   19        MultiOrderedConfigParser.__init__(self)
 
 
   21    def connect(self, user, password, host, port, database):
 
   22        self.
cnx = MySQLdb.connect(user=user,passwd=password,host=host,port=int(port),db=database)
 
 
   24    def read(self, filename, sect=None):
 
   25        MultiOrderedConfigParser.read(self, filename, sect)
 
   27        cursor = self.
cnx.cursor(cursorclass=MySQLdb.cursors.DictCursor)
 
   29        rows = cursor.fetchall()
 
   34                if (row[key] != 
None):
 
   35                    for elem 
in str(row[key]).split(
";"):
 
 
   40        """Write the contents of the mdicts to the specified config file""" 
   41        for section, sect_list 
in mdicts.iteritems():
 
   43            for sect 
in sect_list:
 
   45                if (sect.get(
'type')[0] == 
"endpoint"):
 
   46                    sql += 
"ps_endpoints " 
   47                elif (sect.get(
'type')[0] == 
"aor" and section != 
"sbc"):
 
   49                elif (sect.get(
'type')[0] == 
"identify"):
 
   50                    sql += 
"ps_endpoint_id_ips" 
   54                sql += 
" SET `id` = " + 
"\"" + MySQLdb.escape_string(section) + 
"\"" 
   55                for key, val_list 
in sect.iteritems():
 
   60                    key_val = 
" `" + key + 
"`" 
   61                    key_val += 
" = " + 
"\"" + MySQLdb.escape_string(
";".join(val_list)) + 
"\"" 
   65                config_file.write(
"%s;\n" % (sql))
 
 
   68        """Write configuration information out to a file""" 
   72                print(
"Could not open file " + config_file + 
" for writing")
 
 
 
add_section(self, key, template_keys=None, mdicts=None)
connect(self, user, password, host, port, database)
read(self, filename, sect=None)
__init__(self, tablename="sippeers")
write_dicts(self, config_file, mdicts)