added workaround for python3 (#369)

pull/406/head
Igor Chubin 5 years ago
parent 89ae801177
commit e5ab61dea3

@ -168,7 +168,11 @@ def load_aliases(aliases_filename):
aliases_db = {} aliases_db = {}
with open(aliases_filename, 'r') as f_aliases: with open(aliases_filename, 'r') as f_aliases:
for line in f_aliases.readlines(): for line in f_aliases.readlines():
from_, to_ = line.decode('utf-8').split(':', 1) try:
from_, to_ = line.decode('utf-8').split(':', 1)
except AttributeError:
from_, to_ = line.split(':', 1)
aliases_db[location_normalize(from_)] = location_normalize(to_) aliases_db[location_normalize(from_)] = location_normalize(to_)
return aliases_db return aliases_db

@ -26,14 +26,20 @@ import re
import math import math
import json import json
import datetime import datetime
import StringIO try:
import StringIO
except:
import io as StringIO
import requests import requests
import diagram import diagram
import pyjq import pyjq
import pytz import pytz
import numpy as np import numpy as np
from astral import Astral, Location try:
from astral import Astral, Location
except ImportError:
pass
from scipy.interpolate import interp1d from scipy.interpolate import interp1d
from babel.dates import format_datetime from babel.dates import format_datetime

@ -17,7 +17,10 @@ import sys
import re import re
import datetime import datetime
import json import json
from astral import Astral, Location try:
from astral import Astral, Location
except ImportError:
pass
from constants import WWO_CODE, WEATHER_SYMBOL, WIND_DIRECTION from constants import WWO_CODE, WEATHER_SYMBOL, WIND_DIRECTION
from weather_data import get_weather_data from weather_data import get_weather_data
import spark import spark

Loading…
Cancel
Save