Ejemplo n.º 1
0
 def handle_noargs(self, **options):
     self.check_home_dir(settings.HOME_PATH)
     cmd = "twistd "
     if not options.get('daemonize', False):
         cmd += "-n "
     cmd += "codenode "
     cmd += "--env_path=%s " % settings.HOME_PATH
     cmd += "--server_log=%s " % os.path.join(settings.HOME_PATH, 'server.log')
     cmd += "--static_files=%s " % settings.MEDIA_ROOT
     run(cmd.split()[1:])
Ejemplo n.º 2
0
Archivo: tap.py Proyecto: cryoem/emen2
def run_twistd():
    # This is a (somewhat awful hack) based on twistd.

    # Twistd plugins have great difficulty being packaged
    # by distutils, pip, etc., and there is no
    # current workaround.

    # This function basically recreates twistd,
    # and inserts the EMEN2 Service as the only plugin.
    # This gets around having to have twisted/plugins/emen2_plugin.py
    # in a directory without an __init__.py

    # Run:
    # python -m emen2.tap [twistd options] emen2 [emen2 options]

    from twisted.application.service import ServiceMaker
    from twisted.application import app
    from twisted.python.runtime import platformType
    from twisted import plugin

    #### From twisted/plugins/emen2_plugin.py #####
    EMEN2Server = ServiceMaker("EMEN2", "emen2.tap", ("EMEN2 server"), "emen2")

    #### Copied from twisted/scripts/twistd.py #####
    if platformType == "win32":
        from twisted.scripts._twistw import ServerOptions, \
            WindowsApplicationRunner as _SomeApplicationRunner
    else:
        from twisted.scripts._twistd_unix import ServerOptions, \
            UnixApplicationRunner as _SomeApplicationRunner

    #Create an altered ServerOptions that only runs EMEN2.
    class TestOptions(ServerOptions):
        def _getPlugins(self, interface, package=None):
            f = plugin.getPlugins(interface, package=None)
            return list(f) + [EMEN2Server]

    def runApp(config):
        _SomeApplicationRunner(config).run()

    app.run(runApp, TestOptions)
Ejemplo n.º 3
0
def main(args):
    if args.nodaemon:
        sys.argv = ['', '-ny', TAC_FILE, '--umask=022']
    else:
        sys.argv = ['', '-y', TAC_FILE, '--umask=022']

    if args.pidfile:
        sys.argv.append(f'--pidfile={args.pidfile}')

    if args.logfile:
        sys.argv.append(f'--logfile={args.logfile}')

    from twisted.application import app
    from twisted.scripts._twistd_unix import ServerOptions, UnixApplicationRunner

    def runApp(config):
        runner = UnixApplicationRunner(config)
        runner.run()
        if runner._exitSignal is not None:
            app._exitWithSignal(runner._exitSignal)

    app.run(runApp, ServerOptions)
Ejemplo n.º 4
0
def run_script (_f) :
    _found = False
    _n = list()
    _n.append(sys.argv[0], )
    for i in sys.argv[1:] :
        if _found :
            _found = False
            continue
        elif i in ServerOptions.unused_short :
            _found = True
            continue
        elif filter(i.startswith, ServerOptions.unused_long, ) :
            continue

        _n.append(i, )

    _n.extend(["-y", _f, ], )
    sys.argv = _n

    from twisted.application import app
    from twisted.scripts.twistd import runApp
    app.run(runApp , ServerOptions, )
Ejemplo n.º 5
0
def run():
    app.run(runApp, ServerOptions)
Ejemplo n.º 6
0
def run():
    from twisted.application import app
    app.run(runApp, GettextOptions)
Ejemplo n.º 7
0
def run():
    app.run(runApp, ServerOptions)
Ejemplo n.º 8
0
#!/usr/bin/env python
#-------------------------------------------------------------------------------
# Author: Lukasz Janyst <*****@*****.**>
# Date:   26.11.2017
#
# Licensed under the 3-Clause BSD License, see the LICENSE file for details.
#-------------------------------------------------------------------------------

from twisted.scripts.twistd import _SomeApplicationRunner, ServerOptions
from twisted.application import app
from scrapy_do.app import ScrapyDoServiceMaker


class ScrapyDoRunnerOptions(ServerOptions):
    @property
    def subCommands(self):
        sm = ScrapyDoServiceMaker()
        self.loadedPlugins = {sm.tapname: sm}
        yield (sm.tapname, None, sm.options, sm.description)


def run_app(config):
    _SomeApplicationRunner(config).run()


app.run(run_app, ScrapyDoRunnerOptions)
Ejemplo n.º 9
0
def run():
    app.run(runApp, Options)
Ejemplo n.º 10
0
 def run():
    """
    Replace twisted.application.app.run()
    To use our ServerOptions.
    """
    app.run(runApp, MyServerOptions)
Ejemplo n.º 11
0
    _n.append(sys.argv[0], )
    for i in sys.argv[1:] :
        if _found :
            _found = False
            continue
        elif i in Options.unused_short :
            _found = True
            continue
        elif filter(i.startswith, Options.unused_long, ) :
            continue

        _n.append(i, )

    _n.extend(["-y", __file__, ], )
    sys.argv = _n

    from twisted.application import app
    from twisted.scripts.twistd import runApp
    app.run(runApp , Options, )




if __name__ == "__main__"  :
    import doctest
    doctest.testmod()




Ejemplo n.º 12
0
def run():
    from twisted.application import app
    app.run(runApp, GettextOptions)
Ejemplo n.º 13
0
def run():
    _monkey_patch_twistd_loggers()
    app.run(runApp, ServerOptions)