Skip to content

Commit

Permalink
Windows下导出截图时不重复询问是否覆盖文件
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoZuohong committed Nov 18, 2023
1 parent 48512b3 commit 4d2dca2
Showing 1 changed file with 62 additions and 46 deletions.
108 changes: 62 additions & 46 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import tkinter
from tkinter import messagebox

import platform

mimetypes.add_type("text/html", ".html")
mimetypes.add_type("text/css", ".css")
mimetypes.add_type("application/javascript", ".js")
Expand Down Expand Up @@ -255,7 +257,7 @@ def save_file_dialog():
return "保存已取消"
if not isinstance(img_path, str):
img_path = img_path[0]
if os.path.exists(img_path):
if os.path.exists(img_path) and platform.system() == "Linux":
root = tkinter.Tk()
root.withdraw()
replace = messagebox.askyesno(
Expand Down Expand Up @@ -296,9 +298,9 @@ def get_maa_adb_version():
def get_maa_conn_presets():
try:
with open(
os.path.join(conf["maa_path"], "resource", "config.json"),
"r",
encoding="utf-8",
os.path.join(conf["maa_path"], "resource", "config.json"),
"r",
encoding="utf-8",
) as f:
presets = [i["configName"] for i in json.load(f)["connection"]]
except:
Expand Down Expand Up @@ -333,30 +335,37 @@ def get_report_data():
if os.path.exists(record_path) is False:
logger.debug("基报不存在")
return False
df = pd.read_csv(record_path, encoding='gbk')
data = df.to_dict('records')
earliest_date = str2date(data[0]['Unnamed: 0'])
df = pd.read_csv(record_path, encoding="gbk")
data = df.to_dict("records")
earliest_date = str2date(data[0]["Unnamed: 0"])

for item in data:
format_data.append({
"日期": date2str(str2date(item['Unnamed: 0']) - datetime.timedelta(days=1)),
'作战录像': item['作战录像'],
'赤金': item['赤金'],
'龙门币订单': item['龙门币订单'],
'龙门币订单数': item['龙门币订单数'],
'每单获取龙门币': int(item['龙门币订单'] / item['龙门币订单数']),
})
format_data.append(
{
"日期": date2str(
str2date(item["Unnamed: 0"]) - datetime.timedelta(days=1)
),
"作战录像": item["作战录像"],
"赤金": item["赤金"],
"龙门币订单": item["龙门币订单"],
"龙门币订单数": item["龙门币订单数"],
"每单获取龙门币": int(item["龙门币订单"] / item["龙门币订单数"]),
}
)

if len(format_data) < 15:
for i in range(1, 16 - len(format_data)):
format_data.insert(0, {
"日期": date2str(earliest_date - datetime.timedelta(days=i+1)),
'作战录像': '-',
'赤金': '-',
'龙门币订单': '-',
'龙门币订单数': '-',
'每单获取龙门币': '-',
})
format_data.insert(
0,
{
"日期": date2str(earliest_date - datetime.timedelta(days=i + 1)),
"作战录像": "-",
"赤金": "-",
"龙门币订单": "-",
"龙门币订单数": "-",
"每单获取龙门币": "-",
},
)
logger.debug(format_data)
return format_data
except PermissionError:
Expand All @@ -371,8 +380,8 @@ def get_half_month_data():
if os.path.exists(record_path) is False:
logger.debug("基报不存在")
return False
df = pd.read_csv(record_path, encoding='gbk')
data = df.to_dict('records')
df = pd.read_csv(record_path, encoding="gbk")
data = df.to_dict("records")
earliest_date = datetime.datetime.now()

begin_make_orundum = (earliest_date + datetime.timedelta(days=1)).date()
Expand All @@ -382,36 +391,43 @@ def get_half_month_data():
if 0 < i < len(data) - 15:
data.pop(i)
else:
logger.info("合成玉{}".format(data[i]['合成玉']))
if data[i]['合成玉'] > 0:
begin_make_orundum = str2date(data[i]['Unnamed: 0'])
logger.info("合成玉{}".format(data[i]["合成玉"]))
if data[i]["合成玉"] > 0:
begin_make_orundum = str2date(data[i]["Unnamed: 0"])
else:
for item in data:
if item['合成玉'] > 0:
begin_make_orundum = str2date(item['Unnamed: 0'])
if item["合成玉"] > 0:
begin_make_orundum = str2date(item["Unnamed: 0"])
if begin_make_orundum > earliest_date.date():
return format_data
total_orundum = 0
for item in data:
total_orundum = total_orundum + item['合成玉']
format_data.append({
"日期": date2str(str2date(item['Unnamed: 0']) - datetime.timedelta(days=1)),
'合成玉': item['合成玉'],
'合成玉订单数量': item['合成玉订单数量'],
'抽数': round((item['合成玉'] / 600), 1),
'累计制造合成玉': total_orundum
})
total_orundum = total_orundum + item["合成玉"]
format_data.append(
{
"日期": date2str(
str2date(item["Unnamed: 0"]) - datetime.timedelta(days=1)
),
"合成玉": item["合成玉"],
"合成玉订单数量": item["合成玉订单数量"],
"抽数": round((item["合成玉"] / 600), 1),
"累计制造合成玉": total_orundum,
}
)

if len(format_data) < 15:
earliest_date = str2date(data[0]['Unnamed: 0'])
earliest_date = str2date(data[0]["Unnamed: 0"])
for i in range(1, 16 - len(format_data)):
format_data.insert(0, {
"日期": date2str(earliest_date - datetime.timedelta(days=i+1)),
'合成玉': '-',
'合成玉订单数量': '-',
'抽数': '-',
'累计制造合成玉': 0,
})
format_data.insert(
0,
{
"日期": date2str(earliest_date - datetime.timedelta(days=i + 1)),
"合成玉": "-",
"合成玉订单数量": "-",
"抽数": "-",
"累计制造合成玉": 0,
},
)
logger.debug(format_data)
return format_data
except PermissionError:
Expand Down

0 comments on commit 4d2dca2

Please sign in to comment.