Example #1
0
def loadConf (confFileName):
    print '載入設定檔...('+confFileName+')'
    args = __readConfigFile__(confFileName)
    if args['ERROR'] != []:
        print ''
        print '設定檔語法錯誤:'
        for e in args['ERROR']:
            print 'Line {0}: \033[1;31m{1}\033[m'.format(e[0], e[1])

    if args['WARNING'] != []:
        print ''
        print '警告: 以下參數被覆蓋'
        for e in args['WARNING']:
            print 'Line {0}: \033[1;33m{1}\033[m'.format(e[0], e[1])

    if args['UNKNOWN']:
        print ''
        print '未知的參數:'
        for e in args['UNKNOWN']:
            print 'Line {0}: \033[1;32m{1}\033[m'.format(e[0], e[1])

    if args['ARGS'] != {}:
        print ''
        print '已載入的參數:'
        tempList = []
        for key in args['ARGS']:
            tempList.append(key+':')
            if key == 'PASSWD':
                tempList.append('********')
            else:
                tempList.append(args['ARGS'][key])
        for i in tools.flatList(tempList, 2):
            print i

    if args['ERROR'] != []:
        if args['ERROR'] == [[0, 'Configure file does not exist']]:
            __genExampleConfFile__(confFileName)
        return False

    if __checkLackArguments__(args['ARGS']) != []:
        print '設定檔中缺少必要選項 :'
        for i in lack:
            print i
        return False

    print '設定檔載入成功'
    print ''
    return args['ARGS']
Example #2
0
def loadConf(confFileName):
    print '載入設定檔...(' + confFileName + ')'
    args = __readConfigFile__(confFileName)
    if args['ERROR'] != []:
        print ''
        print '設定檔語法錯誤:'
        for e in args['ERROR']:
            print 'Line {0}: \033[1;31m{1}\033[m'.format(e[0], e[1])

    if args['WARNING'] != []:
        print ''
        print '警告: 以下參數被覆蓋'
        for e in args['WARNING']:
            print 'Line {0}: \033[1;33m{1}\033[m'.format(e[0], e[1])

    if args['UNKNOWN']:
        print ''
        print '未知的參數:'
        for e in args['UNKNOWN']:
            print 'Line {0}: \033[1;32m{1}\033[m'.format(e[0], e[1])

    if args['ARGS'] != {}:
        print ''
        print '已載入的參數:'
        tempList = []
        for key in args['ARGS']:
            tempList.append(key + ':')
            if key == 'PASSWD':
                tempList.append('********')
            else:
                tempList.append(args['ARGS'][key])
        for i in tools.flatList(tempList, 2):
            print i

    if args['ERROR'] != []:
        if args['ERROR'] == [[0, 'Configure file does not exist']]:
            __genExampleConfFile__(confFileName)
        return False

    if __checkLackArguments__(args['ARGS']) != []:
        print '設定檔中缺少必要選項 :'
        for i in lack:
            print i
        return False

    print '設定檔載入成功'
    print ''
    return args['ARGS']
Example #3
0
    def loadFishList (self):
        print '載入記錄 (fishes/%s)...' % self.board
        if not os.path.exists('fishes'):
            os.mkdir('fishes')
        if not os.path.isdir('fishes'):
            os.rename('fishes', 'fishes.tmp')

        open('fishes/'+self.board, 'a').close()
        self.fishList = []
        with open('fishes/'+self.board, 'r') as fishes:
            self.fishList = [i.split()[0].strip() for i in fishes]
        if len(self.fishList) == 0:
            print '名單為空'
        else:
            for i in tools.flatList(self.fishList, 5):
                print i
        print '完成'