Last active
December 13, 2015 19:48
-
-
Save zeux/4965115 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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