Skip to main content

Manager for Vesikanta operations

Project description

Vesikanta manager

PyPI version

Vesikanta package provides all necessary functionality to automate tasks related to customer and real estate management, billing, and data transfers within the Vesikanta system.

[!NOTE] Functions currently not used are marked with NOTE: NOT IN USE This is related to the issue with checking tracking data programmatically. These functions are currently placeholder functions just to save development time if "Seurantatietojen keruu" becomes possible to do programmatically.

Requirements

  • robocorp >= 2.1.0
  • robocorp-windows >= 1.0.4
  • pydantic >= 2.9.2
  • email-validator >= 2.2.0
  • pyautogui >= 0.9.54
  • pandas >= 2.2.3

How to develop

  1. Clone the repository and navigate to the root folder
  2. Install or upgrade build by running: py -m pip install --upgrade build
  3. Generate distribution packages for the package with command: python -m build This command will generate a source distribution (tar.gz) and a wheel (whl) in a dist/ folder.
dist/
├── example_package-1.0.0-py3-none-any.whl
└── example_package-1.0.0.tar.gz
  1. Create a devtask-folder that contains the following files (sema4.ai create task package)
devtask/
├── .gitignore
├── conda.yaml
├── config.json
├── config.py
├── tasks.py

File examples:

.gitignore
  • .gitignore file is just the default one coming with sema4.ai create task package. This can be left out, but conda.yaml file will recognize it missing and warn about it.
output/
venv/
temp/
.rpa/
.idea/
.ipynb_checkpoints/
*/.ipynb_checkpoints/*
.virtual_documents/
*/.virtual_documents/*
.vscode
.DS_Store
*.pyc
*.zip
*/work-items-out/*
testrun/*
.~lock*
*.pkl
conda.yaml
  • conda.yaml Here the package is installed in editable mode.
# For more details on the format and content:
# https://github.com/robocorp/rcc/blob/master/docs/recipes.md#what-is-in-condayaml
# Tip: Adding a link to the release notes of the packages helps maintenance and security.

channels:
  - conda-forge

dependencies:
  - python=3.10.12                # https://pyreadiness.org/3.10
  - pip=23.2.1                    # https://pip.pypa.io/en/stable/news
  - robocorp-truststore=0.8.0     # https://pypi.org/project/robocorp-truststore/
  - pip:
    - robocorp==2.1.0             # https://pypi.org/project/robocorp
    - robocorp-windows==1.0.4     # https://pypi.org/project/robocorp-browser
    - pydantic==2.9.2             # https://pypi.org/project/pydantic
    - email-validator==2.2.0      # https://pypi.org/project/email-validator/
    - pyautogui==0.9.54           # https://pypi.org/project/PyAutoGUI
    - pandas==2.2.3               # https://pandas.pydata.org

rccPostInstall:
  - pip install -e "..\\..\\riverit-vesikanta-manager"
config.json
  • This is the layout of correct configuration in json format. Values must be changed accordingly
{
    "vesikanta_path": "path_to_the_application_exe",
    "vesikanta_creds": "vesikanta_secrets_within_cloud",
    "reading_report_files_path": "robot_working_folder_for_reading_files",
    "reading_report_files_archive_path": "robot_archive_folder_for_reading_files",
    "tracking_report_files_path": "robot_working_folder_for_tracking_files",
    "tracking_report_files_archive_path": "robot_archive_folder_for_tracking_files",
    "ufile_path": "robot_working_folder",
    "customer_group_start": "group_number",
    "customer_group_end": "group_number",
    "email_creds": "email_secrets_within_cloud",
    "email_sender": "sender@mail.com",
    "email_recipients": ["reciever@mail.com"],
    "email_subject": "subject_of_email",
    "email_body": "body_of_email",
    "date_format": "%Y%m%d_%H%M",
    "signature": "name_for_signature",
    "column_p_regex_list": ["item1","item2"]
}
config.py
  • Used to differentiate between development and production environments and load corresponding json configuration
import json
import os

from pydantic import ValidationError
from robocorp import log, storage

from riverit_vesikanta_manager import Config


def read_config(config_name: str) -> Config:
    """
    Reads the configuration based on the runtime environment.
    Automatically determines if it should read from a local (development) config or asset (production) config.

    Args:
        `config_name` (str): The name of the configuration file to read from robocorp cloud.

    Returns:
        `config` (Config): The configuration data.

    Raises:
        `Exception`: If there is an error while reading the configuration.
    """
    # Check for an environment variable to determine the runtime environment
    dev_env = os.getenv("RUNTIME_ENV") == "dev"
    config = None

    if dev_env:
        try:
            with open("config.json", "r", encoding="utf-8") as file:
                config_data = json.load(file)
                log.info("Read local config.")
        except Exception as e:
            raise Exception(f"Failed to read local config: {e}")
    else:
        try:
            config_data = storage.get_json(config_name)
            log.info("Read asset config.")
        except Exception as e:
            raise Exception(f"Failed to read asset config: {e}")

    try:
        config = Config(**config_data)
    except ValidationError as e:
        raise Exception(f"Failed to validate config: {e}")

    return config
robot.yaml
  • Default file coming when creating task package
# For more details on the format and content:
# https://github.com/robocorp/rcc/blob/master/docs/recipes.md#what-is-in-robotyaml

tasks:
  Run Task:
    shell: python -m robocorp.tasks run tasks.py

environmentConfigs:
  - environment_windows_amd64_freeze.yaml
  - environment_linux_amd64_freeze.yaml
  - environment_darwin_amd64_freeze.yaml
  - conda.yaml

artifactsDir: output

PATH:
  - .
PYTHONPATH:
  - .
ignoreFiles:
  - .gitignore
tasks.py
  • Minimal task to test the package with. This should log in Vesikanta and close the application immediately afterwards.
from config import read_config
from robocorp.tasks import task

from riverit_vesikanta_manager import VesikantaManager

config = read_config("cloud_config_name")

vk = VesikantaManager(config)


@task
def minimal_task():
    with vk:
        print("onnistui")

  1. Create .env file in the root folder with following values, to use the local config.json from the devtask folder

.env

RUNTIME_ENV = "dev"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

riverit_vesikanta_manager-0.2.0.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

riverit_vesikanta_manager-0.2.0-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

Details for the file riverit_vesikanta_manager-0.2.0.tar.gz.

File metadata

File hashes

Hashes for riverit_vesikanta_manager-0.2.0.tar.gz
Algorithm Hash digest
SHA256 48a1fc147dc20a28eaf22a4d050b3e87cb45dee97861b8b1e12fe74faba6445c
MD5 2ccfd8142c498a06dcaccde22d92f68d
BLAKE2b-256 82c65ce9f2565bfd620579edaa0e12e2e247cfaf83630797db6289aa84215e16

See more details on using hashes here.

Provenance

File details

Details for the file riverit_vesikanta_manager-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for riverit_vesikanta_manager-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0dae5c9d4a829c071e116e3883dd55cf60d210c0a9ce18011471c78a2f1b2d5f
MD5 88cfbf5ce50342ae1a9bba704117807a
BLAKE2b-256 b12d1b20d92ff8718f33244590b94f9b9387c3a90da15617e020fc21b18541a5

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page