def test_specific_10000047_with_new_crsecsturl_field(self): xml_string = get_string("fixtures/large-test-file.xml") root = ET.fromstring(xml_string) accreditations = Accreditations(root) kisaims = KisAims(root) locations = Locations(root) xml_string = get_string( "fixtures/one_inst_one_course_with_crsecsturl.xml") root = ET.fromstring(xml_string) institution = get_first(root.iter("INSTITUTION")) raw_inst_data = xmltodict.parse( ET.tostring(institution))["INSTITUTION"] ukprn = raw_inst_data["UKPRN"] course = get_first(institution.findall("KISCOURSE")) raw_course_data = xmltodict.parse(ET.tostring(course))["KISCOURSE"] locids = get_locids(raw_course_data, ukprn) expected_course_doc = json.loads( get_string("fixtures/one_inst_one_course_with_crsecsturl.json")) course_doc = get_course_doc( accreditations, locations, locids, raw_inst_data, raw_course_data, kisaims, ) course_doc = remove_variable_elements(course_doc) self.assertEqual(expected_course_doc, course_doc)
def __init__(self, player_details, canvas): self.players = [ Player(name, order, is_human) for (order, (name, is_human)) in enumerate(player_details) ] self.tiles = Tiles() self.locations = Locations(self) self.active_tile = None self.active_target = None self.mode = GameMode.SELECTING_TILE self.canvas = canvas self.source = [] self.target = [] # TODO: Move fonts into Settings or separate fonts module? self.small_floor_tile_scores_font = pygame.font.SysFont( 'Arial', Settings.floor_tile_scores_font_size) self.large_floor_tile_scores_font = pygame.font.SysFont( 'Arial', int(Settings.floor_tile_scores_font_size * Settings.player_area_multiplier)) self.button_font = self.large_floor_tile_scores_font # TODO: Move this in with the ButtonLocation? x, y = Settings.player_area_location multiplier = Settings.player_area_multiplier x += Settings.pattern_area_width * multiplier x += 2 * Settings.tile_width * multiplier width = 3 * Settings.tile_width * multiplier y += (Settings.area_height - Settings.tile_height * 1.9) * multiplier height = Settings.tile_height * multiplier self.locations.all.append( ButtonLocation(self, x, y, width, height, 'Continue', 'confirm'))
def delete_location(): if request.method == 'POST': address = request.form['location-address'] location_instance = Locations() location_instance.delete_location(address) return redirect('/locations') else: return render_template('delete_location.html')
def add_new_location(): if request.method == 'POST': address = request.form['location-address'] type = request.form['location-type'] hours = request.form['location-hours'] manager = request.form['location-manager'] location_instance = Locations() location_instance.add_location(address, type, hours, manager) return redirect('/locations') else: return render_template('add_new_location.html')
def create_course_docs(xml_string): """Parse HESA XML passed in and create JSON course docs in Cosmos DB.""" # TODO Investigate writing docs to CosmosDB in bulk to speed things up. cosmosdb_client = utils.get_cosmos_client() logging.info( "adding ukrlp data into memory ahead of building course documents" ) enricher = UkRlpCourseEnricher() logging.info( "adding subject data into memory ahead of building course documents" ) subject_enricher = SubjectCourseEnricher() collection_link = utils.get_collection_link( "AzureCosmosDbDatabaseId", "AzureCosmosDbCoursesCollectionId" ) # Import the XML dataset root = ET.fromstring(xml_string) # Import accreditations, common, kisaims and location nodes accreditations = Accreditations(root) kisaims = KisAims(root) locations = Locations(root) course_count = 0 for institution in root.iter("INSTITUTION"): raw_inst_data = xmltodict.parse(ET.tostring(institution))[ "INSTITUTION" ] ukprn = raw_inst_data["UKPRN"] for course in institution.findall("KISCOURSE"): raw_course_data = xmltodict.parse(ET.tostring(course))["KISCOURSE"] locids = get_locids(raw_course_data, ukprn) course_doc = get_course_doc( accreditations, locations, locids, raw_inst_data, raw_course_data, kisaims, ) enricher.enrich_course(course_doc) subject_enricher.enrich_course(course_doc) cosmosdb_client.CreateItem(collection_link, course_doc) course_count += 1 logging.info(f"Processed {course_count} courses")
def test_with_large_file(self): xml_string = get_string("fixtures/large-test-file.xml") root = ET.fromstring(xml_string) accreditations = Accreditations(root) kisaims = KisAims(root) locations = Locations(root) for institution in root.iter("INSTITUTION"): raw_inst_data = xmltodict.parse( ET.tostring(institution))["INSTITUTION"] ukprn = raw_inst_data["UKPRN"] for course in institution.findall("KISCOURSE"): raw_course_data = xmltodict.parse( ET.tostring(course))["KISCOURSE"] locids = get_locids(raw_course_data, ukprn) course_doc = get_course_doc( accreditations, locations, locids, raw_inst_data, raw_course_data, kisaims, ) self.assertTrue("institution_id" in course_doc)
def __init__(self, management_cert_path, subscription_id): from hostedservices import HostedServices, ServiceConfiguration from storageaccounts import StorageAccounts from locations import Locations self.service_api = HostedServices(management_cert_path, subscription_id) self.ServiceConfiguration = ServiceConfiguration self.storage_api = StorageAccounts(management_cert_path, subscription_id) self.location_api = Locations(management_cert_path, subscription_id) self._sme = ServiceManagementEndpoint(management_cert_path, subscription_id) self.WASMError = WASMError self.get_operation_status = self._sme.get_operation_status self.request_done = self._sme.request_done self.wait_for_request = self._sme.wait_for_request for op in self.service_api.get_wasm_ops(): setattr(self, op.__name__, op) for op in self.storage_api.get_wasm_ops(): setattr(self, op.__name__, op) for op in self.location_api.get_wasm_ops(): setattr(self, op.__name__, op)
def __init__(self, management_cert_path, subscription_id, management_key_path=None): """Initialise the various API interfaces. Note that management_key_path is not required (except for Python 2.5), as the key can be included in the certificate chain file. The OpenSSL command line can create an appropriate PEM file like so: openssl pkcs12 -in azure.pfx -out azure.pem -nodes """ from hostedservices import HostedServices, ServiceConfiguration from storageaccounts import StorageAccounts from locations import Locations self.service_api = HostedServices(management_cert_path, subscription_id, management_key_path) self.ServiceConfiguration = ServiceConfiguration self.storage_api = StorageAccounts(management_cert_path, subscription_id, management_key_path) self.location_api = Locations(management_cert_path, subscription_id, management_key_path) self._sme = ServiceManagementEndpoint(management_cert_path, subscription_id, management_key_path) self.WASMError = WASMError self.get_operation_status = self._sme.get_operation_status self.request_done = self._sme.request_done self.wait_for_request = self._sme.wait_for_request for op in self.service_api.get_wasm_ops(): setattr(self, op.__name__, op) for op in self.storage_api.get_wasm_ops(): setattr(self, op.__name__, op) for op in self.location_api.get_wasm_ops(): setattr(self, op.__name__, op)
from flask import Flask, render_template, request, redirect, url_for from locations import Locations from forms import AddLocationForm app = Flask(__name__) app.config['SECRET_KEY'] = 'SECRET_PROJECT' visit = Locations() categories = {"recommended": "Recommended", "tovisit": "Places To Go", "visited": "Visited!!!", } UP_ACTION = "\u2197" DEL_ACTION = "X" @app.route("/<category>", methods=["GET", "POST"]) def locations(category): locations = visit.get_list_by_category(category) ## Check the request for form data and process if request.method == "POST": [(name, action)] = request.form.items() if action == UP_ACTION: visit.moveup(name) elif action == DEL_ACTION: visit.delete(name) ## Return the main template with variables return render_template("locations.html", category=category, categories=categories, locations=locations, add_location=AddLocationForm())
def locations(self): # cached list of data center locations for deployments if not self._locations: self._locations = list(Locations(self.cert, self.sub_id, self.key).list_locations()) return self._locations
def secondsToMin(time_seconds): #show 2 decimal places print("{:.2f}".format(time_seconds / 60) + " minutes") # look for end key in the computed-short graph def searchShortest(key, computed_map): if key in computed_map: return computed_map[key] mapData = process_csv("distances.csv") hsuMap = Graph() location = Locations() for i in location._locations: hsuMap.add_vertex(i) for items in mapData: # change last element in list to a float (for adding purposes) items[2] = float(items[2]) # each element in list becomes an argument for paramter hsuMap.connect_vertex(*items) print("** HSU Transit Time Calculator **") print("TIER 1") start = input("Enter starting location: ")
app.add_route("/api/v1/users/{userId}/permissionvalidation", ValidateLocationPermissions(db)) app.add_route("/api/v1/users/{userId}/mqttauth", MqttUserToken()) app.add_route("/api/v1/users/{userId}/locations", UserLocations(db, mqttclient)) app.add_route("/api/v1/users/{userId}/weather", Weather()) app.add_route("/api/v1/users/{userId}/sunschedule", SunSchedule()) app.add_route("/api/v1/users/{userId}/sensors", UserSensors(db)) app.add_route("/api/v1/users/{userId}/permissions/{shareId}", LocationPermission(db)) app.add_route("/api/v1/users/{userId}/bitcoin/current", BitcoinCurrent()) app.add_route("/api/v1/users/{userId}/bitcoin/historical", BitcoinHistorical()) app.add_route("/api/v1/users/{userId}/bitcoin", BitcoinPrice()) app.add_route("/api/v1/users/{userId}/firebasetoken", FirebaseUserToken(db)) app.add_route("/api/v1/users/{userId}/locations/{locationId}", Locations(db, mqttclient)) app.add_route( "/api/v1/users/{userId}/locations/{locationId}/devices", LocationDevices(db, mqttclient), ) app.add_route("/api/v1/users/{userId}/locations/{locationId}/ordersensors", OrderSensors(db)) app.add_route( "/api/v1/users/{userId}/locations/{locationId}/permissions", LocationsPermissions(db), ) app.add_route("/api/v1/users/{userId}/locations/{locationId}/rooms", LocationRooms(db)) app.add_route("/api/v1/users/{userId}/locations/{locationId}/rooms/{roomId}", LocationRoom(db)) app.add_route(
def setUp(self): xml_string = get_string("fixtures/course_with_locations.xml") root = ET.fromstring(xml_string) self.locations = Locations(root)
def locations(): location_instance = Locations() data = location_instance.get_locations() return render_template('locations.html', locations=data)
from locations import Locations from werkzeug.utils import secure_filename from basic_authentication import ( get_password_hash, verify_password, generate_token, verify_token, require_login ) app = Flask(__name__) location_titles = ['Sofia', 'Bansko', 'Shumen', ] Locations.drop() for title in location_titles: location = Locations(*(None, title)) location.save() @app.route("/index.html") @require_login def homepage(user): return render_template("index.html", user=user) @app.route("/login.html", methods=["GET", "POST"]) def login(): if request.method == "GET": return render_template("login.html") if request.method == "POST":