def recover(self):
        """
        从备份文件中回复文件
        :return:
        """
        fileName = self.chooseRecoverFileTools.choose()
        fileName = self.filePath + fileName
        # 获取最新备份文件的文件名
        backupFileNeedToLoad = True  # 循环读取备份文件标记,直到正确读取
        while (backupFileNeedToLoad):
            try:
                loadMissionTools = loadFiles.LoadFiles(filename=fileName)
                list = loadMissionTools.loadFiles(missionType='mission')
                # 读取成功则跳出循环
                backupFileNeedToLoad = False
                # 判断文件是否真的读取成功了(读取失败返回None)
                if list is None:
                    # 打印debug日志
                    if DEBUG and MISSION_DEBUG:
                        print(
                            '{SYS}{W}{MISSION_DEBUG} load backup file fail, return list is None, file name is '
                            + fileName)
                    # 如果是读取失败将循环标记改回,继续下次读取
                    backupFileNeedToLoad = True
            except:
                # 打印debug日志
                if DEBUG and MISSION_DEBUG:
                    print(
                        '{SYS}{W}{MISSION_DEBUG} backup file load fail,name is '
                        + fileName)

        # 将从配置文件读取的信息保存
        saveMissionTools = saveFiles.SaveFiles(filename=self.missionFileName)
        saveMissionTools.saveFiles(list=list)
Exemple #2
0
 def __init__(self, confFileName='conf/recitation.ini', dataFileName='data/recitation.dat'):
     # 初始化工具
     self.loadRecitationTools = loadFiles.LoadFiles(filename=dataFileName)
     self.addRecitationTools = addRecitation.AddRecitation(confFileName=confFileName, dataFileName=dataFileName)
     self.editRecitationTools = editRecitation.EditRecitation(filename=dataFileName)
     self.saveRecitationTools = saveFiles.SaveFiles(filename=dataFileName)
     self.list = self.loadRecitation()
Exemple #3
0
 def __init__(self, filename='../data/mission.dat'):
     # 初始化工具
     self.computeNextTimeTools = computeNextMissionTime.ComputeNextMissionTime(
     )
     self.editMissionTools = editMissionList.EditMissionList()
     self.finishMissionTools = finishMission.FinishMission()
     self.removeMissionTools = removeMission.RemoveMission()
     self.saveMissionTools = saveFiles.SaveFiles(filename=filename)
     pass
 def __init__(self,
              confFileName='../conf/mission.ini',
              dataFileName='../data/mission.dat'):
     # 初始化工具
     self.loadConfigTools = loadConfigFile.LoadConfigFile(
         fileName=confFileName)
     self.addMissionTools = addMissionToList.AddMissionToList()
     self.saveConfigTools = saveConfigFile.SaveConfigFile(
         fileName=confFileName)
     self.saveMissionTools = saveFiles.SaveFiles(filename=dataFileName)
     pass
 def __init__(self,
              confFileName='conf\mission.ini',
              dataFileName='data\mission.dat',
              backupFilePath='data/bkup/mbk/'):
     # 初始化工具
     self.loadMissionTools = loadFiles.LoadFiles(filename=dataFileName)
     self.addMissionTools = addMission.AddMission(confFileName=confFileName,
                                                  dataFileName=dataFileName)
     self.editMissionTools = editMission.EditMission(filename=dataFileName)
     self.saveMissionTools = saveFiles.SaveFiles(filename=dataFileName)
     self.backupMissionTools = backupMission.BackupMission(
         fileLimit=7,
         backupFilePath=backupFilePath,
         missionFileName=dataFileName)
     self.list = self.loadMission()
     self.todayMission = self.findTodayMission()
    def backup(self, list):
        """
        备份文件
        :param list: 需要备份的列表
        :return:
        """
        # 使用当前时间作为备份文件名
        currentTime = datetime.datetime.strptime(
            time.strftime("%Y-%m-%d", time.localtime()),
            '%Y-%m-%d').strftime("%Y%m%d")
        fileName = self.filePath + currentTime + '.dat'
        # 由于文件名发生变化,只能在这里初始化保存工具
        saveMissionTools = saveFiles.SaveFiles(filename=fileName)
        # 打印debug日志
        if DEBUG and MISSION_DEBUG:
            print('{SYS}{MISSION_DEBUG} save backup file')

        # 保存备份文件
        saveMissionTools.saveFiles(list=list)

        # 调用备份管理,管理备份文件
        self.backupManageTools.manage()
 def __init__(self, filename='../data/recitation.dat'):
     # 初始化工具
     self.editRecitationListTools = editRecitationList.EditRecitationList()
     self.removeRecitationTools = removeRecitation.RemoveRecitation()
     self.saveRecitationTools = saveFiles.SaveFiles(filename=filename)
     pass