feat: fixed a bug

This commit is contained in:
RTAkland
2021-12-18 19:44:12 +08:00
parent b6577f1926
commit 5db51f09fc
4 changed files with 28 additions and 29 deletions

View File

@@ -10,29 +10,20 @@
启用等级: DEV
"""
from core.read_config import read_config
import requests
import json
import sys
from ruamel.yaml import YAML
def real_time_air_quality():
yaml = YAML()
with open(sys.path[1] + '/config.yml', 'r', encoding='utf-8') as f:
config = yaml.load(f.read())
settings = read_config()
location = settings[1]['location']
key = settings[1]['key']
lang = settings[1]['lang']
unit = settings[1]['unit']
mode = config['request-settings']['mode']
key = config['request-settings']['key']
location = config['request-settings']['location']
unit = config['request-settings']['unit']
lang = config['request-settings']['lang']
if mode != 'dev':
return False, print('Only Dev-mode')
session = requests.Session()
session.trust_env = False
r = session.get(f'https://devapi.qweather.com/v7/air/now?'
f'location={location}config.yml&key={key}&lang={lang}&unit={unit}&gzip=y')
r = requests.get(f'https://devapi.qweather.com/v7/air/now?'
f'location={location}&key={key}&lang={lang}&unit={unit}&gzip=y')
_data = json.loads(r.text)
return _data['code'], _data['now']
return _data['now']