Esempio n. 1
0
            )
            if not regular:
                trip.date = today
                trip.interval_min = random.randint(0, 6)
                trip.interval_max = random.randint(0, 6)
            else:
                trip.dows = [
                    dow for dow in range(0, 7) if random.random() < 0.5
                ]
                if not trip.dows:
                    trip.dows = [1]
            if trip_type != Trip.OFFER:
                demand = TripDemand(radius=random.choice(DEMAND_RADIUS_CHOICE))
                demand.save()
                trip.demand = demand
            if trip_type != Trip.DEMAND:
                offer = TripOffer(radius=random.choice(OFFER_RADIUS_CHOICE),
                                  route=MultiLineString(
                                      [GEOSGeometry(json.get('geometry')[0])]))
                offer.save()
                trip.offer = offer
            trip.save()
        except Exception, e:
            print "!!!!!!!!!!!!!!!!!!!!!", e
        #if index > 10:
        #    break
finally:
    route_file.close()

print "OK\n"
Esempio n. 2
0
            if not regular:
                trip.date = today
                trip.interval_min = random.randint(0, 6)
                trip.interval_max = random.randint(0, 6)
            else:
                trip.dows = [dow for dow in range(0, 7) if random.random() < 0.5]
                if not trip.dows:
                    trip.dows = [1]
            if trip_type != Trip.OFFER:
                demand = TripDemand(
                    radius=random.choice(DEMAND_RADIUS_CHOICE)
                )
                demand.save()
                trip.demand = demand
            if trip_type != Trip.DEMAND:
                offer = TripOffer(
                    radius=random.choice(OFFER_RADIUS_CHOICE),
                    route=MultiLineString([GEOSGeometry(json.get('geometry')[0])])
                )
                offer.save()
                trip.offer = offer
            trip.save()
        except Exception, e:
            print "!!!!!!!!!!!!!!!!!!!!!", e
        #if index > 10:
        #    break
finally:
    route_file.close()

print "OK\n"