Example #1
0
  def __init__(self):
    super(NextRoute, self).__init__()

    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)

    # Open a handle to the REST API
    self.api = tweepy.API(auth)
    self.api.retry_count = 2
    self.api.retry_delay = 5

    me = self.api.me()
    self.my_id = me.id
    self.my_name = me.screen_name
    print 'Name: %s id: %s' % (self.my_name, self.my_id)

    # Open a handle to the UserStreams API
    self.stream = tweepy.Stream(auth, self, retry_count=2)

    # Open a handle to NextBus API
    self.next_bus = NextBus()
Example #2
0
 def setUp(self):
     self.nextbus = NextBus()
     self.nextbus.get = MagicMock(side_effect=Exception(
         "There should be no get calls in these tests!"))
Example #3
0
 def setUp(self):
     self.nextbus = NextBus()
Example #4
0
 def setUp(self):
     self.nextbus = NextBus()
     self.nextbus.log.error = MagicMock()
                 BATT_BITMAP.height, 0))
    BATT_GROUP.append(BATT_ICON_TILEGRID)
except:
    # If load fails, fall back on text low-batt message
    TEXT = Label(FONT_MEDIUM, text='LOW BATTERY', color=0)
    TEXT.anchor_point = (0.5, 0.5)
    TEXT.anchored_position = (DISPLAY.width // 2, DISPLAY.height // 2)
    BATT_GROUP.append(TEXT)

# Populate list of NextBus objects from STOPS[] and generate initial text
# labels (these get positioned in a second pass later)...
STOP_LIST = []
MAX_SIZE = (0, 0)  # Pixel dimensions of largest route number
for stop in STOPS:
    STOP_LIST.append(
        NextBus(NETWORK, stop[0], stop[1], stop[2], None, MAX_PREDICTIONS,
                MINIMUM_TIME))
    TEXT = Label(FONT_LARGE, text=stop[1], color=0)
    # Keep track of the largest route label for positioning things later
    MAX_SIZE = (max(TEXT.width, MAX_SIZE[0]), max(TEXT.height, MAX_SIZE[1]))
    TEXT.anchor_point = (1.0, 1.0)  # Bottom-right align route
    GROUP.append(TEXT)
    # Because text anchoring works from bounding rectangles rather than
    # the font baseline, we use a kludge here of upper-casing the route
    # description to eliminate descenders that would throw off alignment.
    TEXT = Label(FONT_SMALL, text=stop[3].upper(), color=0)
    TEXT.anchor_point = (0.0, 1.0)  # Bottom-left align description
    GROUP.append(TEXT)
    INITIAL = 'No predictions'
    TEXT = Label(FONT_MEDIUM,
                 text=INITIAL,
                 color=0,