예제 #1
0
    def run(self):
        from pytoolbox import encoding, filesystem
        from pytoolbox.subprocess import cmd

        encoding.configure_unicode()

        docs_directory = os.path.join(os.path.dirname(__file__), 'docs')
        source_directory = os.path.join(docs_directory, 'source')
        package_directory = os.path.join(os.path.dirname(__file__),
                                         'pytoolbox')

        # Cleanup previously generated restructured files
        for path in filesystem.find_recursive(source_directory,
                                              r'^pytoolbox.*\.rst$',
                                              unix_wildcards=False):
            os.remove(path)

        cmd([
            'sphinx-apidoc', '--force', '--module-first', '--separate', '-o',
            source_directory, package_directory
        ])
        shutil.rmtree(os.path.join(docs_directory, 'build', 'html'),
                      ignore_errors=True)
        result = cmd('make html', cwd=docs_directory, fail=False)

        print(
            '{0}Outputs{0}======={0}{1}{0}{0}Errors{0}======{0}{2}{0}'.format(
                os.linesep, result['stdout'].decode('utf-8'),
                result['stderr'].decode('utf-8')))
        sys.exit(1 if result['stderr'] else 0)
예제 #2
0
파일: setup.py 프로젝트: fingul/pytoolbox
    def run(self):
        from pytoolbox import encoding, filesystem
        from pytoolbox.subprocess import cmd

        encoding.configure_unicode()

        docs_directory = os.path.join(os.path.dirname(__file__), 'docs')
        source_directory = os.path.join(docs_directory, 'source')
        package_directory = os.path.join(os.path.dirname(__file__), 'pytoolbox')

        # Cleanup previously generated restructured files
        for path in filesystem.find_recursive(source_directory, r'^pytoolbox.*\.rst$', unix_wildcards=False):
            os.remove(path)

        cmd(['sphinx-apidoc', '--force', '--module-first', '--separate', '-o', source_directory, package_directory])
        shutil.rmtree(os.path.join(docs_directory, 'build', 'html'), ignore_errors=True)
        result = cmd('make html', cwd=docs_directory, fail=False)

        print('{0}Outputs{0}======={0}{1}{0}{0}Errors{0}======{0}{2}{0}'.format(
            os.linesep, result['stdout'].decode('utf-8'), result['stderr'].decode('utf-8'))
        )
        sys.exit(1 if result['stderr'] else 0)
예제 #3
0
    def run(self):
        from pytoolbox import encoding, filesystem
        from pytoolbox.subprocess import cmd

        encoding.configure_unicode()

        docs_directory = os.path.join(os.path.dirname(__file__), 'docs')
        source_directory = os.path.join(docs_directory, 'source')
        package_directory = os.path.join(os.path.dirname(__file__), 'pytoolbox')

        # Cleanup previously generated restructured files
        for path in filesystem.find_recursive(
            source_directory, r'^pytoolbox.*\.rst$', unix_wildcards=False
        ):
            os.remove(path)

        cmd([
            'sphinx-apidoc', '--force', '--module-first', '--separate', '-o',
            source_directory, package_directory
        ])
        shutil.rmtree(os.path.join(docs_directory, 'build', 'html'), ignore_errors=True)
        subprocess.check_call(['make', 'html'], cwd=docs_directory)
예제 #4
0
파일: setup.py 프로젝트: zlorb/pytoolbox
    def run(self):
        from pytoolbox import encoding, filesystem
        from pytoolbox.subprocess import cmd

        encoding.configure_unicode()

        docs_directory = os.path.join(os.path.dirname(__file__), 'docs')
        source_directory = os.path.join(docs_directory, 'source')
        package_directory = os.path.join(os.path.dirname(__file__),
                                         'pytoolbox')

        # Cleanup previously generated restructured files
        for path in filesystem.find_recursive(source_directory,
                                              r'^pytoolbox.*\.rst$',
                                              unix_wildcards=False):
            os.remove(path)

        cmd([
            'sphinx-apidoc', '--force', '--module-first', '--separate', '-o',
            source_directory, package_directory
        ])
        shutil.rmtree(os.path.join(docs_directory, 'build', 'html'),
                      ignore_errors=True)
        subprocess.check_call(['make', 'html'], cwd=docs_directory)
예제 #5
0
# See the European Union Public License for more details.
#
# You should have received a copy of the EUPL General Public License along with this project.
# If not, see he EUPL licence v1.1 is available in 22 languages:
#     22-07-2013, <https://joinup.ec.europa.eu/software/page/eupl/licence-eupl>
#
# Retrieved from https://github.com/davidfischer-ch/pytoolbox.git

from __future__ import absolute_import, division, print_function, unicode_literals

import shutil, sys
from pytoolbox.encoding import configure_unicode
from pytoolbox.subprocess import cmd
from pytoolbox.filesystem import from_template

configure_unicode()

# Detect modules, thanks to find !
modules = sorted(
    m.replace('.py', '').replace('./', '').replace('/', '.')
    for m in cmd('find . -type f -name "*.py"', cwd='../pytoolbox', shell=True)
    ['stdout'].split() if m.endswith('.py') and not '__init__' in m)

print('Detected modules are: {0}'.format(modules))

api_toc = ''
for module in modules:
    if 'django' in module or 'crypto' in module:
        continue  # FIXME temporary hack, see issue #6
    module = 'pytoolbox.{0}'.format(module)
    title = module.replace('.', ' > ')
#
#**********************************************************************************************************************#
#
# This file is part of EBU Technology & Innovation OSCIED Project.
#
# This project is free software: you can redistribute it and/or modify it under the terms of the EUPL v. 1.1 as provided
# by the European Commission. This project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See the European Union Public License for more details.
#
# You should have received a copy of the EUPL General Public License along with this project.
# If not, see he EUPL licence v1.1 is available in 22 languages:
#     22-07-2013, <https://joinup.ec.europa.eu/software/page/eupl/licence-eupl>

from oscied_lib.config import OrchestraLocalConfig
from oscied_lib.api import OrchestraAPICore

class TestOrchestraAPICore(object):

    def test_something(self):
        config = OrchestraLocalConfig()
        api = OrchestraAPICore(config)
        print(api.__dict__)
        # TODO

if __name__ == u'__main__':
    from pytoolbox.encoding import configure_unicode
    configure_unicode()
    TestOrchestraAPICore().test_something()
예제 #7
0
def main():
    u"""
    This is a working example utility using this class, this method will :

    * Parse arguments from command line
    * Register handlers to SIGTERM and SIGINT
    * Instantiate a :mod:`SocketFecGenerator` and start it
    """
    import doctest, errno, signal
    from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, FileType
    from pytoolbox.encoding import configure_unicode
    from pytoolbox.logging import setup_logging
    from ...ip import IPSocket

    configure_unicode()
    setup_logging(name=u'smpte2022lib', filename=None, console=True, level=logging.DEBUG)
    log.info(u'Testing SocketFecGenerator with doctest')
    doctest.testmod(verbose=False)
    log.info(u'OK')

    HELP_MEDIA   = u'Socket of input stream'
    HELP_COL     = u'Socket of generated FEC column stream'
    HELP_ROW     = u'Socket of generated FEC row stream'
    HELP_L       = u'Horizontal size of the FEC matrix (columns)'
    HELP_D       = u'Vertical size of the FEC matrix (rows)'
    HELP_TIMEOUT = u'Set timeout for socket operations (in seconds)'
    HELP_PROFILE = u'Set profiling output file (this enable profiling)'
    HELP_STOP    = u'Automatic stop time (in seconds)'

    dmedia = SocketFecGenerator.DEFAULT_MEDIA
    dcol = SocketFecGenerator.DEFAULT_COL
    drow = SocketFecGenerator.DEFAULT_ROW

    parser = ArgumentParser(
        formatter_class=ArgumentDefaultsHelpFormatter,
        epilog=u'''This utility create SMPTE 2022-1 FEC streams from a sniffed source stream.
                   SMPTE 2022-1 help streaming systems to improve QoE of real-time RTP transmissions.''')
    parser.add_argument(u'-m', u'--media',        type=IPSocket,      help=HELP_MEDIA,   default=dmedia)
    parser.add_argument(u'-c', u'--col',          type=IPSocket,      help=HELP_COL,     default=dcol)
    parser.add_argument(u'-r', u'--row',          type=IPSocket,      help=HELP_ROW,     default=drow)
    parser.add_argument(u'-l',                    type=int,           help=HELP_L,       default=5)
    parser.add_argument(u'-d',                    type=int,           help=HELP_D,       default=6)
    parser.add_argument(u'-t', u'--timeout',      type=int,           help=HELP_TIMEOUT, nargs='?', default=None)
    parser.add_argument(u'-s', u'--stop-time',    type=int,           help=HELP_STOP,    nargs='?', default=None)
    parser.add_argument(u'-p', u'--profile',      type=FileType('w'), help=HELP_PROFILE, nargs='?', default=None)
    args = parser.parse_args()

    def handle_stop_signal(SIGNAL, stack):
        generator.stop()

    try:
        signal.signal(signal.SIGTERM, handle_stop_signal)
        signal.signal(signal.SIGINT, handle_stop_signal)
        generator = SocketFecGenerator(args.media, args.col, args.row, args.l, args.d)
        if args.profile:
            from pycallgraph import PyCallGraph
            from pycallgraph.output import GraphvizOutput
            with PyCallGraph(output=GraphvizOutput(output_file=args.profile.name)):
                generator.run(args.timeout, args.stop_time)
        else:
            generator.run(args.timeout, args.stop_time)
    except socket.error as e:
        if e.errno != errno.EINTR:
            raise
예제 #8
0
def main():
    configure_unicode()
    set_test_settings()
    return runtests(__file__,
                    cover_packages=[u'encodebox'],
                    packages=[u'encodebox', u'tests'])
예제 #9
0
def main():
    u"""
    This is a working example utility using this class, this method will :

    * Parse arguments from command line
    * Register handlers to SIGTERM and SIGINT
    * Instantiate a :mod:`TwistedFecGenerator` and start it
    """
    import doctest, errno, signal
    from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, FileType
    from pytoolbox.encoding import configure_unicode
    from pytoolbox.logging import setup_logging
    from twisted.internet import reactor
    from ...ip import IPSocket

    configure_unicode()
    setup_logging(name=u'smpte2022lib', filename=None, console=True, level=logging.DEBUG)
    log.info(u'Testing TwistedFecGenerator with doctest')
    doctest.testmod(verbose=False)
    log.info(u'OK')

    HELP_MEDIA   = u'Socket of input stream'
    HELP_COL     = u'Socket of generated FEC column stream'
    HELP_ROW     = u'Socket of generated FEC row stream'
    HELP_L       = u'Horizontal size of the FEC matrix (columns)'
    HELP_D       = u'Vertical size of the FEC matrix (rows)'
    HELP_PROFILE = u'Set profiling output file (this enable profiling)'

    dmedia = TwistedFecGenerator.DEFAULT_MEDIA
    dcol = TwistedFecGenerator.DEFAULT_COL
    drow = TwistedFecGenerator.DEFAULT_ROW

    parser = ArgumentParser(
        formatter_class=ArgumentDefaultsHelpFormatter,
        epilog=u'''This utility create SMPTE 2022-1 FEC streams from a sniffed source stream.
                   SMPTE 2022-1 help streaming systems to improve QoE of real-time RTP transmissions.''')
    parser.add_argument(u'-m', u'--media',   type=IPSocket,      help=HELP_MEDIA,   default=dmedia)
    parser.add_argument(u'-c', u'--col',     type=IPSocket,      help=HELP_COL,     default=dcol)
    parser.add_argument(u'-r', u'--row',     type=IPSocket,      help=HELP_ROW,     default=drow)
    parser.add_argument(u'-l',               type=int,           help=HELP_L,       default=5)
    parser.add_argument(u'-d',               type=int,           help=HELP_D,       default=6)
    parser.add_argument(u'-p', u'--profile', type=FileType('w'), help=HELP_PROFILE, nargs='?', default=None)
    args = parser.parse_args()

    def handle_stop_signal(SIGNAL, stack):
        log.info(u'\nGenerator stopped\n')
        reactor.stop()

    try:
        signal.signal(signal.SIGTERM, handle_stop_signal)
        signal.signal(signal.SIGINT, handle_stop_signal)

        # FIXME port ?
        TwistedFecGenerator(args.media[u'ip'], u'MyGenerator', args.col, args.row, args.l, args.d)
        # Disabled otherwise multicast packets are received twice !
        # See ``sudo watch ip maddr show`` they will be 2 clients if uncommented :
        # reactor.run() vs -> reactor.listenMulticast(args.media['port'], generator, listenMultiple=True) <-

        if args.profile:
            from pycallgraph import PyCallGraph
            from pycallgraph.output import GraphvizOutput
            with PyCallGraph(output=GraphvizOutput(output_file=args.profile.name)):
                reactor.run()
        else:
            reactor.run()
    except socket.error as e:
        if e.errno != errno.EINTR:
            raise