コード例 #1
0
    def parseTools(self):
        """parse the xml file and generate sql file""" 
        try:
            analytics_tools = Parser.getNodeTag(self, self.xmlDoc, "analytics_tools")
            atList = Parser.getNodeList(self, analytics_tools, "analytics_tool")

            for at in atList:
                atDic = {}
                name = Parser.getNodeVal(self, at, "name")
                kind = Parser.getNodeVal(self, at, "kind")
               
                if kind.lower() in( "greenplum", "postgres"):
                    atDic["name"]           =   Parser.getNodeVal(self, at, "name")
                    atDic["kind"]           =   Parser.getNodeVal(self, at, "kind")
                    atDic["host"]           =   Parser.getNodeVal(self, at, "host")
                    atDic["port"]           =   Parser.getNodeVal(self, at, "port")
                    atDic["superuser"]  =   Parser.getNodeVal(self, at, "superuser")
                    atDic["database"]       =   Parser.getNodeVal(self, at, "database")
                    atDic["username"]       =   Parser.getNodeVal(self, at, "user")
                    atDic["master_dir"]     =   Parser.getNodeVal(self, at, "master_dir")
                    atDic["env"]    =   Parser.getNodeVal(self, at, "env")
                self.analyticsTools[name] = atDic

        except Exception, exp:
            print str(exp)
            print "Error when parsing analyticsTools"
            sys.exit()
コード例 #2
0
ファイル: test_config.py プロジェクト: madlib/testsuite
    def testconfig(self):
        """Parse logger database connection to store result."""
        try:
            configuration       =   Parser.getNodeTag(self, self.xmlDoc, "configuration")
            metadatadb          =   Parser.getNodeTag(self, configuration, "metadatadb")        
            self.user                =   Parser.getNodeVal(self, metadatadb, "user")
            self.host                =   Parser.getNodeVal(self, metadatadb, "host")
            self.port                =   Parser.getNodeVal(self, metadatadb, "port")
            self.database            =   Parser.getNodeVal(self, metadatadb, "database")
            self.resultDBSchema      =   Parser.getNodeVal(self, metadatadb, "schema")

            self.resultDBconf = {'username':self.user, 'host':self.host, 'port':self.port, \
                       'database':self.database, 'schema':self.resultDBSchema, 'name':'resultDB'}
            self.dbmanager = dbManager.dbManager(self.resultDBconf)
 
        except Exception, exp:
            print str(exp)
            print "Error when parsing testConfig"
            sys.exit()
コード例 #3
0
    def __createToolsTb(self):
        """create the analytics tool table"""
        
        # drop table stmt
        stmt = "DROP TABLE IF EXISTS " + self.analyticsToolTb + " cascade;\n\n"
        self.sqlFileHd.write(stmt)

        analytics_tools = Parser.getNodeTag(self, self.xmlDoc, "analytics_tools")

        metadata = Parser.getNodeTag(self, analytics_tools, "metadata")
        colList = Parser.getNodeList(self, metadata, "column")

        for col in colList:
            colName = Parser.getNodeVal(self, col, "name")
            colType = Parser.getNodeVal(self, col, "type")
            self.colsDesc[colName] = colType

        # convert dict
        cols = self.dicToArray(self.colsDesc)

        # create table stmt
        stmt = "CREATE TABLE " + self.analyticsToolTb + "("
        stmt = stmt + ','.join(cols) + ");\n\n"
        self.sqlFileHd.write(stmt)