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


Python log.Log类代码示例

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


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

示例1: aggregate

    def aggregate(self, data, sensordescription):
        """
        this method is called when stream data has been annotated.
        :param data:
        :param sensordescription:
        :return: The aggregated data
        """
        if not data.fields:
            return None
        result = []
        try:
            aggregation_objs = self.aggregation_objs[sensordescription.uuid]
            for key, agg in aggregation_objs.items():
                agg_result = agg.control(data[key])
                if agg_result:
                    g, start, end, size = agg_result

                    r = JSONObject()
                    r.graph = g
                    r.field = sensordescription.field[key]
                    r.sensorID = sensordescription.sensorID
                    r.propertyName = sensordescription.field[key].propertyName
                    r.category = sensordescription.sensorType
                    r.aggregationMethod = sensordescription.field[key].aggregationMethod
                    r.aggregationConfiguration = sensordescription.field[key].aggregationConfiguration
                    r.start = start
                    r.end = end
                    r.size = size
                    result.append(r)
                return result
        except Exception as e:
            Log.e("aggregation failed due to Exception", e)
            return None
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:33,代码来源:genericaggregation.py

示例2: setReplayMode

    def setReplayMode(self, mode):
        super(BrasovIncidentWrapper, self).setReplayMode(mode)
        # fieldnames of service: "id", "comments", "createdon", "description", "guid", "incidentState", "incidentid", "indsoft_publiclyvisible", "statecode", "ticketnumber", "timestamp", "title", "x", "y"
        fieldnames = [
            "id",
            "comments",
            "createdon",
            "description",
            "guid",
            "i",
            "incidentState",
            "incidentid",
            "indsoft_publiclyvisible",
            "statecode",
            "ticketnumber",
            "timestamp",
            "title",
            "x",
            "y",
        ]
        try:
            fobj = AbstractWrapper.getFileObject(__file__, "incidents%d.csv" % self.number, "rU")
            self.historyreader = CSVHistoryReader(self, fobj, delimiter=",")
            self.historyreader.multiple_observations = False
            self.historyparser = CSVParser(self, fieldnames)

        except Exception as e:
            Log.e("setReplayMode in Brasov Incident Wrapper", self.number, e)
            self.historyreader = None
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:29,代码来源:brasov_incidents.py

示例3: next

 def next(self):
     url = self.source or self.wrapper.getSensorDescription().source
     try:
         return self.load(url)
     except:
         Log.e("HttpPullConnection: failed to load", url)
         return None
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:7,代码来源:httpconnection.py

示例4: __run

    def __run(self):
        while not self.stop:
            sleep(self.delay)
            Log.i(self.counter, self.txt)
#             print self.counter, self.txt
#             print "ThreadedTriplestoreAdapter Buffer Size:", ThreadedTriplestoreAdapter.getTotalBufferSize()
            Log.i("ThreadedTriplestoreAdapter Buffer Size:", ThreadedTriplestoreAdapter.getTotalBufferSize())
            self.counter = 0
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:8,代码来源:performancetestreceiver.py

示例5: setReplayMode

 def setReplayMode(self, mode):
     if mode:
         try:
             self.historyreader = CSVHistoryReader(self, AbstractWrapper.getFileObject(__file__, os.path.join("historicdata", "pollution-%s.csv" % self.sensorDescription.sensorID), "rU"), delimiter=';')
             self.historyparser = CSVParser(self, self.historyreader.headers)
         except Exception as e:
             Log.e(e)
             self.historyreader = None
     super(InternalBrasovWrapper, self).setReplayMode(mode)
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:9,代码来源:brasovpollutionwrapper.py

示例6: load

 def load(self, url):
     try:
         f = urllib2.urlopen(url, timeout=10)
         r = f.read()
         f.close()
         return r
     except:
         Log.e(self.__class__.__name__, "error in load")
         return None
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:9,代码来源:httpconnection.py

示例7: start

 def start(self):
     if self.replaymode:
         try:
             self.historyreader = CSVHistoryReader(self, AbstractWrapper.getFileObject(__file__, os.path.join("historicdata", "weatherAW-%s.csv" % self.sensorDescription.sensorID), "rU"), delimiter=';')
             self.historyparser = CSVParser(self, self.historyreader.headers)
         except Exception as e:
             Log.e(e)
             self.historyreader = None
     super(InternalWeatherAWWrapper, self).start()
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:9,代码来源:romaniaweather_aw.py

示例8: start

    def start(self, restart=False):
        self._startQueues()
        if self.clock:
            self.clock.stop()
        self.clock = RealClock(self.end)

        if ResourceManagement.args.pt:
            from virtualisation.resourcemanagement.performancetestreceiver import PerformanceMeterMinutes

            performancetest = PerformanceMeterMinutes()

        for w in self.wrappers:
            self.startWrapper(w, restart)
            if ResourceManagement.args.pt:
                w.addReceiver(performancetest)
        L.i(datetime.datetime.now())

        if not self.args.noQuality:
            if not self.averageStreamQuality:
                self.averageStreamQuality = AverageStreamQuality(self, self.clock)
            else:
                self.averageStreamQuality.setClock(self.clock)

        self.clock.runAsync()

        raw_input("press Enter to end.\n")
        self.clock.stop()
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:27,代码来源:resourcemanagement.py

示例9: deploy

    def deploy(self, f, autostart=False):
        """

        :param f:
        :param autostart:
        :return: a tuple with 3 elements. 1. status as string, 2. error message as string, 3. list of uuids of added wrapper
        """
        L.i("Deploying", f)
        sensordescriptions = []
        try:
            zFile = zipfile.ZipFile(f)
            if "deploy.json" in zFile.namelist():
                deployDescription = JOb(zFile.open("deploy.json", "r"))
                sys.path.insert(0, f)
                if deployDescription.isList():
                    for dd in deployDescription:
                        module = __import__(dd.module)
                        wrapper = getattr(module, dd["class"])()
                        self.addWrapper(wrapper)
                        sensordescriptions.append(wrapper.getSensorDescription())
                        if autostart:
                            self.startWrapper(wrapper)
                else:
                    module = __import__(deployDescription.module)
                    wrapper = getattr(module, deployDescription["class"])()
                    self.addWrapper(wrapper)
                    sensordescriptions.append(wrapper.getSensorDescription())
                    if autostart:
                        self.startWrapper(wrapper)
            return "OK", "", sensordescriptions
        except Exception as e:
            L.w("Deployment of wrapper", f, "failed.", e.message)
            return "Fail", e.message, []
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:33,代码来源:resourcemanagement.py

示例10: registerExchanges

 def registerExchanges(cls):
     for ex in RabbitMQ.exchanges:
         try:
             RabbitMQ.declareExchange(ex, _type="topic")
         except Exception as e:
             L.e('Exchange %s could not be declared: %s' % (ex, e.message))
             L.e('Exception:', str(e))
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:7,代码来源:rabbitmq.py

示例11: receiveHandler

    def receiveHandler(self, item):
        parsedData, sensordescription, clock, quality = item
        L.d2(parsedData)
        # print parsedData
        if self.sql:
            self.sql.insert_observation(sensordescription, parsedData, dictdeepcopy(quality))

        if ResourceManagement.args.messagebus or ResourceManagement.args.triplestore:
            # if len(parsedData.fields)>0:
            g = self.annotator.annotateObservation(parsedData, sensordescription, clock, quality)

        del quality
        if (
            ResourceManagement.args.messagebus
            and not sensordescription.no_publish_messagebus
            and "fields" in parsedData
            and len(parsedData.fields) > 0
        ):
            message = g.serialize(format="n3")
            # print message
            key = sensordescription.messagebus.routingKey
            # self.messageBusQueue.add((parsedData.dumps(), self.rabbitmqchannel, RabbitMQ.exchange_data, key))
            self.messageBusQueue.add((message, RabbitMQ.exchange_annotated_data, key))
            if self.ui.api:
                self.ui.api.update_observation_cache(str(sensordescription.uuid), message)
        if ResourceManagement.args.triplestore:
            # TODO: The following line is commented out, since the Virtuoso makes so much trouble
            # ThreadedTriplestoreAdapter.getOrMake(sensordescription.graphName).addGraph(g)
            pass
        if ResourceManagement.args.messagebus or ResourceManagement.args.triplestore:
            del g
        if ResourceManagement.args.aggregate:
            self.aggregationQueue.add((parsedData, sensordescription))
        else:
            del parsedData
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:35,代码来源:resourcemanagement.py

示例12: __init__

    def __init__(self, gdi_config, rm):
        self.rm = rm
        self.PAGINATION_LIMIT = 100
        connect_str = "host='%s' dbname='%s' user='%s' password='%s' port=%d" % (
            gdi_config.host, gdi_config.database, gdi_config.username, gdi_config.password, gdi_config.port)
        self.conn = psycopg2.connect(connect_str)
        self.curs = self.conn.cursor()
        try:
            self.curs.execute("CREATE SCHEMA IF NOT EXISTS %s;" % SQL.SCHEMA)
            # self.curs.execute("CREATE TABLE IF NOT EXISTS %s.cp_sensors (sensor_uuid UUID CONSTRAINT uuid_key PRIMARY KEY, sensor_annotation_id VARCHAR, sercvice_category VARCHAR, traffic INTEGER, geom GEOMETRY(GEOMETRY, 4326) );" % (SQL.SCHEMA,))
            self.curs.execute("CREATE TABLE IF NOT EXISTS %s.cp_sensors (sensor_uuid UUID CONSTRAINT uuid_key PRIMARY KEY, sensor_annotation_id VARCHAR, sercvice_category VARCHAR, traffic INTEGER, geom GEOMETRY(GEOMETRY, 4326) );" % ("public",))
            cols = ["sampling_time TIMESTAMP", "sensor_uuid UUID", "observation_uuid UUID", "data JSON", "quality JSON"]
            query = 'CREATE TABLE IF NOT EXISTS %s.cp_observations ( %s, PRIMARY KEY (%s), FOREIGN KEY (sensor_uuid) REFERENCES %s.cp_sensors(sensor_uuid));\n' % (SQL.SCHEMA, ', '.join(cols),  ", ".join(["observation_uuid"]), "public")
            self.curs.execute(query)

            # index over sampling_time and sensor_uuid
            # since a 'IF NOT EXISTS' is not available for us (version < 9.5)
            # the error is catched in a separate try-catch
            try:
                query = 'CREATE INDEX "timeindex" ON %s.cp_observations USING btree (sampling_time);' % (SQL.SCHEMA,)
                self.curs.execute(query)
                query = 'CREATE INDEX uuidindex ON %s.cp_observations USING btree (sensor_uuid);' % (SQL.SCHEMA,)
                self.curs.execute(query)
            except:
                pass

            # primary secondary observation_uuid map
            query = 'CREATE TABLE IF NOT EXISTS %s.p_s_observation_uuid (main UUID, secondary UUID);' % (SQL.SCHEMA,)
            self.curs.execute(query)

            self.conn.commit()
            L.i("SQL: schema/tables created")
        except Exception as e:
            L.e("SQL: Could not create schema/tables", e)
            self.conn.rollback()
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:35,代码来源:sql.py

示例13: saveGraph

 def saveGraph(self, graph, graphName):
     serialisation = graph.serialize(destination=None, format='nt', encoding=None)
     queryString = "".join(["INSERT DATA INTO GRAPH <", self.getGraphURI(graphName), "> {", serialisation, "}"])
     sparql = self.getSparqlObject(graphName, queryString)
     try:
         sparql.query()
     except HTTPError as e:
         L.e("Sparql Endpoint HTTPError in saveGraph:", str(e.code), e.reason)
     except Exception as e:
         L.e("Error in saveGraph:", e.message)
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:10,代码来源:sparqlstore.py

示例14: removeSensorStream

 def removeSensorStream(self, sensor_uuid):
     sql = ("DELETE FROM cp_sensors WHERE sensor_uuid='%(sensor_uuid)s'" % {'sensor_uuid': sensor_uuid})
     try:
         self.curs.execute(sql)
         self.conn.commit()
         return True
     except:
         self.conn.rollback()
         L.e("Cannot delete Sensor: " + str({'sensor_uuid': sensor_uuid}))
         L.e("SQL query used:", sql)
         return False
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:11,代码来源:CityPulseGDInterface.py

示例15: removeAllSensorStreams

 def removeAllSensorStreams(self):
     try:
         sql = "DELETE FROM cp_sensors"
         self.curs.execute(sql)
         self.conn.commit()
         return True
     except:
         self.conn.rollback()
         L.e("Cannot delete all Sensors")
         L.e("SQL query used", sql)
         return False
开发者ID:CityPulse,项目名称:CP_Resourcemanagement,代码行数:11,代码来源:CityPulseGDInterface.py


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