Skip to content

Instantly share code, notes, and snippets.

@zeux
Last active December 13, 2015 19:48
Show Gist options
  • Save zeux/4965115 to your computer and use it in GitHub Desktop.
Save zeux/4965115 to your computer and use it in GitHub Desktop.
import sublime, sublime_plugin
import os, stat
import subprocess
import _thread
class P4Checkout(sublime_plugin.EventListener):
def on_modified(self, view):
def checkout(file):
output = subprocess.check_output(["p4", "edit", file], shell=True)
print(output.decode())
fileToCheckout = view.file_name()
if fileToCheckout != None:
fileMode = os.stat(fileToCheckout)[stat.ST_MODE]
if (not fileMode & stat.S_IWRITE):
_thread.start_new_thread(checkout, (fileToCheckout,))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment