# kontor
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Supported Versions](https://img.shields.io/pypi/pyversions/kontor.svg)](https://pypi.org/project/kontor)
[![License](https://img.shields.io/pypi/l/kontor.svg)](https://pypi.python.org/pypi/kontor/)
[![Tests](https://github.com/morwy/kontor/actions/workflows/python-tests.yml/badge.svg)](https://github.com/morwy/kontor/actions/workflows/python-tests.yml)
kontor is a client-server bundle that is designed to execute pre-defined procedures on server by request of authorized client.
Currently kontor is in pre-alpha stage, providing no secure way of transferring the files.
## Installation
**kontor** can be installed by simply calling **pip**:
```bash
pip install kontor
```
Upgrade of **kontor** is done with the common **pip** command:
```bash
pip install kontor --upgrade
```
## Requirements
Minimum Python version supported is 3.7.
kontor relies on one external package called **dacite**.
## Examples
### Bureau
#### Windows
It is possible to run Bureau as service on Windows by using [WinSW v3](https://github.com/winsw/winsw/tree/v3) as bundled tool.
1. Create a new folder, e.g. `C:\kontor`
2. Download WinSW executable of suitable version
3. Put it to `C:\kontor` folder
4. Rename it to `kontor.exe`
5. Create a `kontor.xml` configuration file and add following text there:
```xml
<service>
<id>kontor</id>
<name>kontor</name>
<description>This service runs kontor as Windows service.</description>
<executable>python</executable>
<arguments>start_server.py</arguments>
<log mode="none" />
<onfailure action="restart" />
</service>
```
6. Create a `start_server.py` file and add following text there (this file is also present in `examples/server` repo folder):
```python
#!/usr/bin/env python
import logging
import os
import signal
import sys
from kontor.bureau import Bureau
def shutdown_signal_handler(sig, frame):
logging.critical("Caught SIGINT signal, bureau will be shut down.")
sys.exit(0)
if __name__ == "__main__":
#
# Catch Ctrl+C signal for notifying about bureau shutdown.
#
signal.signal(signal.SIGINT, shutdown_signal_handler)
bureau = Bureau(os.path.dirname(os.path.realpath(__file__)))
bureau.start()
```
7. Install kontor as a service by calling following command in CMD:
```batch
kontor install
```
8. Create `server_configuration.json` file next to `start_server.py`. Example configuration may look like following:
```json
{
"ip_address": "localhost",
"port": 5690,
"chunk_size_kilobytes": 256,
"client_idle_timeout_seconds": 30,
"max_storage_period_hours": 0,
"max_parallel_connections": 100,
"max_consequent_client_procedures": 1,
"max_grace_shutdown_timeout_seconds": 30,
"procedures": {
"test_procedure": {
"name": "test_procedure",
"operation": "echo \"this is a test procedure\"",
"error_codes": [
1
],
"max_repeats_if_failed": 3,
"time_seconds_between_repeats": 10
}
}
}
```
10. Start service by calling the command:
```batch
kontor start
```
10. [WinSW CLI instruction](https://github.com/winsw/winsw/blob/v3/docs/cli-commands.md) has a lot more of useful commands that can be applied. Most useful though would be following:
```batch
kontor stop
```
```batch
kontor restart
```
```batch
kontor uninstall
```
## Bureau-applicant interaction flowchart
<details>
<summary>Click to show the flowchart (it is pretty long)</summary>
```mermaid
sequenceDiagram
participant Client
participant Server
loop
Server->>Server: waiting for incoming requests
end
Client->>Server: requesting auth
activate Server
loop
Client->>Client: waiting for the response
end
break when the auth fails
Server-->>Client: show failure
end
Server-->>Client: auth success
deactivate Server
Client->>Server: requesting procedure for file
activate Server
loop
Client->>Client: waiting for the response
end
break when the procedure check fails
Server-->>Client: declining procedure
end
Server-->>Client: accepting procedure
deactivate Server
Client->>Server: sending file
activate Server
break when the file transmission fails
Server-->>Client: show failure
end
Server-->>Client: file receiving receipt
loop
Server->>Server: processing file
end
Server->>Client: requesting result file receiving
activate Client
Client->>Server: accepting result file receiving
deactivate Client
Server->>Client: sending result file
deactivate Server
```
</details>
Raw data
{
"_id": null,
"home_page": "https://github.com/morwy/kontor",
"name": "kontor",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "client,server,transfer",
"author": "Pavel Ivanov",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/d9/a6/419301a7fa48b9fd508b897d36220fc6e188ccb284cacee302a13a04d569/kontor-0.0.38.tar.gz",
"platform": "any",
"description": "# kontor\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Supported Versions](https://img.shields.io/pypi/pyversions/kontor.svg)](https://pypi.org/project/kontor)\n[![License](https://img.shields.io/pypi/l/kontor.svg)](https://pypi.python.org/pypi/kontor/)\n[![Tests](https://github.com/morwy/kontor/actions/workflows/python-tests.yml/badge.svg)](https://github.com/morwy/kontor/actions/workflows/python-tests.yml)\n\nkontor is a client-server bundle that is designed to execute pre-defined procedures on server by request of authorized client.\n\nCurrently kontor is in pre-alpha stage, providing no secure way of transferring the files.\n\n## Installation\n\n**kontor** can be installed by simply calling **pip**:\n\n```bash\npip install kontor\n```\n\nUpgrade of **kontor** is done with the common **pip** command:\n\n```bash\npip install kontor --upgrade\n```\n\n## Requirements\n\nMinimum Python version supported is 3.7.\n\nkontor relies on one external package called **dacite**.\n\n## Examples\n### Bureau\n#### Windows\n\nIt is possible to run Bureau as service on Windows by using [WinSW v3](https://github.com/winsw/winsw/tree/v3) as bundled tool.\n1. Create a new folder, e.g. `C:\\kontor`\n2. Download WinSW executable of suitable version\n3. Put it to `C:\\kontor` folder\n4. Rename it to `kontor.exe`\n5. Create a `kontor.xml` configuration file and add following text there:\n```xml\n<service>\n <id>kontor</id>\n <name>kontor</name>\n <description>This service runs kontor as Windows service.</description>\n <executable>python</executable>\n <arguments>start_server.py</arguments>\n <log mode=\"none\" />\n <onfailure action=\"restart\" />\n</service>\n```\n6. Create a `start_server.py` file and add following text there (this file is also present in `examples/server` repo folder):\n```python\n#!/usr/bin/env python\nimport logging\nimport os\nimport signal\nimport sys\n\nfrom kontor.bureau import Bureau\n\n\ndef shutdown_signal_handler(sig, frame):\n logging.critical(\"Caught SIGINT signal, bureau will be shut down.\")\n sys.exit(0)\n\n\nif __name__ == \"__main__\":\n #\n # Catch Ctrl+C signal for notifying about bureau shutdown.\n #\n signal.signal(signal.SIGINT, shutdown_signal_handler)\n\n bureau = Bureau(os.path.dirname(os.path.realpath(__file__)))\n bureau.start()\n```\n7. Install kontor as a service by calling following command in CMD:\n```batch\nkontor install\n```\n8. Create `server_configuration.json` file next to `start_server.py`. Example configuration may look like following:\n```json\n{\n \"ip_address\": \"localhost\",\n \"port\": 5690,\n \"chunk_size_kilobytes\": 256,\n \"client_idle_timeout_seconds\": 30,\n \"max_storage_period_hours\": 0,\n \"max_parallel_connections\": 100,\n \"max_consequent_client_procedures\": 1,\n \"max_grace_shutdown_timeout_seconds\": 30,\n \"procedures\": {\n \"test_procedure\": {\n \"name\": \"test_procedure\",\n \"operation\": \"echo \\\"this is a test procedure\\\"\",\n \"error_codes\": [\n 1\n ],\n \"max_repeats_if_failed\": 3,\n \"time_seconds_between_repeats\": 10\n }\n }\n}\n```\n10. Start service by calling the command:\n```batch\nkontor start\n```\n10. [WinSW CLI instruction](https://github.com/winsw/winsw/blob/v3/docs/cli-commands.md) has a lot more of useful commands that can be applied. Most useful though would be following:\n```batch\nkontor stop\n```\n```batch\nkontor restart\n```\n```batch\nkontor uninstall\n```\n\n## Bureau-applicant interaction flowchart\n\n<details>\n\n<summary>Click to show the flowchart (it is pretty long)</summary>\n\n```mermaid\nsequenceDiagram\nparticipant Client\nparticipant Server\n\nloop\n Server->>Server: waiting for incoming requests\nend\n\nClient->>Server: requesting auth\nactivate Server\nloop\n Client->>Client: waiting for the response\nend\nbreak when the auth fails\n Server-->>Client: show failure\nend\nServer-->>Client: auth success\ndeactivate Server\n\nClient->>Server: requesting procedure for file\nactivate Server\nloop\n Client->>Client: waiting for the response\nend\nbreak when the procedure check fails\n Server-->>Client: declining procedure\nend\nServer-->>Client: accepting procedure\ndeactivate Server\n\n\nClient->>Server: sending file\nactivate Server\nbreak when the file transmission fails\n Server-->>Client: show failure\nend\nServer-->>Client: file receiving receipt\nloop\n Server->>Server: processing file\nend\nServer->>Client: requesting result file receiving\nactivate Client\nClient->>Server: accepting result file receiving\ndeactivate Client\nServer->>Client: sending result file\ndeactivate Server\n```\n</details>\n",
"bugtrack_url": null,
"license": "BSD-3-Clause",
"summary": "kontor package",
"version": "0.0.38",
"project_urls": {
"Bug Tracker": "https://github.com/morwy/kontor/issues",
"Homepage": "https://github.com/morwy/kontor",
"Source Code": "https://github.com/morwy/kontor"
},
"split_keywords": [
"client",
"server",
"transfer"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6ebfb1379fbe8277fb26fafaa24ef57ff108fe3e2484d699645dc636ccac2209",
"md5": "c24010c8263e2d30ae55aef0e29d45fb",
"sha256": "534d029340768389b188427eaca0e8f3eef92f2f045df94d39e4a48bd39b9123"
},
"downloads": -1,
"filename": "kontor-0.0.38-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "c24010c8263e2d30ae55aef0e29d45fb",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.7",
"size": 16830,
"upload_time": "2023-09-28T07:45:56",
"upload_time_iso_8601": "2023-09-28T07:45:56.664399Z",
"url": "https://files.pythonhosted.org/packages/6e/bf/b1379fbe8277fb26fafaa24ef57ff108fe3e2484d699645dc636ccac2209/kontor-0.0.38-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d9a6419301a7fa48b9fd508b897d36220fc6e188ccb284cacee302a13a04d569",
"md5": "f07c472c2369f2cffd0e23d096caa3b8",
"sha256": "c72ebe6e769da02235c4385fff14091a27d11ceb14566d67c939849bd58c2e55"
},
"downloads": -1,
"filename": "kontor-0.0.38.tar.gz",
"has_sig": false,
"md5_digest": "f07c472c2369f2cffd0e23d096caa3b8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 17214,
"upload_time": "2023-09-28T07:45:57",
"upload_time_iso_8601": "2023-09-28T07:45:57.836810Z",
"url": "https://files.pythonhosted.org/packages/d9/a6/419301a7fa48b9fd508b897d36220fc6e188ccb284cacee302a13a04d569/kontor-0.0.38.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-28 07:45:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "morwy",
"github_project": "kontor",
"github_not_found": true,
"lcname": "kontor"
}