feat(SublimeText2.UtilPackages): cache packages

This commit is contained in:
Iristyle
2013-04-04 08:54:47 -04:00
parent 1e6f643a1b
commit d65666cdfc
541 changed files with 26347 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
# Environment-specific files such as configuration, logs, and setup
*.pyc
# Misc and OS files
Desktop.ini # Directory atttributes in Windows.
Thumbs.db # Picture thumbnail cache in Windows 98.
.DS_Store # Directory attributes in Mac OS X.

View File

@@ -0,0 +1,19 @@
Copyright (c) 2012 Joe Esposito
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,74 @@
Console Exec
============
Plugin for [Sublime Text 2][sublime] to execute a command in a console
window. After the process exits, the console remains open and displays
**"Press any key to exit"** before closing.
This plugin is based on the exec command shipped with Sublime Text, and
uses the launcher that ships with [Crimson Editor][crimson]
to wait for a keypress before closing the window.
![Running a Flask application screenshot][example]
Source [available on Github][repo].
[sublime]: http://www.sublimetext.com
[crimson]: http://crimsoneditor.com
[example]: https://raw.github.com/joeyespo/sublimetext-console-exec/master/examples/flask_application_screenshot.png
[repo]: http://github.com/joeyespo/sublimetext-console-exec
Why?
----
Aside from personal preference of having an external console in web projects,
- Sublime leaves your background process running when you quit
- Rebuilding a project overwrites your running process, leaking processes if you're not careful
- Certain environments such as [Pyglet][] will not run within the integrated console window
This plugin ties these loose ends in a familiar way.
[Pyglet]: http://www.pyglet.org
Usage
-----
In any **.sublime-build** file add the following line to run it in a console:
"target": "console_exec"
For example, here's a modified **Python.sublime-build** file:
{
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"target": "console_exec"
}
Note: you can find the appropriate build file from **"Browse Packages..."**
Installation
------------
With [Sublime Package Control][package_control], simply
1. Select **Package Control: Install Package** from the command palette
2. Locate **ConsoleExec** and press enter to install it
[package_control]: http://wbond.net/sublime_packages/package_control
#### Manual installation (advanced)
Clone this repository into the Packages directory.
To see where it's located enter `print sublime.packages_path()` in the console.
Notes
-----
This plugin is Windows-only for the moment.

View File

@@ -0,0 +1,107 @@
# -*- coding: utf-8 -*-
"""
Console Exec
Plugin for Sublime Text 2 to execute a command and redirect its output
into a console window. This is based on the default exec command.
"""
import sublime
import sublime_plugin
import os
import sys
import subprocess
import time
class Process(object):
def __init__(self, arg_list, env, listener,
# "path" is an option in build systems
path='',
# "shell" is an options in build systems
shell=False):
self.listener = listener
self.killed = False
self.start_time = time.time()
# Set temporary PATH to locate executable in arg_list
if path:
old_path = os.environ["PATH"]
# The user decides in the build system whether he wants to append $PATH
# or tuck it at the front: "$PATH;C:\\new\\path", "C:\\new\\path;$PATH"
os.environ["PATH"] = os.path.expandvars(path).encode(sys.getfilesystemencoding())
proc_env = os.environ.copy()
proc_env.update(env)
for k, v in proc_env.iteritems():
proc_env[k] = os.path.expandvars(v).encode(sys.getfilesystemencoding())
self.proc = subprocess.Popen(arg_list, env=proc_env, shell=shell)
if path:
os.environ["PATH"] = old_path
def kill(self):
if not self.killed:
self.killed = True
self.proc.terminate()
self.listener = None
def poll(self):
return self.proc.poll() == None
class ConsoleExecCommand(sublime_plugin.WindowCommand):
def run(self, cmd=[], file_regex='', line_regex='', working_dir='', encoding='utf-8', env={}, quiet=False, kill=False, **kwargs):
launcher = os.path.join(sublime.packages_path(), 'ConsoleExec', 'launch.exe')
if not os.path.exists(launcher):
if not quiet:
print 'Error: Could not find the ConsoleExec package.'
return
cmd = [launcher] + map(lambda s: '"%s"' % s if ' ' in s else s, cmd)
if kill:
if self.proc:
self.proc.kill()
self.proc = None
return
# Default the to the current files directory if no working directory was given
if (working_dir == '' and self.window.active_view()
and self.window.active_view().file_name()):
working_dir = os.path.dirname(self.window.active_view().file_name())
# Call get_output_panel a second time after assigning the above
# settings, so that it'll be picked up as a result buffer
self.window.get_output_panel("exec")
self.encoding = encoding
self.quiet = quiet
self.proc = None
if not self.quiet:
print "Running " + " ".join(cmd)
sublime.status_message("Building")
merged_env = env.copy()
if self.window.active_view():
user_env = self.window.active_view().settings().get('build_env')
if user_env:
merged_env.update(user_env)
# Change to the working dir, rather than spawning the process with it,
# so that emitted working dir relative path names make sense
if working_dir != '':
os.chdir(working_dir)
# Forward kwargs to Process
self.proc = Process(cmd, merged_env, self, **kwargs)
def is_enabled(self, kill=False):
if kill:
return hasattr(self, 'proc') and self.proc and self.proc.poll()
else:
return True

View File

@@ -0,0 +1 @@
{"url": "https://github.com/joeyespo/sublimetext-console-exec", "version": "1.0.0", "description": "Plugin for Sublime Text 2 to execute a command in a console window."}

View File

@@ -0,0 +1,20 @@
{
"schema_version": "1.2",
"packages": [
{
"name": "ConsoleExec",
"description": "Plugin for Sublime Text 2 to execute a command in a console window.",
"author": "Joe Esposito",
"homepage": "https://github.com/joeyespo/sublimetext-console-exec",
"last_modified": "2012-12-12 20:00:00",
"platforms": {
"windows": [
{
"version": "1.0.0",
"url": "https://nodeload.github.com/joeyespo/sublimetext-console-exec/zipball/master"
}
]
}
}
]
}