deep-wine-runner/req/__init__.py

28 lines
902 B
Python
Raw Normal View History

2023-03-19 15:49:49 +08:00
# 此库用于实现 52 版不连接程序服务器(不再区分)
2022-09-24 21:02:50 +08:00
import requests
2022-09-24 19:54:08 +08:00
unConnect = False
2023-03-19 15:49:49 +08:00
# 不再区分吾爱版
2023-03-19 14:58:20 +08:00
#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专版将会无法连接服务器")
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:
2023-03-19 15:49:49 +08:00
#if unConnect:
2022-12-04 19:29:09 +08:00
# 全部 Url 都拦截
2023-03-19 15:49:49 +08:00
#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):
2023-03-19 15:49:49 +08:00
#if unConnect:
2022-12-04 19:29:09 +08:00
# 全部 Url 都拦截
2023-03-19 15:49:49 +08:00
# 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)