Skip to content

Commit 1b2a18a

Browse files
committed
Change import of requests
requests is in the requirements
1 parent c9a44ef commit 1b2a18a

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

windpowerlib/wind_turbine.py

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@
1111
import pandas as pd
1212
import logging
1313
import sys
14-
import os
15-
16-
try:
17-
import requests as rq
18-
except ImportError:
19-
rq = None
14+
import requests
2015

2116

2217
class WindTurbine(object):
@@ -326,27 +321,22 @@ def load_turbine_data_from_oedb():
326321
'turbine_type', nominal power ('installed_capacity_kw'), '
327322
328323
"""
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.")
346335
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())
350340
return turbine_data
351341

352342

0 commit comments

Comments
 (0)