Server API
Implementation of server for ellclockin.
-
class ellclockin.server.Server(config)[source]
Bases: RpcBroker
Elldev server that is also a SHV Broker.
- Parameters:
config (ServerConfig) –
-
class Client(client, broker, *args, user=None, **kwargs)[source]
Bases: Client
The client exposed in Broker.
- Parameters:
-
-
class LoginClient(*args, **kwargs)[source]
Bases: Client
, LoginClient
Broker’s client that expects login from client.
- Parameters:
-
-
APP_NAME: str = 'clockin-broker'
Name reported as application name for pyshvbroker.
-
class ConnectClient(*args, target_mount_point=None, **kwargs)[source]
Bases: Client
, ConnectClient
Broker client that actively connects to some other peer.
- Parameters:
-
-
APP_NAME: str = 'clockin-broker-client'
Name reported as application name for pyshvbroker connection.
-
class ellclockin.server.ServerConfig(port=3755, users=<factory>, dbfile=PosixPath('ellclockin.db'))[source]
Bases: object
Elldev server config.
- Parameters:
-
-
port: int = 3755
TCP/IP port where server will be listening.
-
users: dict[str, str]
Mapping of user name to their passwords.
-
dbfile: Path = PosixPath('ellclockin.db')
Path to the SQLite database file.
-
shvbroker_config()[source]
Provide new SHV Broker config based on this configuration.
- Return type:
RpcBrokerConfig
-
classmethod load(path)[source]
Load configuration file.
- Parameters:
path (Path) – path to the configuration file
- Return type:
ServerConfig
-
class ellclockin.server.ServerDatabase(config)[source]
Bases: object
Abstraction on top of the database to provide data retention functionality.
- Parameters:
config (ServerConfig) –
-
projects()[source]
Iterate over project names.
- Return type:
Iterator[str]
-
projects_in_progress()[source]
Iterate over project names for those not yet completed.
- Return type:
Iterator[str]
-
new_project(name)[source]
Create new project.
- Parameters:
name (str) – name of the new project
- Return type:
None
-
complete_project(name)[source]
Make project completed.
- Parameters:
name (str) – name of the project
- Return type:
None
-
project_complete(name)[source]
Check if given project is complete or not.
- Parameters:
name (str) – name of the project
- Return type:
bool
-
project_workers(name)[source]
Set of all workers participating in this project.
- Parameters:
name (str) – name of the project
- Return type:
set[str]
-
project_worker_seconds(project, worker)[source]
Provide number of seconds invested in this project by this worker so far.
- Parameters:
-
- Returns:
number of seconds invested
- Return type:
int
-
project_seconds(name)[source]
Provide number of seconds invested in this project so far.
- Parameters:
name (str) – name of the project
- Return type:
int
-
workers()[source]
Iterate over all worker names.
- Return type:
Iterator[str]
-
new_worker(name)[source]
Register new worker.
- Parameters:
name (str) – name of the new worker
- Return type:
None
-
work(name, project)[source]
Start or end worker’s work on project.
- Parameters:
name (str) – name of the worker
project (str | None) – name of the project, None when ending the work
- Return type:
None
-
retroactive_clockout(name, retro_date)[source]
Retroactively end worker’s work on their current project.
- Parameters:
-
- Return type:
None
-
add_work(name, project, seconds)[source]
Add record about work in the past.
- Parameters:
name (str) – name of the worker
project (str) – name of the project
seconds (int) – number of seconds invested
- Return type:
None
-
current_project(name)[source]
Get current project user is working on.
- Parameters:
name (str) – name of the worker
- Return type:
str | None
-
current_seconds(name)[source]
Get current number of seconds user already invested into the current project.
- Parameters:
name (str) – name of the project
- Returns:
number of seconds invested
- Return type:
int | None