annotate sat/tools/common/async_process.py @ 3028:ab2696e34d29

Python 3 port: /!\ this is a huge commit /!\ starting from this commit, SàT is needs Python 3.6+ /!\ SàT maybe be instable or some feature may not work anymore, this will improve with time This patch port backend, bridge and frontends to Python 3. Roughly this has been done this way: - 2to3 tools has been applied (with python 3.7) - all references to python2 have been replaced with python3 (notably shebangs) - fixed files not handled by 2to3 (notably the shell script) - several manual fixes - fixed issues reported by Python 3 that where not handled in Python 2 - replaced "async" with "async_" when needed (it's a reserved word from Python 3.7) - replaced zope's "implements" with @implementer decorator - temporary hack to handle data pickled in database, as str or bytes may be returned, to be checked later - fixed hash comparison for password - removed some code which is not needed anymore with Python 3 - deactivated some code which needs to be checked (notably certificate validation) - tested with jp, fixed reported issues until some basic commands worked - ported Primitivus (after porting dependencies like urwid satext) - more manual fixes
author Goffi <goffi@goffi.org>
date Tue, 13 Aug 2019 19:08:41 +0200
parents 181735d1b062
children 0d55a52056f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
1 #!/usr/bin/env python3
2793
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
3
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # SAT: a jabber client
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # Copyright (C) 2009-2019 Jérôme Poisson (goffi@goffi.org)
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
6
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
11
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
16
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
19
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
20 """tools to launch process in a async way (using Twisted)"""
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
21
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
22 import os.path
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from twisted.internet import defer, reactor, protocol
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from twisted.python.failure import Failure
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from sat.core.i18n import _
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from sat.core import exceptions
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from sat.core.log import getLogger
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
28 log = getLogger(__name__)
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
29
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
30
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
31 class CommandProtocol(protocol.ProcessProtocol):
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
32 """handle an external command"""
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
33 # name of the command (unicode)
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
34 name = None
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
35 # full path to the command (bytes)
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
36 command = None
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
37 # True to activate logging of command outputs (bool)
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
38 log = False
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
39
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
40 def __init__(self, deferred, stdin=None):
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
41 """
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
42 @param deferred(defer.Deferred): will be called when command is completed
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
43 @param stdin(str, None): if not None, will be push to standard input
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
44 """
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
45 self._stdin = stdin
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
46 self._deferred = deferred
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
47 self.data = []
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
48 self.err_data = []
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
49
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
50 @property
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
51 def command_name(self):
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
52 """returns command name or empty string if it can't be guessed"""
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
53 if self.name is not None:
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
54 return self.name
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
55 elif self.command is not None:
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
56 return os.path.splitext(os.path.basename(self.command))[0].decode('utf-8',
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
57 'ignore')
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
58 else:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
59 return ''
2793
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
60
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
61 def connectionMade(self):
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
62 if self._stdin is not None:
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
63 self.transport.write(self._stdin)
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
64 self.transport.closeStdin()
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
65
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
66 def outReceived(self, data):
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
67 if self.log:
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
68 log.info(data.decode('utf-8', 'replace'))
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
69 self.data.append(data)
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
70
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
71 def errReceived(self, data):
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
72 if self.log:
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
73 log.warning(data.decode('utf-8', 'replace'))
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
74 self.err_data.append(data)
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
75
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
76 def processEnded(self, reason):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
77 data = b''.join(self.data)
2793
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
78 if (reason.value.exitCode == 0):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
79 log.debug(_('{name} command succeed').format(name=self.command_name))
2793
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
80 # we don't use "replace" on purpose, we want an exception if decoding
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
81 # is not working properly
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
82 self._deferred.callback(data)
2793
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
83 else:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
84 err_data = b''.join(self.err_data)
2793
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
85
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
86 msg = (_("Can't complete {name} command (error code: {code}):\n"
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
87 "stderr:\n{stderr}\n{stdout}\n")
2793
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
88 .format(name = self.command_name,
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
89 code = reason.value.exitCode,
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
90 stderr= err_data.encode('utf-8', 'replace'),
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
91 stdout = "stdout: " + data.decode('utf-8', 'replace')
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
92 if data else '',
2793
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
93 ))
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
94 self._deferred.errback(Failure(exceptions.CommandException(
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
95 msg, data, err_data)))
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
96
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
97 @classmethod
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
98 def run(cls, *args, **kwargs):
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
99 """Create a new CommandProtocol and execute the given command.
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
100
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
101 @param *args(unicode): command arguments
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
102 if cls.command is specified, it will be the path to the command to execture
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
103 otherwise, first argument must be the path
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
104 @param **kwargs: can be:
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
105 - stdin(unicode, None): data to push to standard input
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
106 - verbose(bool): if True stdout and stderr will be logged
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
107 other keyword arguments will be used in reactor.spawnProcess
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
108 @return ((D)): stdout in case of success
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
109 @raise RuntimeError: command returned a non zero status
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
110 stdin and stdout will be given as arguments
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
111
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
112 """
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
113 stdin = kwargs.pop('stdin', None)
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
114 if stdin is not None:
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
115 stdin = stdin.encode('utf-8')
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
116 verbose = kwargs.pop('verbose', False)
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
117 if 'path' in kwargs:
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
118 kwargs['path'] = kwargs['path'].encode('utf-8')
2793
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
119 args = [a.encode('utf-8') for a in args]
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
120 kwargs = {k:v.encode('utf-8') for k,v in list(kwargs.items())}
2793
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
121 d = defer.Deferred()
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
122 prot = cls(d, stdin=stdin)
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
123 if verbose:
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
124 prot.log = True
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
125 if cls.command is None:
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
126 if not args:
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
127 raise ValueError(
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
128 "You must either specify cls.command or use a full path to command "
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
129 "to execute as first argument")
2793
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
130 command = args.pop(0)
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
131 if prot.name is None:
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
132 name = os.path.splitext(os.path.basename(command))[0]
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2793
diff changeset
133 prot.name = name
2793
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
134 else:
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
135 command = cls.command
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
136 cmd_args = [os.path.basename(command)] + args
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
137 reactor.spawnProcess(prot,
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
138 command,
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
139 cmd_args,
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
140 **kwargs)
181735d1b062 plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
diff changeset
141 return d