当前位置: 首页>>代码示例>>Python>>正文


Python lang.Class类代码示例

本文整理汇总了Python中java.lang.Class的典型用法代码示例。如果您正苦于以下问题:Python Class类的具体用法?Python Class怎么用?Python Class使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Class类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_Database_entries

    def check_Database_entries(self):
        head, tail = os.path.split(os.path.abspath(__file__)) 
        settings_db = os.path.join(head, "GUI_Settings.db3")
        try: 
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s"  % settings_db)
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings DB!")
 
        try:
           stmt = dbConn.createStatement()
           SQL_Statement = 'Select Setting_Name, Setting_Value from settings;' 
           resultSet = stmt.executeQuery(SQL_Statement)
           while resultSet.next():
               if resultSet.getString("Setting_Name") == "Program_Exec_Name":
                   self.Program_Executable_TF.setText(resultSet.getString("Setting_Value"))
                   self.local_settings.setSetting('ExecFile', resultSet.getString("Setting_Value"))
                   self.local_settings.setSetting('Exec_Prog_Flag', 'true')
                   self.Exec_Program_CB.setSelected(True)
                   self.Program_Executable_TF.setEnabled(True)
                   self.Find_Program_Exec_BTN.setEnabled(True)
           self.Error_Message.setText("Settings Read successfully!")
        except SQLException as e:
            self.Error_Message.setText("Error Reading Settings Database")

        stmt.close()
        dbConn.close()
开发者ID:markmckinnon,项目名称:Autopsy-Plugins,代码行数:27,代码来源:Gui_Test_With_Settings.py

示例2: connect_db

def connect_db(jdbc_url, driverName):
    try:
        Class.forName(driverName).newInstance()
        dbConn = DriverManager.getConnection(jdbc_url)
    except Exception, msg:
        print msg
        sys.exit(1)
开发者ID:mmisono,项目名称:osv-jython-flask,代码行数:7,代码来源:database.py

示例3: __init__

    def __init__(self, connectURI, username, password, pool_name):
        self.connectionPool = GenericObjectPool(None)
        self._pool_name = pool_name

        source = BasicDataSource()
        source.setUrl(connectURI)
        source.setUsername(username)
        source.setPassword(password)
        source.setInitialSize(1) # Number of connections to start with
        source.setMinIdle(5)     # Allow a bottom of 5 idle connections
        source.setMaxActive(10)  # Max of 10 database connection
        source.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED)
        source.setMinEvictableIdleTimeMillis(500) 

        self.connectionFactory = DataSourceConnectionFactory(source)

        #  Now we'll create the PoolableConnectionFactory, which wraps
        #  the "real" Connections created by the ConnectionFactory with
        #  the classes that implement the pooling functionality.
        self.poolableConnectionFactory = PoolableConnectionFactory(self.connectionFactory,
                self.connectionPool,
                None,
                None,
                False,
                True)

        #  Finally, we create the PoolingDriver itself...
        Class.forName("org.apache.commons.dbcp.PoolingDriver")
        driver = DriverManager.getDriver("jdbc:apache:commons:dbcp:")

        #  ...and register our pool with it.
        driver.registerPool(self._pool_name, self.connectionPool)
开发者ID:VanyaDNDZ,项目名称:doj-sybase,代码行数:32,代码来源:pool.py

示例4: getConnection

def getConnection(jdbc_url, driverName):
	print "Using database at", jdbc_url, "driver", driverName
	try:
		Class.forName(driverName).newInstance()
	except Exception, msg:
		print msg
		sys.exit(-1)
开发者ID:cartershanklin,项目名称:SQLFireStuff,代码行数:7,代码来源:newSales.py

示例5: _jdbc_connect_jython

def _jdbc_connect_jython(jclassname, jars, libs, *args):
    if _converters is None:
        from java.sql import Types
        types = Types
        types_map = {}
        const_re = re.compile('[A-Z][A-Z_]*$')
        for i in dir(types):
            if const_re.match(i):
                types_map[i] = getattr(types, i)
        _init_converters(types_map)
    global _java_array_byte
    if _java_array_byte is None:
        import jarray
        def _java_array_byte(data):
            return jarray.array(data, 'b')
    # register driver for DriverManager
    jpackage = jclassname[:jclassname.rfind('.')]
    dclassname = jclassname[jclassname.rfind('.') + 1:]
    # print jpackage
    # print dclassname
    # print jpackage
    from java.lang import Class
    from java.lang import ClassNotFoundException
    try:
        Class.forName(jclassname).newInstance()
    except ClassNotFoundException:
        if not jars:
            raise
        _jython_set_classpath(jars)
        Class.forName(jclassname).newInstance()
    from java.sql import DriverManager
    return DriverManager.getConnection(*args)
开发者ID:LetschM,项目名称:iis,代码行数:32,代码来源:dbapi2.py

示例6: get_profiles

    def get_profiles(self):
        head, tail = os.path.split(os.path.abspath(__file__)) 
        settings_db = os.path.join(head, "GUI_Settings.db3")
        try: 
            Class.forName("org.sqlite.JDBC").newInstance()
            dbConn = DriverManager.getConnection("jdbc:sqlite:%s"  % settings_db)
            self.Error_Message.setText("Database opened")
        except SQLException as e:
            self.Error_Message.setText("Error Opening Settings DB!")
 
        try:
           stmt = dbConn.createStatement()
           SQL_Statement = "select profile_name from profiles where volatility_version = '" + self.Version_CB.getSelectedItem() + "';" 
           resultSet = stmt.executeQuery(SQL_Statement)
           profile_list = []
           while resultSet.next():
              profile_list.append(resultSet.getString("profile_name"))

           stmt.close()
           dbConn.close()
           return profile_list
        except SQLException as e:
            self.Error_Message.setText("Error Reading plugins")
            stmt.close()
            dbConn.close()
            return "Error"
开发者ID:markmckinnon,项目名称:Autopsy-Plugins,代码行数:26,代码来源:Volatility.py

示例7: __findGeoLocationsInDB

    def __findGeoLocationsInDB(self, databasePath, abstractFile):
        if not databasePath:
            return

        try:
            Class.forName("org.sqlite.JDBC") #load JDBC driver
            connection = DriverManager.getConnection("jdbc:sqlite:" + databasePath)
            statement = connection.createStatement()
        except (ClassNotFoundException) as ex:
            self._logger.log(Level.SEVERE, "Error loading JDBC driver", ex)
            self._logger.log(Level.SEVERE, traceback.format_exc())
            return
        except (SQLException) as ex:
            # Error connecting to SQL databse.
            return

        resultSet = None
        try:
            resultSet = statement.executeQuery("SELECT timestamp, latitude, longitude, accuracy FROM CachedPosition;")
            while resultSet.next():
                timestamp = Long.valueOf(resultSet.getString("timestamp")) / 1000
                latitude = Double.valueOf(resultSet.getString("latitude"))
                longitude = Double.valueOf(resultSet.getString("longitude"))

                attributes = ArrayList()
                artifact = abstractFile.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACKPOINT)
                attributes.add(BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE, general.MODULE_NAME, latitude))
                attributes.add(BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE, general.MODULE_NAME, longitude))
                attributes.add(BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME, general.MODULE_NAME, timestamp))
                attributes.add(BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, general.MODULE_NAME, "Browser Location History"))
                # artifact.addAttribute(BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_VALUE.getTypeID(),moduleName, accuracy))
                # NOTE: originally commented out

                artifact.addAttributes(attributes);
                try:
                    # index the artifact for keyword search
                    blackboard = Case.getCurrentCase().getServices().getBlackboard()
                    blackboard.indexArtifact(artifact)
                except Blackboard.BlackboardException as ex:
                    self._logger.log(Level.SEVERE, "Unable to index blackboard artifact " + str(artifact.getArtifactTypeName()), ex)
                    self._logger.log(Level.SEVERE, traceback.format_exc())
                    MessageNotifyUtil.Notify.error("Failed to index GPS trackpoint artifact for keyword search.", artifact.getDisplayName())

        except SQLException as ex:
            # Unable to execute browser location SQL query against database.
            pass
        except Exception as ex:
            self._logger.log(Level.SEVERE, "Error putting artifacts to blackboard", ex)
            self._logger.log(Level.SEVERE, traceback.format_exc())
        finally:
            try:
                if resultSet is not None:
                    resultSet.close()
                statement.close()
                connection.close()
            except Exception as ex:
                # Error closing database.
                pass
开发者ID:sleuthkit,项目名称:autopsy,代码行数:58,代码来源:browserlocation.py

示例8: connect

def connect(dburl="jdbc:mysql://localhost:3306/mtgo", dbuser="root", dbpass=None):
    try:
        try:
            Class.forName("com.mysql.jdbc.Driver").newInstance()
        except NameError:
            raise ErrorHandler("Internal MySQL error")
        conn = DriverManager.getConnection(dburl, dbuser, dbpass)
    except SQLException, error:
        raise ErrorHandler("MySQL error: %s" % str(error))
开发者ID:veelckoo,项目名称:MTGOBOT,代码行数:9,代码来源:Mysql.py

示例9: __init__

    def __init__(self, *args, **kwds):
        unittest.TestCase.__init__(self, *args, **kwds)

        self._primitive_types = {
            Class.forName('java.lang.Boolean'): Boolean,
            Class.forName('java.lang.Integer'): Integer,
            Class.forName('java.lang.Long'): Long,
            Class.forName('java.lang.Double'): Double,
            Class.forName('java.lang.String'): String
        }
开发者ID:svn2github,项目名称:pylucene,代码行数:10,代码来源:test_Collections.py

示例10: getConnection

def getConnection(jdbc_url, driverName):
    """
        Given the name of a JDBC driver class and the url to be used 
        to connect to a database, attempt to obtain a connection to 
        the database.
    """
    try:
        Class.forName(driverName).newInstance()
    except Exception, msg:
        print msg
        sys.exit(-1)
开发者ID:favoritemedium,项目名称:jython-jdbc,代码行数:11,代码来源:sample.py

示例11: dbOpen

 def dbOpen(self):
     self.database = "exp.db"
     driver = "org.sqlite.JDBC"
     self.url = "jdbc:sqlite:" + self.database
     Class.forName(driver)
     try:
         self.db = DriverManager.getConnection(self.url);
         self.stat = self.db.createStatement()
         self.stat.executeUpdate("CREATE TABLE IF NOT EXISTS " + self.TABLENAME + " (" + self.EMAIL + " TEXT, " + self.HOST + " TEXT, " + self.NICK + " TEXT, " +  self.EXP + " INTEGER);");
     except SQLException, e:
         self.requestAdd("ERROR : OPEN")
开发者ID:andinue,项目名称:elizabeth-modules,代码行数:11,代码来源:PMExp.py

示例12: dbOpen

 def dbOpen(self):
     self.database = "MACard.db"
     driver = "org.sqlite.JDBC"
     self.url = "jdbc:sqlite:" + self.database
     Class.forName(driver)
     try:
         self.db = DriverManager.getConnection(self.url);
         self.stat = self.db.createStatement()
         self.stat.executeUpdate("CREATE TABLE IF NOT EXISTS " + self.TABLENAME + " ("+ self.CARDID + " INTEGER, " + self.COUNTRY + " TEXT, "+ self.CARDURL + " TEXT, " + self.CARDNAME + " TEXT, "+ self.CARDALTERNATIVE + " TEXT);");
     except SQLException, e:
         self.requestAdd("DB OPEN ERROR")
开发者ID:andinue,项目名称:elizabeth-modules,代码行数:11,代码来源:PMMACard2.py

示例13: dbOpen

 def dbOpen(self):
     self.database = "CustomMsg.db"
     driver = "org.sqlite.JDBC"
     self.url = "jdbc:sqlite:" + self.database
     Class.forName(driver)
     try:
         self.db = DriverManager.getConnection(self.url);
         self.stat = self.db.createStatement()
         self.stat.executeUpdate("CREATE TABLE IF NOT EXISTS " + self.TABLENAME + " ("+ self.HOST + " TEXT PRIMARY KEY, "+  self.MSG + " TEXT);");
     except SQLException, e:
         self.requestAdd("ERROR")
开发者ID:andinue,项目名称:elizabeth-modules,代码行数:11,代码来源:PMCustomMsg.py

示例14: emit_java_expression

def emit_java_expression(klass, name):
    try:
        cog.out(CONVERSIONS[klass].to_java_format % name)
    except KeyError:
        if klass.isPrimitive():
            raise Exception("You need a converter for %s" % klass.getName())
        simpleName = Class.getName(klass)
        if klass.isArray():
            simpleName = Class.getSimpleName(klass)
        if simpleName != 'java.lang.Object':
            cog.out('(%s)' % simpleName)
        cog.out('%s.__tojava__(%s.class)' % (name, simpleName))
开发者ID:christhompson,项目名称:processing.py,代码行数:12,代码来源:processing_parser.py

示例15: __init__

 def __init__(self, dbType):
     log_file_name = "history_%s.log" % datetime.now().strftime("%Y%m%d")
     self.logger = Logger.getLog(log_file_name)
     self.conn = None
     self.__stmt__ = None
     self.__rs__ = None
     config = dbType
     if config:
         try:
             Class.forName(config["DRIVER"]).newInstance()
             self.conn = DriverManager.getConnection(config["URL"], config["USER"], config["PASSWD"])
         except SQLException, e:
             self.logger.error("(db.py => __init__)Get %s connection error! \n %s" % (dbType, str(e)))
             raise Exception
开发者ID:enix223,项目名称:DataXfer,代码行数:14,代码来源:db.py


注:本文中的java.lang.Class类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。