-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtodo
More file actions
136 lines (116 loc) · 5.15 KB
/
todo
File metadata and controls
136 lines (116 loc) · 5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# 我希望实现以下功能,具体怎样实现比较好:
# 我有一台iphone设备,我喜欢使用其中的reminders功能。我有一台服务器,有logs数据库。
# 我有自建的nextcloud tasks服务,支持caldav协议,iphone已经同步。
# 我想通过创建一个tag或列表的方式,在桌面添加一个小组件,显示今天复习的单词
# 所以我希望有个一便捷的方法,可以让我记录和自动完成每日单词。具体来说
# - 当我背单词遇到一个生词,我可以快速记录(使用手机记录太麻烦了,最好可以通过电脑记录)
# - 旧的一天单词删除的条件是:新的一天有新的单词记录。
# - 添加单词时候不要在reminder中直接记录时间(可以记录到备注等但是不要真的设置时间,不然我reminder中通过时间筛选todo就会很慢),删除单词的时候设置单词截止时间是添加时间再“完成”
# record ppt字体
# newSolution.py go自动4space2tab
# 源码转md时自动tab24space
# auto remove last empty line
# 记录iphone快捷指令 自动化 当到达某位置时触发
# move beautify.sh to github repo/gist
# record: py proxy
# Python\Lib\site-packages\requests\utils.py
# F:\OtherApps\Program\Python\Python\Lib\urllib\request.py
"""
2689行的proxies['https'] = 'https://%s' % proxyServer
修改为了
if '127.0.0.1' in proxyServer or 'localhost' in proxyServer:
proxies['https'] = 'http://%s' % proxyServer
else:
proxies['https'] = 'https://%s' % proxyServer
"""
import re
import os
def should_bypass_proxies(a, no_proxy):
return False
def getproxies_registry():
"""Return a dictionary of scheme -> proxy server URL mappings.
Win32 uses the registry to store proxies.
"""
proxies = {}
try:
import winreg
except ImportError:
# Std module, so should be around - but you never know!
return proxies
try:
internetSettings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')
proxyEnable = winreg.QueryValueEx(internetSettings,
'ProxyEnable')[0]
if proxyEnable:
# Returned as Unicode but problems if not converted to ASCII
proxyServer = str(winreg.QueryValueEx(internetSettings,
'ProxyServer')[0])
if '=' in proxyServer:
# Per-protocol settings
for p in proxyServer.split(';'):
protocol, address = p.split('=', 1)
# See if address has a type:// prefix
if not re.match('(?:[^/:]+)://', address):
address = '%s://%s' % (protocol, address)
proxies[protocol] = address
else:
# Use one setting for all protocols
if proxyServer[:5] == 'http:':
proxies['http'] = proxyServer
else:
proxies['http'] = 'http://%s' % proxyServer
proxies['https'] = 'https://%s' % proxyServer
proxies['ftp'] = 'ftp://%s' % proxyServer
internetSettings.Close()
except (OSError, ValueError, TypeError):
# Either registry key not found etc, or the value in an
# unexpected format.
# proxies already set up to be empty so nothing to do
pass
return proxies
# Proxy handling
def getproxies_environment():
"""Return a dictionary of scheme -> proxy server URL mappings.
Scan the environment for variables named <scheme>_proxy;
this seems to be the standard convention. If you need a
different way, you can pass a proxies dictionary to the
[Fancy]URLopener constructor.
"""
proxies = {}
# in order to prefer lowercase variables, process environment in
# two passes: first matches any, second pass matches lowercase only
for name, value in os.environ.items():
name = name.lower()
if value and name[-6:] == '_proxy':
proxies[name[:-6]] = value
# CVE-2016-1000110 - If we are running as CGI script, forget HTTP_PROXY
# (non-all-lowercase) as it may be set from the web server by a "Proxy:"
# header from the client
# If "proxy" is lowercase, it will still be used thanks to the next block
if 'REQUEST_METHOD' in os.environ:
proxies.pop('http', None)
for name, value in os.environ.items():
if name[-6:] == '_proxy':
name = name.lower()
if value:
proxies[name[:-6]] = value
else:
proxies.pop(name[:-6], None)
return proxies
def getproxies():
"""Return a dictionary of scheme -> proxy server URL mappings.
Returns settings gathered from the environment, if specified,
or the registry.
"""
return getproxies_environment() or getproxies_registry()
def get_environ_proxies(url, no_proxy=None):
"""
Return a dict of environment proxies.
:rtype: dict
"""
if should_bypass_proxies(url, no_proxy=no_proxy):
return {}
else:
return getproxies()
print(get_environ_proxies("https://letmefly.xyz"))