pyppms.system

Module representing bookable systems in PPMS.

 1"""Module representing bookable systems in PPMS."""
 2
 3# pylint: disable-msg=too-many-instance-attributes
 4# pylint: disable-msg=too-many-arguments
 5
 6from loguru import logger as log
 7
 8
 9class PpmsSystem:
10
11    """Object representing a bookable system in PPMS.
12
13    Attributes
14    ----------
15    system_id : int
16        The ID of the system in PPMS (the system's unique identifier).
17    name : str
18        The system's (human friendly) name.
19    localisation : str
20        The location of the system, corresponds to ``Room`` in the PPMS web interface.
21    system_type : str
22        The ``System Type`` field in PPMS, e.g. "`Confocal Microscopes`" or "`Virtual
23        Machine class PowerWorkstations`".
24    core_facility_ref : str
25        The core facility reference of the system, for example ``2``.
26    schedules : bool
27        Indicates whether to list this system in the (read-only) resources and schedules
28        pages of PPMS.
29    active : bool
30        Indicates whether the system is active in PPMS.
31    stats : bool
32        Indicates whether to integrate this system in the PPMS global usage statistics.
33    bookable : bool
34        Indicates whether the system is actually bookable in PPMS. A system that's not
35        bookable can still be used in incident management.
36    autonomy_required : bool
37        Indicates whether explicit permissions are required for a user for being allowed
38        to book the system. Corresponds to the field ``User right/training required`` in
39        the PPMS web interface.
40    autonomy_required_after_hours : bool
41        Corresponds to the field ``User right/training required only after hours`` in
42        the PPMS web interface. Unfortunately there is no description given what that
43        actually means - probably it refers to the "after hours" / "non-peak hours".
44    """
45
46    def __init__(self, details):
47        """Initialize the system object.
48
49        Parameters
50        ----------
51        details : dict
52            A dict with the parsed response from a `getsystems` request.
53        """
54        try:
55            self.system_id = int(details["System id"])
56        except ValueError as err:
57            log.error("Unable to parse system ID: {} - {}", details["System id"], err)
58            raise
59
60        self.name = details["Name"]
61        self.localisation = details["Localisation"]
62        self.system_type = details["Type"]
63        self.core_facility_ref = details["Core facility ref"]
64        self.schedules = details["Schedules"]
65        self.active = details["Active"]
66        self.stats = details["Stats"]
67        self.bookable = details["Bookable"]
68        self.autonomy_required = details["Autonomy Required"]
69        self.autonomy_required_after_hours = details["Autonomy Required After Hours"]
70        log.trace(
71            "PpmsSystem(system_id={}, name=[{}], localisation=[{}], system_type=[{}])",
72            self.system_id,
73            self.name,
74            self.localisation,
75            self.system_type,
76        )
77        # log.debug('PpmsSystem details: core_facility_ref={}, schedules={}, '
78        #           'active={}, stats={}, bookable={}, autonomy_required={}, '
79        #           'autonomy_required_after_hours={}', core_facility_ref,
80        #           schedules, active, stats, bookable, autonomy_required,
81        #           autonomy_required_after_hours)
82
83    def __str__(self):
84        return (
85            f"system_id: {self.system_id}, "
86            f"name: {self.name}, "
87            f"localisation: {self.localisation}, "
88            f"system_type: {self.system_type}, "
89            f"core_facility_ref: {self.core_facility_ref}, "
90            f"schedules: {self.schedules}, "
91            f"active: {self.active}, "
92            f"stats: {self.stats}, "
93            f"bookable: {self.bookable}, "
94            f"autonomy_required: {self.autonomy_required}, "
95            f"autonomy_required_after_hours: {self.autonomy_required_after_hours}"
96        )
class PpmsSystem:
10class PpmsSystem:
11
12    """Object representing a bookable system in PPMS.
13
14    Attributes
15    ----------
16    system_id : int
17        The ID of the system in PPMS (the system's unique identifier).
18    name : str
19        The system's (human friendly) name.
20    localisation : str
21        The location of the system, corresponds to ``Room`` in the PPMS web interface.
22    system_type : str
23        The ``System Type`` field in PPMS, e.g. "`Confocal Microscopes`" or "`Virtual
24        Machine class PowerWorkstations`".
25    core_facility_ref : str
26        The core facility reference of the system, for example ``2``.
27    schedules : bool
28        Indicates whether to list this system in the (read-only) resources and schedules
29        pages of PPMS.
30    active : bool
31        Indicates whether the system is active in PPMS.
32    stats : bool
33        Indicates whether to integrate this system in the PPMS global usage statistics.
34    bookable : bool
35        Indicates whether the system is actually bookable in PPMS. A system that's not
36        bookable can still be used in incident management.
37    autonomy_required : bool
38        Indicates whether explicit permissions are required for a user for being allowed
39        to book the system. Corresponds to the field ``User right/training required`` in
40        the PPMS web interface.
41    autonomy_required_after_hours : bool
42        Corresponds to the field ``User right/training required only after hours`` in
43        the PPMS web interface. Unfortunately there is no description given what that
44        actually means - probably it refers to the "after hours" / "non-peak hours".
45    """
46
47    def __init__(self, details):
48        """Initialize the system object.
49
50        Parameters
51        ----------
52        details : dict
53            A dict with the parsed response from a `getsystems` request.
54        """
55        try:
56            self.system_id = int(details["System id"])
57        except ValueError as err:
58            log.error("Unable to parse system ID: {} - {}", details["System id"], err)
59            raise
60
61        self.name = details["Name"]
62        self.localisation = details["Localisation"]
63        self.system_type = details["Type"]
64        self.core_facility_ref = details["Core facility ref"]
65        self.schedules = details["Schedules"]
66        self.active = details["Active"]
67        self.stats = details["Stats"]
68        self.bookable = details["Bookable"]
69        self.autonomy_required = details["Autonomy Required"]
70        self.autonomy_required_after_hours = details["Autonomy Required After Hours"]
71        log.trace(
72            "PpmsSystem(system_id={}, name=[{}], localisation=[{}], system_type=[{}])",
73            self.system_id,
74            self.name,
75            self.localisation,
76            self.system_type,
77        )
78        # log.debug('PpmsSystem details: core_facility_ref={}, schedules={}, '
79        #           'active={}, stats={}, bookable={}, autonomy_required={}, '
80        #           'autonomy_required_after_hours={}', core_facility_ref,
81        #           schedules, active, stats, bookable, autonomy_required,
82        #           autonomy_required_after_hours)
83
84    def __str__(self):
85        return (
86            f"system_id: {self.system_id}, "
87            f"name: {self.name}, "
88            f"localisation: {self.localisation}, "
89            f"system_type: {self.system_type}, "
90            f"core_facility_ref: {self.core_facility_ref}, "
91            f"schedules: {self.schedules}, "
92            f"active: {self.active}, "
93            f"stats: {self.stats}, "
94            f"bookable: {self.bookable}, "
95            f"autonomy_required: {self.autonomy_required}, "
96            f"autonomy_required_after_hours: {self.autonomy_required_after_hours}"
97        )

Object representing a bookable system in PPMS.

Attributes
  • system_id (int): The ID of the system in PPMS (the system's unique identifier).
  • name (str): The system's (human friendly) name.
  • localisation (str): The location of the system, corresponds to Room in the PPMS web interface.
  • system_type (str): The System Type field in PPMS, e.g. "Confocal Microscopes" or "Virtual Machine class PowerWorkstations".
  • core_facility_ref (str): The core facility reference of the system, for example 2.
  • schedules (bool): Indicates whether to list this system in the (read-only) resources and schedules pages of PPMS.
  • active (bool): Indicates whether the system is active in PPMS.
  • stats (bool): Indicates whether to integrate this system in the PPMS global usage statistics.
  • bookable (bool): Indicates whether the system is actually bookable in PPMS. A system that's not bookable can still be used in incident management.
  • autonomy_required (bool): Indicates whether explicit permissions are required for a user for being allowed to book the system. Corresponds to the field User right/training required in the PPMS web interface.
  • autonomy_required_after_hours (bool): Corresponds to the field User right/training required only after hours in the PPMS web interface. Unfortunately there is no description given what that actually means - probably it refers to the "after hours" / "non-peak hours".
PpmsSystem(details)
47    def __init__(self, details):
48        """Initialize the system object.
49
50        Parameters
51        ----------
52        details : dict
53            A dict with the parsed response from a `getsystems` request.
54        """
55        try:
56            self.system_id = int(details["System id"])
57        except ValueError as err:
58            log.error("Unable to parse system ID: {} - {}", details["System id"], err)
59            raise
60
61        self.name = details["Name"]
62        self.localisation = details["Localisation"]
63        self.system_type = details["Type"]
64        self.core_facility_ref = details["Core facility ref"]
65        self.schedules = details["Schedules"]
66        self.active = details["Active"]
67        self.stats = details["Stats"]
68        self.bookable = details["Bookable"]
69        self.autonomy_required = details["Autonomy Required"]
70        self.autonomy_required_after_hours = details["Autonomy Required After Hours"]
71        log.trace(
72            "PpmsSystem(system_id={}, name=[{}], localisation=[{}], system_type=[{}])",
73            self.system_id,
74            self.name,
75            self.localisation,
76            self.system_type,
77        )
78        # log.debug('PpmsSystem details: core_facility_ref={}, schedules={}, '
79        #           'active={}, stats={}, bookable={}, autonomy_required={}, '
80        #           'autonomy_required_after_hours={}', core_facility_ref,
81        #           schedules, active, stats, bookable, autonomy_required,
82        #           autonomy_required_after_hours)

Initialize the system object.

Parameters
  • details (dict): A dict with the parsed response from a getsystems request.