def __init__(self): self.last_update = 0 self.UpdateFrequency = 30 self.Arrivals = Data.BusList() self.Departures = Data.BusList() checks = UpdateChecks() config = Settings.Config() self.LocalSource = 'cache/' + os.path.basename(config.SourceURI) ## Path to the downloaded file. self.RemoteSource = config.SourceURI
def SourceUpdate(self): del self.Arrivals[:] del self.Departures[:] derp = "a b c d e f g h i j k l m n o p q r s t u v w x y z".upper().split(" ") arrivals = Data.BusList() departures = Data.BusList() for i in range(10): arrivals.append_bus(Data.BusArrival("Company " + derp[i], "City " + derp[:i], str(i) + ":00pm", random.randint(1, 4))) for i in range(10): departures.append_bus(Data.BusDeparture("Company " + derp[i], "City " + derp[:i], str(i) + ":00pm", random.randint(1, 4), random.randint(1, 12), random.randint(1, 9999)))
def __init__(self, width = 1280, height = 720): config = Settings.Config() if config.DisplayFullscreen is False: os.environ['SDL_VIDEO_CENTERED'] = '1' self.screen = pygame.display.set_mode((width, height)) else: self.screen = pygame.display.set_mode((width, height), pygame.FULLSCREEN | pygame.HWSURFACE | pygame.DOUBLEBUF) pygame.init() self.Background = TileImage("img/bg-dark.gif", self.screen) self.screen.blit(self.Background, (0,0)) pygame.mouse.set_visible(False) pygame.display.flip() checks = UpdateChecks() checks.AddTimer('page_delay', config.PageInterval) checks.AddTimer('source_update', config.UpdateInterval) checks.Update('page_delay') checks.AddState('dirty_source', True) checks.AddState('dirty_screen', True) checks.AddState('dirty_page', False) checks.AddState('error', False) self.DrawArrivals = True if config.DisplayScreen == 'departures': self.DrawArrivals = False self.CurrentPage = 1 self.RowsPerPage = 10 # 12 rows minus the header self.FirstRow = 0 # First row to draw # FIXME: proper error handling and checking needed here. if config.SourceURI[-4:] == '.xml': self.Source = ds.JSONSource() Debug('XML source found.') else: self.Source = ds.XMLSource() Debug('JSON source found.') self.CachedList = Data.BusList() self.List = Data.BusList() self.ArrivalHeader = HeaderRow(Data.BusArrival("Company", "City", "Time", "Status")) self.DepartureHeader = HeaderRow(Data.BusDeparture("Company", "City", "Time", "Status", "Gate", "Bus #")) self.ErrorScreen = None