示例#1
0
    def getTwistedVersion(self):
        """
        This function returns a Version-ready tuple. For use with the Version
        object, use extended call syntax:

            v = Version(*getTwistedVersion())
            v.full()
        """
        from twisted._version import version as v

        return Version('Twisted', v.major, v.minor, v.micro)
示例#2
0
    def getPythonVersion(self):
        """
        This function returns a Version-ready tuple. For use with the Version
        object, use extended call syntax:

            v = Version(*getPythonVersion())
            v.full()
        """
        name = 'Python'
        major, minor, micro, releaselevel, serial = sys.version_info
        return Version(name, major, minor, micro)
示例#3
0
    def getZopeVersion(self):
        """
        This function returns a Version-ready tuple. For use with the Version
        object, use extended call syntax:

            v = Version(*getZopeVersion())
            v.full()
        """
        from App import version_txt as version

        name = 'Zope'
        major, minor, micro, status, release = version.getZopeVersion()
        return Version(name, major, minor, micro)
示例#4
0
    def getRRDToolVersion(self):
        """
        This function returns a Version-ready tuple. For use with the Version
        object, use extended call syntax:

            v = Version(*getRRDToolVersion())
            v.full()
        """
        cmd = binPath('rrdtool')
        if not os.path.exists(cmd):
            cmd = 'rrdtool'
        fd = os.popen(cmd)
        output = fd.readlines()[0].strip()
        fd.close()
        name, version = output.split()[:2]
        major, minor, micro = getVersionTupleFromString(version)
        return Version(name, major, minor, micro)
示例#5
0
    def getOSVersion(self):
        """
        This function returns a Version-ready tuple. For use with the Version
        object, use extended call syntax:

            v = Version(*getOSVersion())
            v.full()
        """
        if os.name == 'posix':
            sysname, nodename, version, build, arch = os.uname()
            name = "%s (%s)" % (sysname, arch)
            major, minor, micro = getVersionTupleFromString(version)
            comment = ' '.join(os.uname())
        elif os.name == 'nt':
            from win32api import GetVersionEx
            major, minor, micro, platformID, additional = GetVersionEx()
            name = 'Windows %s (%s)' % (os.name.upper(), additional)
            comment = ''
        else:
            raise VersionNotSupported
        return Version(name, major, minor, micro, 0, comment)
示例#6
0
    def getMySQLVersion(self):
        """
        This function returns a Version-ready tuple. For use with the Version
        object, use extended call syntax:

            v = Version(*getMySQLVersion())
            v.full()
        """
        cfg = getGlobalConfiguration()
        params = {
                'host': cfg.get("zodb-host", "localhost"),
                'port': int(cfg.get("zodb-port", 3306)),
                'user': cfg.get("zodb-user", "zenoss"),
                'passwd': cfg.get("zodb-password", "zenoss"),
            }
        if "zodb-socket" in cfg:
            params["unix_socket"] = cfg["zodb-socket"]
        db = None
        useZenDS = os.environ.get("USE_ZENDS", False)
        name = "ZenDS" if useZenDS else "MySQL"
        try:
            db = MySQLdb.connect(**params)
            db.query("select version()")
            data = db.use_result().fetch_row()
            if data:
                regex = re.compile("([0-9]+)\.([0-9]+)\.([0-9]+)(.*)")
                versionstr = data[0][0]
                match = regex.match(versionstr)
                if match:
                    major, minor, micro, info = match.groups()
                    return Version(
                            name,
                            int(major), int(minor), int(micro), 0,
                            versionstr
                        )
            raise RuntimeError("Unable to determine %s version" % (name,))
        finally:
            if db:
                db.close()