# Path: opencenteragent/modules/output_manager.py
# LOG = logging.getLogger('opencenter.output')
# def _ok(code=0, message='success', data={}):
# def _fail(code=1, message='unknown failure', data={}):
# def _xfer_to_eof(fd_in, sock_out):
#     def __init__(self, path, config={}):
#     def register_action(self, plugin, shortpath, action, method,
#                         constraints=[], consequences=[], args={},
#                         timeout=30):
#     def actions(self):
#     def dispatch(self, input_data):
#     def handle_logfile(self, input_data, sock=None):
#     def handle_modules(self, input_data):
# class OutputManager(manager.Manager):
# 
# Path: opencenteragent/utils.py
# def detailed_exception():
# def temporary_file():
# def temporary_directory():


import fixtures
import os
import socket
import testtools
import unittest
from opencenteragent.modules import output_manager
from opencenteragent import utils
                                                     'offset': 1024}})
                self.assertEqual(out['result_code'], 1)
                self.assertEqual(out['result_str'],
                                 'no such transaction log file')

    def test_handle_logfile_remote_connection_failed(self):
        with utils.temporary_directory() as path:
            with utils.temporary_directory() as logdir:
                om = output_manager.OutputManager(path)
                om.config = {'main': {'trans_log_dir': logdir}}

                with open(os.path.join(logdir, 'trans_42.log'), 'w') as f:
                    f.write('This\nis\na\nlog\nfile')

                out = om.handle_logfile({'action': 'logfile.tail',
                                         'payload': {'task_id': '42',
                                                     'dest_ip': '127.0.0.1',
                                                     'dest_port': 4242,
                                                     'offset': 1024}})
                self.assertEqual(out['result_code'], 1)
                #
                # Symbolic errnos are specified by posix.  Values are not.
                # Neither is the actual text of strerror(3).
                #
                # self.assertEqual(out['result_str'],
                #                  '[Errno 111] Connection refused')

    def test_handle_logfile_tail(self):
        sock = FakeSocket(socket.AF_INET, socket.SOCK_STREAM)
        with utils.temporary_directory() as path:

# Path: opencenteragent/modules/output_manager.py
# LOG = logging.getLogger('opencenter.output')
# def _ok(code=0, message='success', data={}):
# def _fail(code=1, message='unknown failure', data={}):
# def _xfer_to_eof(fd_in, sock_out):
#     def __init__(self, path, config={}):
#     def register_action(self, plugin, shortpath, action, method,
#                         constraints=[], consequences=[], args={},
#                         timeout=30):
#     def actions(self):
#     def dispatch(self, input_data):
#     def handle_logfile(self, input_data, sock=None):
#     def handle_modules(self, input_data):
# class OutputManager(manager.Manager):
# 
# Path: opencenteragent/utils.py
# def detailed_exception():
# def temporary_file():
# def temporary_directory():


# Path: tests/test_modules_output_manager.py
import fixtures
import os
import socket
import testtools
import unittest
from opencenteragent.modules import output_manager
from opencenteragent import utils

                                                     'offset': 1024}})
                self.assertEqual(out['result_code'], 1)
                self.assertEqual(out['result_str'],
                                 'no such transaction log file')

    def test_handle_logfile_remote_connection_failed(self):
        with utils.temporary_directory() as path:
            with utils.temporary_directory() as logdir:
                om = output_manager.OutputManager(path)
                om.config = {'main': {'trans_log_dir': logdir}}

                with open(os.path.join(logdir, 'trans_42.log'), 'w') as f:
                    f.write('This\nis\na\nlog\nfile')

                out = om.handle_logfile({'action': 'logfile.tail',
                                         'payload': {'task_id': '42',
                                                     'dest_ip': '127.0.0.1',
                                                     'dest_port': 4242,
                                                     'offset': 1024}})
                self.assertEqual(out['result_code'], 1)
                #
                # Symbolic errnos are specified by posix.  Values are not.
                # Neither is the actual text of strerror(3).
                #
                # self.assertEqual(out['result_str'],
                #                  '[Errno 111] Connection refused')

    def test_handle_logfile_tail(self):
        sock = FakeSocket(socket.AF_INET, socket.SOCK_STREAM)
        with utils.temporary_directory() as path:

            with utils.temporary_directory() as logdir: