Python sys.subversion() Examples

The following are code examples for showing how to use sys.subversion(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: DevOps   Author: YoLoveLife   File: facts.py    (license) View Source Project 6 votes vote down vote up
def get_python_facts(self):
        self.facts['python'] = {
            'version': {
                'major': sys.version_info[0],
                'minor': sys.version_info[1],
                'micro': sys.version_info[2],
                'releaselevel': sys.version_info[3],
                'serial': sys.version_info[4]
            },
            'version_info': list(sys.version_info),
            'executable': sys.executable,
            'has_sslcontext': HAS_SSLCONTEXT
        }
        try:
            self.facts['python']['type'] = sys.subversion[0]
        except AttributeError:
            self.facts['python']['type'] = None 
Example 2
Project: ansible-provider-docs   Author: alibaba   File: python.py    (license) View Source Project 6 votes vote down vote up
def collect(self, module=None, collected_facts=None):
        python_facts = {}
        python_facts['python'] = {
            'version': {
                'major': sys.version_info[0],
                'minor': sys.version_info[1],
                'micro': sys.version_info[2],
                'releaselevel': sys.version_info[3],
                'serial': sys.version_info[4]
            },
            'version_info': list(sys.version_info),
            'executable': sys.executable,
            'has_sslcontext': HAS_SSLCONTEXT
        }

        try:
            python_facts['python']['type'] = sys.subversion[0]
        except AttributeError:
            try:
                python_facts['python']['type'] = sys.implementation.name
            except AttributeError:
                python_facts['python']['type'] = None

        return python_facts 
Example 3
Project: zippy   Author: securesystemslab   File: test_platform.py    (license) View Source Project 5 votes vote down vote up
def setUp(self):
        self.save_version = sys.version
        self.save_subversion = sys.subversion
        self.save_mercurial = sys._mercurial
        self.save_platform = sys.platform 
Example 4
Project: zippy   Author: securesystemslab   File: test_platform.py    (license) View Source Project 5 votes vote down vote up
def tearDown(self):
        sys.version = self.save_version
        sys.subversion = self.save_subversion
        sys._mercurial = self.save_mercurial
        sys.platform = self.save_platform 
Example 5
Project: pytypes   Author: Stewori   File: util.py    (license) View Source Project 5 votes vote down vote up
def _python_version_string():
    try:
        impl = sys.subversion[0]
    except AttributeError:
        impl = sys.implementation.name
        if impl == 'cpython':
            impl = 'CPython'
    lst = [impl,
            '.'.join([str(x) for x in sys.version_info[:3]]),
            ' '.join([str(x) for x in sys.version_info[3:]])]
    return '%s %s %s' % tuple(lst) 
Example 6
Project: oil   Author: oilshell   File: test_platform.py    (license) View Source Project 5 votes vote down vote up
def setUp(self):
        self.save_version = sys.version
        self.save_subversion = sys.subversion
        self.save_platform = sys.platform 
Example 7
Project: oil   Author: oilshell   File: test_platform.py    (license) View Source Project 5 votes vote down vote up
def tearDown(self):
        sys.version = self.save_version
        sys.subversion = self.save_subversion
        sys.platform = self.save_platform 
Example 8
Project: python2-tracer   Author: extremecoders-re   File: test_platform.py    (license) View Source Project 5 votes vote down vote up
def setUp(self):
        self.save_version = sys.version
        self.save_subversion = sys.subversion
        self.save_platform = sys.platform 
Example 9
Project: python2-tracer   Author: extremecoders-re   File: test_platform.py    (license) View Source Project 5 votes vote down vote up
def tearDown(self):
        sys.version = self.save_version
        sys.subversion = self.save_subversion
        sys.platform = self.save_platform 
Example 10
Project: NZ-ORCID-Hub   Author: Royal-Society-of-New-Zealand   File: pyinfo.py    (license) View Source Project 5 votes vote down vote up
def get_system_info():  # noqa: D103
    system_info = []

    distname = platform.linux_distribution()[0]
    version = platform.linux_distribution()[1]
    if distname != '' and version != '':
        os_version = '%s %s (%s %s)' % (platform.system(), platform.release(), distname, version)
    else:
        os_version = '%s %s' % (platform.system(), platform.release())
    system_info.append(('OS Version', os_version))

    if hasattr(os, 'path'):
        system_info.append(('OS Path', os.environ['PATH']))

    if hasattr(sys, 'version'):
        system_info.append(('Python Version', sys.version))

    if hasattr(sys, 'subversion'):
        system_info.append(('Python Subversion', sys.subversion[0]))

    if hasattr(sys, 'prefix'):
        system_info.append(('Python Prefix', sys.prefix))

    if hasattr(sys, 'path'):
        system_info.append(('Python Path', sys.path))

    if hasattr(sys, 'executable'):
        system_info.append(('Python Executable', sys.executable))

    if hasattr(sys, 'api_version'):
        system_info.append(('Python API', sys.api_version))

    system_info.append(('Build Date', platform.python_build()[1]))
    system_info.append(('Compiler', platform.python_compiler()))

    return system_info 
Example 11
Project: pefile.pypy   Author: cloudtracer   File: test_platform.py    (license) View Source Project 5 votes vote down vote up
def setUp(self):
        self.save_version = sys.version
        self.save_subversion = sys.subversion
        self.save_platform = sys.platform 
Example 12
Project: pefile.pypy   Author: cloudtracer   File: test_platform.py    (license) View Source Project 5 votes vote down vote up
def tearDown(self):
        sys.version = self.save_version
        sys.subversion = self.save_subversion
        sys.platform = self.save_platform 
Example 13
Project: ndk-python   Author: gittor   File: test_platform.py    (license) View Source Project 5 votes vote down vote up
def setUp(self):
        self.save_version = sys.version
        self.save_subversion = sys.subversion
        self.save_platform = sys.platform 
Example 14
Project: ndk-python   Author: gittor   File: test_platform.py    (license) View Source Project 5 votes vote down vote up
def tearDown(self):
        sys.version = self.save_version
        sys.subversion = self.save_subversion
        sys.platform = self.save_platform 
Example 15
Project: zippy   Author: securesystemslab   File: test_platform.py    (license) View Source Project 4 votes vote down vote up
def test_sys_version(self):
        # Old test.
        for input, output in (
            ('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]',
             ('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')),
            ('IronPython 1.0.60816 on .NET 2.0.50727.42',
             ('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')),
            ('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42',
             ('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')),
            ):
            # branch and revision are not "parsed", but fetched
            # from sys.subversion.  Ignore them
            (name, version, branch, revision, buildno, builddate, compiler) \
                   = platform._sys_version(input)
            self.assertEqual(
                (name, version, '', '', buildno, builddate, compiler), output)

        # Tests for python_implementation(), python_version(), python_branch(),
        # python_revision(), python_build(), and python_compiler().
        sys_versions = {
            ("2.6.1 (r261:67515, Dec  6 2008, 15:26:00) \n[GCC 4.0.1 (Apple Computer, Inc. build 5370)]",
             ('CPython', 'tags/r261', '67515'), self.save_platform)
            :
                ("CPython", "2.6.1", "tags/r261", "67515",
                 ('r261:67515', 'Dec  6 2008 15:26:00'),
                 'GCC 4.0.1 (Apple Computer, Inc. build 5370)'),
            ("IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.3053", None, "cli")
            :
                ("IronPython", "2.0.0", "", "", ("", ""),
                 ".NET 2.0.50727.3053"),
            ("2.5 (trunk:6107, Mar 26 2009, 13:02:18) \n[Java HotSpot(TM) Client VM (\"Apple Computer, Inc.\")]",
            ('Jython', 'trunk', '6107'), "java1.5.0_16")
            :
                ("Jython", "2.5.0", "trunk", "6107",
                 ('trunk:6107', 'Mar 26 2009'), "java1.5.0_16"),
            ("2.5.2 (63378, Mar 26 2009, 18:03:29)\n[PyPy 1.0.0]",
             ('PyPy', 'trunk', '63378'), self.save_platform)
            :
                ("PyPy", "2.5.2", "trunk", "63378", ('63378', 'Mar 26 2009'),
                 "")
            }
        for (version_tag, subversion, sys_platform), info in \
                sys_versions.items():
            sys.version = version_tag
            if subversion is None:
                if hasattr(sys, "_mercurial"):
                    del sys._mercurial
                if hasattr(sys, "subversion"):
                    del sys.subversion
            else:
                sys._mercurial = subversion
            if sys_platform is not None:
                sys.platform = sys_platform
            self.assertEqual(platform.python_implementation(), info[0])
            self.assertEqual(platform.python_version(), info[1])
            self.assertEqual(platform.python_branch(), info[2])
            self.assertEqual(platform.python_revision(), info[3])
            self.assertEqual(platform.python_build(), info[4])
            self.assertEqual(platform.python_compiler(), info[5]) 
Example 16
Project: ndk-python   Author: gittor   File: test_platform.py    (license) View Source Project 4 votes vote down vote up
def test_sys_version(self):
        # Old test.
        for input, output in (
            ('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]',
             ('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')),
            ('IronPython 1.0.60816 on .NET 2.0.50727.42',
             ('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')),
            ('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42',
             ('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')),
            ):
            # branch and revision are not "parsed", but fetched
            # from sys.subversion.  Ignore them
            (name, version, branch, revision, buildno, builddate, compiler) \
                   = platform._sys_version(input)
            self.assertEqual(
                (name, version, '', '', buildno, builddate, compiler), output)

        # Tests for python_implementation(), python_version(), python_branch(),
        # python_revision(), python_build(), and python_compiler().
        sys_versions = {
            ("2.6.1 (r261:67515, Dec  6 2008, 15:26:00) \n[GCC 4.0.1 (Apple Computer, Inc. build 5370)]",
             ('CPython', 'tags/r261', '67515'), self.save_platform)
            :
                ("CPython", "2.6.1", "tags/r261", "67515",
                 ('r261:67515', 'Dec  6 2008 15:26:00'),
                 'GCC 4.0.1 (Apple Computer, Inc. build 5370)'),
            ("IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.3053", None, "cli")
            :
                ("IronPython", "2.0.0", "", "", ("", ""),
                 ".NET 2.0.50727.3053"),
            ("2.5 (trunk:6107, Mar 26 2009, 13:02:18) \n[Java HotSpot(TM) Client VM (\"Apple Computer, Inc.\")]",
            ('Jython', 'trunk', '6107'), "java1.5.0_16")
            :
                ("Jython", "2.5.0", "trunk", "6107",
                 ('trunk:6107', 'Mar 26 2009'), "java1.5.0_16"),
            ("2.5.2 (63378, Mar 26 2009, 18:03:29)\n[PyPy 1.0.0]",
             ('PyPy', 'trunk', '63378'), self.save_platform)
            :
                ("PyPy", "2.5.2", "trunk", "63378", ('63378', 'Mar 26 2009'),
                 "")
            }
        for (version_tag, subversion, sys_platform), info in \
                sys_versions.iteritems():
            sys.version = version_tag
            if subversion is None:
                if hasattr(sys, "subversion"):
                    del sys.subversion
            else:
                sys.subversion = subversion
            if sys_platform is not None:
                sys.platform = sys_platform
            self.assertEqual(platform.python_implementation(), info[0])
            self.assertEqual(platform.python_version(), info[1])
            self.assertEqual(platform.python_branch(), info[2])
            self.assertEqual(platform.python_revision(), info[3])
            self.assertEqual(platform.python_build(), info[4])
            self.assertEqual(platform.python_compiler(), info[5])