File: shell.py

package info (click to toggle)
buildbot 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 21,080 kB
  • sloc: python: 174,183; sh: 1,204; makefile: 332; javascript: 119; xml: 16
file content (61 lines) | stat: -rw-r--r-- 2,189 bytes parent folder | download | duplicates (2)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# This file is part of Buildbot.  Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members

from buildbot_worker import runprocess
from buildbot_worker.commands import base


class WorkerShellCommand(base.Command):
    requiredArgs = ['workdir', 'command']

    def start(self):
        args = self.args
        workdir = args['workdir']

        c = runprocess.RunProcess(
            self.command_id,
            args['command'],
            workdir,
            self.protocol_command.unicode_encoding,
            self.protocol_command.send_update,
            environ=args.get('env'),
            timeout=args.get('timeout', None),
            maxTime=args.get('maxTime', None),
            max_lines=args.get('max_lines', None),
            sigtermTime=args.get('sigtermTime', None),
            sendStdout=args.get('want_stdout', True),
            sendStderr=args.get('want_stderr', True),
            sendRC=True,
            initialStdin=args.get('initial_stdin'),
            logfiles=args.get('logfiles', {}),
            usePTY=args.get('usePTY', False),
            logEnviron=args.get('logEnviron', True),
        )
        if args.get('interruptSignal'):
            c.interruptSignal = args['interruptSignal']
        c._reactor = self._reactor
        self.command = c
        d = self.command.start()
        return d

    def interrupt(self):
        self.interrupted = True
        self.command.kill("command interrupted")

    def writeStdin(self, data):
        self.command.writeStdin(data)

    def closeStdin(self):
        self.command.closeStdin()