Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b884319660ceaeabac3002d432f33ca39752317b (plain) (blame)
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
62
63
64
65
66
67
68
69
70
71
# *****************************************************************************
# * Copyright (c) 2011-2014, 2016 Wind River Systems, Inc. and others.
# * All rights reserved. This program and the accompanying materials
# * are made available under the terms of the Eclipse Public License v1.0
# * which accompanies this distribution, and is available at
# * http://www.eclipse.org/legal/epl-v10.html
# *
# * Contributors:
# *     Wind River Systems - initial API and implementation
# *****************************************************************************

from . import ProcessesProxy
from .. import processes_v1
from ...channel.Command import Command


class ProcessesV1Proxy(ProcessesProxy.ProcessesProxy,
                       processes_v1.ProcessesV1Service):

    def start(self, directory, filePath, command_line, environment, params,
              done):
        done = self._makeCallback(done)
        service = self
        env = ProcessesProxy._toEnvStringArray(environment)

        class StartCommand(Command):
            def __init__(self):
                super(StartCommand, self).__init__(service.channel, service,
                                                   "start",
                                                   (directory, filePath,
                                                    command_line, env, params))

            def done(self, error, args):
                ctx = None
                if not error:
                    assert len(args) == 2
                    error = self.toError(args[0])
                    if args[1]:
                        ctx = ProcessesProxy.ProcessContext(service, args[1])
                done.doneStart(self.token, error, ctx)
        return StartCommand().token

    def getCapabilities(self, contextId, done):
        done = self._makeCallback(done)
        service = self

        class GetCapabilitiesCommand(Command):

            def __init__(self):
                super(GetCapabilitiesCommand, self).__init__(service.channel,
                                                             service,
                                                             "getCapabilities",
                                                             (contextId,))

            def done(self, error, args):
                capabilityData = None
                if not error:
                    # Defect WB4-1784, getting capabilities with a null
                    # context ID does not return the global system capabilities
                    # as it should
                    if len(args) == 1:
                        error = self.toError(args[0])
                        capabilityData = {}
                    else:
                        assert len(args) == 2
                        error = self.toError(args[0])
                        capabilityData = args[1]

                done.doneGetCapabilities(self.token, error, capabilityData)

        return GetCapabilitiesCommand().token

Back to the top