本文整理汇总了Python中msg_logger.MSGLogger类的典型用法代码示例。如果您正苦于以下问题:Python MSGLogger类的具体用法?Python MSGLogger怎么用?Python MSGLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MSGLogger类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: MECODataAutoloader
class MECODataAutoloader(object):
"""
Provide automated loading of MECO energy data from exports in gzip-compressed XML source data.
"""
def __init__(self):
"""
Constructor.
"""
self.logger = MSGLogger(__name__)
self.configer = MSGConfiger()
self.fileUtil = MSGFileUtil()
def newDataExists(self):
"""
Check the data autoload folder for the presence of new data.
:returns: True if new data exists.
"""
autoloadPath = self.configer.configOptionValue('MECO Autoload', 'meco_new_data_path')
if not self.fileUtil.validDirectory(autoloadPath):
raise Exception('InvalidDirectory', '%s' % autoloadPath)
patterns = ['*.gz']
matchCnt = 0
for root, dirs, filenames in os.walk(autoloadPath):
for pat in patterns:
for filename in fnmatch.filter(filenames, pat):
print filename
matchCnt += 1
if matchCnt > 0:
return True
else:
return False
def loadNewData(self):
"""
Load new data contained in the new data path.
"""
autoloadPath = self.configer.configOptionValue('MECO Autoload', 'meco_new_data_path')
command = self.configer.configOptionValue('MECO Autoload', 'data_load_command')
os.chdir(autoloadPath)
try:
subprocess.check_call(command, shell = True)
except subprocess.CalledProcessError, e:
self.logger.log("An exception occurred: %s" % e, 'error')
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:52,代码来源:meco_data_autoloader.py
示例2: setUp
def setUp(self):
self.logger = MSGLogger(__name__, 'DEBUG')
self.configer = MSGConfiger()
self.exporter = MSGDBExporter()
self.testDir = 'db_exporter_test'
self.uncompressedTestFilename = 'meco_v3_test_data.sql'
self.compressedTestFilename = 'meco_v3_test_data.sql.gz'
self.exportTestDataPath = self.configer.configOptionValue('Testing',
'export_test_data_path')
self.fileUtil = MSGFileUtil()
self.fileChunks = []
self.testDataFileID = ''
self.pyUtil = MSGPythonUtil()
conn = None
try:
conn = MSGDBConnector().connectDB()
except Exception as detail:
self.logger.log("Exception occurred: {}".format(detail), 'error')
exit(-1)
self.logger.log("conn = {}".format(conn), 'debug')
self.assertIsNotNone(conn)
# Create a temporary working directory.
try:
os.mkdir(self.testDir)
except OSError as detail:
self.logger.log(
'Exception during creation of temp directory: %s' % detail,
'ERROR')
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:31,代码来源:test____msg_db_exporter.py
示例3: __init__
def __init__(self):
"""
Constructor.
"""
self._config = ConfigParser.ConfigParser()
self.logger = MSGLogger(__name__, 'INFO')
# Define tables that will have data inserted. Data will only be inserted
# to tables that are defined here.
self.insertTables = (
'MeterData', 'RegisterData', 'RegisterRead', 'Tier', 'Register',
'IntervalReadData', 'Interval', 'Reading', 'EventData', 'Event')
# Check permissions on the config file. Refuse to run if the permissions
# are not set appropriately.
configFilePath = '~/.msg-data-operations.cfg'
if self.isMoreThanOwnerReadableAndWritable(
os.path.expanduser(configFilePath)):
self.logger.log(
"Configuration file permissions are too permissive. Operation "
"will not continue.", 'error')
sys.exit()
try:
self._config.read(['site.cfg', os.path.expanduser(configFilePath)])
except:
self.logger.log("Critical error: The data in {} cannot be "
"accessed successfully.".format(configFilePath),
'ERROR')
sys.exit(-1)
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:33,代码来源:msg_configer.py
示例4: __init__
def __init__(self):
"""
Constructor.
"""
self.logger = MSGLogger(__name__, 'debug')
self.cols = ["wban", "datetime", "datetime", "station_type",
"sky_condition", "sky_condition_flag", "visibility",
"visibility_flag", "weather_type", "weather_type_flag",
"dry_bulb_farenheit", "dry_bulb_farenheit_flag",
"dry_bulb_celsius", "dry_bulb_celsius_flag",
"wet_bulb_farenheit", "wet_bulb_farenheit_flag",
"wet_bulb_celsius", "wet_bulb_celsius_flag",
"dew_point_farenheit", "dew_point_farenheit_flag",
"dew_point_celsius", "dew_point_celsius_flag",
"relative_humidity", "relative_humidity_flag",
"wind_speed", "wind_speed_flag", "wind_direction",
"wind_direction_flag", "value_for_wind_character",
"value_for_wind_character_flag", "station_pressure",
"station_pressure_flag", "pressure_tendency",
"pressure_tendency_flag", "pressure_change",
"pressure_change_flag", "sea_level_pressure",
"sea_level_pressure_flag", "record_type",
"record_type_flag", "hourly_precip", "hourly_precip_flag",
"altimeter", "altimeter_flag"]
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:25,代码来源:msg_noaa_weather_data_parser.py
示例5: __init__
def __init__(self):
"""
Constructor.
"""
self.logger = MSGLogger(__name__, 'DEBUG')
self.cursor = MSGDBConnector().connectDB().cursor()
self.dbUtil = MSGDBUtil()
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:8,代码来源:msg_data_verifier.py
示例6: __init__
def __init__(self):
"""
Constructor.
"""
self.logger = MSGLogger(__name__)
self.configer = MSGConfiger()
self.fileUtil = MSGFileUtil()
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:8,代码来源:meco_data_autoloader.py
示例7: MSGWeatherDataDupeChecker
class MSGWeatherDataDupeChecker(object):
"""
Determine if a duplicate record exists based on the tuple
(WBAN, Date, Time, StationType).
"""
def __init__(self, testing = False):
"""
Constructor.
:param testing: Flag for testing mode.
"""
self.logger = MSGLogger(__name__, 'debug')
self.dbUtil = MSGDBUtil()
def duplicateExists(self, dbCursor, wban, datetime, recordType):
"""
Check for the existence of a duplicate record.
:param dbCursor
:param wban
:param datetime
:param recordType
:returns: True if a duplicate record exists, otherwise False.
"""
tableName = "WeatherNOAA"
sql = """SELECT wban, datetime, record_type FROM \"%s\" WHERE
wban = '%s' AND datetime = '%s' AND record_type = '%s'""" % (
tableName, wban, datetime, recordType)
self.logger.log("sql=%s" % sql, 'debug')
self.logger.log("wban=%s, datetime=%s, record_type=%s" % (
wban, datetime, recordType), 'debug')
self.dbUtil.executeSQL(dbCursor, sql)
rows = dbCursor.fetchall()
if len(rows) > 0:
return True
else:
return False
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:45,代码来源:msg_noaa_weather_data_dupe_checker.py
示例8: __init__
def __init__(self, testing = False):
"""
Constructor.
:param testing: Flag for testing mode.
"""
self.logger = MSGLogger(__name__, 'debug')
self.dbUtil = MSGDBUtil()
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:9,代码来源:msg_noaa_weather_data_dupe_checker.py
示例9: __init__
def __init__(self, testing = False):
"""
Constructor.
:param testing: True if testing mode is being used.
"""
self.logger = MSGLogger(__name__, 'info')
self.dbUtil = MSGDBUtil()
self.dupeChecker = MSGWeatherDataDupeChecker()
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:9,代码来源:msg_noaa_weather_data_inserter.py
示例10: __init__
def __init__(self):
"""
Constructor.
"""
self.logger = MSGLogger(__name__, 'debug')
self.mecoConfig = MSGConfiger()
self.currentReadingID = 0
self.dbUtil = MSGDBUtil()
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:9,代码来源:meco_dupe_check.py
示例11: __init__
def __init__(self):
"""
Constructor.
"""
self.logger = MSGLogger(__name__, 'debug')
self.mapper = MECOMapper()
self.dupeChecker = MECODupeChecker()
self.dbUtil = MSGDBUtil()
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:9,代码来源:meco_db_insert.py
示例12: MSGTimeUtilTester
class MSGTimeUtilTester(unittest.TestCase):
def setUp(self):
self.logger = MSGLogger(__name__, 'debug')
self.timeUtil = MSGTimeUtil()
def test_concise_now(self):
conciseNow = self.timeUtil.conciseNow()
self.logger.log(conciseNow)
pattern = '\d+-\d+-\d+_\d+'
result = re.match(pattern, conciseNow)
self.assertTrue(result is not None,
"Concise now matches the regex pattern.")
def test_split_dates(self):
start = dt(2014, 01, 07)
end = dt(2014, 04, 04)
print self.timeUtil.splitDates(start, end)
self.assertEqual(len(self.timeUtil.splitDates(start, end)), 4,
'Unexpected date count.')
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:19,代码来源:test____msg_time_util.py
示例13: __init__
def __init__(self, testing = False):
"""
Constructor.
:param testing: Flag indicating if testing mode is on.
"""
self.logger = MSGLogger(__name__)
self.parser = MECOXMLParser(testing)
self.configer = MSGConfiger()
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:10,代码来源:insertSingleMECOEnergyDataFile.py
示例14: __init__
def __init__(self):
"""
Constructor.
"""
print __name__
self.logger = MSGLogger(__name__)
self.connector = MSGDBConnector()
self.dbUtil = MSGDBUtil()
self.notifier = MSGNotifier()
self.configer = MSGConfiger()
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:11,代码来源:msg_egauge_new_data_checker.py
示例15: WeatherDataLoadingTester
class WeatherDataLoadingTester(unittest.TestCase):
def setUp(self):
self.weatherUtil = MSGWeatherDataUtil()
self.logger = MSGLogger(__name__, 'DEBUG')
self.dbConnector = MSGDBConnector()
self.cursor = self.dbConnector.conn.cursor()
self.configer = MSGConfiger()
def testLoadDataSinceLastLoaded(self):
"""
Data should be loaded since the last data present in the database.
"""
pass
def testRetrieveDataSinceLastLoaded(self):
"""
Data since the last loaded date is retrieved.
"""
pass
def testGetLastLoadedDate(self):
myDate = self.weatherUtil.getLastDateLoaded(self.cursor).strftime(
"%Y-%m-%d %H:%M:%S")
pattern = '^(\d+-\d+-\d+\s\d+:\d+:\d+)$'
match = re.match(pattern, myDate)
assert match and (match.group(1) == myDate), "Date format is valid."
def testWeatherDataPattern(self):
myPattern = self.configer.configOptionValue('Weather Data',
'weather_data_pattern')
testString = """<A HREF="someURL">QCLCD201208.zip</A>"""
match = re.match(myPattern, testString)
self.logger.log("pattern = %s" % myPattern, 'info')
if match:
self.logger.log("match = %s" % match)
self.logger.log("match group = %s" % match.group(1))
else:
self.logger.log("match not found")
assert match and match.group(
1) == 'QCLCD201208.zip', "Download filename was matched."
def testWeatherDataURL(self):
myURL = self.configer.configOptionValue('Weather Data',
'weather_data_url')
pass
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:51,代码来源:test____noaa_weather_data_loading.py
示例16: __init__
def __init__(self):
"""
Constructor.
"""
self.config = MSGConfiger()
self.logger = MSGLogger(__name__, 'info')
self.notificationHeader = "This is a message from the Hawaii Smart " \
"Energy Project MSG Project notification " \
"system.\n\n"
self.noReplyNotice = """\n\nThis email account is not monitored. No
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:12,代码来源:msg_notifier.py
示例17: __init__
def __init__(self):
"""
Constructor.
"""
self.logger = MSGLogger(__name__, 'DEBUG')
self.aggregator = MSGDataAggregator()
self.notifier = MSGNotifier()
self.rawTypes = ['weather', 'egauge', 'circuit', 'irradiance']
self.connector = MSGDBConnector()
self.conn = self.connector.connectDB()
self.cursor = self.conn.cursor()
self.dbUtil = MSGDBUtil()
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:12,代码来源:aggregateNewData.py
示例18: __init__
def __init__(self, exitOnError = True, commitOnEveryInsert = False,
testing = False):
"""
Constructor.
:param testing: if True, the testing DB will be connected instead of
the production DB.
"""
self.logger = MSGLogger(__name__, 'info')
self.configer = MSGConfiger()
self.conn = MSGDBConnector().connectDB()
self.cursor = self.conn.cursor()
self.dbUtil = MSGDBUtil()
self.notifier = MSGNotifier()
self.mathUtil = MSGMathUtil()
self.timeUtil = MSGTimeUtil()
self.nextMinuteCrossing = {}
self.nextMinuteCrossingWithoutSubkeys = None
self.exitOnError = exitOnError
self.commitOnEveryInsert = commitOnEveryInsert
section = 'Aggregation'
tableList = ['irradiance', 'agg_irradiance', 'weather', 'agg_weather',
'circuit', 'agg_circuit', 'egauge', 'agg_egauge']
self.dataParams = {'weather': ('agg_weather', 'timestamp', ''),
'egauge': ('agg_egauge', 'datetime', 'egauge_id'),
'circuit': ('agg_circuit', 'timestamp', 'circuit'),
'irradiance': (
'agg_irradiance', 'timestamp', 'sensor_id')}
self.columns = {}
# tables[datatype] gives the table name for datatype.
self.tables = {
t: self.configer.configOptionValue(section, '%s_table' % t) for t in
tableList}
for t in self.tables.keys():
self.logger.log('t:%s' % t, 'DEBUG')
try:
self.columns[t] = self.dbUtil.columnsString(self.cursor,
self.tables[t])
except TypeError as error:
self.logger.log('Ignoring missing table: Error is %s.' % error,
'error')
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:44,代码来源:msg_data_aggregator.py
示例19: setUp
def setUp(self):
self.i = MECODBInserter()
# Connect to the testing database.
self.connector = MSGDBConnector(testing = True)
self.conn = self.connector.connectDB()
self.lastSeqVal = None
# Does this work having the dictCur be in another class?
self.dictCur = self.connector.dictCur
self.cursor = self.conn.cursor()
self.deleter = MECODBDeleter()
self.tableName = 'MeterData'
self.columnName = 'meter_data_id'
self.configer = MSGConfiger()
self.logger = MSGLogger(__name__, 'debug')
self.dbUtil = MSGDBUtil()
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:19,代码来源:test____msg_db_util.py
示例20: __init__
def __init__(self):
"""
Constructor.
A database connection is not maintained here to keep this class
lightweight. This results in the class not having a parameter for
TESTING MODE.
"""
self.logger = MSGLogger(__name__, 'info')
self.configer = MSGConfiger()
self.url = self.configer.configOptionValue('Weather Data',
'weather_data_url')
self.pattern = self.configer.configOptionValue('Weather Data',
'weather_data_pattern')
self.fileList = []
self.dateList = [] # List of dates corresponding weather data files.
self.fillFileListAndDateList()
self.dbUtil = MSGDBUtil()
开发者ID:daveyshindig,项目名称:Maui-Smart-Grid,代码行数:19,代码来源:msg_noaa_weather_data_util.py
注:本文中的msg_logger.MSGLogger类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论