Example #1
0
 def t010_Sector(self):
     """Settori di applicazione"""
     L.i("SectorTestData load start")
     c = 0
     for el in TestData.listSectors:
         L.i("    Dataloaded #{0}".format(c))
         c += 1
         sector = Sector(title=el['title'], description=el['description'])
         self.sectors.append(sector)
         sector.put()
     L.i("SectorTestData load ended")
     return True
Example #2
0
def loadsectors():
    for i in range(1, 5):
        new_sector = Sector()
        db.session.add(new_sector)
    for i in range(1, 5):
        with open('Sector ' + str(i)) as sector:
            for line in sector.readlines():
                loclat, loclong = line.split(', ')
                new_parking = Parking()
                new_parking.sectorid = i
                new_parking.loclat = loclat
                new_parking.loclong = loclong
                new_parking.available = 2
                new_parking.disability = random.choice(range(0, 2))
                db.session.add(new_parking)
    db.session.commit()
    flash("successfully added parking spots")
    return redirect(url_for('login'))
Example #3
0
def generate_sectors(session, sectors_data):
    """ Get or create sectors using static config data. """
    print(sectors_data)
    for sector_name, sector_data in sectors_data.items():
        try:
            sector = get_sector(session, sector_name=sector_name)
        except NoResultFound:
            print(f"{sector_name} not in db, creating it")
            sector = Sector(name=sector_name)
            session.add(sector)

        cities_data = sector_data.pop("cities")
        for city_name, city_data in cities_data.items():
            try:
                get_city(session, city_name=city_name)
            except NoResultFound:
                print(f"{city_name} not found, creating it")
                coordinate = Coordinate.load(city_data["location"])
                location = get_location(session, sector, coordinate)
                create_city(session, city_name, location)

        load_map(session, f"data/maps/{sector.name}.map", sector)
Example #4
0
def create_sectors():
    if Sector.query.first() is None:
        for i in range(1, 11):
            sector = Sector(name=str(i))
            db.session.add(sector)
        db.session.commit()