Esempio n. 1
0
  def __init__(self, message, proto=None):
    Exception.__init__(self)

    assert isinstance(message, str)
    assert proto is None or IProcessProtocol.providedBy(proto)

    self._message = message
    self._proto = proto
Esempio n. 2
0
  def handle(self, exception, protocol=None):
    assert IException.providedBy(exception)
    assert IProcessProtocol.providedBy(protocol) or protocol is None

    if protocol is None:
      protocol = exception.getProtocol()

    errorProtocol = ErrorProtocol(str(exception))
    errorProtocol.makeConnection(protocol)
Esempio n. 3
0
def authorizationErrorHandler(fail, app, proto):
  from gitexd import Factory

  assert isinstance(fail, Failure)
  assert isinstance(app, Factory)
  assert IProcessProtocol.providedBy(proto)

  r = fail.trap(GitError, Exception)

  if r == GitError:
    """Pass to the ExceptionHandler"""

    app.getErrorHandler().handle(fail.value, proto)
  else:
    """Unknown exception, halt excecution."""

    fail.printTraceback()
    reactor.stop()
Esempio n. 4
0
    def run(self, protocol, extra_tahoe_args=()):
        """
        Start the node running.

        :param IProcessProtocol protocol: This protocol will be hooked up to
            the node process and can handle output or generate input.
        """
        if not IProcessProtocol.providedBy(protocol):
            raise TypeError("run requires process protocol, got {}".format(protocol))
        self.process = self._execute(
            protocol,
            list(extra_tahoe_args) + [u"run", self.basedir.asTextMode().path],
        )
        # Don't let the process run away forever.
        try:
            self.active()
        except OSError as e:
            if ENOENT != e.errno:
                raise
Esempio n. 5
0
 def _invariant(self):
   Object._invariant(self)
   assert IProcessProtocol.providedBy(self._protocol)
   assert isinstance(self._repositoryPath, list)
   assert isinstance(self._environmentVariables, dict)
   assert self.getType() in (PUSH, PULL)