mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:...
This commit is contained in:
parent
50bb12561b
commit
cd15edb7ba
@ -327,36 +327,37 @@ def extract(path, dir):
|
||||
extractor(path, dir)
|
||||
|
||||
def get_proxies():
|
||||
proxies = {}
|
||||
if iswindows:
|
||||
try:
|
||||
winreg = __import__('_winreg')
|
||||
settings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
|
||||
'Software\\Microsoft\\Windows'
|
||||
'\\CurrentVersion\\Internet Settings')
|
||||
proxy = winreg.QueryValueEx(settings, "ProxyEnable")[0]
|
||||
if proxy:
|
||||
server = str(winreg.QueryValueEx(settings, 'ProxyServer')[0])
|
||||
if ';' in server:
|
||||
for p in server.split(';'):
|
||||
protocol, address = p.split('=')
|
||||
proxies[protocol] = address
|
||||
else:
|
||||
proxies['http'] = server
|
||||
proxies['ftp'] = server
|
||||
settings.Close()
|
||||
except Exception, e:
|
||||
print('Unable to detect proxy settings: %s' % str(e))
|
||||
if proxies:
|
||||
print('Using proxies: %s' % proxies)
|
||||
else:
|
||||
for q in ('http', 'ftp'):
|
||||
proxy = os.environ.get(q+'_proxy', None)
|
||||
if not proxy: continue
|
||||
if proxy.startswith(q+'://'):
|
||||
proxy = proxy[7:]
|
||||
proxies[q] = proxy
|
||||
return proxies
|
||||
proxies = {}
|
||||
|
||||
for q in ('http', 'ftp'):
|
||||
proxy = os.environ.get(q+'_proxy', None)
|
||||
if not proxy: continue
|
||||
if proxy.startswith(q+'://'):
|
||||
proxy = proxy[7:]
|
||||
proxies[q] = proxy
|
||||
|
||||
if iswindows:
|
||||
try:
|
||||
winreg = __import__('_winreg')
|
||||
settings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
|
||||
'Software\\Microsoft\\Windows'
|
||||
'\\CurrentVersion\\Internet Settings')
|
||||
proxy = winreg.QueryValueEx(settings, "ProxyEnable")[0]
|
||||
if proxy:
|
||||
server = str(winreg.QueryValueEx(settings, 'ProxyServer')[0])
|
||||
if ';' in server:
|
||||
for p in server.split(';'):
|
||||
protocol, address = p.split('=')
|
||||
proxies[protocol] = address
|
||||
else:
|
||||
proxies['http'] = server
|
||||
proxies['ftp'] = server
|
||||
settings.Close()
|
||||
except Exception, e:
|
||||
print('Unable to detect proxy settings: %s' % str(e))
|
||||
if proxies:
|
||||
print('Using proxies: %s' % proxies)
|
||||
return proxies
|
||||
|
||||
|
||||
def browser(honor_time=False):
|
||||
|
@ -21,10 +21,11 @@ if iswindows:
|
||||
elif isosx:
|
||||
config_dir = os.path.expanduser('~/Library/Preferences/calibre')
|
||||
else:
|
||||
config_dir = os.path.expanduser('~/.config/calibre')
|
||||
bdir = os.path.abspath(os.path.expanduser(os.environ.get('XDG_CONFIG_HOME', '~/.config')))
|
||||
config_dir = os.path.join(bdir, 'calibre')
|
||||
|
||||
if not os.path.exists(config_dir):
|
||||
os.makedirs(config_dir)
|
||||
os.makedirs(config_dir, mode=448) # 0700 == 448
|
||||
|
||||
class Option(object):
|
||||
|
||||
|
@ -73,11 +73,6 @@ MAP = {
|
||||
u"ь" : u"'",
|
||||
} #: Translation table
|
||||
|
||||
for c in string.whitespace:
|
||||
MAP[c] = ' '
|
||||
PAT = re.compile('['+u''.join(MAP.keys())+']')
|
||||
print repr('['+u''.join(MAP.keys())+']')
|
||||
|
||||
def ascii_filename(orig):
|
||||
orig = PAT.sub(lambda m:MAP[m.group()], orig)
|
||||
buf = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user