Welcome to jaraco.services documentation!

This module provides a Service base class for modeling management of a service, typically launched as a subprocess.

class jaraco.services.Guard

Bases: object

Prevent execution of a function unless arguments pass self.allowed()

>>> class OnlyInts(Guard):
...     def allowed(self, *args, **kwargs):
...         return all(isinstance(arg, int) for arg in args)
>>> @OnlyInts()
... def the_func(val):
...     print(val)
>>> the_func(1)
1
>>> the_func('1')
>>> the_func(1, '1') is None
True
allowed(*args, **kwargs)
class jaraco.services.HTTPStatus

Bases: object

Mix-in for services that have an HTTP Service for checking the status

build_url(path, host='localhost')
proto = 'http'
status_path = '/_status/system'
wait_for_http(host='localhost', timeout=15)
class jaraco.services.Service

Bases: object

An abstract base class for services

is_running()
static port_free(port, host='localhost')
start()
stop()
class jaraco.services.Subprocess

Bases: object

Mix-in to handle common subprocess handling

class PortFree

Bases: Guard

allowed(service, *args, **kwargs)
assert_running()
get_log()
is_external()

A service is external if there’s another process already providing this service, typically detected by the port already being occupied.

is_running()
log_root

Much like the property builtin, but only implements __get__, making it a non-data property, and can be subsequently reset.

See http://users.rcn.com/python/download/Descriptor.htm for more information.

>>> class X(object):
...   @NonDataProperty
...   def foo(self):
...     return 3
>>> x = X()
>>> x.foo
3
>>> x.foo = 4
>>> x.foo
4

‘…’ below should be ‘jaraco.classes’ but for pytest-dev/pytest#3396 >>> X.foo <….properties.NonDataProperty object at …>

stop()
wait_for_pattern(pattern, timeout=5)
class jaraco.services.paths.PathFinder

Bases: object

A base class for locating an executable or executables.

args: List[str] = []

Additional args to pass to the exe when testing for its suitability

candidate_paths = ['']

Potential roots to search for self.exe

abstract property exe

The target executable

classmethod find_root()
classmethod find_valid_roots()

Generate valid roots for the target executable based on the candidate paths.

classmethod is_valid_root(root)
classmethod resolve()

Resolve an executable or raise RuntimeError if one cannot be found.

Indices and tables