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


Python Configuration.getInstance方法代码示例

本文整理汇总了Python中configuration.Configuration.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.getInstance方法的具体用法?Python Configuration.getInstance怎么用?Python Configuration.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在configuration.Configuration的用法示例。


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

示例1: main

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import getInstance [as 别名]
def main():
    # The configuration is merged from the different sources
    configuration= Configuration.getInstance()
    logging= configuration["loggingModule"]
    random.seed()
    
    configuration["stats"]= {
        "emailsSuccessfully" : 0, # emails were sent
        "emailsFailed" : 0, # emails could not be sent
        "groupsSuccessfully" : 0, # groups were processed and removed from the db
        "groupsFailed" : 0, # groups could not be processed because of failing emails
        "remainingNotifications" : 0,  # notifications are still remaining in the database
        "remainingGroups" : 0,  # notifications are still remaining in the database
        "remainingEmails" : 0, } # notifications are still remaining in the database
    
    # The notifications to be sent are fetched from the database
    logging.debug("Connecting to the database server \"%s\"..." % (configuration["DB"]["host"],))
    
    try:
        connection= MySQLdb.connect(**configuration["DB"])
        
        connection.query("""
            select 
                `notifications`.`unique`, 
                `notifications`.`email`, 
                `groups`.`unique`, 
                `groups`.`name`, 
                `groups`.`theory_or_lab`, 
                `groupsT`.`teacher`, 
                `groupsL`.`teacher`, 
                `courses_semester`.`course_type`, 
                `courses`.`symbol`, 
                `courses`.`title` 
            from `notifications` 
            inner join `groups` on 
                `notifications`.`group` = `groups`.`unique` 
            left join `groups` as `groupsT` on 
                `groups`.`course_semester` = `groupsT`.`course_semester` and 
                `groups`.`name` = `groupsT`.`name` and 
                `groupsT`.`theory_or_lab` = 'C' 
            left join `groups` as `groupsL` on 
                `groups`.`course_semester` = `groupsL`.`course_semester` and 
                `groups`.`name` = `groupsL`.`name` and 
                `groupsL`.`theory_or_lab` = 'L' 
            inner join `courses_semester` on 
                `groups`.`course_semester` = `courses_semester`.`unique` 
            inner join `courses` on 
                `courses_semester`.`course` = `courses`.`unique` 
            where `groups`.`closed` = '0'
            order by `notifications`.`email`
        """)
    except MySQLdb.MySQLError, message:
        logging.critical("MySQL error %d: %s" % (message[0], message[1]))
        return 1
开发者ID:mbahlabs,项目名称:sopti,代码行数:56,代码来源:emailer.py

示例2: getTemplateValues

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import getInstance [as 别名]
def getTemplateValues(notification):
    configuration= Configuration.getInstance()
    
    values= {
        "symbol" : notification["courses.symbol"], 
        "title" : notification["courses.title"], 
        "name" : notification["groups.name"],}
    
    if notification["courses_semester.course_type"] == "TL":
        values["theory_or_lab"]= "combinée théorique et laboratoire"
        values["teacher"]= "\n\tThéorie: %s\n\tLab: %s" % (notification["groupsT.teacher"], notification["groupsL.teacher"],)
    elif notification["groups.theory_or_lab"] == "C":
        values["theory_or_lab"]= "théorique"
        values["teacher"]= notification["groupsT.teacher"]
    elif notification["groups.theory_or_lab"] == "L":
        values["theory_or_lab"]= "laboratoire"
        values["teacher"]= notification["groupsL.teacher"]
    else:
        raise(Exception("Unknown course type"))
    
    return values
开发者ID:mbahlabs,项目名称:sopti,代码行数:23,代码来源:emailer.py


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