• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

unity-sds / unity-py / 9846236301

08 Jul 2024 08:10PM UTC coverage: 46.923% (-5.9%) from 52.801%
9846236301

push

github

web-flow
Ogc processes api (#92)

* added ogc client, started to make changes to support those methods

* added process.execute method

* added job processes, ogc_notebook example

* updated ogc api from local build to tagged git version

* added normal commit

* updated changelog

* Removed process regression test since it relies on changing environment. This will be added back in when we get the 'unity-venue-ops' account set up

24 of 129 new or added lines in 4 files covered. (18.6%)

20 existing lines in 6 files now uncovered.

366 of 780 relevant lines covered (46.92%)

2.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.47
/unity_sds_client/unity.py
1
import os
6✔
2
from configparser import ConfigParser, ExtendedInterpolation
6✔
3
from unity_sds_client.services.data_service import DataService
6✔
4
from unity_sds_client.services.process_service import ProcessService
6✔
5
from unity_sds_client.services.health_service import HealthService
6✔
6
from unity_sds_client.unity_session import UnitySession
6✔
7
from unity_sds_client.unity_exception import UnityException
6✔
8
from unity_sds_client.unity_environments import UnityEnvironments
6✔
9
from unity_sds_client.unity_services import UnityServices
6✔
10

11

12
class Unity(object):
6✔
13
    """
6✔
14
    The Unity class is used to create services and resources that facilitate interacting with the Unity Platform.
15
    Basic shared configuration items are also saved here. This wraps an underlying unity_session.Session object, which
16
    is passed to different services and resources as needed.
17
    """
18

19
    def __init__(self, environment: UnityEnvironments = UnityEnvironments.TEST, config_file_override:str = None):
6✔
20
        """
21
        :param environment: the default environment for a session to work with. Defaults to 'TEST' unity environment.
22
        :param config_file_override: absolute path to a config file containing settings to override default config
23
        """
24
        env = environment
6✔
25
        config = _read_config([
6✔
26
            os.path.dirname(os.path.realpath(__file__)) + "/envs/environments.cfg".format(str(env.value).lower()),
27
            config_file_override
28
        ])
29
        self._session = UnitySession(env.value, config)
6✔
30

31
    def set_project(self, project):
6✔
32
        """
33
        :param project: the project to use when interacting with venue specific services. Used in building the restful
34
        endpoint.
35
        """
36
        self._session._project  = project
6✔
37

38
    def set_venue(self, venue):
6✔
39
        """
40
        :param venue: the venue to use when interacting with venue specific services. Used in building the restful
41
        endpoint.
42
        """
43
        self._session._venue = venue
6✔
44

45
    def set_venue_id(self, venue_id):
6✔
46
        """
47
        :param venue_id: explicitly name the venue identifier. Useful for legacy or non-hierarchical venue ids.  Used in
48
         building the restful
49
        endpoint.
50
        """
UNCOV
51
        self._session._venue_id = venue_id
×
52

53
    def client(self, service_name: UnityServices):
6✔
54
        """
55
        :param service_name - the desired service, such as UnityServices.APPLICATION_SERVICE, UnityServices.DATA_SERVICE, or UnityServices.PROCESS_SERVICE.
56
        """
57
        if service_name == UnityServices.DATA_SERVICE:
6✔
58
            return DataService(session=self._session)
6✔
59
        if service_name == UnityServices.HEALTH_SERVICE:
6✔
60
            return HealthService(session=self._session)
6✔
61
        elif service_name == UnityServices.PROCESS_SERVICE:
6✔
62
            return ProcessService(session=self._session)
6✔
63
        else:
64
            raise UnityException("Invalid service name: " + str(service_name))
×
65

66
    def __str__(self):
6✔
67
        response = "\nUNITY CONFIGURATION"
×
68
        response = response + "\n" + len(response) * "-" + "\n"
×
69
        
70
        config = self._session.get_config()
×
71
        config_sections = config.sections()
×
72
        for section in config_sections:
×
73
            response = response + "\n[{}]\n".format(section)
×
74
            for setting in dict(config[section]):
×
75
                response = response + "{}: {}\n".format(setting, dict(config[section])[setting])
×
76

77
        response = response + self.client(UnityServices.HEALTH_SERVICE).generate_health_status_report()
×
78

79
        return response
×
80

81

82
def _read_config(config_files):
6✔
83
    config = ConfigParser(interpolation=ExtendedInterpolation())
6✔
84

85
    for config_file in config_files:
6✔
86
        if config_file is not None:
6✔
87
            with open(config_file) as source:
6✔
88
                config.read_file(source)
6✔
89

90
    return config
6✔
91

92

93
def _get_config(config, section, setting):
6✔
94
    return config.get(section.upper(), setting)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc