-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsandbox.py
More file actions
30 lines (24 loc) · 967 Bytes
/
sandbox.py
File metadata and controls
30 lines (24 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from subprocess import Popen, PIPE
import os
import threading
# class CommandExecutor:
# def __report(self, result):
# print result
# def run_cmd_without_callback(self, *popenArgs):
# self.run_cmd(self.__report, *popenArgs)
# def run_cmd(self, callback, *popenArgs):
# def runInThread(callback, popenArgs):
# env = {'PATH': os.environ['PATH'],
# 'EDITOR': 'subl'}
# proc = Popen(*popenArgs, env=env, stdout=PIPE, stderr=PIPE)
# proc.wait()
# stat = proc.communicate()
# okay = proc.returncode == 0
# callback({'okay': okay, 'out': stat[0], 'err': stat[1]})
# return
# thread = threading.Thread(target=runInThread,
# args=(callback, popenArgs))
# thread.start()
# return thread
# a = CommandExecutor()
# a.run_cmd_without_callback(['bundle', 'open', 'rspec-core'])