blob: 0c7f279b948951c5eaadc1658918e2bc0db75e12 [file] [log] [blame]
George Keishinge7e91712021-09-03 11:28:44 -05001#!/usr/bin/env python3
Anusha Dathatriaad48f22019-08-23 02:01:15 -05002
George Keishinge635ddc2022-12-08 07:38:02 -06003import gen_print as gp
4import gen_cmd as gc
Anusha Dathatriaad48f22019-08-23 02:01:15 -05005import collections
6
George Keishinge635ddc2022-12-08 07:38:02 -06007module_names = ['Selenium2Library', 'SeleniumLibrary', 'SSHLibrary', 'requests',
8 'XvfbRobot', 'robotremoteserver', 'redfish']
Anusha Dathatriaad48f22019-08-23 02:01:15 -05009
10import_versions = collections.OrderedDict()
11
12for module_name in module_names:
13 try:
14 cmd_buf = "import " + module_name
15 exec(cmd_buf)
George Keishinge635ddc2022-12-08 07:38:02 -060016 cmd_buf = "import_versions['" + module_name + "'] = " + module_name \
17 + ".__version__"
Anusha Dathatriaad48f22019-08-23 02:01:15 -050018 exec(cmd_buf)
19 except ImportError:
20 import_versions[module_name] = "Not installed"
21
22
23def software_versions():
24 r"""
25 Get the versions for several of the software packages used by
26 openbmc-test-automation and return as a dictionary.
27
28 Example call:
29 ${software_versions}= Software Versions
30 Rprint Vars software_versions
31
32 Example output:
33 software_versions:
34 [python]: Python 2.7.12
35 [robot]: Robot Framework 3.1.2 (Python 3.6.8 on linux)
36 [firefox]: Mozilla Firefox 54.0
37 [google-chrome]: Not installed
38 [Selenium2Library]: 3.0.0
39 [SeleniumLibrary]: 3.3.1
40 [SSHLibrary]: 3.3.0
41 [requests]: 2.22.0
42 [XvfbRobot]: 1.2.2
43 [robotremoteserver]: 1.1
44 [redfish]: 2.1.1
45 [robotframework-angularjs]: 0.0.10
46 [robotframework-scplibrary]: 1.2.0
47 [robotframework-extendedselenium2library]: 0.9.1
48 [host OS]: Ubuntu 16.04.6 LTS
49 """
50
51 quiet = 1
52 versions = collections.OrderedDict()
George Keishinge635ddc2022-12-08 07:38:02 -060053 for package in ['python', 'python3', 'robot', 'firefox', 'google-chrome']:
Anusha Dathatriaad48f22019-08-23 02:01:15 -050054 # Note: "robot --version" returns 0x00000000000000fb.
55 # Note: If package does not exist, 0x7f is returned.
George Keishinge635ddc2022-12-08 07:38:02 -060056 rc, version = gc.shell_cmd(package + " --version",
57 valid_rcs=[0, 0x7f, 0xfb])
58 versions[package] = "Not installed" if rc == 0x7f else version.rstrip('\n')
Anusha Dathatriaad48f22019-08-23 02:01:15 -050059
60 versions.update(import_versions)
61
George Keishinge635ddc2022-12-08 07:38:02 -060062 for package in ['robotframework-angularjs', 'robotframework-scplibrary',
63 'robotframework-extendedselenium2library']:
64 rc, version = gc.shell_cmd("pip3 show " + package
65 + " | grep Version | sed -re 's/.*: //g'")
66 versions[package] = "Not installed" if not version else version.rstrip('\n')
Anusha Dathatriaad48f22019-08-23 02:01:15 -050067
68 rc, version = gc.shell_cmd("lsb_release -d -s")
George Keishinge635ddc2022-12-08 07:38:02 -060069 versions["host OS"] = "Failed" if not version else version.rstrip('\n')
Anusha Dathatriaad48f22019-08-23 02:01:15 -050070 return versions