pulsar.util.pastescript package

Submodules

pulsar.util.pastescript.loadwsgi module

pulsar.util.pastescript.loadwsgi.appconfig(uri, name=None, relative_to=None, global_conf=None)[source]
pulsar.util.pastescript.loadwsgi.loadapp(uri, name=None, **kw)[source]
pulsar.util.pastescript.loadwsgi.loadfilter(uri, name=None, **kw)[source]
pulsar.util.pastescript.loadwsgi.loadserver(uri, name=None, **kw)[source]

pulsar.util.pastescript.serve module

exception pulsar.util.pastescript.serve.BadCommand(message, exit_code=2)[source]

Bases: Exception

property message

Getter for ‘message’; needed only to override deprecation in BaseException.

class pulsar.util.pastescript.serve.BoolOptionParser(usage=None, option_list=None, option_class=<class 'optparse.Option'>, version=None, conflict_handler='error', description=None, formatter=None, add_help_option=True, prog=None, epilog=None)[source]

Bases: OptionParser

class pulsar.util.pastescript.serve.Command(name)[source]

Bases: object

exception BadCommand(message, exit_code=2)

Bases: Exception

property message

Getter for ‘message’; needed only to override deprecation in BaseException.

default_interactive = 0
default_verbosity = 0
description: str | None = None
group_name = ''
hidden = False
logging_file_config(config_file)[source]

Setup logging via the logging module’s fileConfig function with the specified config_file, if applicable.

ConfigParser defaults are specified for the special __file__ and here variables, similar to PasteDeploy config loading.

max_args = None
max_args_error = 'You must provide no more than %(max_args)s arguments'
min_args: int | None = None
min_args_error = 'You must provide at least %(min_args)s arguments'
pad(s, length, dir='left')[source]
parse_args(args)[source]
parse_vars(args)[source]

Given variables like ['a=b', 'c=d'] turns it into {'a': 'b', 'c': 'd'}

quote_first_command_arg(arg)[source]

There’s a bug in Windows when running an executable that’s located inside a path with a space in it. This method handles that case, or on non-Windows systems or an executable with no spaces, it just leaves well enough alone.

required_args = ()
return_code = 0
run(args)[source]
classmethod standard_parser(verbose=True, interactive=False, no_interactive=False, simulate=False, quiet=False, overwrite=False)

Create a standard OptionParser instance.

Typically used like:

class MyCommand(Command):
    parser = Command.standard_parser()

Subclasses may redefine standard_parser, so use the nearest superclass’s class method.

takes_config_file: int | None = None
usage = ''
exception pulsar.util.pastescript.serve.DaemonizeException[source]

Bases: Exception

class pulsar.util.pastescript.serve.LazyWriter(filename, mode='w')[source]

Bases: object

File-like object that opens a file lazily when it is first written to.

flush()[source]
open()[source]
write(text)[source]
writelines(text)[source]
class pulsar.util.pastescript.serve.NoDefault[source]

Bases: object

class pulsar.util.pastescript.serve.NotFoundCommand(name)[source]

Bases: Command

run(args)[source]
class pulsar.util.pastescript.serve.ServeCommand(name)[source]

Bases: Command

change_user_group(user, group)[source]
command()[source]
daemonize()[source]
default_verbosity = 1
description: str | None = "    This command serves a web application that uses a paste.deploy\n    configuration file for the server and application.\n\n    If start/stop/restart is given, then --daemon is implied, and it will\n    start (normal operation), stop (--stop-daemon), or do both.\n\n    You can also include variable assignments like 'http_port=8080'\n    and then use %(http_port)s in your config files.\n    "
min_args: int | None = 0
parser = <pulsar.util.pastescript.serve.BoolOptionParser object>
possible_subcommands = ('start', 'stop', 'restart', 'status')
record_pid(pid_file)[source]
requires_config_file = True
restart_with_monitor(reloader=False)[source]
restart_with_reloader()[source]
show_status()[source]
stop_daemon()[source]
summary = 'Serve the described application'
takes_config_file: int | None = 1
usage = 'CONFIG_FILE [start|stop|restart|status] [var=value]'
pulsar.util.pastescript.serve.difflib = None

A subclass of optparse.OptionParser that allows boolean long options (like --verbose) to also take arguments (like --verbose=true). Arguments must use =.

pulsar.util.pastescript.serve.ensure_port_cleanup(bound_addresses, maxtries=30, sleeptime=2)[source]

This makes sure any open ports are closed.

Does this by connecting to them until they give connection refused. Servers should call like:

import paste.script
ensure_port_cleanup([80, 443])
pulsar.util.pastescript.serve.invoke(command, command_name, options, args)[source]
pulsar.util.pastescript.serve.live_pidfile(pidfile)[source]

(pidfile:str) -> int | None Returns an int found in the named file, if there is one, and if there is a running process with that process id. Return None if no such process exists.

pulsar.util.pastescript.serve.read_pidfile(filename)[source]
pulsar.util.pastescript.serve.run(args=None)[source]

Module contents

Command for loading and serving wsgi apps taken from PasteScript