deep-wine-runner/req/__init__.py

38 lines
1.1 KiB
Python
Raw Normal View History

2022-09-24 19:54:08 +08:00
# 此库用于实现 52 版不连接程序服务器
2022-09-24 21:02:50 +08:00
import requests
2022-09-24 19:54:08 +08:00
unConnect = False
with open("/var/lib/dpkg/status", "r") as i:
unConnect = "Package: spark-deepin-wine-runner-52" in open("/var/lib/dpkg/status", "r").read()
if unConnect:
print("52专版将会无法连接服务器")
badUrl = [
"http://120.25.153.144",
"https://304626p927.goho.co",
2022-11-06 17:35:41 +08:00
"https://30x46269h2.goho.co",
"http://gfdgdxi.msns.cn"
2022-09-24 19:54:08 +08:00
]
class Respon:
text = ""
2022-10-26 21:50:59 +08:00
def get(url, timeout=None): # -> requests.Response:
2022-09-24 19:54:08 +08:00
if unConnect:
# 筛选 Url只有特定的 url 才会被拦截
for i in badUrl:
if i in url:
raise Exception("52专版不支持连接作者服务器")
2022-10-26 21:50:59 +08:00
if timeout == None:
return requests.get(url)
return requests.get(url, timeout=timeout)
2022-09-24 19:54:08 +08:00
2022-10-26 21:50:59 +08:00
def post(url, data, timeout=None):
2022-09-24 19:54:08 +08:00
if unConnect:
# 筛选 Url只有特定的 url 才会被拦截
for i in badUrl:
if i in url:
raise Exception("52专版不支持连接作者服务器")
2022-10-26 21:50:59 +08:00
if timeout == None:
return requests.post(url, data)
return requests.post(url, data, timeout=timeout)