|
| 1 | +# The MIT License (MIT) |
| 2 | +# |
| 3 | +# Copyright (C) 2024 - Ericsson |
| 4 | +# |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files (the "Software"), to deal |
| 7 | +# in the Software without restriction, including without limitation the rights |
| 8 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +# copies of the Software, and to permit persons to whom the Software is |
| 10 | +# furnished to do so, subject to the following conditions: |
| 11 | +# |
| 12 | +# The above copyright notice and this permission notice shall be included in |
| 13 | +# all copies or substantial portions of the Software. |
| 14 | +# |
| 15 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | +# SOFTWARE. |
| 22 | + |
| 23 | +"""Identifier Service Class""" |
| 24 | + |
| 25 | +SERVER_VERSION = "version" |
| 26 | +BUILD_TIME = "buildTime" |
| 27 | +OS_NAME = "os" |
| 28 | +OS_ARCH = "osArch" |
| 29 | +OS_VERSION = "osVersion" |
| 30 | +CPU_COUNT = "cpuCount" |
| 31 | +MAX_MEMORY = "maxMemory" |
| 32 | +LAUNCHER_NAME = "launcherName" |
| 33 | +PRODUCT_ID = "productId" |
| 34 | + |
| 35 | + |
| 36 | +class Identifier: |
| 37 | + ''' |
| 38 | + Model of the Identifier Service. This is a Service used to identify important information |
| 39 | + regarding the trace server and the system it is running on. |
| 40 | + ''' |
| 41 | + def __init__(self, params): |
| 42 | + ''' |
| 43 | + Constructor |
| 44 | + ''' |
| 45 | + |
| 46 | + # Server Version |
| 47 | + if SERVER_VERSION in params: |
| 48 | + self.server_version = params.get(SERVER_VERSION) |
| 49 | + del params[SERVER_VERSION] |
| 50 | + else: |
| 51 | + self.server_version = None |
| 52 | + |
| 53 | + # Build Time |
| 54 | + if BUILD_TIME in params: |
| 55 | + self.build_time = params.get(BUILD_TIME) |
| 56 | + del params[BUILD_TIME] |
| 57 | + else: |
| 58 | + self.build_time = None |
| 59 | + |
| 60 | + # OS Name |
| 61 | + if OS_NAME in params: |
| 62 | + self.os_name = params.get(OS_NAME) |
| 63 | + del params[OS_NAME] |
| 64 | + else: |
| 65 | + self.os_name = None |
| 66 | + |
| 67 | + # OS Arch |
| 68 | + if OS_ARCH in params: |
| 69 | + self.os_arch = params.get(OS_ARCH) |
| 70 | + del params[OS_ARCH] |
| 71 | + else: |
| 72 | + self.os_arch = None |
| 73 | + |
| 74 | + # OS Version |
| 75 | + if OS_VERSION in params: |
| 76 | + self.os_version = params.get(OS_VERSION) |
| 77 | + del params[OS_VERSION] |
| 78 | + else: |
| 79 | + self.os_version = None |
| 80 | + |
| 81 | + # CPU Count |
| 82 | + if CPU_COUNT in params: |
| 83 | + self.cpu_count = params.get(CPU_COUNT) |
| 84 | + del params[CPU_COUNT] |
| 85 | + else: |
| 86 | + self.cpu_count = None |
| 87 | + |
| 88 | + # Max Memory |
| 89 | + if MAX_MEMORY in params: |
| 90 | + self.max_memory = params.get(MAX_MEMORY) |
| 91 | + del params[MAX_MEMORY] |
| 92 | + else: |
| 93 | + self.max_memory = None |
| 94 | + |
| 95 | + # Product ID |
| 96 | + if PRODUCT_ID in params: |
| 97 | + self.product_id = params.get(PRODUCT_ID) |
| 98 | + del params[PRODUCT_ID] |
| 99 | + else: |
| 100 | + self.product_id = None |
| 101 | + |
| 102 | + # Launcher Name |
| 103 | + if LAUNCHER_NAME in params: |
| 104 | + self.launcher_name = params.get(LAUNCHER_NAME) |
| 105 | + del params[LAUNCHER_NAME] |
| 106 | + else: |
| 107 | + self.launcher_name = None |
| 108 | + |
| 109 | + def to_string(self): |
| 110 | + ''' |
| 111 | + to_string method |
| 112 | + ''' |
| 113 | + return f"Identifier[version={self.server_version}, buildTime={self.build_time}, os={self.os_name}, osArch={self.os_arch}, osVersion={self.os_version}, cpuCount={self.cpu_count}, maxMemory={self.max_memory}, productId={self.product_id}, launcherName={self.launcher_name}]" |
0 commit comments