本文整理汇总了Python中virtualisation.misc.log.Log.e方法的典型用法代码示例。如果您正苦于以下问题:Python Log.e方法的具体用法?Python Log.e怎么用?Python Log.e使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类virtualisation.misc.log.Log
的用法示例。
在下文中一共展示了Log.e方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: registerExchanges
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
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))
示例2: aggregate
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
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
示例3: setReplayMode
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
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
示例4: __init__
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
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()
示例5: next
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
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
示例6: setReplayMode
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
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)
示例7: load
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
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
示例8: start
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
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()
示例9: saveGraph
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
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)
示例10: deleteGraph
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
def deleteGraph(self, graphName):
queryString = "DEFINE sql:log-enable 3 DROP SILENT GRAPH <" + self.getGraphURI(graphName) + ">"
L.d("deleteGraph using query:", queryString)
sparql = self.getSparqlObject(graphName, queryString)
sparql.setTimeout(300)
try:
ret = sparql.query()
return True
except Exception as e:
L.e("Error in deleteGraph:", e.message)
return False
示例11: removeAllSensorStreams
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
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
示例12: removeSensorStream
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
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
示例13: createGraph
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
def createGraph(self, graphName):
queryString = "CREATE GRAPH <" + self.getGraphURI(graphName) + ">"
sparql = self.getSparqlObject(graphName, queryString)
try:
ret = sparql.query().convert()
return True
except HTTPError as e:
L.e("Sparql Endpoint HTTPError in createGraph:", str(e.code), e.reason)
except Exception as e:
L.e("Error in createGraph:", e.message)
return False
示例14: saveTriple
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
def saveTriple(self, graphName, subject, predicate, object):
sparql = self.getSparqlObject(graphName)
# insert into doesn't work with set default graph, have to "... INSERT DATA INTO <graph>..."
queryString = "INSERT DATA INTO <" + self.getGraphURI(
graphName) + "> { <" + subject + "> <" + predicate + "> <" + object + "> }"
sparql.setQuery(queryString)
try:
sparql.query()
except HTTPError as e:
L.e("Sparql Endpoint HTTPError in saveTriple:", str(e.code), e.reason)
except Exception as e:
L.e("Error in saveTriple:", e.message)
示例15: saveMultipleGraphs
# 需要导入模块: from virtualisation.misc.log import Log [as 别名]
# 或者: from virtualisation.misc.log.Log import e [as 别名]
def saveMultipleGraphs(self, serialisedGraph, graphName=None):
queryString = "".join(["INSERT DATA { GRAPH <", self.getGraphURI(graphName), "> {", serialisedGraph, "}}"])
sparql = self.getSparqlObject(graphName, queryString)
sparql.queryType = INSERT
try:
ret = sparql.query()
except EndPointInternalError as e: #transaction deadlock case
raise SPARQL_Exception()
except EndPointNotFound as e: #temporarily 404 error
raise SPARQL_Exception()
except Exception as e:
L.e("Error in saveMultipleGraphs:", e.message)
raise StoreOffline_Exception()