|
def | __init__ (self, str contributors_file, float start_time_utc, float contribution_interval, str tls_key, str tls_certificate, int port=5000, Optional[str] email_server=None, Optional[str] email_address=None, Optional[str] email_password_file=None) |
|
str | to_json (self) |
|
str | to_json_template (self) |
|
Static configuration provided at startup
Definition at line 19 of file server_configuration.py.
◆ __init__()
def coordinator.server_configuration.Configuration.__init__ |
( |
|
self, |
|
|
str |
contributors_file, |
|
|
float |
start_time_utc, |
|
|
float |
contribution_interval, |
|
|
str |
tls_key, |
|
|
str |
tls_certificate, |
|
|
int |
port = 5000 , |
|
|
Optional[str] |
email_server = None , |
|
|
Optional[str] |
email_address = None , |
|
|
Optional[str] |
email_password_file = None |
|
) |
| |
Definition at line 23 of file server_configuration.py.
25 contributors_file: str,
26 start_time_utc: float,
27 contribution_interval: float,
31 email_server: Optional[str] =
None,
32 email_address: Optional[str] =
None,
33 email_password_file: Optional[str] =
None):
34 if not contributors_file:
35 raise Exception(
"no contributors file specified")
36 if start_time_utc == 0.0:
37 raise Exception(
"invalid start time")
38 if (email_server
or email_address
or email_password_file)
and \
39 (
not (email_server
and email_address
and email_password_file)):
41 "must all or none of email server, address and password file " +
43 if email_password_file
and not exists(email_password_file):
44 raise Exception(f
"no email password file: {email_password_file}")
46 self.contributors_file: str = contributors_file
47 self.start_time_utc: float = float(start_time_utc)
48 self.contribution_interval: float = float(contribution_interval)
49 self.email_server: Optional[str] = email_server
50 self.email_address: Optional[str] = email_address
51 self.email_password_file: Optional[str] = email_password_file
52 self.tls_key: str = tls_key
53 self.tls_certificate: str = tls_certificate
◆ from_json()
Configuration coordinator.server_configuration.Configuration.from_json |
( |
str |
config_json | ) |
|
|
static |
Definition at line 88 of file server_configuration.py.
88 def from_json(config_json: str) -> Configuration:
89 return Configuration._from_json_dict(json.loads(config_json))
◆ template()
Configuration coordinator.server_configuration.Configuration.template |
( |
| ) |
|
|
static |
Populate contributors field, and other fields with sensible defaults
for a configuration template. All fields are expected to be
overridden.
Definition at line 57 of file server_configuration.py.
57 def template() -> Configuration:
59 Populate contributors field, and other fields with sensible defaults
60 for a configuration template. All fields are expected to be
64 contributors_file=
"contributors.json",
65 start_time_utc=time.time() + 6 * 60 * 60,
66 contribution_interval=24 * 60 * 60,
68 tls_certificate=
"cert.pem",
70 email_server=
"smtp.mymail.com:465",
71 email_address=
"mpc_coordinator@mymail.com",
72 email_password_file=
"password.txt")
◆ to_json()
str coordinator.server_configuration.Configuration.to_json |
( |
|
self | ) |
|
Definition at line 74 of file server_configuration.py.
74 def to_json(self) -> str:
75 return json.dumps(self._to_json_dict(), indent=4)
◆ to_json_template()
str coordinator.server_configuration.Configuration.to_json_template |
( |
|
self | ) |
|
For the case where ana administrator has a list of contributors (e.g.
from an online form) and keys and wants to import it into a
server_config.json file. This function writes the contributors
correctly, and places dummy data / descriptions in other fields,
prefixed with '_', for the admin to fill in later.
Definition at line 77 of file server_configuration.py.
77 def to_json_template(self) -> str:
79 For the case where ana administrator has a list of contributors (e.g.
80 from an online form) and keys and wants to import it into a
81 server_config.json file. This function writes the contributors
82 correctly, and places dummy data / descriptions in other fields,
83 prefixed with '_', for the admin to fill in later.
85 return json.dumps(self._to_json_template_dict(), indent=4)
◆ port
coordinator.server_configuration.Configuration.port |
The documentation for this class was generated from the following file: