# Path: tensor/utils.py
# def fork(executable, args=(), env={}, path=None, timeout=3600):
#     """fork
#     Provides a deferred wrapper function with a timeout function
# 
#     :param executable: Executable
#     :type executable: str.
#     :param args: Tupple of arguments
#     :type args: tupple.
#     :param env: Environment dictionary
#     :type env: dict.
#     :param timeout: Kill the child process if timeout is exceeded
#     :type timeout: int.
#     """
#     d = defer.Deferred()
#     p = ProcessProtocol(d, timeout)
#     reactor.spawnProcess(p, executable, (executable,)+tuple(args), env, path)
#     return d
# 
# Path: tensor/protocol/ssh.py
# class FakeLog(object):
# class SSHCommandProtocol(protocol.Protocol):
# class SSHClient(object):
#     def msg(self, *a):
#     def callWithLogger(self, *a, **kw):
#     def connectionMade(self):
#     def dataReceived(self, data):
#     def extReceived(self, code, data):
#     def connectionLost(self, reason):
#     def __init__(self, hostname, username, port, password=None,
#                  knownhosts=None):
#     def verifyHostKey(self, ui, hostname, ip, key):
#         def gotHasKey(result):
#     def addKeyFile(self, kfile, password=None):
#     def addKeyString(self, kstring, password=None):
#     def _get_endpoint(self):
#     def connect(self):
#         def connected(protocol):
#     def fork(self, command, args=(), env={}, path=None, timeout=3600):
#         def finished(result):
#         def connected(connection):


import hashlib
import re
import time
import socket
    from exceptions import NotImplementedError
from twisted.internet import task, defer
from twisted.python import log
from tensor.utils import fork
from tensor.protocol import ssh
            self.ssh_connector = False
        else:
            self.ssh_connector = True
            self.ssh_client = ssh.SSHClient(self.ssh_host, self.ssh_user,
                    self.ssh_port, password=self.ssh_password,
                    knownhosts=self.known_hosts)

            if self.ssh_keyfile:
                self.ssh_client.addKeyFile(self.ssh_keyfile, self.ssh_keypass)

            if self.ssh_key:
                self.ssh_client.addKeyString(self.ssh_key, self.ssh_keypass)

            self.tensor.hostConnectorCache[cHash] = self.ssh_client

    def _queueBack(self, caller):
        return lambda events: caller(self, events)

    def startTimer(self):
        """Starts the timer for this source"""
        self.td = self.t.start(self.inter)

        if self.use_ssh and self.ssh_connector:
            self.ssh_client.connect()

    def stopTimer(self):
        """Stops the timer for this source"""
        self.td = None
        self.t.stop()


# Path: tensor/utils.py
# def fork(executable, args=(), env={}, path=None, timeout=3600):
#     """fork
#     Provides a deferred wrapper function with a timeout function
# 
#     :param executable: Executable
#     :type executable: str.
#     :param args: Tupple of arguments
#     :type args: tupple.
#     :param env: Environment dictionary
#     :type env: dict.
#     :param timeout: Kill the child process if timeout is exceeded
#     :type timeout: int.
#     """
#     d = defer.Deferred()
#     p = ProcessProtocol(d, timeout)
#     reactor.spawnProcess(p, executable, (executable,)+tuple(args), env, path)
#     return d
# 
# Path: tensor/protocol/ssh.py
# class FakeLog(object):
# class SSHCommandProtocol(protocol.Protocol):
# class SSHClient(object):
#     def msg(self, *a):
#     def callWithLogger(self, *a, **kw):
#     def connectionMade(self):
#     def dataReceived(self, data):
#     def extReceived(self, code, data):
#     def connectionLost(self, reason):
#     def __init__(self, hostname, username, port, password=None,
#                  knownhosts=None):
#     def verifyHostKey(self, ui, hostname, ip, key):
#         def gotHasKey(result):
#     def addKeyFile(self, kfile, password=None):
#     def addKeyString(self, kstring, password=None):
#     def _get_endpoint(self):
#     def connect(self):
#         def connected(protocol):
#     def fork(self, command, args=(), env={}, path=None, timeout=3600):
#         def finished(result):
#         def connected(connection):


# Path: tensor/objects.py
import hashlib
import re
import time
import socket
    from exceptions import NotImplementedError
from twisted.internet import task, defer
from twisted.python import log
from tensor.utils import fork
from tensor.protocol import ssh

            self.ssh_connector = False
        else:
            self.ssh_connector = True
            self.ssh_client = ssh.SSHClient(self.ssh_host, self.ssh_user,
                    self.ssh_port, password=self.ssh_password,
                    knownhosts=self.known_hosts)

            if self.ssh_keyfile:
                self.ssh_client.addKeyFile(self.ssh_keyfile, self.ssh_keypass)

            if self.ssh_key:
                self.ssh_client.addKeyString(self.ssh_key, self.ssh_keypass)

            self.tensor.hostConnectorCache[cHash] = self.ssh_client

    def _queueBack(self, caller):
        return lambda events: caller(self, events)

    def startTimer(self):
        """Starts the timer for this source"""
        self.td = self.t.start(self.inter)

        if self.use_ssh and self.ssh_connector:
            self.ssh_client.connect()

    def stopTimer(self):
        """Stops the timer for this source"""
        self.td = None
        self.t.stop()


    def fork(self, *a, **kw):