Sublime Text 3 安装 Package Control 组件 (设置HTTP代理)

快捷键:< *Ctrl + `* >,打开console,命令如下:

import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); proxyConfig = 'http://%s:%s' % ('proxy_host', proxy_port);proxyHandler=urllib.request.ProxyHandler({'http':proxyConfig});defaultHTTPPasswordMgr=urllib.request.HTTPPasswordMgrWithDefaultRealm();proxy_auth_handler = urllib.request.ProxyBasicAuthHandler(defaultHTTPPasswordMgr);proxy_auth_handler.add_password(None, proxyConfig, 'proxy_auth_user', 'proxy_auth_password') ;urllib.request.install_opener( urllib.request.build_opener( proxy_handler,proxy_auth_handler )); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())

替换以上proxy_host(代理主机域名)\proxy_port(代理主机端口)\proxy_auth_user(代理认证用户名)\proxy_auth_password(代理认证密码)即可。

可读代码如下:

import urllib.request,os;   
pf = 'Package Control.sublime-package';    
ipp = sublime.installed_packages_path();   
proxyConfig = 'http://%s:%s' % ('proxy_host', proxy_port);  
proxyHandler=urllib.request.ProxyHandler({'http':proxyConfig});  
defaultHTTPPasswordMgr=urllib.request.HTTPPasswordMgrWithDefaultRealm();  
proxy_auth_handler = urllib.request.ProxyBasicAuthHandler(defaultHTTPPasswordMgr);  
proxy_auth_handler.add_password(None, proxyConfig, 'proxy_auth_user', 'proxy_auth_password') ;  
urllib.request.install_opener( urllib.request.build_opener( proxy_handler,proxy_auth_handler ));   
open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())

你可能感兴趣的:(安装,sublimetext3,packagecontrol,设置HTTP代理)