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)
|
extractor(path, dir)
|
||||||
|
|
||||||
def get_proxies():
|
def get_proxies():
|
||||||
proxies = {}
|
proxies = {}
|
||||||
if iswindows:
|
|
||||||
try:
|
for q in ('http', 'ftp'):
|
||||||
winreg = __import__('_winreg')
|
proxy = os.environ.get(q+'_proxy', None)
|
||||||
settings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
|
if not proxy: continue
|
||||||
'Software\\Microsoft\\Windows'
|
if proxy.startswith(q+'://'):
|
||||||
'\\CurrentVersion\\Internet Settings')
|
proxy = proxy[7:]
|
||||||
proxy = winreg.QueryValueEx(settings, "ProxyEnable")[0]
|
proxies[q] = proxy
|
||||||
if proxy:
|
|
||||||
server = str(winreg.QueryValueEx(settings, 'ProxyServer')[0])
|
if iswindows:
|
||||||
if ';' in server:
|
try:
|
||||||
for p in server.split(';'):
|
winreg = __import__('_winreg')
|
||||||
protocol, address = p.split('=')
|
settings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
|
||||||
proxies[protocol] = address
|
'Software\\Microsoft\\Windows'
|
||||||
else:
|
'\\CurrentVersion\\Internet Settings')
|
||||||
proxies['http'] = server
|
proxy = winreg.QueryValueEx(settings, "ProxyEnable")[0]
|
||||||
proxies['ftp'] = server
|
if proxy:
|
||||||
settings.Close()
|
server = str(winreg.QueryValueEx(settings, 'ProxyServer')[0])
|
||||||
except Exception, e:
|
if ';' in server:
|
||||||
print('Unable to detect proxy settings: %s' % str(e))
|
for p in server.split(';'):
|
||||||
if proxies:
|
protocol, address = p.split('=')
|
||||||
print('Using proxies: %s' % proxies)
|
proxies[protocol] = address
|
||||||
else:
|
else:
|
||||||
for q in ('http', 'ftp'):
|
proxies['http'] = server
|
||||||
proxy = os.environ.get(q+'_proxy', None)
|
proxies['ftp'] = server
|
||||||
if not proxy: continue
|
settings.Close()
|
||||||
if proxy.startswith(q+'://'):
|
except Exception, e:
|
||||||
proxy = proxy[7:]
|
print('Unable to detect proxy settings: %s' % str(e))
|
||||||
proxies[q] = proxy
|
if proxies:
|
||||||
return proxies
|
print('Using proxies: %s' % proxies)
|
||||||
|
return proxies
|
||||||
|
|
||||||
|
|
||||||
def browser(honor_time=False):
|
def browser(honor_time=False):
|
||||||
|
@ -21,10 +21,11 @@ if iswindows:
|
|||||||
elif isosx:
|
elif isosx:
|
||||||
config_dir = os.path.expanduser('~/Library/Preferences/calibre')
|
config_dir = os.path.expanduser('~/Library/Preferences/calibre')
|
||||||
else:
|
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):
|
if not os.path.exists(config_dir):
|
||||||
os.makedirs(config_dir)
|
os.makedirs(config_dir, mode=448) # 0700 == 448
|
||||||
|
|
||||||
class Option(object):
|
class Option(object):
|
||||||
|
|
||||||
|
@ -73,11 +73,6 @@ MAP = {
|
|||||||
u"ь" : u"'",
|
u"ь" : u"'",
|
||||||
} #: Translation table
|
} #: 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):
|
def ascii_filename(orig):
|
||||||
orig = PAT.sub(lambda m:MAP[m.group()], orig)
|
orig = PAT.sub(lambda m:MAP[m.group()], orig)
|
||||||
buf = []
|
buf = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user