# 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
        and passes that result back to the queueBack method

        Returns a deferred"""

        if self.sync:
            if self.running:
                defer.returnValue(None)

        self.running = True

        try:
            event = yield self._get()
            if event:
                self.queueBack(event)

        except Exception as ex:
            if self.duct.config.get('debug'):
                tb_lines = traceback.format_exc().splitlines()
                header = "[%s] Unhandled error: %%s" % (self.service)
                log.msg(header % tb_lines[0])
                if len(tb_lines) > 1:
                    for l in tb_lines[1:]:
                        log.msg(l)

            else:
                log.msg("[%s] Unhandled error: %s" % (self.service, ex))

        self.running = False

    def createEvent(self, state, description, metric, prefix=None,

# 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

        and passes that result back to the queueBack method

        Returns a deferred"""

        if self.sync:
            if self.running:
                defer.returnValue(None)

        self.running = True

        try:
            event = yield self._get()
            if event:
                self.queueBack(event)

        except Exception as ex:
            if self.duct.config.get('debug'):
                tb_lines = traceback.format_exc().splitlines()
                header = "[%s] Unhandled error: %%s" % (self.service)
                log.msg(header % tb_lines[0])
                if len(tb_lines) > 1:
                    for l in tb_lines[1:]:
                        log.msg(l)

            else:
                log.msg("[%s] Unhandled error: %s" % (self.service, ex))

        self.running = False

    def createEvent(self, state, description, metric, prefix=None,

                    hostname=None, aggregation=None, evtime=None):