mini_buildd.net module

mini_buildd.net.parse_hopo(hopo)
class mini_buildd.net.Protocol

Bases: enum.Enum

An enumeration.

HTTP = 1
FTP = 2
mini_buildd.net.escape(string)
mini_buildd.net.unescape(string)
class mini_buildd.net.Endpoint(desc, protocol)

Bases: object

Network server endpoint description parser (twisted-like).

Syntax and semantic of the description string should be like in the twisted framework, see

https://twistedmatrix.com/documents/current/core/howto/endpoints.html#servers

Generic form: ‘:’-separated list of parameters:
<param>[:<param>]…
1st parameter is always the type, determining the syntax and semantics of the following parameters:
<type>[:<param>]…
A parameter may also be in key=value style, which we then call an option (can be accessed by its name):
<type>[:<option>=<value>]…
>>> Endpoint.hopo2desc("0.0.0.0:8066")
'tcp:interface=0.0.0.0:port=8066'
>>> print(Endpoint.hopo2desc(":::8066"))
tcp6:interface=\:\::port=8066
>>> Endpoint("tcp:host=example.com:port=1234", Protocol.HTTP).url()  # HTTP client
'http://example.com:1234/'
>>> Endpoint("tls:host=example.com:port=1234", Protocol.HTTP).url()  # HTTPS client
'https://example.com:1234/'
>>> Endpoint("tcp6:port=1234", Protocol.HTTP).url(host="example.com")  # HTTP server
'http://example.com:1234/'
>>> Endpoint("ssl:port=1234", Protocol.HTTP).url(host="example.com")  # HTTPS server
'https://example.com:1234/'
param(index)
type
option(key, default=None)
hopo(host=None)
url(host=None)
classmethod hopo2desc(hopo, server=True)

Needed for HoPo compat.

port
class mini_buildd.net.ServerEndpoint(*args, **kwargs)

Bases: mini_buildd.net.Endpoint

get_certificate()
class mini_buildd.net.ClientEndpoint(*args, **kwargs)

Bases: mini_buildd.net.Endpoint

get_certificate()
class mini_buildd.net.UserURL(url, username=None)

Bases: object

URL with a username attached.

>>> U = UserURL("http://admin@localhost:8066")
>>> (U.username, U.plain, U.full)
('admin', 'http://localhost:8066', 'http://admin@localhost:8066')
>>> U = UserURL("http://example.org:8066", "admin")
>>> (U.username, U.plain, U.full)
('admin', 'http://example.org:8066', 'http://admin@example.org:8066')
>>> UserURL("http://localhost:8066")
Traceback (most recent call last):
  ...
Exception: UserURL: No username given
>>> UserURL("http://admin@localhost:8066", "root")
Traceback (most recent call last):
  ...
Exception: UserURL: Username given in twice, in URL and parameter
username
plain

URL string without username.

full

URL string with username.

mini_buildd.net.urlopen_ca_certificates(url, **kwargs)

urlopen() with system’s default ssl context.

mini_buildd.net.detect_apt_cacher_ng(url='http://localhost:3142')

Little heuristic helper for the “local archives” wizard.

mini_buildd.net.canonize_url(url)

Poor man’s URL canonizer: Always include the port (currently only works for ‘http’ and ‘https’ default ports).

mini_buildd.net.web_login(host, user, credentials, proto='http', login_loc='/accounts/login/', next_loc='/mini_buildd/')