Ejemplo n.º 1
0
 def __init__(self):
     self.filesToWatch = [
         WatchedFile(
             MatroxCommandManager.reloadAnnouncements,
             FileManager.Instance().formatPath(
                 FileManager.Instance().ROOT_FILEPATH,
                 FileManager.Instance().ANNOUNCEMENTS_FILENAME))
     ]
Ejemplo n.º 2
0
 def addAnnouncementMessage(self, message):
     if(self.loadedFile == False):
         self.loadAnnouncements()
     self.maxAnnouncementId += 1
     newAnnouncement = Announcement(self.maxAnnouncementId, message)
     if(FileManager.Instance().addAnnouncement(newAnnouncement)):
         self.announcements[self.maxAnnouncementId] = newAnnouncement
         return "Added announcement " + newAnnouncement.messageToString()
     return "Failed to add announcement " + message + ". Check error logs."
Ejemplo n.º 3
0
 def loadAnnouncements(self):
     self.loadedFile, fileContents = FileManager.Instance().loadAnnouncementFile()
     if(self.loadedFile):
         # Clear out announcements
         self.announcements.clear()
         # Parse file into individual announcements
         for line in fileContents:
             announce = line.split( )
             if (len(announce) > 1):
                 parsed, loadedId = Utility().try_parse_int(announce[0])
                 if (parsed):
                     if (loadedId > self.maxAnnouncementId):
                          self.maxAnnouncementId = loadedId
                     newAnnouncement = Announcement(loadedId, ' '.join(announce[1:]))
                     self.announcements[loadedId] = newAnnouncement
                 else:
                     print "Error parsing announcement id ", announce[0]
             else:
                 print "Invalid announcement format ", announce
     else:
         print "Error loading announcements"