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


Python logger.SEKLogger类代码示例

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


在下文中一共展示了SEKLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = SEKLogger(__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_autoload_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_autoload_new_data_path")
        command = self.configer.configOptionValue("MECO Autoload", "meco_autoload_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:Hawaii-Smart-Energy-Project,项目名称:Maui-Smart-Grid,代码行数:51,代码来源:meco_data_autoloader.py

示例2: __init__

    def __init__(self):
        """
        Constructor.
        """
        self.logger = SEKLogger(__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:Hawaii-Smart-Energy-Project,项目名称:Maui-Smart-Grid,代码行数:25,代码来源:msg_noaa_weather_data_parser.py

示例3: __init__

    def __init__(self):
        """
        Constructor.
        """

        self._config = ConfigParser.ConfigParser()
        self.logger = SEKLogger(__name__, 'INFO')
        self.fileUtil = SEKFileUtil()

        # 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.fileUtil.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:Hawaii-Smart-Energy-Project,项目名称:Maui-Smart-Grid,代码行数:34,代码来源:msg_configer.py

示例4: setUp

 def setUp(self):
     self.logger = SEKLogger(__name__,'DEBUG')
     self.configer = SIConfiger()
     self.conn = SEKDBConnector(
         dbName = self.configer.configOptionValue('Database', 'db_name'),
         dbHost = self.configer.configOptionValue('Database', 'db_host'),
         dbPort = self.configer.configOptionValue('Database', 'db_port'),
         dbUsername = self.configer.configOptionValue('Database',
                                                      'db_username'),
         dbPassword = self.configer.configOptionValue('Database',
                                                      'db_password')).connectDB()
     self.cursor = self.conn.cursor()
     self.dbUtil = SEKDBUtil()
     self.dataUtil = SIDataUtil()
     self.inserter = SingleFileLoader('data/test-meter/log.csv')
     self.data = '"2014-07-12 16:22:30",0,,,1187488464896.00,' \
                 '2322185846784.00,1134697381888.00,35184644096.00,' \
                 '290857353216.00,10133100822528.00,367.13,' \
                 '-17660932096.00,1078.01,17660934144.00,-7.86,1.80,8.06,' \
                 '-0.97,244.01,122.00,32.93,60.01,-7.09,1.42,7.24,8.06,' \
                 '3.34,8.35,-40.18,-5.68,40.52,516.72,403.12,0,' \
                 '8797179904.00,47518.67,0,86.03,50.23,4198.40,' \
                 '281475022848.00,2251868602368.00,0,6820.01,' \
                 '8796095488.00,0,178.83,188.30,0,620.07,505.19,' \
                 '288230389841920.02,12668.18,68729384.00,0,-3.68,-4.18,,' \
                 '1.00,0.79,,3.81,4.25,,-0.97,-0.98,,244.01,,,121.54,' \
                 '122.46,,31.28,34.59,'
     self.testMeterName = 'test-meter'
开发者ID:Hawaii-Smart-Energy-Project,项目名称:Smart-Grid-PV-Inverter,代码行数:28,代码来源:test_insert_single_meter_data_file.py

示例5: setUp

    def setUp(self):
        self.logger = SEKLogger(__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()
        self.timeUtil = MSGTimeUtil()

        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:Hawaii-Smart-Energy-Project,项目名称:Maui-Smart-Grid,代码行数:32,代码来源:test_msg_db_exporter.py

示例6: __init__

    def __init__(self):
        """
        Constructor.
        """

        self._config = ConfigParser.ConfigParser()
        self.logger = SEKLogger(__name__, 'INFO')
        self.fileUtil = SEKFileUtil()
        self.dbUtil = SEKDBUtil()
        self.cursor = None

        configFilePath = '~/.smart-inverter.cfg'

        if self.fileUtil.isMoreThanOwnerReadableAndWritable(
                os.path.expanduser(configFilePath)):
            self.logger.log(
                "Configuration file permissions are too permissive. Operation "
                "will not continue.", 'error')
            sys.exit(-1)

        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:Hawaii-Smart-Energy-Project,项目名称:Smart-Grid-PV-Inverter,代码行数:27,代码来源:si_configer.py

示例7: __init__

    def __init__(self):
        """
        Constructor.
        """

        warnings.simplefilter('default')
        warnings.warn("This module is deprecated in favor of SEKNotifier.",
                      DeprecationWarning)

        self.config = MSGConfiger()
        self.logger = SEKLogger(__name__, 'info')
        self.connector = MSGDBConnector()
        self.conn = self.connector.connectDB()
        self.cursor = self.conn.cursor()
        self.dbUtil = MSGDBUtil()
        self.noticeTable = 'NotificationHistory'
        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 ' \
                             'replies will originate from this ' \
                             'account.\n\nYou are receiving this message ' \
                             'because you are on the recipient list for ' \
                             'notifications for the Hawaii Smart Energy ' \
                             'Project.'
开发者ID:Hawaii-Smart-Energy-Project,项目名称:Maui-Smart-Grid,代码行数:26,代码来源:msg_notifier.py

示例8: __init__

    def __init__(self, dbName = '', dbHost = '', dbPort = '', dbUsername = '',
                 dbPassword = '', testing = False, logLevel = 'silent'):
        """
        Constructor.

        :param testing: Boolean indicating if Testing Mode is on. When
        testing mode is on, a connection to the testing database will be made
        instead of the production database. This is useful for unit testing.
        :param logLevel
        """

        self.logger = SEKLogger(__name__, logLevel)

        if testing:
            self.logger.log("Testing Mode is ON.")

        self.dbName = dbName
        self.dbHost = dbHost
        self.dbPort = dbPort
        self.dbPassword = dbPassword
        self.dbUsername = dbUsername

        self.logger.log(
            "Instantiating DB connector with database {}.".format(dbName))

        self.conn = self.connectDB()
        if not self.conn:
            self.logger.log('DB connection not available.', 'error')
            sys.exit(-1)

        try:
            self.dictCur = self.conn.cursor(
                cursor_factory = psycopg2.extras.DictCursor)
        except AttributeError as error:
            self.logger.log('Error while getting DictCursor: {}'.format(error))
开发者ID:Hawaii-Smart-Energy-Project,项目名称:Smart-Energy-Kit,代码行数:35,代码来源:db_connector.py

示例9: __init__

 def __init__(self):
     """
     Constructor.
     """
     warnings.simplefilter('default')
     warnings.warn("This module is deprecated in favor of SEKFileUtil.",
                   DeprecationWarning)
     self.logger = SEKLogger(__name__, 'DEBUG')
开发者ID:Hawaii-Smart-Energy-Project,项目名称:Maui-Smart-Grid,代码行数:8,代码来源:msg_file_util.py

示例10: __init__

    def __init__(self):
        """
        Constructor.
        """

        self.logger = SEKLogger(__name__, 'DEBUG')
        self.cursor = MSGDBConnector().connectDB().cursor()
        self.dbUtil = MSGDBUtil()
开发者ID:Hawaii-Smart-Energy-Project,项目名称:Maui-Smart-Grid,代码行数:8,代码来源:msg_data_verifier.py

示例11: __init__

    def __init__(self):
        """
        Constructor.
        """

        self.logger = SEKLogger(__name__)
        self.configer = MSGConfiger()
        self.fileUtil = MSGFileUtil()
开发者ID:Hawaii-Smart-Energy-Project,项目名称:Maui-Smart-Grid,代码行数:8,代码来源:meco_data_autoloader.py

示例12: 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 = SEKLogger(__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:Hawaii-Smart-Energy-Project,项目名称:Maui-Smart-Grid,代码行数:45,代码来源:msg_noaa_weather_data_dupe_checker.py

示例13: __init__

    def __init__(self, testing = False):
        """
        Constructor.
        :param testing: True if testing mode is being used.
        """

        self.logger = SEKLogger(__name__, 'info')
        self.dbUtil = MSGDBUtil()
        self.dupeChecker = MSGWeatherDataDupeChecker()
开发者ID:Hawaii-Smart-Energy-Project,项目名称:Maui-Smart-Grid,代码行数:9,代码来源:msg_noaa_weather_data_inserter.py

示例14: __init__

    def __init__(self):
        """
        Constructor.
        """

        self.logger = SEKLogger(__name__, 'debug')
        self.mecoConfig = MSGConfiger()
        self.currentReadingID = 0
        self.dbUtil = MSGDBUtil()
开发者ID:Hawaii-Smart-Energy-Project,项目名称:Maui-Smart-Grid,代码行数:9,代码来源:meco_dupe_check.py

示例15: setUp

 def setUp(self):
     """
     Constructor.
     """
     self.logger = SEKLogger(__name__, "DEBUG")
     self.aggregator = MSGDataAggregator()
     self.testStart = "2014-01-02 11:59"
     self.testEnd = "2014-01-02 12:14"
     self.rawTypes = ["weather", "egauge", "circuit", "irradiance"]
开发者ID:Hawaii-Smart-Energy-Project,项目名称:Maui-Smart-Grid,代码行数:9,代码来源:test_msg_data_aggregator.py


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