|
11 | 11 | import pandas as pd |
12 | 12 | import logging |
13 | 13 | import sys |
14 | | -import os |
15 | | - |
16 | | -try: |
17 | | - import requests as rq |
18 | | -except ImportError: |
19 | | - rq = None |
| 14 | +import requests |
20 | 15 |
|
21 | 16 |
|
22 | 17 | class WindTurbine(object): |
@@ -326,27 +321,22 @@ def load_turbine_data_from_oedb(): |
326 | 321 | 'turbine_type', nominal power ('installed_capacity_kw'), ' |
327 | 322 |
|
328 | 323 | """ |
329 | | - if rq: |
330 | | - # url of Open Energy Platform that contains the oedb |
331 | | - oep_url = 'http://oep.iks.cs.ovgu.de/' |
332 | | - # location of data |
333 | | - schema = 'model_draft' |
334 | | - table = 'openfred_windpower_powercurve' |
335 | | - # load data |
336 | | - result = rq.get( |
337 | | - oep_url + '/api/v0/schema/{}/tables/{}/rows/?'.format( |
338 | | - schema, table), ) |
339 | | - if result.status_code == 200: |
340 | | - logging.info("Data base connection successful.") |
341 | | - else: |
342 | | - raise ConnectionError("Data base connection not successful. " + |
343 | | - "Error: ".format(result.status_code)) |
344 | | - # extract data |
345 | | - turbine_data = pd.DataFrame(result.json()) |
| 324 | + # url of Open Energy Platform that contains the oedb |
| 325 | + oep_url = 'http://oep.iks.cs.ovgu.de/' |
| 326 | + # location of data |
| 327 | + schema = 'model_draft' |
| 328 | + table = 'openfred_windpower_powercurve' |
| 329 | + # load data |
| 330 | + result = requests.get( |
| 331 | + oep_url + '/api/v0/schema/{}/tables/{}/rows/?'.format( |
| 332 | + schema, table), ) |
| 333 | + if result.status_code == 200: |
| 334 | + logging.info("Data base connection successful.") |
346 | 335 | else: |
347 | | - raise ImportError('If you want to load turbine data from the oedb' + |
348 | | - 'you have to install the requests package.' + |
349 | | - 'see https://pypi.org/project/requests/') |
| 336 | + raise ConnectionError("Data base connection not successful. " + |
| 337 | + "Error: ".format(result.status_code)) |
| 338 | + # extract data |
| 339 | + turbine_data = pd.DataFrame(result.json()) |
350 | 340 | return turbine_data |
351 | 341 |
|
352 | 342 |
|
|
0 commit comments