Ejemplo n.º 1
0
 def background(self):
     import json
     import config
     from dateutil import parser
     self.events = url_handler.load_json(
         "http://www.mscroggs.co.uk/room_list.json")
     now = config.now().replace(tzinfo=None)
     for e in self.events:
         e[0] = parser.parse(e[0])
         e[1] = parser.parse(e[1])
     self.events = [e for e in self.events if e[1] > now]
Ejemplo n.º 2
0
    def background(self):
        import url_handler, json
        from time import sleep

        i = 0

        step = 30
        try:
            for j in range(0, len(self.ordered_ids), step):
                url = "http://api.openweathermap.org/data/2.5/group?id=" + ",".join(
                    self.ordered_ids[j:j + step]
                ) + "&units=metric&appid=05f6b7c72cd541dd510d7bc08f6a8bb0"
                data = url_handler.load_json(url)
                for city in data['list']:
                    self.temps[i] = float(city['main']['temp'])
                    i += 1
                #sleep(5)
        except:
            pass
Ejemplo n.º 3
0
 def background(self):
     self.data = url_handler.load_json(
         "http://api.openweathermap.org/data/2.5/group?id=5368361,5128638,3530597,2643743,2968815,2950158,3169070,344979,1820906,1816670,1850147,7839805&units=metric&appid=05f6b7c72cd541dd510d7bc08f6a8bb0"
     )
Ejemplo n.º 4
0
 def background(self):
     self.results = url_handler.load_json(
         'http://worldcup.sfg.io/teams/group_results')
Ejemplo n.º 5
0
 def background(self):
     self.results = url_handler.load_json('http://worldcup.sfg.io/matches')
Ejemplo n.º 6
0
    def generate_content(self):
        tube_times = url_handler.load_json("http://api.tfl.gov.uk/stopPoint/" +
                                           self.code + "/arrivals?mode=tube")

        tubes = []
        for b in tube_times:
            tubes.append(
                (int(b['timeToStation']),
                 str(b['timeToStation'] // 60) + " min",
                 b['lineName'].replace('Hammersmith',
                                       'Ham').replace('Waterloo', 'Wloo'),
                 b['towards'], b['currentLocation']))

        tubes.sort()

        self.add_title(self.station, font='size4', fg="BRIGHTWHITE", bg="BLUE")

        underground = ("WWWWWWWWWWW\n"
                       "WWWrrrrrWWW\n"
                       "WWrrWWWrrWW\n"
                       "WbbbbbbbbbW\n"
                       "WbbbbbbbbbW\n"
                       "WWrrWWWrrWW\n"
                       "WWWrrrrrWWW\n"
                       "WWWWWWWWWWW")
        self.print_image(underground, 0, 69)

        pos = (0, 7, 20, 45)
        for p, t in zip(pos,
                        ("Time", "Line", "Destination", "Current Location")):
            self.move_cursor(x=p)
            self.add_text(t)
        self.add_newline()

        for tube in tubes:
            if tube[2] == "Bakerloo":
                self.start_fg_color("WHITE")
                self.start_bg_color("ORANGE")
            if tube[2] == "Central":
                self.start_fg_color("WHITE")
                self.start_bg_color("RED")
            if tube[2] == "Circle":
                self.start_fg_color("BLACK")
                self.start_bg_color("YELLOW")
            if tube[2] == "District":
                self.start_fg_color("BLACK")
                self.start_bg_color("GREEN")
            if tube[2] == "Ham & City":
                self.start_fg_color("BLACK")
                self.start_bg_color("PINK")
            if tube[2] == "Jubilee":
                self.start_fg_color("WHITE")
                self.start_bg_color("GREY")
            if tube[2] == "Metropolitan":
                self.start_fg_color("WHITE")
                self.start_bg_color("MAGENTA")
            if tube[2] == "Northern":
                self.start_fg_color("WHITE")
                self.start_bg_color("BLACK")
            if tube[2] == "Piccadilly":
                self.start_fg_color("WHITE")
                self.start_bg_color("BLUE")
            if tube[2] == "Victoria":
                self.start_fg_color("WHITE")
                self.start_bg_color("LIGHTBLUE")
            if tube[2] == "Wloo & City":
                self.start_fg_color("WHITE")
                self.start_bg_color("LIGHTCYAN")
            self.add_text(" " * 80)
            for p, t in zip(pos, tube[1:]):
                self.move_cursor(x=p)
                self.add_text(t)
            self.end_fg_color()
            self.end_bg_color()
            self.add_newline()