コード例 #1
0
ファイル: record.py プロジェクト: Jbaldy16/rideData
def addUberPOOLFareEstimate(start, end, timezone, newSurge, newHigh, newLow, newEstimate, newDistance, newDuration, newService):
    utc_time = defineUTC(datetime.datetime.utcnow())
    timeZoneDelta = getTimeZoneOffset(timezone)
    new_fare_estimate = RideData(start_location_id=start, end_location_id=end, surge=newSurge, \
        highEstimate=newHigh, lowEstimate=newLow, estimate=newEstimate, distance=newDistance, \
        service=newService, duration=newDuration, timestamp = utc_time , \
        timestamp_interval=defineUTC(roundTime(datetime.datetime.utcnow())), \
        timestamp_interval_EST=roundTime(datetime.datetime.utcnow())-timeZoneDelta)
    session.add(new_fare_estimate)
    session.commit()
コード例 #2
0
	def testRoundTime(self):		
		print 'MN ', roundTime(self.date, MN)

		print '5MN ', roundTime(self.date, 5*MN)

		print '15MN ', roundTime(self.date, 15*MN)

		print '30MN ', roundTime(self.date, 30*MN)

		print 'HR ', roundTime(self.date, HR)

		print 'D ', roundTime(self.date, D)

		print 'W ', roundTime(self.date, W)

		print 'M ', roundTime(self.date, M)

		print 'Y ', roundTime(self.date, Y)

		pass
コード例 #3
0
ファイル: record.py プロジェクト: Jbaldy16/rideData
def updateUberXData(startLoc, endLoc):
    start_location = session.query(Locations).filter(Locations.name == startLoc).one()
    end_location = session.query(Locations).filter(Locations.name == endLoc).one()

    uberXEntry = requestUberData('uberX', start_location.latitude, start_location.longitude, \
        end_location.latitude, end_location.longitude)

    timeZoneDelta = getTimeZoneOffset(start_location.timezone)
    time_interval = roundTime(datetime.datetime.utcnow())-timeZoneDelta
    weekday_index = time_interval.weekday()
    time = time_interval.time()

    dayTimeInterval_record = session.query(DayTimeIntervals).filter(DayTimeIntervals.day_index==weekday_index). \
        filter(DayTimeIntervals.time_interval==time).first()

    updateUberXMean(start_location.id, end_location.id, dayTimeInterval_record.id, uberXEntry)
コード例 #4
0
    def get(self):
        # Fetch buses data from a minute ago
        buses = None
        minute_ago = utils.roundTime(
            datetime.datetime.now() - datetime.timedelta(seconds=60),
            roundTo=1)
        retries = 0
        while not buses and retries < 10:
            buses = Buses.gql('WHERE time_stamp=:1', minute_ago).get()
            minute_ago += datetime.timedelta(seconds=1)
            retries += 1

        if buses:
            self.response.headers['Content-Type'] = 'application/json'
            self.response.out.write(buses.data)
        else:
            self.response.out.write('Couldn\'t find data. Sorry!')
コード例 #5
0
    def get(self):
        # Fetch buses data from a minute ago
        buses = None
        minute_ago = utils.roundTime(datetime.datetime.now() -
                                     datetime.timedelta(seconds=60),
                                     roundTo=1)
        retries = 0
        while not buses and retries < 10:
            buses = Buses.gql('WHERE time_stamp=:1', minute_ago).get()
            minute_ago += datetime.timedelta(seconds=1)
            retries += 1

        if buses:
            self.response.headers['Content-Type'] = 'application/json'
            self.response.out.write(buses.data)
        else:
            self.response.out.write('Couldn\'t find data. Sorry!')
コード例 #6
0
 def post(self):
     data = urllib.urlopen('http://bus.rice.edu/json/buses.php').read()
     now_rounded = utils.roundTime(datetime.datetime.now(), roundTo=1)
     Buses(time_stamp=now_rounded, data=data).put()
コード例 #7
0
 def post(self):
     data = urllib.urlopen('http://bus.rice.edu/json/buses.php').read()
     now_rounded = utils.roundTime(datetime.datetime.now(), roundTo=1)
     Buses(time_stamp=now_rounded, data=data).put()