added workaround for python3 (#369)

This commit is contained in:
Igor Chubin 2020-02-12 21:44:56 +01:00
parent 89ae801177
commit e5ab61dea3
3 changed files with 17 additions and 4 deletions

View file

@ -168,7 +168,11 @@ def load_aliases(aliases_filename):
aliases_db = {}
with open(aliases_filename, 'r') as f_aliases:
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_)
return aliases_db

View file

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

View file

@ -17,7 +17,10 @@ import sys
import re
import datetime
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 weather_data import get_weather_data
import spark