Esempio n. 1
0
class FileParser:
    def __init__(self, fileName):
        '''
        :param fileName:
        '''
        self.logger = Logger(logger="FileParser").getlog()
        try:
            self.config = ConfigParser()
            self.config.read(fileName, encoding='gbk')
            # self.config.read(fileName, encoding='utf8')
        except:
            self.logger.info(fileName)
            self.logger.exception('文件名不存在,请检查配置!')

    def get(self, section, option):
        '''
        :param section:
        :param option:
        :return:value
        '''
        res = self.config.get(section, option)
        if res.strip() == '':
            return False
        else:
            return res

    def set(self, section, option):
        return self.config.set(section, option)

    def get_sections(self):
        '''返回所有的sections'''
        return self.config.sections()
Esempio n. 2
0
class FileParser:

    def __init__(self, fileName):
        '''
        :param fileName:
        '''
        self.logger = Logger(logger="FileParser").getlog()
        try:
            self.config = ConfigParser()
            self.config.read(fileName, encoding='utf-8')
        except:
            self.logger.exception('文件名不存在,请检查配置!')




    def get(self, section, option):
        '''
        :param section:
        :param option:
        :return:value
        '''
        # 获取对应环境的配置信息,使用get('env',url)
        # if section == 'env':
        #     section = self.config.get(section, 'env')
        #     return self.config.get(section, option)
        return self.config.get(section, option)
Esempio n. 3
0
def runTask():
    if datetime.today().weekday() < 5 and datetime.now(
    ).hour >= 9 and datetime.now().hour < 10 and datetime.now().minute <= 20:
        begin = datetime.now()
        sendMessageToMySelf(unicode("启动今日提醒程序"))

        reminder()

        end = datetime.now()
        sendMessageToMySelf(
            unicode("今日提醒程序运行结束,当前时间:{0},执行用时:{1}").format(
                datetime.now(), end - begin))

    t = Timer(900, runTask)
    t.start()


def main(argv):
    reload(sys)
    sys.setdefaultencoding('utf-8')

    runTask()


if __name__ == '__main__':
    logger = Logger()
    try:
        main(sys.argv)
    except Exception, e:
        logger.exception(str(e))