Exemple #1
0
    def _show_clipboard_data(name):
        try:
            memstream = F.Clipboard.GetData(name)
            data = IO.StreamReader(memstream)
            data_string = data.ReadToEnd()

            print "Clipboard data for " + name + ": " + data_string
            bkt.helpers.message("Clipboard data for " + name + ": " +
                                data_string)
        except:
            print "could not read " + name
Exemple #2
0
    def __init__(self,
                 command,
                 arguments=None,
                 env=None,
                 stdout=None,
                 stderr=None,
                 redirect_output=True,
                 working_dir=None):
        self._cmdline = _get_cmd(command, arguments)
        self._process = CSharpProcess()
        self._started = False
        start_info = self._process.StartInfo
        start_info.FileName = self._cmdline[0]
        start_info.Arguments = self._cmdline[1:]
        self._env = env
        start_info.CreateNoWindow = True
        if working_dir is not None:
            start_info.WorkingDirectory = working_dir

        self._stdout = os.path.abspath(stdout) if stdout else None
        self._stderr = os.path.abspath(stderr) if stderr else None
        self._redirect_output = (stdout or stderr or redirect_output)
        if self._redirect_output:
            start_info.UseShellExecute = False
            start_info.RedirectStandardInput = True
            start_info.RedirectStandardOutput = True
            start_info.RedirectStandardError = True
            self._process.OutputDataReceived += self._stdout_handler
            self._process.ErrorDataReceived += self._stderr_handler
            self._stdout_lock = threading.Lock()
            if self._stdout:
                if os.path.isfile(self._stdout):
                    shell.remove(self._stdout)
                self._stdout_ostream = IO.FileStream(self._stdout,
                                                     IO.FileMode.Append,
                                                     IO.FileAccess.Write,
                                                     IO.FileShare.Read)
                self._stdout_istream = IO.FileStream(self._stdout,
                                                     IO.FileMode.Open,
                                                     IO.FileAccess.Read,
                                                     IO.FileShare.ReadWrite)
                self._stdout_writer = IO.StreamWriter(self._stdout_ostream)
                self._stdout_reader = IO.StreamReader(self._stdout_istream)
            else:
                self._stdout_buffer = b''
            self._stderr_lock = threading.Lock()
            if self._stderr:
                if os.path.isfile(self._stderr):
                    shell.remove(self._stderr)
                self._stderr_ostream = IO.FileStream(self._stderr,
                                                     IO.FileMode.Append,
                                                     IO.FileAccess.Write,
                                                     IO.FileShare.Read)
                self._stderr_istream = IO.FileStream(self._stderr,
                                                     IO.FileMode.Open,
                                                     IO.FileAccess.Read,
                                                     IO.FileShare.ReadWrite)
                self._stderr_writer = IO.StreamWriter(self._stderr_ostream)
                self._stderr_reader = IO.StreamReader(self._stderr_istream)
            else:
                self._stderr_buffer = b''
        else:
            start_info.UseShellExecute = True
            start_info.RedirectStandardInput = False
            start_info.RedirectStandardOutput = False
            start_info.RedirectStandardError = False

        self._pid = None
        self._immutable = None
Exemple #3
0
import clr
import System
from System import IO

print("hello")
sr=IO.StreamReader("helloiron.py")
data=sr.ReadToEnd()
sr.Close()

print(data)