blob: 3f1d33112f6a8007c1def56e44c4a17e5e194c63 [file] [log] [blame]
George Keishinge7e91712021-09-03 11:28:44 -05001#!/usr/bin/env python3
Anusha Dathatriaad48f22019-08-23 02:01:15 -05002
Anusha Dathatriaad48f22019-08-23 02:01:15 -05003import collections
4
Patrick Williams20f38712022-12-08 06:18:26 -06005import gen_cmd as gc
6import gen_print as gp
7
8module_names = [
9 "Selenium2Library",
10 "SeleniumLibrary",
11 "SSHLibrary",
12 "requests",
13 "XvfbRobot",
14 "robotremoteserver",
15 "redfish",
16]
Anusha Dathatriaad48f22019-08-23 02:01:15 -050017
18import_versions = collections.OrderedDict()
19
20for module_name in module_names:
21 try:
22 cmd_buf = "import " + module_name
23 exec(cmd_buf)
Patrick Williams20f38712022-12-08 06:18:26 -060024 cmd_buf = (
25 "import_versions['"
26 + module_name
27 + "'] = "
28 + module_name
29 + ".__version__"
30 )
Anusha Dathatriaad48f22019-08-23 02:01:15 -050031 exec(cmd_buf)
32 except ImportError:
33 import_versions[module_name] = "Not installed"
34
35
36def software_versions():
37 r"""
38 Get the versions for several of the software packages used by
39 openbmc-test-automation and return as a dictionary.
40
41 Example call:
42 ${software_versions}= Software Versions
43 Rprint Vars software_versions
44
45 Example output:
46 software_versions:
47 [python]: Python 2.7.12
48 [robot]: Robot Framework 3.1.2 (Python 3.6.8 on linux)
49 [firefox]: Mozilla Firefox 54.0
50 [google-chrome]: Not installed
51 [Selenium2Library]: 3.0.0
52 [SeleniumLibrary]: 3.3.1
53 [SSHLibrary]: 3.3.0
54 [requests]: 2.22.0
55 [XvfbRobot]: 1.2.2
56 [robotremoteserver]: 1.1
57 [redfish]: 2.1.1
58 [robotframework-angularjs]: 0.0.10
59 [robotframework-scplibrary]: 1.2.0
60 [robotframework-extendedselenium2library]: 0.9.1
61 [host OS]: Ubuntu 16.04.6 LTS
62 """
63
64 quiet = 1
65 versions = collections.OrderedDict()
Patrick Williams20f38712022-12-08 06:18:26 -060066 for package in ["python", "python3", "robot", "firefox", "google-chrome"]:
Anusha Dathatriaad48f22019-08-23 02:01:15 -050067 # Note: "robot --version" returns 0x00000000000000fb.
68 # Note: If package does not exist, 0x7f is returned.
Patrick Williams20f38712022-12-08 06:18:26 -060069 rc, version = gc.shell_cmd(
70 package + " --version", valid_rcs=[0, 0x7F, 0xFB]
71 )
72 versions[package] = (
73 "Not installed" if rc == 0x7F else version.rstrip("\n")
74 )
Anusha Dathatriaad48f22019-08-23 02:01:15 -050075
76 versions.update(import_versions)
77
Patrick Williams20f38712022-12-08 06:18:26 -060078 for package in [
79 "robotframework-angularjs",
80 "robotframework-scplibrary",
81 "robotframework-extendedselenium2library",
82 ]:
83 rc, version = gc.shell_cmd(
84 "pip3 show " + package + " | grep Version | sed -re 's/.*: //g'"
85 )
86 versions[package] = (
87 "Not installed" if not version else version.rstrip("\n")
88 )
Anusha Dathatriaad48f22019-08-23 02:01:15 -050089
90 rc, version = gc.shell_cmd("lsb_release -d -s")
Patrick Williams20f38712022-12-08 06:18:26 -060091 versions["host OS"] = "Failed" if not version else version.rstrip("\n")
Anusha Dathatriaad48f22019-08-23 02:01:15 -050092 return versions