Exemple #1
0
 def _banner_data(self, worker: Worker) -> TableDataT:
     app = cast(FaustWorker, worker).app
     logfile = worker.logfile if worker.logfile else "-stderr-"
     loglevel = level_name(worker.loglevel or "WARN").lower()
     transport_extra = self._human_transport_info(worker.loop)
     return list(
         filter(
             None,
             [
                 ("id", app.conf.id),
                 ("transport", f"{app.conf.broker} {transport_extra}"),
                 ("store", f"{app.conf.store}"),
                 ("web",
                  f"{app.web.url}") if app.conf.web_enabled else None,
                 ("log", f"{logfile} ({loglevel})"),
                 ("pid", f"{os.getpid()}"),
                 ("hostname", f"{socket.gethostname()}"),
                 ("platform", self.platform()),
                 self._human_cython_info(),
                 ("drivers", ""),
                 ("  transport", app.transport.driver_version),
                 ("  web", app.web.driver_version),
                 ("datadir", f"{str(app.conf.datadir.absolute()):<40}"),
                 ("appdir", f"{str(app.conf.appdir.absolute()):<40}"),
             ],
         ))
Exemple #2
0
 def banner(self, worker: Worker) -> str:
     """Generate the text banner emitted before the worker starts."""
     app = worker.app
     loop = worker.loop
     transport_extra = ''
     # uvloop didn't leave us with any way to identify itself,
     # and also there's no uvloop.__version__ attribute.
     if loop.__class__.__module__ == 'uvloop':
         transport_extra = '+uvloop'
     if 'gevent' in loop.__class__.__module__:
         transport_extra = '+gevent'
     logfile = worker.logfile if worker.logfile else '-stderr-'
     loglevel = level_name(worker.loglevel or 'WARN').lower()
     compiler = platform.python_compiler()
     cython_info = None
     try:
         import faust._cython.windows  # noqa: F401
     except ImportError:
         pass
     else:
         cython_info = ('       +', f'Cython ({compiler})')
     data = list(
         filter(None, [
             ('id', app.conf.id),
             ('transport', f'{app.conf.broker} {transport_extra}'),
             ('store', app.conf.store),
             ('web', app.web.url) if app.conf.web_enabled else None,
             ('log', f'{logfile} ({loglevel})'),
             ('pid', f'{os.getpid()}'),
             ('hostname', f'{socket.gethostname()}'),
             ('platform', self.platform()),
             cython_info if cython_info else None,
             ('drivers', ''),
             ('  transport', app.transport.driver_version),
             ('  web', app.web.driver_version),
             ('datadir', f'{str(app.conf.datadir.absolute()):<40}'),
             ('appdir', f'{str(app.conf.appdir.absolute()):<40}'),
         ]))
     table = self.table(
         [(self.bold(x), str(y)) for x, y in data],
         title=self.faust_ident(),
     )
     table.inner_heading_row_border = False
     table.inner_row_border = False
     return table.table
Exemple #3
0
 def _banner_data(self, worker: Worker) -> TableDataT:
     app = cast(FaustWorker, worker).app
     logfile = worker.logfile if worker.logfile else '-stderr-'
     loglevel = level_name(worker.loglevel or 'WARN').lower()
     transport_extra = self._human_transport_info(worker.loop)
     return list(filter(None, [
         ('id', app.conf.id),
         ('transport', f'{app.conf.broker} {transport_extra}'),
         ('store', f'{app.conf.store}'),
         ('web', f'{app.web.url}') if app.conf.web_enabled else None,
         ('log', f'{logfile} ({loglevel})'),
         ('pid', f'{os.getpid()}'),
         ('hostname', f'{socket.gethostname()}'),
         ('platform', self.platform()),
         self._human_cython_info(),
         ('drivers', ''),
         ('  transport', app.transport.driver_version),
         ('  web', app.web.driver_version),
         ('datadir', f'{str(app.conf.datadir.absolute()):<40}'),
         ('appdir', f'{str(app.conf.appdir.absolute()):<40}'),
     ]))
Exemple #4
0
 def banner(self, worker: Worker) -> str:
     """Generate the text banner emitted before the worker starts."""
     app = worker.app
     loop = worker.loop
     website = worker.website
     transport_extra = ''
     # uvloop didn't leave us with any way to identify itself,
     # and also there's no uvloop.__version__ attribute.
     if loop.__class__.__module__ == 'uvloop':
         transport_extra = '+uvloop'
     if 'gevent' in loop.__class__.__module__:
         transport_extra = '+gevent'
     logfile = worker.logfile if worker.logfile else '-stderr-'
     loglevel = level_name(worker.loglevel or 'WARN').lower()
     data = [
         ('id', app.conf.id),
         ('transport', f'{app.conf.broker} {transport_extra}'),
         ('store', app.conf.store),
         ('web', website.web.url),
         ('log', f'{logfile} ({loglevel})'),
         ('pid', f'{os.getpid()}'),
         ('hostname', f'{socket.gethostname()}'),
         ('platform', self.platform()),
         ('drivers', '{transport_v} {http_v}'.format(
             transport_v=app.transport.driver_version,
             http_v=website.web.driver_version)),
         ('datadir', f'{str(app.conf.datadir.absolute()):<40}'),
         ('appdir', f'{str(app.conf.appdir.absolute()):<40}'),
     ]
     table = self.table(
         [(self.bold(x), y) for x, y in data],
         title=self.faust_ident(),
     )
     table.inner_heading_row_border = False
     table.inner_row_border = False
     return table.table
Exemple #5
0
def test_level_name(input, expected):
    assert level_name(input) == expected