Sublime text 3安装package control

推荐使用package control来安装

按Ctrl+`或View > Show Console 打开命令控制行

 

sublime text 3输入:

import urllib.request,os,hashlib; h = ‘2915d1851351e5ee549c20394736b442’ + ‘8bc59f460fa1548d1514676163dafc88’; pf = ‘Package Control.sublime-package’; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( ‘http://packagecontrol.io/’ + pf.replace(‘ ‘, ‘%20’)).read(); dh = hashlib.sha256(by).hexdigest(); print(‘Error validating download (got %s instead of %s), please try manual install’ % (dh, h)) if dh != h else open(os.path.join( ipp, pf), ‘wb’ ).write(by)

 

sublime text 2输入:

<code><span class="kwd">import</span><span class="pln"> urllib2</span><span class="pun">,</span><span class="pln">os</span><span class="pun">,</span><span class="pln">hashlib</span><span class="pun">;</span><span class="pln"> h </span><span class="pun">=</span> <span class="str">'7183a2d3e96f11eeadd761d777e62404'</span> <span class="pun">+</span> <span class="str">'e330c659d4bb41d3bdf022e94cab3cd0'</span><span class="pun">;</span><span class="pln"> pf </span><span class="pun">=</span> <span class="str">'Package Control.sublime-package'</span><span class="pun">;</span><span class="pln"> ipp </span><span class="pun">=</span><span class="pln"> sublime</span><span class="pun">.</span><span class="pln">installed_packages_path</span><span class="pun">();</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">makedirs</span><span class="pun">(</span><span class="pln"> ipp </span><span class="pun">)</span> <span class="kwd">if</span> <span class="kwd">not</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">path</span><span class="pun">.</span><span class="pln">exists</span><span class="pun">(</span><span class="pln">ipp</span><span class="pun">)</span> <span class="kwd">else</span> <span class="kwd">None</span><span class="pun">;</span><span class="pln"> urllib2</span><span class="pun">.</span><span class="pln">install_opener</span><span class="pun">(</span><span class="pln"> urllib2</span><span class="pun">.</span><span class="pln">build_opener</span><span class="pun">(</span><span class="pln"> urllib2</span><span class="pun">.</span><span class="typ">ProxyHandler</span><span class="pun">())</span> <span class="pun">);</span> <span class="kwd">by</span> <span class="pun">=</span><span class="pln"> urllib2</span><span class="pun">.</span><span class="pln">urlopen</span><span class="pun">(</span> <span class="str">'http://sublime.wbond.net/'</span> <span class="pun">+</span><span class="pln"> pf</span><span class="pun">.</span><span class="pln">replace</span><span class="pun">(</span><span class="str">' '</span><span class="pun">,</span> <span class="str">'%20'</span><span class="pun">)).</span><span class="pln">read</span><span class="pun">();</span><span class="pln"> dh </span><span class="pun">=</span><span class="pln"> hashlib</span><span class="pun">.</span><span class="pln">sha256</span><span class="pun">(</span><span class="kwd">by</span><span class="pun">).</span><span class="pln">hexdigest</span><span class="pun">();</span><span class="pln"> open</span><span class="pun">(</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">path</span><span class="pun">.</span><span class="pln">join</span><span class="pun">(</span><span class="pln"> ipp</span><span class="pun">,</span><span class="pln"> pf</span><span class="pun">),</span> <span class="str">'wb'</span> <span class="pun">).</span><span class="pln">write</span><span class="pun">(</span><span class="kwd">by</span><span class="pun">)</span> <span class="kwd">if</span><span class="pln"> dh </span><span class="pun">==</span><span class="pln"> h </span><span class="kwd">else</span> <span class="kwd">None</span><span class="pun">;</span> <span class="kwd">print</span><span class="pun">(</span><span class="str">'Error validating download (got %s instead of %s), please try manual install'</span> <span class="pun">%</span> <span class="pun">(</span><span class="pln">dh</span><span class="pun">,</span><span class="pln"> h</span><span class="pun">)</span> <span class="kwd">if</span><span class="pln"> dh </span><span class="pun">!=</span><span class="pln"> h </span><span class="kwd">else</span> <span class="str">'Please restart Sublime Text to finish installation'</span><span class="pun">)

</span></code>运行后即可



无觅相关文章插件,快速提升流量

标签:,

实在不堪垃圾评论的骚扰,还是禁止了吧,有事微博联系吧。