+ def _showSoftwareVersions(self, softwares=None):
+ config = configparser.SafeConfigParser()
+ absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH')
+ filename = os.path.join(absoluteAppliPath, "sha1_collections.txt")
+ versions = {}
+ max_len = 0
+ with open(filename) as f:
+ for line in f:
+ try:
+ software, version, sha1 = line.split()
+ versions[software.upper()] = version
+ if len(software) > max_len:
+ max_len = len(software)
+ except:
+ pass
+ pass
+ pass
+ if softwares:
+ for soft in softwares:
+ if versions.has_key(soft.upper()):
+ print(soft.upper().rjust(max_len), versions[soft.upper()])
+ else:
+ import collections
+ od = collections.OrderedDict(sorted(versions.items()))
+ for name, version in od.iteritems():
+ print(name.rjust(max_len), versions[name])
+ pass
+
+ def _showInfo(self, args=None):
+ if args is None:
+ args = []
+
+ usage = "Usage: salome info [options]"
+ epilog = """\n
+Display some information about SALOME.\n
+Available options are:
+ -p,--ports Show the list of busy ports (running SALOME instances).
+ -s,--softwares [software(s)] Show the list and versions of SALOME softwares.
+ Software names must be separated by blank characters.
+ If no software is given, show version of all softwares.
+ -v,--version Show running SALOME version.
+ -h,--help Show this message.
+"""
+ if not args:
+ args = ["--version"]
+
+ if "-h" in args or "--help" in args:
+ print(usage + epilog)
+ return 0
+
+ if "-p" in args or "--ports" in args:
+ import PortManager
+ ports = PortManager.getBusyPorts()
+ this_ports = ports['this']
+ other_ports = ports['other']
+ if this_ports or other_ports:
+ print("SALOME instances are running on the following ports:")
+ if this_ports:
+ print(" This application:", this_ports)
+ else:
+ print(" No SALOME instances of this application")
+ if other_ports:
+ print(" Other applications:", other_ports)
+ else:
+ print(" No SALOME instances of other applications")
+ else:
+ print("No SALOME instances are running")
+
+ if "-s" in args or "--softwares" in args:
+ if "-s" in args:
+ index = args.index("-s")
+ else:
+ index = args.index("--softwares")
+ indexEnd=index+1
+ while indexEnd < len(args) and args[indexEnd][0] != "-":
+ indexEnd = indexEnd + 1
+ self._showSoftwareVersions(softwares=args[index+1:indexEnd])
+
+ if "-v" in args or "--version" in args:
+ print("Running with python", platform.python_version())
+ return self._runAppli(["--version"])
+
+ return 0