# Path: duct/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.
#     """
#     de = defer.Deferred()
#     proc = ProcessProtocol(de, timeout)
#     reactor.spawnProcess(proc, executable, (executable,)+tuple(args), env,
#                          path)
#     return de
# 
# Path: duct/protocol/ssh.py
# class FakeLog(object):
# class SSHCommandProtocol(protocol.Protocol):
# class SSHClient(object):
#     def msg(self, *a):
#     def callWithLogger(self, *a, **kw):
#     def __init__(self):
#     def connectionMade(self):
#     def dataReceived(self, data):
#     def extReceived(self, _code, data):
#     def connectionLost(self, reason=protocol.connectionDone):
#     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 conLost(reason):
#     def connectionLost(self, transport, reason):
#     def fork(self, command, args=(), env={}, path=None, _timeout=3600):
#         def finished(result):
#         def connected(connection):


import hashlib
import time
import socket
import traceback
from twisted.internet import task, defer
from twisted.python import log
from duct.utils import fork
from duct.protocol import ssh

        if self.use_ssh and self.ssh_connector:
            yield defer.maybeDeferred(self.ssh_client.connect)


    def stop(self):
        """Called when source is stopped
        """
        pass

    def stopTimer(self):
        """Stops the timer for this source"""
        self.timerDeferred = None
        if self.timer.running:
            self.timer.stop()
        return defer.maybeDeferred(self.stop)

    def fork(self, *a, **kw):
        """Wrapper function to execute another process

           Passes off to either ssh or local system based on whether
           use_ssh is set
        """
        if self.use_ssh:
            return self.ssh_client.fork(*a, **kw)
        else:
            return fork(*a, **kw)

    @defer.inlineCallbacks
    def _get(self):

# Path: duct/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.
#     """
#     de = defer.Deferred()
#     proc = ProcessProtocol(de, timeout)
#     reactor.spawnProcess(proc, executable, (executable,)+tuple(args), env,
#                          path)
#     return de
# 
# Path: duct/protocol/ssh.py
# class FakeLog(object):
# class SSHCommandProtocol(protocol.Protocol):
# class SSHClient(object):
#     def msg(self, *a):
#     def callWithLogger(self, *a, **kw):
#     def __init__(self):
#     def connectionMade(self):
#     def dataReceived(self, data):
#     def extReceived(self, _code, data):
#     def connectionLost(self, reason=protocol.connectionDone):
#     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 conLost(reason):
#     def connectionLost(self, transport, reason):
#     def fork(self, command, args=(), env={}, path=None, _timeout=3600):
#         def finished(result):
#         def connected(connection):


# Path: duct/objects.py
import hashlib
import time
import socket
import traceback
from twisted.internet import task, defer
from twisted.python import log
from duct.utils import fork
from duct.protocol import ssh


        if self.use_ssh and self.ssh_connector:
            yield defer.maybeDeferred(self.ssh_client.connect)


    def stop(self):
        """Called when source is stopped
        """
        pass

    def stopTimer(self):
        """Stops the timer for this source"""
        self.timerDeferred = None
        if self.timer.running:
            self.timer.stop()
        return defer.maybeDeferred(self.stop)

    def fork(self, *a, **kw):
        """Wrapper function to execute another process

           Passes off to either ssh or local system based on whether
           use_ssh is set
        """
        if self.use_ssh:
            return self.ssh_client.fork(*a, **kw)
        else:
            return fork(*a, **kw)

    @defer.inlineCallbacks
    def _get(self):

        if self.use_ssh and not self.ssh: