107 Commits

Author SHA1 Message Date
RTAkland
6db23a3e28 feat: update README.md 2022-01-14 18:41:46 +08:00
RTAkland
5bed020e65 feat: remove something useless 2022-01-14 18:31:25 +08:00
RTAkland
506bb81f44 feat: add GUI 2022-01-14 18:30:34 +08:00
RTAkland
3a0902509a feat: add gui 2022-01-14 18:30:11 +08:00
RTAkland
704158bc64 feat: update gui insert 2022-01-14 18:22:24 +08:00
RTAkland
f6f97a0785 feat: update gui insert 2022-01-14 18:22:06 +08:00
RTAkland
b41be502f2 feat: fix bug 2022-01-01 15:34:45 +08:00
RTAkland
cc8bed1890 feat: update README.md 2022-01-01 15:33:20 +08:00
RTAkland
9174e11ecd feat: fix bug 2022-01-01 15:32:38 +08:00
RTAkland
31ea638770 feat: update version 2021-12-26 14:13:52 +08:00
RTAkland
11244734fd feat: update version 2021-12-26 14:13:31 +08:00
RTAkland
9cbd3b5063 feat: fix a bug 2021-12-26 14:13:09 +08:00
RTAkland
3622b094fd feat: add 404 page 2021-12-26 14:12:40 +08:00
RTAkland
4c73240fe9 feat: update language files 2021-12-26 14:12:24 +08:00
RTAkland
451aed59d0 feat: del 2021-12-26 10:34:10 +08:00
RTAkland
0b41c9c1f5 feat: update README.md 2021-12-26 10:00:07 +08:00
RTAkland
b205533ae7 feat: del 2021-12-26 09:39:03 +08:00
RTAkland
b493c06387 feat: update .gitignore 2021-12-26 09:36:33 +08:00
RTAkland
936dd14a87 feat: updated 2021-12-25 12:18:22 +08:00
RTAkland
21a7f9140d feat: updated 2021-12-25 12:15:13 +08:00
RTAkland
23f44c3f78 feat: fixed a bug 2021-12-25 12:14:53 +08:00
RTAkland
9477c33952 feat: update 2021-12-25 12:09:30 +08:00
RTAkland
7fdd0d56a1 feat: fixed a bug 2021-12-25 12:08:52 +08:00
RTAkland
2117771518 feat: update README.md 2021-12-24 19:52:11 +08:00
RTAkland
ea4d04a71c feat: add hitokoto 2021-12-24 19:51:49 +08:00
RTAkland
235e252bab feat: update README.md 2021-12-24 18:58:26 +08:00
RTAkland
278913b2c3 update language files 2021-12-24 18:57:25 +08:00
RTAkland
3cc8afa1f4 feat: optimized output information 2021-12-24 18:56:16 +08:00
RTAkland
3034346c73 feat: removed some text 2021-12-24 18:55:11 +08:00
RTAkland
7b4a0dd033 feat: update 2021-12-23 21:09:19 +08:00
RTAkland
c9ec788cd3 feat: update version 2021-12-21 21:37:53 +08:00
RTAkland
30240033cf feat: update language files 2021-12-21 21:37:33 +08:00
RTAkland
f986a037a8 feat: added SSL 2021-12-21 21:37:13 +08:00
RTAkland
1b96caf719 feat: fixed a bug 2021-12-21 21:36:29 +08:00
RTAkland
df1d5a13b4 feat: added a small info 2021-12-21 20:59:05 +08:00
RTAkland
2c111536c7 feat: update version 2021-12-21 20:57:56 +08:00
RTAkland
1bedb05ac1 feat: rename webserver -> webservice 2021-12-21 20:56:14 +08:00
RTAkland
fd10791baa feat: update language files 2021-12-21 20:55:39 +08:00
RTAkland
98b4b9305b feat: rename file 2021-12-21 20:55:09 +08:00
RTAkland
62d08096b3 feat: added get_host_ip.py 2021-12-21 20:54:38 +08:00
RTAkland
c32efe4b44 feat: added webservice host ip info 2021-12-21 20:54:02 +08:00
RTAkland
9e3f866fb8 feat: fixed a small bug 2021-12-21 20:53:35 +08:00
RTAkland
e8b1a910ae feat: fixed a bug 2021-12-20 22:03:49 +08:00
RTAkland
dd1dc2e3e6 feat: update README.md 2021-12-20 21:58:03 +08:00
RTAkland
bac4565289 feat: update requirements.txt -> space 2021-12-20 21:38:50 +08:00
RTAkland
25f755fd27 feat: update requirements.txt -> openpyxl 2021-12-20 21:25:40 +08:00
RTAkland
09ebfc1a76 feat: update config.yml 2021-12-20 21:25:23 +08:00
RTAkland
ee9e4a4c0f feat: update language files 2021-12-20 21:24:55 +08:00
RTAkland
c2bc49b0d4 feat: added an error collector 2021-12-20 21:24:26 +08:00
RTAkland
fe8d850422 feat: added some comments 2021-12-20 21:23:57 +08:00
RTAkland
51023efc76 feat: fixed a bug 2021-12-20 21:23:22 +08:00
RTAkland
0c6a267967 feat: added some comments 2021-12-20 21:23:10 +08:00
RTAkland
28e1319ee3 feat: fixed many bugs 2021-12-20 21:22:42 +08:00
RTAkland
c8b2662d02 feat: update README.md 2021-12-18 21:58:56 +08:00
RTAkland
c69dedba45 feat: update requirements.txt 2021-12-18 21:54:55 +08:00
RTAkland
346b8c6289 feat: update .gitignore 2021-12-18 21:54:29 +08:00
RTAkland
35ff3d6e81 feat: removed test file 2021-12-18 21:53:57 +08:00
RTAkland
214ec5bf10 feat: update README.md 2021-12-18 21:53:34 +08:00
RTAkland
89c5ff2597 feat: update webserver 2021-12-18 21:41:59 +08:00
RTAkland
3b14691aea feat: change multiprocessing to concurrent 2021-12-18 21:41:24 +08:00
RTAkland
ae2cfce166 feat: change multiprocessing to concurrent 2021-12-18 21:40:48 +08:00
RTAkland
59f6561159 feat: removed something 2021-12-18 21:39:48 +08:00
RTAkland
95254ab80c feat: removed something 2021-12-18 21:39:14 +08:00
RTAkland
575de9463d feat: use high quality pictures 2021-12-18 21:38:29 +08:00
RTAkland
5db51f09fc feat: fixed a bug 2021-12-18 19:44:12 +08:00
RTAkland
b6577f1926 feat: update README.md 2021-12-18 17:16:48 +08:00
RTAkland
4ca0b9afe9 feat: added log level 2021-12-18 17:12:57 +08:00
RTAkland
3dc41d32c9 feat: fixed a bug 2021-12-18 17:12:13 +08:00
RTAkland
c8a6f4fbfe feat: added log level 2021-12-18 17:10:33 +08:00
RTAkland
33bf556ed2 feat: added a log info 2021-12-18 17:03:36 +08:00
RTAkland
76e448ffa5 feat: update README.md 2021-12-18 10:23:39 +08:00
RTAkland
1899c24d62 feat: update README.md 2021-12-18 08:42:28 +08:00
RTAkland
2a6a91f2e6 feat: added log info 2021-12-18 08:14:15 +08:00
RTAkland
03ab659d05 feat: fixed a bug 2021-12-17 17:40:08 +08:00
RTAkland
029da172c3 feat: added a logger 2021-12-17 17:14:14 +08:00
RTAkland
b1bd4ab1db feat: update README.md 2021-12-16 22:44:07 +08:00
RTAkland
ce5dc74071 feat: update README.md 2021-12-16 22:43:37 +08:00
RTAkland
fd376123b5 del 2021-12-16 22:39:02 +08:00
RTAkland
66fc365ca5 feat: updtae README.md 2021-12-16 22:34:03 +08:00
RTAkland
0b4d36cbea feat: update language files 2021-12-16 22:27:53 +08:00
RTAkland
9d2f1e192c feat: main 2021-12-16 22:25:21 +08:00
RTAkland
afaf92df35 feat: sendmail.py 2021-12-16 22:23:48 +08:00
RTAkland
b97e52f7a1 feat: start 2021-12-16 22:22:45 +08:00
RTAkland
a820b4ae33 feat: fixed a bug 2021-12-16 22:22:27 +08:00
RTAkland
c31e0c7248 feat: fixed a bug 2021-12-16 21:58:25 +08:00
RTAkland
8f41fb5220 feat: fixed a bug 2021-12-16 21:57:45 +08:00
RTAkland
d28dde9ff3 feat: sendmail.py 2021-12-16 21:50:35 +08:00
RTAkland
0d6e6401e5 feat: fixed a bug 2021-12-16 21:10:18 +08:00
RTAkland
fba2694df3 feat: fixed a bug 2021-12-16 21:01:22 +08:00
RTAkland
f7973fa3ee feat: fixed a bug 2021-12-16 21:00:23 +08:00
RTAkland
56e3ea9afa feat: fixed a bug 2021-12-16 21:00:16 +08:00
RTAkland
a16d3a89d4 feat: fixed a bug 2021-12-16 21:00:12 +08:00
RTAkland
5ad45b5f1c feat: fixed a bug 2021-12-16 21:00:04 +08:00
RTAkland
9767bc9ef1 feat: qweather.py 2021-12-15 22:08:57 +08:00
RTAkland
905709808b feat: update language files 2021-12-15 22:00:05 +08:00
RTAkland
c076b521c6 feat: __init__.py 2021-12-15 21:59:00 +08:00
RTAkland
07b8ee96f2 feat: settings.py 2021-12-15 21:58:07 +08:00
RTAkland
a83f6cb4ae feat: read_config.py 2021-12-15 21:57:52 +08:00
RTAkland
312789e4cc read_excel.py 2021-12-15 21:47:55 +08:00
RTAkland
1db1d0f545 feat: language.py 2021-12-15 21:47:44 +08:00
RTAkland
ce30d6ef75 feat: __init__.py 2021-12-15 21:46:09 +08:00
RTAkland
cfc75d5c13 feat: git weather information 2021-12-15 21:27:16 +08:00
RTAkland
e0dcf8af56 feat: check settings 2021-12-15 21:26:36 +08:00
RTAkland
3c019ad98c feat: Logger 2021-12-15 21:21:39 +08:00
RTAkland
99bc9481da feat: update README.md 2021-12-15 20:40:11 +08:00
RTAkland
bb50346e60 Delete SECURITY.md 2021-12-14 21:52:10 +08:00
RTAkland
7b68df55b2 Create SECURITY.md 2021-12-14 21:51:37 +08:00
190 changed files with 1597 additions and 831 deletions

3
.gitignore vendored
View File

@@ -1,7 +1,6 @@
test.py
*.yml
!config.yml
*.token
*.zip
*.log
*.log.*
**/__pycache__

View File

@@ -2,742 +2,43 @@
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/10/23
# @Create Time: 2021/12/16
# @File Name: QWeather.py
import os
import sys
import json
import time
import pandas
import smtplib
import getpass
import requests
import argparse
import multiprocessing
import logging.handlers
from ruamel.yaml import YAML
from email.header import Header
from email.mime.text import MIMEText
from colorlog import ColoredFormatter
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
import threading
from core import qweather
from tkinter import messagebox
from lib.buildGUIClass import tk
from lib.buildGUIClass import root
from lib.buildGUIClass import Features
class SendWeatherMail:
def __init__(self):
with open(CONFIG_NAME, 'r', encoding='utf-8') as config_f:
self.config = YAML().load(config_f)
self.location = self.config['request-settings']['location'] # 城市ID
self.key = self.config['request-settings']['key'] # API密钥
self.unit = self.config['request-settings']['unit'] # 度量单位
self.lang = self.config['request-settings']['lang'] # 语言
self.mode = self.config['request-settings']['mode'] # 发送模式 --仅作判断标识
self.receiver = self.config['request-settings']['receiver'] # 接收者邮箱 --> 列表 [无论有几个人都必须是列表]
self.sender = self.config['mail-settings']['sender'] # 发送者邮箱
self.password = self.config['mail-settings']['password'] # 服务器登录密码
self.server = self.config['mail-settings']['server'] # 邮箱服务器
self.port = self.config['mail-settings']['port'] # 邮箱端口号
self.enableSSL = self.config['client-settings'] # 是否使用SSL连接到邮箱服务器
self.city_name = self.config['only-view-settings']['city-name'] # 城市名称仅作邮件内容
self.dev_url = 'https://devapi.qweather.com/v7/weather/7d' # 开发版本天气信息url
self.free_url = 'https://devapi.qweather.com/v7/weather/3d' # 免费版本天气信息url
self.warning_url = 'https://devapi.qweather.com/v7/warning/now' # 自然灾害预警信息url
self.headers = {'Accept-Encoding': 'gzip, deflate'} # 请求头
self.params = {'location': self.location,
'key': self.key,
'unit': self.unit,
'lang': self.lang} # GET方式请求参数
self.message = MIMEMultipart('related')
self.message['From'] = Header('QWeather') # 发件人名称
self.message['To'] = Header('All allowed User') # 收件人显示名称
self.msg_content = MIMEMultipart('alternative') # 文字目录
if self.enableSSL:
self.smtp = smtplib.SMTP_SSL(self.server, self.port) # 登录服务器 使用SSL连接
else:
self.smtp = smtplib.SMTP(self.server, self.port) # 登录邮箱服务器 不使用SSL连接
def dev_mode(self):
"""
开发版本发送邮件
[全七天] | date: 日期 (1-7)
[全七天] | day_weather: 白天天气 (1-7)
[全七天] | night_weather: 晚上天气 (1-7)
[全七天] | temperature_max: 最高气温 (1-7)
[全七天] | temperature_min: 最低气温 (1-7)
[全七天] | icon_list: 白天和晚上的天气图标 (1-14)
[第一天] | sunrise: 日出时间 (1)
[第一天] | sunset: 日落时间 (1)
[第一天] | humidity: 空气湿度(相对) (1)
[第一天] | wind_speed: 风速 (1)
[第一天] | wind_scale: 风级 (1)
[第一天] | wind_dir: 风向 (1)
[第一天] | ultraviolet_rays: 紫外线强度指数 (1)
[第一天] | cloud: 云量(相对) (1)
[第一天] | pressure: 气压 (1)
[第一天] | vis: 能见度 (1)
:return: None
"""
r_day = session.get(self.dev_url, headers=self.headers, params=self.params)
weather_day_text = r_day.json() # 使用json加载数据
logger.info(f'{language["request_result_weather"]}:{r_day}')
# 1-7天数据
day_1 = weather_day_text['daily'][0]
day_2 = weather_day_text['daily'][1]
day_3 = weather_day_text['daily'][2]
day_4 = weather_day_text['daily'][3]
day_5 = weather_day_text['daily'][4]
day_6 = weather_day_text['daily'][5]
day_7 = weather_day_text['daily'][6]
date = [day_1['fxDate'][5:], day_2['fxDate'][5:], day_3['fxDate'][5:], day_4['fxDate'][5:], day_5['fxDate'][5:],
day_6['fxDate'][5:],
day_7['fxDate'][5:]]
day_weather = [day_1['textDay'], day_2['textDay'], day_3['textDay'], day_4['textDay'], day_5['textDay'],
day_6['textDay'], day_7['textDay']]
night_weather = [day_1['textNight'], day_2['textNight'], day_3['textNight'], day_4['textNight'],
day_5['textNight'], day_6['textNight'], day_7['textNight']]
temperature_max = [day_1['tempMax'], day_2['tempMax'], day_3['tempMax'], day_4['tempMax'], day_5['tempMax'],
day_6['tempMax'], day_7['tempMax']]
temperature_min = [day_1['tempMin'], day_2['tempMin'], day_3['tempMin'], day_4['tempMin'], day_5['tempMin'],
day_6['tempMin'], day_7['tempMin']]
icon_list = [day_1['iconDay'], day_2['iconDay'], day_3['iconDay'], day_4['iconDay'], day_5['iconDay'],
day_6['iconDay'], day_7['iconDay'], day_1['iconNight'], day_2['iconNight'], day_3['iconNight'],
day_4['iconNight'], day_5['iconNight'], day_6['iconNight'], day_7['iconNight']]
sunset = day_1['sunset']
sunrise = day_1['sunrise']
humidity = day_1['humidity']
wind_speed = day_1['windSpeedDay']
wind_scale = day_1['windScaleDay']
wind_dir = day_1['windDirDay']
ultraviolet_rays = day_1['uvIndex']
cloud = day_1['cloud']
pressure = day_1['pressure']
vis = day_1['vis']
# 邮件内容主体
mail_html = f"""
<p style="text-align: center">
<i>
<b>
{language['area']}:{self.city_name}
<br>
{language['sender']}:{self.sender}
</b>
</i>
</p>
<br />
<table style="border: 0; text-align: center; margin:0 auto">
<tr>
<th>|&nbsp;{language['date']}&nbsp;&nbsp;</th>
<th>|&nbsp;{language['weather']}&nbsp;&nbsp;</th>
<th>|&nbsp;{language['lowestTemp']}&nbsp;&nbsp;</th>
<th>|&nbsp;{language['highestTemp']}&nbsp;&nbsp;</th>
</tr>
<tr>
<!--日期 天气 最低 最高/Date Weather LowestTemp HighestTemp-->
<td>{language['today']}</td>
<td>{day_weather[0]}<img src="cid:img1" width="20" alt="">/{night_weather[0]}<img src="cid:img2"
width="20" alt=""></td> <td>{temperature_min[0]}℃</td>
<td>{temperature_max[0]}℃</td>
</tr>
<tr>
<td>{date[1]}</td>
<td>{day_weather[1]}<img src="cid:img3" width="20" alt="">/{night_weather[1]}<img src="cid:img4"
width="20" alt=""></td> <td>{temperature_min[1]}℃</td>
<td>{temperature_max[1]}℃</td>
</tr>
<tr>
<td>{date[2]}</td>
<td>{day_weather[2]}<img src="cid:img5" width="20" alt="">/{night_weather[2]}<img src="cid:img6"
width="20" alt=""></td> <td>{temperature_min[2]}℃</td>
<td>{temperature_max[2]}℃</td>
</tr>
<tr>
<td>{date[3]}</td>
<td>{day_weather[3]}<img src="cid:img7" width="20" alt="">/{night_weather[3]}<img src="cid:img8"
width="20" alt=""></td> <td>{temperature_min[3]}℃</td>
<td>{temperature_max[3]}℃</td>
</tr>
<tr>
<td>{date[4]}</td>
<td>{day_weather[4]}<img src="cid:img9" width="20" alt="">/{night_weather[4]}<img src="cid:img10"
width="20" alt=""></td> <td>{temperature_min[4]}℃</td>
<td>{temperature_max[4]}℃</td>
</tr>
<tr>
<td>{date[5]}</td>
<td>{day_weather[5]}<img src="cid:img11" width="20" alt="">/{night_weather[5]}<img src="cid:img12"
width="20" alt=""></td> <td>{temperature_min[5]}℃</td>
<td>{temperature_max[5]}℃</td>
</tr>
<tr>
<td>{date[6]}</td>
<td>{day_weather[6]}<img src="cid:img13" width="20" alt="">/{night_weather[6]}<img src="cid:img14"
width="20" alt=""></td> <td>{temperature_min[6]}℃</td>
<td>{temperature_max[6]}℃</td>
</tr>
</table>
<table style="border: 0;text-align: center; margin:0 auto">
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th>{language['wind_info']}</th>
<th>{language['humidity']}</th>
<th>{language['uv_info']}</th>
</tr>
<tr>
<td>{wind_speed}m/s&nbsp; {wind_scale}&nbsp; {wind_dir}&nbsp;</td>
<td>{humidity}%&nbsp;</td>
<td>{ultraviolet_rays}&nbsp;</td>
</tr>
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th>{language['vis']}</th>
<th>{language['pressure']}</th>
<th>{language['cloud']}</th>
</tr>
<tr>
<td>{vis}km&nbsp;</td>
<td>{pressure}hPa&nbsp;</td>
<td>{cloud}%&nbsp;</td>
</tr>
</table>
<table style="border: 0;text-align: center; margin:0 auto">
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<td><img src="cid:sunrise" alt="Sunrise" width="30"></td>
<td>&nbsp;</td>
<td><img src="cid:sunset" alt="Sunset" width="30"></td>
</tr>
<tr>
<td>&nbsp;{sunrise}&nbsp;</td>
<td>---------------</td>
<td>&nbsp;{sunset}&nbsp;</td>
</tr>
</table>
<div style="text-align: center;" id="About">
<br />
<br />
<br />
<i>
<b>
<a href="https://dev.qweather.com/" style="color: black" target="_blank">QWeather</a>
<a style="color: black">&nbsp;·&nbsp;</a>
<a href="https://github.com/MarkusJoe/QWeather" style="color: black" target="_blank">Github Repo</a>
</b>
</i>
</div>"""
self.message['Subject'] = language['subject_7'] # 邮件标题
self.message.attach(MIMEText(mail_html, 'html', 'utf-8'))
# 循环将图片attach到html里
image_count = 1
for image_resource in icon_list:
with open(f'./resource/icons/{image_resource}.png', 'rb') as fp:
MyImage = MIMEImage(fp.read())
MyImage.add_header('Content-ID', f'img{image_count}')
self.message.attach(MyImage)
image_count += 1
with open('./resource/basic-resources/sunrise.png', 'rb') as sr_f:
sunrise_img = MIMEImage(sr_f.read())
sunrise_img.add_header('Content-ID', 'sunrise')
self.message.attach(sunrise_img)
with open('./resource/basic-resources/sunset.png', 'rb') as ss_f:
sunset_img = MIMEImage(ss_f.read())
sunset_img.add_header('Content-ID', 'sunset')
self.message.attach(sunset_img)
try:
self.smtp.login(self.sender, self.password) # 登录
self.smtp.sendmail(self.sender, self.receiver, self.message.as_string()) # 发送
except smtplib.SMTPException as e:
logger.critical(f'{language["mail_error"]}:', e)
sys.exit(1)
def free_mode(self):
"""
免费版本发送邮件
:return:
"""
f_request = session.get(self.free_url, headers=self.headers, params=self.params)
f_weather = f_request.json()
logger.info(f'{language["request_result_weather"]}:{f_request}')
day_1 = f_weather['daily'][0]
day_2 = f_weather['daily'][1]
day_3 = f_weather['daily'][2]
date = [day_1['fxDate'][5:], day_2['fxDate'][5:], day_2['fxDate'][5:]]
day_weather = [day_1['textDay'], day_2['textDay'], day_2['textDay']]
night_weather = [day_1['textNight'], day_2['textNight'], day_2['textNight']]
temperature_max = [day_1['tempMax'], day_2['tempMax'], day_3['tempMax']]
temperature_min = [day_1['tempMin'], day_2['tempMin'], day_2['tempMin']]
icon_list = [day_1['iconDay'], day_1['iconDay'], day_3['iconDay'], day_1['iconNight'], day_2['iconNight'],
day_3['iconNight']]
sunset = day_1['sunset']
sunrise = day_1['sunrise']
humidity = day_1['humidity']
wind_speed = day_1['windSpeedDay']
wind_scale = day_1['windScaleDay']
wind_dir = day_1['windDirDay']
ultraviolet_rays = day_1['uvIndex']
cloud = day_1['cloud']
pressure = day_1['pressure']
vis = day_1['vis']
mail_html = f"""
<p style="text-align: center">
<i>
<b>
{language['area']}:{self.city_name}
<br>
{language['sender']}:{self.sender}
</b>
</i>
</p>
<br />
<table style="border: 0; text-align: center; margin:0 auto">
<tr>
<th>|&nbsp;{language['date']}&nbsp;&nbsp;</th>
<th>|&nbsp;{language['weather']}&nbsp;&nbsp;</th>
<th>|&nbsp;{language['lowestTemp']}&nbsp;&nbsp;</th>
<th>|&nbsp;{language['highestTemp']}&nbsp;&nbsp;</th>
</tr>
<tr>
<!--日期 天气 最低 最高/Date Weather LowestTemp HighestTemp-->
<td>{language['today']}</td>
<td>{day_weather[0]}<img src="cid:img1" width="20" alt="">/{night_weather[0]}<img src="cid:img2"
width="20" alt=""></td> <td>{temperature_min[0]}℃</td>
<td>{temperature_max[0]}℃</td>
</tr>
<tr>
<td>{date[1]}</td>
<td>{day_weather[1]}<img src="cid:img3" width="20" alt="">/{night_weather[1]}<img src="cid:img4"
width="20" alt=""></td> <td>{temperature_min[1]}℃</td>
<td>{temperature_max[1]}℃</td>
</tr>
<tr>
<td>{date[2]}</td>
<td>{day_weather[2]}<img src="cid:img5" width="20" alt="">/{night_weather[2]}<img src="cid:img6"
width="20" alt=""></td> <td>{temperature_min[2]}℃</td>
<td>{temperature_max[2]}℃</td>
</tr>
</table>
<table style="border: 0;text-align: center; margin:0 auto">
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th>{language['wind_info']}</th>
<th>{language['humidity']}</th>
<th>{language['uv_info']}</th>
</tr>
<tr>
<td>{wind_speed}m/s&nbsp; {wind_scale}&nbsp; {wind_dir}&nbsp;</td>
<td>{humidity}%&nbsp;</td>
<td>{ultraviolet_rays}&nbsp;</td>
</tr>
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th>{language['vis']}</th>
<th>{language['pressure']}</th>
<th>{language['cloud']}</th>
</tr>
<tr>
<td>{vis}km&nbsp;</td>
<td>{pressure}hPa&nbsp;</td>
<td>{cloud}%&nbsp;</td>
</tr>
</table>
<table style="border: 0;text-align: center; margin:0 auto">
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<td><img src="cid:sunrise" alt="Sunrise" width="30"></td>
<td>&nbsp;</td>
<td><img src="cid:sunset" alt="Sunset" width="30"></td>
</tr>
<tr>
<td>&nbsp;{sunrise}&nbsp;</td>
<td>---------------</td>
<td>&nbsp;{sunset}&nbsp;</td>
</tr>
</table>
<div style="text-align: center;" id="About">
<br />
<br />
<br />
<i>
<b>
<a href="https://dev.qweather.com/" style="color: black" target="_blank">QWeather</a>
<a style="color: black">&nbsp;·&nbsp;</a>
<a href="https://github.com/MarkusJoe/QWeather" style="color: black" target="_blank">Github Repo</a>
</b>
</i>
</div>"""
self.message['Subject'] = language['subject_3']
self.message.attach(MIMEText(mail_html, 'html', 'utf-8'))
image_count = 1
for image_source_free in icon_list:
with open(f'./resource/icons/{image_source_free}.png', 'rb') as file:
MyImage = MIMEImage(file.read())
MyImage.add_header('Content-ID', f'img{image_count}')
self.message.attach(MyImage)
image_count += 1
with open('resource/basic-resources/sunrise.png', 'rb') as sr_f:
sunrise_img = MIMEImage(sr_f.read())
sunrise_img.add_header('Content-ID', 'sunrise')
self.message.attach(sunrise_img)
with open('resource/basic-resources/sunset.png', 'rb') as ss_f:
sunset_img = MIMEImage(ss_f.read())
sunset_img.add_header('Content-ID', 'sunset')
self.message.attach(sunset_img)
try:
self.smtp.login(self.sender, self.password)
self.smtp.sendmail(self.sender, self.receiver, self.message.as_string())
except smtplib.SMTPException as e:
logger.critical(f'{language["mail_error"]}:', e)
sys.exit(1)
def warning_send_mail(self):
"""
发送自然灾害预警信息
releaseTime: 更新时间(并不是获取数据的时间 而是API更新数据的时间)
title: 标题
startTime: 开始时间
endTime: 结束时间
status: 状态
level: 等级
type: 类型
text: 详细描述
获取自然灾害并判断灾害信息是否为空
如果空则跳过
如果不为空则单独发送一封邮件
:return:
"""
r = session.get(self.warning_url, headers=self.headers, params=self.params).json()
logger.info(f'{language["request_result_warning"]}:{r["code"]}')
if r['warning']:
public_time = r['warning'][0]['pubTime']
title = r['warning'][0]['title']
start_time = r['warning'][0]['startTime']
end_time = r['warning'][0]['endTime']
if not start_time:
start_time = None
elif not end_time:
end_time = None
warning_status = r['warning'][0]['status']
if warning_status == 'update':
warning_status = {language["new_warning"]}
logger.info(f'{language["new_warning"]}')
elif warning_status == 'active':
warning_status = language["warning_updated"]
logger.info(f'{language["warning_updated"]}')
elif warning_status == 'cancel':
logger.info(f'{language["warning_canceled"]}')
level = r['warning'][0]['level']
type_ = r['warning'][0]['typeName']
text = r['warning'][0]['text']
self.message['Subject'] = language['subject_war']
self.message['Subject'] = f'{title}'
mail_html = f"""
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>Warning</title>
</head>
<body>
<div style="text-align: center;color: black;">
<h2>{title}</h2>
<h3>{language['release_time']}:{public_time[:10]} {level}{language['early_warning']}</h3>
<p>
{language['warning_status']}:{warning_status} {language['warning_type']}:{type_} {language['warning_duration']}:{start_time[:10]}~{end_time[:10]}
<br />
{text}
</p>
</div>
<div style="text-align: center;" id="About">
<br />
<br />
<br />
<i>
<b>
<a href="https://dev.qweather.com/" style="color: black" target="_blank">QWeather</a>
<a style="color: black">&nbsp;·&nbsp;</a>
<a href="https://github.com/MarkusJoe/QWeather" style="color: black" target="_blank">Github Repo</a>
</b>
</i>
</div>
</body>
</html>
"""
self.msg_content.attach(MIMEText(mail_html, 'html', 'utf-8'))
self.message.attach(self.msg_content)
try:
if warning_status != 'cancel':
self.smtp.login(self.sender, self.password)
self.smtp.sendmail(self.sender, self.receiver, self.message.as_string())
except smtplib.SMTPException as e:
logger.error(f'{language["mail_error"]}:', e)
sys.exit(1)
def loop_check(mode: str, time_list: list):
"""
循环检测时间如果本地时间等于配置文件内填写的时间则发送一封天气信息的邮件
:return:
"""
match mode:
case 'dev':
while True:
local_time = time.strftime("%H:%M", time.localtime())
time.sleep(1)
if local_time in time_list:
SendWeatherMail().dev_mode()
logger.info(f'{language["mail_succeed"]}')
logger.info(f'{language["wait_seconds"]}')
time.sleep(61)
case 'free':
while True:
local_time = time.strftime("%H:%M", time.localtime())
time.sleep(1)
if local_time in time_list:
SendWeatherMail().free_mode()
logger.info(f'{language["mail_succeed"]}')
logger.info(f'{language["wait_seconds"]}')
time.sleep(61)
def check_config():
"""
检查各项配置是否填写完成
:return:
"""
for mail in config['mail-settings'].values():
if mail is None:
logger.critical(f'"mail-settings"{language["config_not_filled"]}')
sys.exit(1)
for request in config['request-settings'].values():
if request is None:
logger.critical(f'"request-settings"{language["config_not_filled"]}')
sys.exit(1)
for other in config['client-settings'].values():
if other is None:
logger.critical(f'"client-settings"{language["config_not_filled"]}')
sys.exit(1)
def read_excel(kw: str):
"""
读取xlsx城市ID文件并返回搜索到的结果
:param kw: 用于搜索的关键字
:return: city_list
"""
index_count = 0
city_list = []
logger.info(f'[Search]{language["reading_the_file"]}')
df = pandas.read_excel(f'./resource/{LOCATION_ID_FILE_NAME}')
pandas.set_option('max_rows', None) # 读取xlsx文件不折叠
data_records = df.to_dict(orient='split')
for i in data_records['data']:
if kw in str(i):
logger.info(f' {index_count} | {i[2]}-{i[4]}-{i[6]}')
city = [index_count, i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8], i[9]]
index_count += 1
city_list.append(city)
return city_list
def modify_config(mode: bool = False):
"""
修改配置文件 -> 检测配置文件内的location项是否填写
填写 -> 跳过
未填写 -> 触发
(如果不小心在location项内随便输入了什么会导致误判)
:param mode: 触发修改模式的条件
:return: Nothing
"""
if not _LOCATION or not mode: # 如果配置中location未填写或status未False则触发条件
logger.info(f'[Modify]{language["fill_the_config"]}')
logger.info(f'[Modify]{language["input_a_city_name"]}')
while True:
time.sleep(0.3)
city_name = input('-->')
match city_name:
case 'q':
logger.info(f'[Modify]User quit.')
sys.exit(0)
case '':
logger.critical(f'[Modify]{language["null_value"]}')
continue
case _:
break
searched_city = read_excel(city_name)
logger.info(f'[Modify]{language["user_input"]}:[{city_name}]')
logger.info(f'[Modify]{language["select_a_index"]}')
if not searched_city:
logger.error(f'[Modify]{language["no_result"]}')
sys.exit(1)
time.sleep(0.3)
while True:
try:
time.sleep(0.3)
user_input = input('-->')
if user_input == 'q':
logger.info('[Quit]User quit')
sys.exit(1)
index = searched_city[int(user_input)]
with open(CONFIG_NAME, 'r', encoding='utf-8') as of:
data = YAML().load(of)
data['request-settings']['location'] = index[1]
data['only-view-settings']['city-name'] = f'{index[3]}-{index[7]}-{index[7]}'
data['only-view-settings']['time'] = time.strftime("%a %b %d %Y %H:%M:%S", time.localtime())
data['only-view-settings']['user'] = getpass.getuser()
with open(CONFIG_NAME, 'w', encoding='utf-8') as wf:
YAML().dump(data, wf)
logger.info(f'[Write]{language["write_successfully"]}:{CONFIG_NAME}')
break
except (IndexError, ValueError) as e:
logger.info(e)
logger.error(f'[Write]{language["input_type_error"]}')
continue
finally:
logger.info('[Done]Program has done.')
sys.exit(0)
def on_closing():
if messagebox.askokcancel('Exit', 'Confirm exit?'):
Features().quit_()
if __name__ == '__main__':
CONFIG_NAME = 'config.yml' # 配置文件名称
LOCATION_ID_FILE_NAME = 'china_city_list.xlsx' # 城市id文件必须为xlsx文件
# logs为空文件夹git上传时会自动忽略此文件夹 故添加自动创建文件夹
if not os.path.isdir('./logs'):
os.mkdir('./logs')
date_format = '%H:%M:%S'
info_format_console = '%(log_color)s[%(asctime)s] |%(levelname)-8s |%(lineno)-3s |%(message)s'
info_format_file = '[%(asctime)s] |%(levelname)-8s |%(lineno)-3s |%(funcName)s |%(pathname)s |%(message)s'
formatter = ColoredFormatter(fmt=info_format_console,
datefmt=date_format,
reset=True,
log_colors={
'DEBUG': 'light_purple',
'INFO': 'light_cyan',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'red,bold_red'})
formatter_file = logging.Formatter(fmt=info_format_file,
datefmt=date_format)
logger = logging.getLogger('MainLogger')
logger.setLevel(logging.DEBUG)
ConsoleLogger = logging.StreamHandler() # 输出到终端
ConsoleLogger.setFormatter(formatter)
log_name = time.strftime('%Y-%m-%d#%H') # 一小时内使用的日志文件都是同一个
FileLogger = logging.handlers.RotatingFileHandler(filename=f'./logs/{log_name}.log',
maxBytes=102400,
backupCount=5) # 每个日志文件最大102400字节(100Kb)
FileLogger.setFormatter(formatter_file)
logger.addHandler(ConsoleLogger)
logger.addHandler(FileLogger)
# 使用本地网络进行请求
session = requests.Session()
session.trust_env = False
# 获取语言配置
with open(CONFIG_NAME, 'r', encoding='utf-8') as lang:
config = YAML().load(lang.read())
language_sel = config['client-settings']['language']
if language_sel not in ['zh_cn', 'en_us']:
language_sel = 'zh_cn'
# 打开语言json文件
with open(f'./resource/lang/{language_sel}.json', 'r', encoding='utf-8') as lang_f:
language = json.loads(lang_f.read())
_TIMES = config['client-settings']['send-times']
_MODE = config['request-settings']['mode']
_LOCATION = config['request-settings']['location']
modify_config(True)
# 获取参数
parser = argparse.ArgumentParser()
arg_keywords = ['free', 'dev', 'warning', 'modify']
parser.add_argument('-t',
'--test',
help='Some operations for test.',
choices=arg_keywords)
startup_arg = parser.parse_args().test
# Python3.10 更新的match-case 语法
match startup_arg:
case 'free':
SendWeatherMail().free_mode()
logger.debug(f'{language["debug_done"]}')
sys.exit(0)
case 'dev':
SendWeatherMail().dev_mode()
logger.debug(f'{language["debug_done"]}')
sys.exit(0)
case 'warning':
SendWeatherMail().warning_send_mail()
logger.debug(f'{language["debug_done"]}')
sys.exit(0)
case 'modify':
modify_config()
logger.info(f'{language["debug_done"]}')
case _:
pass
# 检查配置文件是否填写完成
check_config()
# 输出声明
logger.info(f'{language["statement_1"]}')
logger.info(f'{language["statement_2"]}')
logger.info(f'{language["statement_3"]}')
logger.info(f'{language["statement_4"]}')
logger.info(f'{language["current_profile"]}: {CONFIG_NAME}')
# 另开一个进程与主进程同时运行 --> 运行loopCheck --> 循环检查本地时间是否与配置内时间相符
multiprocessing.Process(target=loop_check, args=(_MODE, _TIMES,)).run()
# 循环检测时间 --> 每10分钟检查一次, 如果有则发送如果无则直接跳过
loop_timer = 0
while True:
time.sleep(1)
loop_timer += 1
if loop_timer == 600:
SendWeatherMail().warning_send_mail()
loop_timer = 0
b1 = tk.Button(root,
text='Click to run QWeather',
command=threading.Thread(target=qweather.main, name='main').start)
b1.place(x=45, y=300)
b2 = tk.Button(root,
text='Exit the main program',
command=on_closing)
b2.place(x=275, y=300)
l1 = tk.Label(root,
text='更多功能敬请期待\nEnjoy this ~',)
l1.place(x=530, y=70)
information = """
已知问题:
1.开启QWeather主程序后退出只会退出界面主程序并不会退出
2.webservice.py 的输出并不会被插入到GUI界面里
* 更多问题待发现...
"""
l2 = tk.Label(root,
text=information)
l2.place(x=140, y=350)
root.protocol('WM_DELETE_WINDOW', on_closing)
root.mainloop()

View File

@@ -1,37 +1,71 @@
<p align="center">
<a href="https://github.com/MarkusJoe/QWeather">
<img src="https://img.shields.io/badge/Python-V3.10-blue.svg" alt="PythonVersion">
<img src="https://img.shields.io/badge/release-V2.9.0-green.svg" alt="QWeatherVersion">
<img src="https://img.shields.io/badge/Python-3.10.x-blue.svg" alt="PythonVersion">
<img src="https://img.shields.io/badge/release-4.0.0-green.svg" alt="QWeatherVersion">
<img src="https://img.shields.io/badge/LINCESE-Apache2.0-orange.svg" alt="LICENSE">
</a>
</p>
<div align="center">
## *QWeather*
## *QWeatherReporter*
<i style="text-align: center;"><a href="https://www.qweather.com/">QWeather Official Website</a></i>\
<i style="text-align: center;"><a href="https://dev.qweather.com/">QWeather Development Platform</a></i>
> GUI问题: 无法填写城市位置, 清手动打开./res/china_city_list.xlsx 进行手动查询
> 并填写至`requests-settings` > `location`
> `only-view-settings` > `city-name` 也需手动填写
</div>
## 问题汇总
#### Python 版本:
> 程序使用了Python3.10中的match-case语句
> 请使用Python3.10版本运行
#### 主题选择:
> 在2.9.0之后的版本不支持自定义天气图标 只能使用最新的图标
#### 配置填写问题:
> `location`项和`only-view-settings`类不需要用户填写, 只需要打开`QWeather.py`进行自助填写
<div align="center">
<b><i>当前分支: GUI, 为界面分支, 仍存在bug以及一些问题<br></i></b>
<b><i>当前分支版本为重构后的版本重构前版本请在before分支中查看<br>(重构前版本不再更新,最新版本为v2.9.0)</i></b><br>
<b><i><a href="https://markusjoe.github.io/" target="_blank">点击跳转到帮助文档</a></i></b>
</div>
## 声明
- > 程序作者: **RTAkland (markushammered@gmail.com)**
- > 和风天气开发者平台https://dev.qweather.com
- > 和风天气官网: https://qweather.com
### 开源
- 本项目以[Apache-2.0](./LICENSE)许可开源, 即:
- 你可以直接使用该项目提供的功能, 无需任何授权
- 你可以在**注明来源版权信息**的情况下对源代码进行任意分发和修改以及衍生
### 已实现功能
- [x] 发送免费版&开发版天气预报功能
- [x] 间隔10分钟请求一次自然灾害预警信息
- [x] 在网页上快速查看天气
- [x] 在邮件html内附带一句一言
- [ ] ~~推送到QQ(咕咕咕)~~
- [x] GUI界面 (无法填写城市位置, 清手动打开./res/china_city_list.xlsx 进行手动查询)
### 问题汇总
#### Python 版本:
> 程序使用了*Python3.10.x*中的match-case语句
> 请使用*Python3.10.x*版本运行
#### 主题选择:
> 在2.9.0之后的版本不支持自定义天气图标 只能使用最新的图标
#### 配置填写问题:
> `location`项和`only-view-settings`类不需要用户填写, 只需要打开`QWeather.py`进行自助填写
## 如何使用
- 程序基于python3.10开发 务必使用python3.10版本运行
- 将config.yml正确填写完成
- 使用`pip/pip3 install -r requirements.txt` 安装需要的库
- 运行`QWeather.py`
- 运行`QWeather.py`
### 网页上查看天气
- 将所有准备工作完成(能正常运行QWeather.py)
- 运行`QWeather.py`
- 打开浏览器输入**127.0.0.1:7898**
>127.0.0.1可以更改为部署本项目的服务器ip, 7898端口不能被其他程序占用或不开放此端口
## 联系方式
- 邮箱: <markushammered@gmail.com>

View File

@@ -95,12 +95,31 @@ client-settings:
# 填错默认 "zh_cn"
language: zh_cn
# [必填/只能一个] 日志等级
# 默认: DEBUG
# 可选: "DEBUG" "INFO" "WARNING" "ERROR" "CRITICAL"
level: DEBUG
# [选填/只能一个] 开启本地网页快速查看天气
# 默认: False
# 可选: "True" "False"
webservice: false
# [必填/只能一个] 是否使用SSL 连接到邮箱服务器
# 默认 True
# 可选: "True" "False"
SSL: True
# [必填/只能一个] enable GUI or disable GUI
enable-GUI: True
# [标识/不填] 仅作用户读取标识
only-view-settings:
# 城市名
city-name: 黄岩-台州-台州
# 修改时间
time: Sun Dec 12 2021 14:49:38
time: Mon Dec 20 2021 21:08:22
# 修改用户
user: rtakland

12
core/__init__.py Normal file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/15
# @File Name: __init__.py
import os
if not os.path.exists('./logs'):
os.mkdir('./logs')

132
core/information.py Normal file
View File

@@ -0,0 +1,132 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/15
# @File Name: information.py
import requests
from core.read_config import read_config
class WeatherInfo:
def __init__(self):
self.config = read_config()
self.dev = 'https://devapi.qweather.com/v7/weather/7d'
self.free = 'https://devapi.qweather.com/v7/weather/3d'
self.warning = 'https://devapi.qweather.com/v7/warning/now'
self.key = self.config[1]['key']
self.location = self.config[1]['location']
self.unit = self.config[1]['unit']
self.language = self.config[1]['lang']
self.params = {'location': self.location,
'key': self.key,
'unit': self.unit,
'lang': self.language}
self.session = requests.Session()
self.session.trust_env = False
def dev_version(self):
"""
Developer's Qweather version
:return: dates, day_weathers, night_weathers, highest_temps, lowest_temps,
icon_list, sunset, sunrise, humidity, wind_speed, wind_scale, wind_dir, ultraviolet_rays, cloud, pressure, vis
"""
dev_res = self.session.get(self.dev, params=self.params).json()
day_1 = dev_res['daily'][0]
day_2 = dev_res['daily'][1]
day_3 = dev_res['daily'][2]
day_4 = dev_res['daily'][3]
day_5 = dev_res['daily'][4]
day_6 = dev_res['daily'][5]
day_7 = dev_res['daily'][6]
dates = [day_1['fxDate'][5:], day_2['fxDate'][5:], day_3['fxDate'][5:], day_4['fxDate'][5:],
day_5['fxDate'][5:],
day_6['fxDate'][5:],
day_7['fxDate'][5:]]
day_weathers = [day_1['textDay'], day_2['textDay'], day_3['textDay'], day_4['textDay'], day_5['textDay'],
day_6['textDay'], day_7['textDay']]
night_weathers = [day_1['textNight'], day_2['textNight'], day_3['textNight'], day_4['textNight'],
day_5['textNight'], day_6['textNight'], day_7['textNight']]
highest_temps = [day_1['tempMax'], day_2['tempMax'], day_3['tempMax'], day_4['tempMax'], day_5['tempMax'],
day_6['tempMax'], day_7['tempMax']]
lowest_temps = [day_1['tempMin'], day_2['tempMin'], day_3['tempMin'], day_4['tempMin'], day_5['tempMin'],
day_6['tempMin'], day_7['tempMin']]
icon_list = [day_1['iconDay'], day_2['iconDay'], day_3['iconDay'], day_4['iconDay'], day_5['iconDay'],
day_6['iconDay'], day_7['iconDay'], day_1['iconNight'], day_2['iconNight'], day_3['iconNight'],
day_4['iconNight'], day_5['iconNight'], day_6['iconNight'], day_7['iconNight']]
sunset = day_1['sunset']
sunrise = day_1['sunrise']
humidity = day_1['humidity']
wind_speed = day_1['windSpeedDay']
wind_scale = day_1['windScaleDay']
wind_dir = day_1['windDirDay']
ultraviolet_rays = day_1['uvIndex']
cloud = day_1['cloud']
pressure = day_1['pressure']
vis = day_1['vis']
return dates, day_weathers, night_weathers, highest_temps, lowest_temps, icon_list, sunset, sunrise, humidity, \
wind_speed, wind_scale, wind_dir, ultraviolet_rays, cloud, pressure, vis
def free_version(self):
"""
:return: return dates, day_weathers, night_weathers, highest_temps, lowest_temps, icon_list, sunset, sunrise,
humidity, wind_speed, wind_scale, wind_dir, ultraviolet_rays, cloud, pressure, vis
"""
free_res = self.session.get(self.free, params=self.params).json()
day_1 = free_res['daily'][0]
day_2 = free_res['daily'][1]
day_3 = free_res['daily'][2]
dates = [day_1['fxDate'][5:], day_2['fxDate'][5:], day_2['fxDate'][5:]]
day_weathers = [day_1['textDay'], day_2['textDay'], day_2['textDay']]
night_weathers = [day_1['textNight'], day_2['textNight'], day_2['textNight']]
highest_temps = [day_1['tempMax'], day_2['tempMax'], day_3['tempMax']]
lowest_temps = [day_1['tempMin'], day_2['tempMin'], day_2['tempMin']]
icon_list = [day_1['iconDay'], day_1['iconDay'], day_3['iconDay'], day_1['iconNight'], day_2['iconNight'],
day_3['iconNight']]
sunset = day_1['sunset']
sunrise = day_1['sunrise']
humidity = day_1['humidity']
wind_speed = day_1['windSpeedDay']
wind_scale = day_1['windScaleDay']
wind_dir = day_1['windDirDay']
ultraviolet_rays = day_1['uvIndex']
cloud = day_1['cloud']
pressure = day_1['pressure']
vis = day_1['vis']
return dates, day_weathers, night_weathers, highest_temps, lowest_temps, icon_list, sunset, sunrise, humidity, \
wind_speed, wind_scale, wind_dir, ultraviolet_rays, cloud, pressure, vis
def warning_(self):
"""
:return: release_time, title, status, level, type_, text, start_time, end_time
"""
warning_res = self.session.get(self.warning, params=self.params).json()
release_time = warning_res['warning'][0]['pubTime'][:10]
title = warning_res['warning'][0]['title']
status = warning_res['warning'][0]['status']
level = warning_res['warning'][0]['level']
type_ = warning_res['warning'][0]['typeName']
text = warning_res['warning'][0]['text']
start_time = warning_res['warning'][0]['startTime']
end_time = warning_res['warning'][0]['endTime']
match start_time, end_time:
case None, None:
start_time, end_time = None, None
case _:
pass
return release_time, title, status, level, type_, text, start_time, end_time

27
core/language.py Normal file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/15
# @File Name: language.py
from ruamel.yaml import YAML
import json
def Language():
"""
读取配置文件中的语言选项并返回相对因的语言文件的读取结果
:return:
"""
with open('./config.yml', 'r', encoding='utf-8') as lang:
config = YAML().load(lang.read())
language_sel = config['client-settings']['language']
if language_sel not in ['zh_cn', 'en_us']:
language_sel = 'zh_cn'
# 打开语言json文件
with open(f'./res/lang/{language_sel}.json', 'r', encoding='utf-8') as lang_f:
language = json.loads(lang_f.read())
return language

55
core/logger.py Normal file
View File

@@ -0,0 +1,55 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/15
# @File Name: logger.py
from colorlog import ColoredFormatter
from core.read_config import read_config
import logging.handlers
import time
level = read_config()[2]['level']
date_format = '%H:%M:%S'
info_format_console = '%(log_color)s[%(asctime)s] |%(filename)s[%(lineno)-3s] |%(levelname)-8s |%(message)s'
info_format_file = '[%(asctime)s] |%(filename)s[%(funcName)sline:%(lineno)d] |%(levelname)-8s |%(message)s'
formatter = ColoredFormatter(fmt=info_format_console,
datefmt=date_format,
reset=True,
log_colors={
'DEBUG': 'light_purple',
'INFO': 'light_cyan',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'red,bold_red'})
formatter_file = logging.Formatter(fmt=info_format_file,
datefmt=date_format)
Logger = logging.getLogger('MainLogger')
match level:
case 'DEBUG':
Logger.setLevel(logging.DEBUG)
case 'INFO':
Logger.setLevel(logging.INFO)
case 'WARNING':
Logger.setLevel(logging.WARNING)
case 'ERROR':
Logger.setLevel(logging.ERROR)
case 'CRITICAL':
Logger.setLevel(logging.CRITICAL)
case _:
Logger.setLevel(logging.DEBUG)
ConsoleLogger = logging.StreamHandler() # 输出到终端
ConsoleLogger.setFormatter(formatter)
log_name = time.strftime('%Y-%m-%d#%H') # 一小时内使用的日志文件都是同一个
FileLogger = logging.handlers.RotatingFileHandler(filename=f'./logs/{log_name}.log',
maxBytes=102400,
backupCount=5) # 每个日志文件最大102400字节(100Kb)
FileLogger.setFormatter(formatter_file)
Logger.addHandler(ConsoleLogger)
Logger.addHandler(FileLogger)

154
core/qweather.py Normal file
View File

@@ -0,0 +1,154 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/15
# @File Name: qweather.py
import os
import sys
import time
import argparse
from concurrent.futures import ProcessPoolExecutor
from core.logger import Logger
from core.language import Language
from core.settings import change_settings
from core.read_config import read_config
from core.sendmail import Mail
from lib.webservice import accept_requests
from lib.buildGUIClass import InsertLog
language = Language()
settings = read_config()
processes = ProcessPoolExecutor(max_workers=3)
gui_log = InsertLog()
def check_time():
"""
通过多进程让函数和主程序并行,
并持续检测本地计算机时间是否和配置文件内填写的发送时间一致
:return:
"""
mode = settings[1]['mode']
time_list = settings[2]['send-times']
match mode:
case 'dev':
while True:
local_time = time.strftime("%H:%M", time.localtime())
time.sleep(1)
if local_time in time_list:
Mail().dev_version()
Logger.info(f'{language["mail_succeed"]}')
gui_log.insert(f'{language["wait_seconds"]}')
Logger.info(f'{language["wait_seconds"]}')
gui_log.insert(f'{language["mail_succeed"]}')
time.sleep(60)
case 'free':
while True:
local_time = time.strftime("%H:%M", time.localtime())
time.sleep(1)
if local_time in time_list:
Mail().free_version()
Logger.info(f'{language["mail_succeed"]}')
gui_log.insert(f'{language["wait_seconds"]}')
Logger.info(f'{language["wait_seconds"]}')
gui_log.insert(f'{language["mail_succeed"]}')
time.sleep(60)
def check_config():
"""
返回配置文件中的location项是否填写
:return: True or False
"""
location = settings[1]['location']
if location:
return True
else:
return False
def setting():
"""
检查配置文件是否填写完成
:return:
"""
for mail in settings[0].values():
if not mail:
Logger.critical('mail-settings 有未填写项目')
sys.exit(1)
for request in settings[1].values():
if not request:
Logger.critical('request-settings 有未填写项目')
sys.exit(1)
for other in settings[1].values():
if not other:
Logger.critical('client-settings 有未填写项目')
sys.exit(1)
def main():
"""
主程序
:return:
"""
Logger.info(f'{language["statement_1"]}')
gui_log.insert(f'{language["statement_1"]}')
Logger.info(f'{language["statement_2"]}')
gui_log.insert(f'{language["statement_2"]}')
Logger.info(f'{language["statement_3"]}')
gui_log.insert(f'{language["statement_3"]}')
Logger.info(f'{language["statement_4"]}')
gui_log.insert(f'{language["statement_4"]}')
parser = argparse.ArgumentParser()
arg_keywords = ['free', 'dev', 'warning', 'setting']
parser.add_argument('-t',
'--test',
help='Some operations for test.',
choices=arg_keywords)
startup_arg = parser.parse_args().test
match startup_arg:
case 'free':
Mail().free_version()
Logger.debug(f'{language["debug_done"]}')
gui_log.insert(f'{language["debug_done"]}')
sys.exit(0)
case 'dev':
Mail().dev_version()
Logger.debug(f'{language["debug_done"]}')
gui_log.insert(f'{language["debug_done"]}')
sys.exit(0)
case 'warning':
Mail().warning_()
Logger.debug(f'{language["debug_done"]}')
gui_log.insert(f'{language["debug_done"]}')
sys.exit(0)
case 'setting':
change_settings()
Logger.debug(f'{language["debug_done"]}')
gui_log.insert(f'{language["debug_done"]}')
case _:
if check_config():
setting()
else:
change_settings()
processes.submit(check_time)
if settings[2]['webservice']:
Logger.info(f'{language["webservice_ip"]}:127.0.0.1:7898')
gui_log.insert(f'{language["webservice_ip"]}:127.0.0.1:7898')
processes.submit(accept_requests)
time_count = 0
while True:
time_count += 1
time.sleep(1)
if time_count == 600:
Mail().warning_()
time_count = 0

24
core/read_config.py Normal file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/15
# @File Name: read_config.py
from ruamel.yaml import YAML
def read_config():
"""
读取配置文件并返回读取到的内容同
:return: mail-settings, request-settings, client-settings, only-view-settings --> 0, 1, 2, 3
"""
config_file = 'config.yml'
with open(f'./{config_file}', 'r') as conf:
config = YAML().load(conf.read())
mail_settings = config['mail-settings']
request_settings = config['request-settings']
client_settings = config['client-settings']
only_view = config['only-view-settings']
return mail_settings, request_settings, client_settings, only_view

38
core/read_excel.py Normal file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/15
# @File Name: read_excel.py
import pandas
from core.logger import Logger
from core.language import Language
from lib.buildGUIClass import InsertLog
gui_log = InsertLog()
def read_excel(kw: str):
"""
读取china_city_list.xlsx并搜索匹配关键字的结果并输出到终端
:param kw: keyword
:return: city_list
"""
language = Language()
index_count = 0
city_list = []
Logger.info(f'[Search]{language["reading_the_file"]}')
gui_log.insert(f'[Search]{language["reading_the_file"]}')
df = pandas.read_excel(f'./res/china_city_list.xlsx')
pandas.set_option('max_rows', None) # 读取xlsx文件不折叠
data_records = df.to_dict(orient='split')
for i in data_records['data']:
if kw in str(i):
Logger.info(f' {index_count} | {i[2]}-{i[4]}-{i[6]}')
gui_log.insert(f' {index_count} | {i[2]}-{i[4]}-{i[6]}')
city = [index_count, i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8], i[9]]
index_count += 1
city_list.append(city)
return city_list

451
core/sendmail.py Normal file
View File

@@ -0,0 +1,451 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/16
# @File Name: sendmail.py
import sys
import smtplib
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.header import Header
from email.mime.text import MIMEText
from core.logger import Logger
from core.language import Language
from core.information import WeatherInfo
from core.read_config import read_config
from lib.hitokoto import hitokoto
from lib.buildGUIClass import InsertLog
gui_log = InsertLog()
class Mail:
def __init__(self):
self.settings = read_config()
self.language = Language()
self.enableSSL = self.settings[2]['SSL']
self.server = self.settings[0]['server']
self.port = self.settings[0]['port']
self.password = self.settings[0]['password']
self.sender = self.settings[0]['sender']
self.receiver = self.settings[1]['receiver']
self.city_name = self.settings[3]['city-name']
self.message = MIMEMultipart('related')
self.message['From'] = Header('QWeather') # 发件人名称
self.message['To'] = Header('All allowed User') # 收件人显示名称
self.hitokoto = hitokoto() # 一言
if self.enableSSL:
self.smtp = smtplib.SMTP_SSL(self.server, self.port) # 登录服务器 使用SSL连接
else:
self.smtp = smtplib.SMTP(self.server, self.port) # 登录邮箱服务器 不使用SSL连接
def dev_version(self):
"""
开发者版本
:return:
"""
dev_weather = WeatherInfo().dev_version()
dates = dev_weather[0]
day_weathers = dev_weather[1]
night_weathers = dev_weather[2]
highest_temps = dev_weather[3]
lowest_temps = dev_weather[4]
icons = dev_weather[5]
sunset = dev_weather[6]
sunrise = dev_weather[7]
humidity = dev_weather[8]
wind_speed = dev_weather[9]
wind_scale = dev_weather[10]
wind_dir = dev_weather[11]
uv_index = dev_weather[12]
cloud = dev_weather[13]
pressure = dev_weather[14]
vis = dev_weather[15]
mail_html = f"""
<p style="text-align: center">
<i>
<b>
地区:{self.city_name}
<br>
发送者:{self.sender}
</b>
</i>
</p>
<br />
<table style="border: 0; text-align: center; margin:0 auto">
<tr>
<th>|&nbsp;日期&nbsp;&nbsp;</th>
<th>|&nbsp;天气&nbsp;&nbsp;</th>
<th>|&nbsp;最低温度&nbsp;&nbsp;</th>
<th>|&nbsp;最高温度&nbsp;&nbsp;</th>
</tr>
<tr>
<!--日期 天气 最低 最高/Date Weather LowestTemp HighestTemp-->
<td>今天</td>
<td>{day_weathers[0]}<img src="cid:img1" width="20" alt="">/{night_weathers[0]}<img src="cid:img2"
width="20" alt=""></td> <td>{lowest_temps[0]}℃</td>
<td>{highest_temps[0]}℃</td>
</tr>
<tr>
<td>{dates[1]}</td>
<td>{day_weathers[1]}<img src="cid:img3" width="20" alt="">/{night_weathers[1]}<img src="cid:img4"
width="20" alt=""></td> <td>{lowest_temps[1]}℃</td>
<td>{highest_temps[1]}℃</td>
</tr>
<tr>
<td>{dates[2]}</td>
<td>{day_weathers[2]}<img src="cid:img5" width="20" alt="">/{night_weathers[2]}<img src="cid:img6"
width="20" alt=""></td> <td>{lowest_temps[2]}℃</td>
<td>{highest_temps[2]}℃</td>
</tr>
<tr>
<td>{dates[3]}</td>
<td>{day_weathers[3]}<img src="cid:img7" width="20" alt="">/{night_weathers[3]}<img src="cid:img8"
width="20" alt=""></td> <td>{lowest_temps[3]}℃</td>
<td>{highest_temps[3]}℃</td>
</tr>
<tr>
<td>{dates[4]}</td>
<td>{day_weathers[4]}<img src="cid:img9" width="20" alt="">/{night_weathers[4]}<img src="cid:img10"
width="20" alt=""></td> <td>{lowest_temps[4]}℃</td>
<td>{highest_temps[4]}℃</td>
</tr>
<tr>
<td>{dates[5]}</td>
<td>{day_weathers[5]}<img src="cid:img11" width="20" alt="">/{night_weathers[5]}<img src="cid:img12"
width="20" alt=""></td> <td>{lowest_temps[5]}℃</td>
<td>{highest_temps[5]}℃</td>
</tr>
<tr>
<td>{dates[6]}</td>
<td>{day_weathers[6]}<img src="cid:img13" width="20" alt="">/{night_weathers[6]}<img src="cid:img14"
width="20" alt=""></td> <td>{lowest_temps[6]}℃</td>
<td>{highest_temps[6]}℃</td>
</tr>
</table>
<table style="border: 0;text-align: center; margin:0 auto">
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th>风速/级/向</th>
<th>湿度</th>
<th>紫外线</th>
</tr>
<tr>
<td>{wind_speed}m/s&nbsp; {wind_scale}&nbsp; {wind_dir}&nbsp;</td>
<td>{humidity}%&nbsp;</td>
<td>{uv_index}&nbsp;</td>
</tr>
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th>能见度</th>
<th>压强</th>
<th>云量</th>
</tr>
<tr>
<td>{vis}km&nbsp;</td>
<td>{pressure}hPa&nbsp;</td>
<td>{cloud}%&nbsp;</td>
</tr>
</table>
<table style="border: 0;text-align: center; margin:0 auto">
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<td><img src="cid:sunrise" alt="Sunrise" width="30"></td>
<td>&nbsp;</td>
<td><img src="cid:sunset" alt="Sunset" width="30"></td>
</tr>
<tr>
<td>&nbsp;{sunrise}&nbsp;</td>
<td>---------------</td>
<td>&nbsp;{sunset}&nbsp;</td>
</tr>
</table>
<br />
<div style="text-align: center" id="hitokoto">
<p>
{self.hitokoto}
</p>
</div>
<div style="text-align: center;" id="About">
<br />
<i>
<b>
<a href="https://dev.qweather.com/" style="color: black" target="_blank">QWeather</a>
<a style="color: black">&nbsp;·&nbsp;</a>
<a href="https://github.com/MarkusJoe/QWeather" style="color: black" target="_blank">Github Repo</a>
</b>
</i>
</div>"""
self.message['Subject'] = '七天天气预报' # 邮件标题
self.message.attach(MIMEText(mail_html, 'html', 'utf-8'))
image_count = 1
for image_resource in icons:
with open(f'./res/icons/{image_resource}.png', 'rb') as fp:
MyImage = MIMEImage(fp.read())
MyImage.add_header('Content-ID', f'img{image_count}')
self.message.attach(MyImage)
image_count += 1
with open('./res/basic-resources/sunrise.png', 'rb') as sr_f:
sunrise_img = MIMEImage(sr_f.read())
sunrise_img.add_header('Content-ID', 'sunrise')
self.message.attach(sunrise_img)
with open('./res/basic-resources/sunset.png', 'rb') as ss_f:
sunset_img = MIMEImage(ss_f.read())
sunset_img.add_header('Content-ID', 'sunset')
self.message.attach(sunset_img)
try:
self.smtp.login(self.sender, self.password) # 登录
self.smtp.sendmail(self.sender, self.receiver, self.message.as_string()) # 发送
Logger.info(f'{self.language["mail_succeed"]}')
gui_log.insert(f'{self.language["mail_succeed"]}')
except smtplib.SMTPException as e: # 处理错误
Logger.critical(f'{self.language["mail_error"]}: {e}')
gui_log.insert(f'{self.language["mail_error"]}: {e}')
sys.exit(1)
def free_version(self):
"""
免费版本
:return:
"""
free_weather = WeatherInfo().free_version()
dates = free_weather[0]
day_weathers = free_weather[1]
night_weathers = free_weather[2]
highest_temps = free_weather[3]
lowest_temps = free_weather[4]
icons = free_weather[5]
sunset = free_weather[6]
sunrise = free_weather[7]
humidity = free_weather[8]
wind_speed = free_weather[9]
wind_scale = free_weather[10]
wind_dir = free_weather[11]
uv_index = free_weather[12]
cloud = free_weather[13]
pressure = free_weather[14]
vis = free_weather[15]
mail_html = f"""
<p style="text-align: center">
<i>
<b>
地区:{self.city_name}
<br>
发送者:{self.sender}
</b>
</i>
</p>
<br />
<table style="border: 0; text-align: center; margin:0 auto">
<tr>
<th>|&nbsp;日期&nbsp;&nbsp;</th>
<th>|&nbsp;天气&nbsp;&nbsp;</th>
<th>|&nbsp;最低温度&nbsp;&nbsp;</th>
<th>|&nbsp;最高温度&nbsp;&nbsp;</th>
</tr>
<tr>
<!--日期 天气 最低 最高/Date Weather LowestTemp HighestTemp-->
<td>今天</td>
<td>{day_weathers[0]}<img src="cid:img1" width="20" alt="">/{night_weathers[0]}<img src="cid:img2"
width="20" alt=""></td> <td>{lowest_temps[0]}℃</td>
<td>{highest_temps[0]}℃</td>
</tr>
<tr>
<td>{dates[1]}</td>
<td>{day_weathers[1]}<img src="cid:img3" width="20" alt="">/{night_weathers[1]}<img src="cid:img4"
width="20" alt=""></td> <td>{lowest_temps[1]}℃</td>
<td>{highest_temps[1]}℃</td>
</tr>
<tr>
<td>{dates[2]}</td>
<td>{day_weathers[2]}<img src="cid:img5" width="20" alt="">/{night_weathers[2]}<img src="cid:img6"
width="20" alt=""></td> <td>{lowest_temps[2]}℃</td>
<td>{highest_temps[2]}℃</td>
</table>
<table style="border: 0;text-align: center; margin:0 auto">
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th>风速/级/向</th>
<th>湿度</th>
<th>紫外线</th>
</tr>
<tr>
<td>{wind_speed}m/s&nbsp; {wind_scale}&nbsp; {wind_dir}&nbsp;</td>
<td>{humidity}%&nbsp;</td>
<td>{uv_index}&nbsp;</td>
</tr>
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th>能见度</th>
<th>压强</th>
<th>云量</th>
</tr>
<tr>
<td>{vis}km&nbsp;</td>
<td>{pressure}hPa&nbsp;</td>
<td>{cloud}%&nbsp;</td>
</tr>
</table>
<table style="border: 0;text-align: center; margin:0 auto">
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<td><img src="cid:sunrise" alt="Sunrise" width="30"></td>
<td>&nbsp;</td>
<td><img src="cid:sunset" alt="Sunset" width="30"></td>
</tr>
<tr>
<td>&nbsp;{sunrise}&nbsp;</td>
<td>---------------</td>
<td>&nbsp;{sunset}&nbsp;</td>
</tr>
</table>
<br />
<div style="text-align: center" id="hitokoto">
<p>
{self.hitokoto}
</p>
</div>
<div style="text-align: center;" id="About">
<br />
<i>
<b>
<a href="https://dev.qweather.com/" style="color: black" target="_blank">QWeather</a>
<a style="color: black">&nbsp;·&nbsp;</a>
<a href="https://github.com/MarkusJoe/QWeather" style="color: black" target="_blank">Github Repo</a>
</b>
</i>
</div>"""
self.message['Subject'] = '三天天气预报' # 邮件标题
self.message.attach(MIMEText(mail_html, 'html', 'utf-8'))
image_count = 1
for image_resource in icons:
with open(f'./res/icons/{image_resource}.png', 'rb') as fp:
MyImage = MIMEImage(fp.read())
MyImage.add_header('Content-ID', f'img{image_count}')
self.message.attach(MyImage)
image_count += 1
with open('./res/basic-resources/sunrise.png', 'rb') as sr_f:
sunrise_img = MIMEImage(sr_f.read())
sunrise_img.add_header('Content-ID', 'sunrise')
self.message.attach(sunrise_img)
with open('./res/basic-resources/sunset.png', 'rb') as ss_f:
sunset_img = MIMEImage(ss_f.read())
sunset_img.add_header('Content-ID', 'sunset')
self.message.attach(sunset_img)
try:
self.smtp.login(self.sender, self.password) # 登录
self.smtp.sendmail(self.sender, self.receiver, self.message.as_string()) # 发送
Logger.info(f'{self.language["mail_succeed"]}')
Logger.info(f'{self.language["mail_succeed"]}')
except smtplib.SMTPException as e: # 处理错误
Logger.critical(f'{self.language["mail_error"]}: {e}')
gui_log.insert(f'{self.language["mail_error"]}: {e}')
sys.exit(1)
def warning_(self):
"""
自然灾害预警
:return:
"""
info = WeatherInfo().warning_()
release_time = info[0]
title = info[1]
status = info[2]
level = info[3]
type_ = info[4]
text = info[5]
start_time = info[6]
end_time = info[7]
match status:
case 'update':
status = '预警更新'
Logger.info(f'{self.language["new_warning"]}')
gui_log.insert(f'{self.language["new_warning"]}')
case 'active':
status = '已有灾害'
Logger.info(f'{self.language["warning_updated"]}')
gui_log.insert(f'{self.language["warning_updated"]}')
case 'cancel':
Logger.info(f'{self.language["warning_canceled"]}')
gui_log.insert(f'{self.language["warning_canceled"]}')
mail_html = f"""
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>Warning</title>
</head>
<body>
<div style="text-align: center;color: black;">
<h2>{title}</h2>
<h3>释放时间:{release_time} {level}级</h3>
<p>
预警状态:{status} 预警类型:{type_} 灾害持续时间:{start_time[:10]}~{end_time[:10]}
<br />
{text}
</p>
</div>
<div style="text-align: center;" id="About">
<br />
<br />
<br />
<i>
<b>
<a href="https://dev.qweather.com/" style="color: black" target="_blank">QWeather</a>
<a style="color: black">&nbsp;·&nbsp;</a>
<a href="https://github.com/MarkusJoe/QWeather" style="color: black" target="_blank">Github Repo</a>
</b>
</i>
</div>
</body>
</html>
"""
self.message['Subject'] = '自然灾害预警' # 邮件标题
self.message.attach(MIMEText(mail_html, 'html', 'utf-8'))
with open('./res/basic-resources/sunrise.png', 'rb') as sr_f:
sunrise_img = MIMEImage(sr_f.read())
sunrise_img.add_header('Content-ID', 'sunrise')
self.message.attach(sunrise_img)
with open('./res/basic-resources/sunset.png', 'rb') as ss_f:
sunset_img = MIMEImage(ss_f.read())
sunset_img.add_header('Content-ID', 'sunset')
self.message.attach(sunset_img)
try:
if status != 'cancel':
self.smtp.login(self.sender, self.password) # 登录
self.smtp.sendmail(self.sender, self.receiver, self.message.as_string()) # 发送
Logger.info(f'{self.language["mail_succeed"]}')
gui_log.insert(f'{self.language["mail_succeed"]}')
except smtplib.SMTPException as e: # 处理错误
Logger.critical(f'{self.language["mail_error"]}: {e}')
gui_log.insert(f'{self.language["mail_error"]}: {e}')
sys.exit(1)

90
core/settings.py Normal file
View File

@@ -0,0 +1,90 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/15
# @File Name: settings.py
import sys
import time
import getpass
from core.logger import Logger
from core.language import Language
from core.read_excel import read_excel
from core.read_config import read_config
from ruamel.yaml import YAML
from lib.buildGUIClass import InsertLog
from lib.buildGUIClass import var_command
gui_log = InsertLog()
gui = read_config()[2]['enable-GUI']
def change_settings():
"""
使用read_excel.py搜索到的结果再次进行二次选择, 并写入文件
:return:
"""
language = Language()
Logger.info(f'[Modify]{language["change_setting"]}')
gui_log.insert(f'[Modify]{language["change_setting"]}')
Logger.info(f'[Modify]{language["fill_the_config"]}')
gui_log.insert(f'[Modify]{language["fill_the_config"]}')
Logger.info(f'[Modify]{language["input_a_city_name"]}')
gui_log.insert(f'[Modify]{language["input_a_city_name"]}')
while True:
time.sleep(0.3)
city_name = input('-->')
match city_name:
case 'q':
Logger.info(f'[Exit]{language["exit"]}')
sys.exit(0)
case '':
Logger.error(f'[Modify]{language["null_value"]}')
continue
case _:
break
searched_city = read_excel(city_name)
Logger.info(f'[Modify]{language["user_input"]}:[{city_name}]')
gui_log.insert(f'[Modify]{language["user_input"]}:[{city_name}]')
Logger.info(f'[Modify]{language["select_a_index"]}')
gui_log.insert(f'[Modify]{language["select_a_index"]}')
if not searched_city:
Logger.error(f'[Modify]{language["no_result"]}')
gui_log.insert(f'[Modify]{language["no_result"]}')
sys.exit(1)
time.sleep(0.3)
while True:
try:
time.sleep(0.3)
# if not gui:
user_input = input('-->')
# else:
# user_input = var_command.get()
if user_input == 'q':
Logger.info(f'[Exit]{language["exit"]}')
gui_log.insert(f'[Exit]{language["exit"]}')
sys.exit(1)
index = searched_city[int(user_input)]
with open('./config.yml', 'r', encoding='utf-8') as of:
data = YAML().load(of)
data['request-settings']['location'] = index[1]
data['only-view-settings']['city-name'] = f'{index[3]}-{index[7]}-{index[7]}'
data['only-view-settings']['time'] = time.strftime("%a %b %d %Y %H:%M:%S", time.localtime())
data['only-view-settings']['user'] = getpass.getuser()
with open('./config.yml', 'w', encoding='utf-8') as wf:
YAML().dump(data, wf)
Logger.info(f'[Write]{language["write_successfully"]}:config.yml')
gui_log.insert(f'[Write]{language["write_successfully"]}:config.yml')
break
except (IndexError, ValueError) as e:
Logger.info(e)
gui_log.insert(e)
Logger.error(f'[Write]{language["input_type_error"]}')
gui_log.insert(f'[Write]{language["input_type_error"]}')
continue
finally:
Logger.info(f'[Exit]{language["exit"]}')
gui_log.insert(f'[Exit]{language["exit"]}')
sys.exit(0)

58
lib/buildGUIClass.py Normal file
View File

@@ -0,0 +1,58 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/1/9
# @File Name: buildGUIClass.py
import tkinter
import tkinter as tk
root = tk.Tk()
root.title('QWeather client')
sw = root.winfo_screenwidth()
sh = root.winfo_screenheight()
ww = 700
wh = 490
x = (sw - ww) / 2
y = (sh - wh) / 2
root.geometry("%dx%d+%d+%d" % (ww, wh, x, y))
root.minsize(700, 490)
root.maxsize(700, 490)
log_label = tk.Label(root, text='Log information')
log_label.place(x=170, y=4)
log_text = tk.Text(root, width=55, height=15)
log_text.place(x=30, y=30)
var_command = tk.StringVar()
class InsertLog:
def __init__(self):
self.log_text = log_text
def insert(self, msg: str):
"""
insert the information to gui(Text)
:param msg: information
:return:
"""
if '\n' not in msg:
msg = msg + '\n'
self.log_text.configure(state=tkinter.NORMAL) # writable
self.log_text.insert('insert', msg) # insert information
self.log_text.configure(state=tkinter.DISABLED) # readable
class Features:
def __init__(self):
self.root = root
self.tk = tk
self.log_text = log_text
def quit_(self):
"""
quit gui
:return:
"""
self.root.destroy()
self.root.quit()

View File

@@ -10,17 +10,27 @@
启用等级: DEV
"""
from core.read_config import read_config
import requests
import json
def hourly_weather(location: int, key: str, lang: str = 'zh', unit: str = 'm'):
def hourly_weather():
"""
获取24小时的天气
:return:
"""
settings = read_config()
location = settings[1]['location']
key = settings[1]['key']
lang = settings[1]['lang']
unit = settings[1]['unit']
r = requests.get(
f'https://devapi.qweather.com/v7/weather/24h?location={location}&key={key}&lang={lang}&unit={unit}')
data = json.loads(r.text)
status_code = data['code']
updateTime = str(data['updateTime'][:-6]).replace('T', '')
updateTime = str(data['updateTime'][:-6])[10:].replace('T', '')
main_data = data['hourly'] # 24
return status_code, updateTime, main_data

View File

@@ -11,11 +11,21 @@
启用等级: DEV
"""
from core.read_config import read_config
import requests
import json
def indices(location: int, key: str, lang: str = 'zh', unit: str = 'm'):
def indices():
"""
获取生活建议
:return:
"""
settings = read_config()
location = settings[1]['location']
key = settings[1]['key']
lang = settings[1]['lang']
unit = settings[1]['unit']
r = requests.get(
f'https://devapi.qweather.com/v7/indices/1d?type=0&location={location}&key={key}&lang={lang}&unit={unit}')
data = json.loads(r.text)

View File

@@ -10,29 +10,24 @@
启用等级: 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())
"""
获取实时的空气质量数据
:return:
"""
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']

View File

@@ -10,18 +10,19 @@
启用等级: DEV
"""
from core.read_config import read_config
import requests
import json
from ruamel.yaml import YAML
def get_warning_list(_range='cn'):
yaml = YAML()
with open('./config.yml', 'r', encoding='utf-8') as f:
config = yaml.load(f.read())
key = config['request-settings']['key']
session = requests.Session()
session.trust_env = False
r = session.get(f'https://devapi.qweather.com/v7/warning/list?range={_range}&key={key}')
"""
获取当前正在发送自然灾害的城市id列表
:param _range: Range
:return:
"""
settings = read_config()
key = settings[1]['key']
r = requests.get(f'https://devapi.qweather.com/v7/warning/list?range={_range}&key={key}')
_data = json.loads(r.text)
return _data['code'], _data['warningLocList'][0]['locationId']

23
lib/hitokoto.py Normal file
View File

@@ -0,0 +1,23 @@
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/24
# @File Name: hitokoto.py
import requests
from core.language import Language
from core.logger import Logger
def hitokoto():
language = Language()
url = 'https://v1.hitokoto.cn/'
Logger.info(f'{language["hitokoto"]}')
res = requests.get(url).json()
speaker = res['from_who']
text = res['hitokoto']
if not speaker:
speaker = language['noname']
full_text = f'{text} --{speaker}'
return full_text

344
lib/webservice.py Normal file
View File

@@ -0,0 +1,344 @@
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2021/12/18
# @File Name: webservice.py
import socket
import threading
from core.logger import Logger
from core.read_config import read_config
from core.information import WeatherInfo
from core.language import Language
from lib.buildGUIClass import InsertLog
gui_log = InsertLog()
try:
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(('0.0.0.0', 7898))
server.listen(5)
except OSError as e:
Logger.critical(e)
gui_log.insert(e)
language = Language()
def build_html():
"""
构建html主体
:return:
"""
settings = read_config()
city = settings[3]['city-name']
mode = settings[1]['mode']
match mode:
case 'dev':
dev_weather = WeatherInfo().dev_version()
dates = dev_weather[0]
day_weathers = dev_weather[1]
night_weathers = dev_weather[2]
highest_temps = dev_weather[3]
lowest_temps = dev_weather[4]
icons = dev_weather[5]
sunset = dev_weather[6]
sunrise = dev_weather[7]
humidity = dev_weather[8]
wind_speed = dev_weather[9]
wind_scale = dev_weather[10]
wind_dir = dev_weather[11]
uv_index = dev_weather[12]
cloud = dev_weather[13]
pressure = dev_weather[14]
vis = dev_weather[15]
html = f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>QWeather|网页查看天气服务</title>
</head>
<body>
<p style="text-align: center"><i><b>地区:{city}</b></i></p>
<br />
<table style="border: 0; text-align: center; margin:0 auto">
<tr>
<th>|&nbsp;日期&nbsp;&nbsp;</th>
<th>|&nbsp;天气&nbsp;&nbsp;</th>
<th>|&nbsp;最低温度&nbsp;&nbsp;</th>
<th>|&nbsp;最高温度&nbsp;&nbsp;</th>
</tr>
<tr>
<!--日期 天气 最低 最高/Date Weather LowestTemp HighestTemp-->
<td>今天</td>
<td>{day_weathers[0]}<img src="./res/icons/{icons[0]}.png" width="20" alt="">/{night_weathers[0]}
<img src="./res/icons/{icons[1]}.png"
width="20" alt=""></td> <td>{lowest_temps[0]}℃</td>
<td>{highest_temps[0]}℃</td>
</tr>
<tr>
<td>{dates[1]}</td>
<td>{day_weathers[1]}<img src="./res/icons/{icons[2]}.png" width="20" alt="">/{night_weathers[1]}
<img src="./res/icons/{icons[3]}.png"
width="20" alt=""></td> <td>{lowest_temps[1]}℃</td>
<td>{highest_temps[1]}℃</td>
</tr>
<tr>
<td>{dates[2]}</td>
<td>{day_weathers[2]}<img src="./res/icons/{icons[4]}.png" width="20" alt="">/{night_weathers[2]}
<img src="./res/icons/{icons[5]}.png"
width="20" alt=""></td> <td>{lowest_temps[2]}℃</td>
<td>{highest_temps[2]}℃</td>
</tr>
<tr>
<td>{dates[3]}</td>
<td>{day_weathers[3]}<img src="./res/icons/{icons[6]}.png" width="20" alt="">/{night_weathers[3]}
<img src="./res/icons/{icons[7]}.png"
width="20" alt=""></td> <td>{lowest_temps[3]}℃</td>
<td>{highest_temps[3]}℃</td>
</tr>
<tr>
<td>{dates[4]}</td>
<td>{day_weathers[4]}<img src="./res/icons/{icons[8]}.png" width="20" alt="">/{night_weathers[4]}
<img src="./res/icons/{icons[9]}.png"
width="20" alt=""></td> <td>{lowest_temps[4]}℃</td>
<td>{highest_temps[4]}℃</td>
</tr>
<tr>
<td>{dates[5]}</td>
<td>{day_weathers[5]}<img src="./res/icons/{icons[10]}.png" width="20" alt="">/{night_weathers[5]}
<img src="./res/icons/{icons[11]}.png"
width="20" alt=""></td> <td>{lowest_temps[5]}℃</td>
<td>{highest_temps[5]}℃</td>
</tr>
<tr>
<td>{dates[6]}</td>
<td>{day_weathers[6]}<img src="./res/icons/{icons[12]}.png" width="20" alt="">/{night_weathers[6]}
<img src="./res/icons/{icons[13]}.png"
width="20" alt=""></td> <td>{lowest_temps[6]}℃</td>
<td>{highest_temps[6]}℃</td>
</tr>
</table>
<table style="border: 0;text-align: center; margin:0 auto">
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th>风速/级/向</th>
<th>湿度</th>
<th>紫外线</th>
</tr>
<tr>
<td>{wind_speed}m/s&nbsp; {wind_scale}&nbsp; {wind_dir}&nbsp;</td>
<td>{humidity}%&nbsp;</td>
<td>{uv_index}&nbsp;</td>
</tr>
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th>能见度</th>
<th>压强</th>
<th>云量</th>
</tr>
<tr>
<td>{vis}km&nbsp;</td>
<td>{pressure}hPa&nbsp;</td>
<td>{cloud}%&nbsp;</td>
</tr>
</table>
<table style="border: 0;text-align: center; margin:0 auto">
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<td><img src="./res/basic-resources/sunrise.png" alt="Sunrise" width="30"></td>
<td>&nbsp;</td>
<td><img src="./res/basic-resources/sunset.png" alt="Sunset" width="30"></td>
</tr>
<tr>
<td>&nbsp;{sunrise}&nbsp;</td>
<td>---------------</td>
<td>&nbsp;{sunset}&nbsp;</td>
</tr>
</table>
<div style="text-align: center;" id="About">
<br />
<br />
<br />
<i>
<b>
<a href="https://dev.qweather.com/" style="color: black" target="_blank">QWeather</a>
<a style="color: black">&nbsp;·&nbsp;</a>
<a href="https://github.com/MarkusJoe/QWeather" style="color: black" target="_blank">Github Repo</a>
</b>
</i>
</div>
</body>
</html>"""
return html
case 'free':
dev_weather = WeatherInfo().free_version()
dates = dev_weather[0]
day_weathers = dev_weather[1]
night_weathers = dev_weather[2]
highest_temps = dev_weather[3]
lowest_temps = dev_weather[4]
icons = dev_weather[5]
sunset = dev_weather[6]
sunrise = dev_weather[7]
humidity = dev_weather[8]
wind_speed = dev_weather[9]
wind_scale = dev_weather[10]
wind_dir = dev_weather[11]
uv_index = dev_weather[12]
cloud = dev_weather[13]
pressure = dev_weather[14]
vis = dev_weather[15]
html = f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>QWeather|网页查看天气服务</title>
</head>
<body>
<p style="text-align: center"><i><b>地区:{city}</b></i></p>
<br />
<table style="border: 0; text-align: center; margin:0 auto">
<tr>
<th>|&nbsp;日期&nbsp;&nbsp;</th>
<th>|&nbsp;天气&nbsp;&nbsp;</th>
<th>|&nbsp;最低温度&nbsp;&nbsp;</th>
<th>|&nbsp;最高温度&nbsp;&nbsp;</th>
</tr>
<tr>
<!--日期 天气 最低 最高/Date Weather LowestTemp HighestTemp-->
<td>今天</td>
<td>{day_weathers[0]}<img src="./res/icons/{icons[0]}.png" width="20" alt="">/{night_weathers[0]}
<img src="./res/icons/{icons[1]}.png"
width="20" alt=""></td> <td>{lowest_temps[0]}℃</td>
<td>{highest_temps[0]}℃</td>
</tr>
<tr>
<td>{dates[1]}</td>
<td>{day_weathers[1]}<img src="./res/icons/{icons[2]}.png" width="20" alt="">/{night_weathers[1]}
<img src="./res/icons/{icons[3]}.png"
width="20" alt=""></td> <td>{lowest_temps[1]}℃</td>
<td>{highest_temps[1]}℃</td>
</tr>
<tr>
<td>{dates[2]}</td>
<td>{day_weathers[2]}<img src="./res/icons/{icons[4]}.png" width="20" alt="">/{night_weathers[2]}
<img src="./res/icons/{icons[5]}.png"
width="20" alt=""></td> <td>{lowest_temps[2]}℃</td>
<td>{highest_temps[2]}℃</td>
</table>
<table style="border: 0;text-align: center; margin:0 auto">
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th>风速/风级/风向</th>
<th>相对湿度</th>
<th>紫外线</th>
</tr>
<tr>
<td>{wind_speed}m/s&nbsp; {wind_scale}&nbsp; {wind_dir}&nbsp;</td>
<td>{humidity}%&nbsp;</td>
<td>{uv_index}&nbsp;</td>
</tr>
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th>能见度</th>
<th>压强</th>
<th>云量</th>
</tr>
<tr>
<td>{vis}km&nbsp;</td>
<td>{pressure}hPa&nbsp;</td>
<td>{cloud}%&nbsp;</td>
</tr>
</table>
<table style="border: 0;text-align: center; margin:0 auto">
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<td><img src="./res/basic-resources/sunrise.png" alt="Sunrise" width="30"></td>
<td>&nbsp;</td>
<td><img src="./res/basic-resources/sunset.png" alt="Sunset" width="30"></td>
</tr>
<tr>
<td>&nbsp;{sunrise}&nbsp;</td>
<td>---------------</td>
<td>&nbsp;{sunset}&nbsp;</td>
</tr>
</table>
<div style="text-align: center;" id="About">
<br />
<br />
<br />
<i>
<b>
<a href="https://dev.qweather.com/" style="color: black" target="_blank">QWeather</a>
<a style="color: black">&nbsp;·&nbsp;</a>
<a href="https://github.com/MarkusJoe/QWeather" style="color: black" target="_blank">Github Repo</a>
</b>
</i>
</div>
</body>
</html>"""
return html
case _:
return "You hadn't selected a mode"
def process_requests(c, a):
"""
处理请求
:param c: connection
:param a: address
:return:
"""
try:
data = str(c.recv(1024)).split(':')[0][6:][:-17]
html = build_html()
if data == '/': # 判断用户请求的目标是否为根目录, 如果是则返回html; 如果不是则继续判断
c.send('HTTP/1.1 200 OK\r\n\r\n'.encode('utf-8'))
c.send(html.encode('utf-8'))
Logger.info(f'{language["get_resource"]} {data} {language["get_resource_from"]} {a[0]}:{a[1]}')
gui_log.insert(f'{language["get_resource"]} {data} {language["get_resource_from"]} {a[0]}:{a[1]}')
try:
with open(f'./{data}', 'rb') as f:
c.send('HTTP/1.1 200 OK\r\n\r\n'.encode('utf-8'))
c.send(f.read())
Logger.info(f'{language["get_resource"]} {data} {language["get_resource_from"]} {a[0]}:{a[1]}')
gui_log.insert(f'{language["get_resource"]} {data} {language["get_resource_from"]} {a[0]}:{a[1]}')
except FileNotFoundError:
with open('./res/basic-resources/404.html', 'r') as not_found:
c.send(f'HTTP/1.1 404 Not Found\r\n\r\n{not_found.read()}'.encode('utf-8'))
except BrokenPipeError:
Logger.error(f'{language["connection_speed_too_fast"]}')
gui_log.insert(f'{language["connection_speed_too_fast"]}')
finally:
c.close()
return
def accept_requests():
"""
接受请求
:return:
"""
while True:
c, a = server.accept()
threading.Thread(target=process_requests, args=(c, a,)).start()

View File

@@ -1,7 +1,5 @@
requests==2.26.0
ruamel.yaml==0.17.17
pandas==1.3.4
pyppeteer==0.2.6
bs4==0.0.1
openpyxl==3.0.9
colorlog==6.5.0
requests>=2.26.0
ruamel.yaml>=0.17.17
pandas>=1.3.4
colorlog>=6.5.0
openpyxl>=3.0.9

View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>QWeather|网页查看天气服务</title>
</head>
<body>
<i><b><p style="text-align: center; color: red">404 File Not Found</p></b></i>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Some files were not shown because too many files have changed in this diff Show More