Example #1
0
    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])
    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, "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])
    def test_sys_version(self):

        platform._sys_version_cache.clear()
        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)
Example #4
0
    import readline
    import termios

    from distutils import sysconfig
    for var_name in 'LDSHARED', 'CC':
        value = sysconfig.get_config_var(var_name)
        assert value.split()[0] == 'gcc', value
    value = sysconfig.get_config_var('CXX')
    assert value.split()[0] == 'g++', value
    readline.clear_history()

if not (armv7l or ppc64le):
    import _tkinter
    import Tkinter
    import turtle
    print('TK_VERSION:', _tkinter.TK_VERSION)
    print('TCL_VERSION:', _tkinter.TCL_VERSION)
    assert _tkinter.TK_VERSION == _tkinter.TCL_VERSION == '8.5'

print('OPENSSL_VERSION:', ssl.OPENSSL_VERSION)
if sys.platform != 'win32':
    assert '1.0.2j' in ssl.OPENSSL_VERSION

pprint(platform._sys_version())
sys.version = ('2.7.6 (#1, Jan  9 2013, 06:47:03)\n'
               '[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2')
pprint(platform._sys_version())

if int(os.getenv('GUI_TEST', 0)):
    turtle.forward(100)
Example #5
0
    def get_server_info(self, environ=None):
        import platform
        import rhodecode
        import pkg_resources
        from rhodecode.model.meta import Base as sql_base, Session
        from sqlalchemy.engine import url
        from rhodecode.lib.base import get_server_ip_addr, get_server_port
        from rhodecode.lib.vcs.backends.git import discover_git_version
        from rhodecode.model.gist import GIST_STORE_LOC

        try:
            # cygwin cannot have yet psutil support.
            import psutil
        except ImportError:
            psutil = None

        environ = environ or {}
        _NA = 'NOT AVAILABLE'
        _memory = _NA
        _uptime = _NA
        _boot_time = _NA
        _cpu = _NA
        _disk = dict(percent=0, used=0, total=0, error='')
        _load = {'1_min': _NA, '5_min': _NA, '15_min': _NA}

        model = VcsSettingsModel()
        storage_path = model.get_repos_location()
        gist_storage_path = os.path.join(storage_path, GIST_STORE_LOC)
        archive_storage_path = rhodecode.CONFIG.get('archive_cache_dir', '')
        search_index_storage_path = rhodecode.CONFIG.get('search.location', '')

        if psutil:
            # disk storage
            try:
                _disk = dict(psutil.disk_usage(storage_path)._asdict())
            except Exception as e:
                log.exception('Failed to fetch disk info')
                _disk = {'percent': 0, 'used': 0, 'total': 0, 'error': str(e)}

            # memory
            _memory = dict(psutil.virtual_memory()._asdict())
            _memory['percent2'] = psutil._common.usage_percent(
                (_memory['total'] - _memory['free']), _memory['total'], 1)

            # load averages
            if hasattr(psutil.os, 'getloadavg'):
                _load = dict(
                    zip(['1_min', '5_min', '15_min'], psutil.os.getloadavg()))
            _uptime = time.time() - psutil.boot_time()
            _boot_time = psutil.boot_time()
            _cpu = psutil.cpu_percent(0.5)

        mods = dict([(p.project_name, p.version)
                     for p in pkg_resources.working_set])

        def get_storage_size(storage_path):
            sizes = []
            for file_ in os.listdir(storage_path):
                storage_file = os.path.join(storage_path, file_)
                if os.path.isfile(storage_file):
                    try:
                        sizes.append(os.path.getsize(storage_file))
                    except OSError:
                        log.exception('Failed to get size of storage file %s',
                                      storage_file)
                        pass

            return sum(sizes)

        # archive cache storage
        _disk_archive = {'percent': 0, 'used': 0, 'total': 0}
        try:
            archive_storage_path_exists = os.path.isdir(archive_storage_path)
            if archive_storage_path and archive_storage_path_exists:
                used = get_storage_size(archive_storage_path)
                _disk_archive.update({
                    'used': used,
                    'total': used,
                })
        except Exception as e:
            log.exception('failed to fetch archive cache storage')
            _disk_archive['error'] = str(e)

        # search index storage
        _disk_index = {'percent': 0, 'used': 0, 'total': 0}
        try:
            search_index_storage_path_exists = os.path.isdir(
                search_index_storage_path)
            if search_index_storage_path_exists:
                used = get_storage_size(search_index_storage_path)
                _disk_index.update({
                    'percent': 100,
                    'used': used,
                    'total': used,
                })
        except Exception as e:
            log.exception('failed to fetch search index storage')
            _disk_index['error'] = str(e)

        # gist storage
        _disk_gist = {'percent': 0, 'used': 0, 'total': 0, 'items': 0}
        try:
            items_count = 0
            used = 0
            for root, dirs, files in os.walk(safe_str(gist_storage_path)):
                if root == gist_storage_path:
                    items_count = len(dirs)

                for f in files:
                    try:
                        used += os.path.getsize(os.path.join(root, f))
                    except OSError:
                        pass
            _disk_gist.update({
                'percent': 100,
                'used': used,
                'total': used,
                'items': items_count
            })
        except Exception as e:
            log.exception('failed to fetch gist storage items')
            _disk_gist['error'] = str(e)

        # GIT info
        git_ver = discover_git_version()

        # SVN info
        # TODO: johbo: Add discover_svn_version to replace this code.
        try:
            import svn.core
            svn_ver = svn.core.SVN_VERSION
        except ImportError:
            svn_ver = None

        # DB stuff
        db_info = url.make_url(rhodecode.CONFIG['sqlalchemy.db1.url'])
        db_type = db_info.__to_string__()
        try:
            engine = sql_base.metadata.bind
            db_server_info = engine.dialect._get_server_version_info(
                Session.connection(bind=engine))
            db_version = '%s %s' % (db_info.drivername, '.'.join(
                map(str, db_server_info)))
        except Exception:
            log.exception('failed to fetch db version')
            db_version = '%s %s' % (db_info.drivername, '?')

        db_migrate = DbMigrateVersion.query().filter(
            DbMigrateVersion.repository_id == 'rhodecode_db_migrations').one()
        db_migrate_version = db_migrate.version

        info = {
            'py_version':
            ' '.join(platform._sys_version()),
            'py_path':
            sys.executable,
            'py_modules':
            sorted(mods.items(), key=lambda k: k[0].lower()),
            'platform':
            safe_unicode(platform.platform()),
            'storage':
            storage_path,
            'archive_storage':
            archive_storage_path,
            'index_storage':
            search_index_storage_path,
            'gist_storage':
            gist_storage_path,
            'db_type':
            db_type,
            'db_version':
            db_version,
            'db_migrate_version':
            db_migrate_version,
            'rhodecode_version':
            rhodecode.__version__,
            'rhodecode_config_ini':
            rhodecode.CONFIG.get('__file__'),
            'server_ip':
            '%s:%s' % (get_server_ip_addr(
                environ, log_errors=False), get_server_port(environ)),
            'server_id':
            rhodecode.CONFIG.get('instance_id'),
            'git_version':
            safe_unicode(git_ver),
            'hg_version':
            mods.get('mercurial'),
            'svn_version':
            svn_ver,
            'uptime':
            _uptime,
            'boot_time':
            _boot_time,
            'load':
            _load,
            'cpu':
            _cpu,
            'memory':
            _memory,
            'disk':
            _disk,
            'disk_archive':
            _disk_archive,
            'disk_gist':
            _disk_gist,
            'disk_index':
            _disk_index,
        }
        return info
Example #6
0
 def update_event(self, inp=-1):
     self.set_output_val(0, platform._sys_version(self.input(0)))
Example #7
0
#
# general info
#

import sys
import platform

print """
      <html><link rel=stylesheet href=style.css>
      <h2 align=center>general info</h2>
      <p>
      <table class=table border=0 cellpadding=4 cellspacing=1 width=100%>
             <tr>
                 <td width=35% class=tdd><b>python version:</b></td>
                 <td width=65% class=tdl>""" , platform._sys_version()[0] , """</td>
             </tr>
             <tr>
                 <td class=tdd><b>python compiled on:</b></td>
                 <td class=tdl>""" , platform.python_compiler() , """</td>
             </tr>
             <tr>
                 <td class=tdd><b>python executable:</b></td>
                 <td class=tdl>""" , sys.executable , """</td>
             </tr>
             <tr>
                 <td class=tdd><b>location of python:</b></td>
                 <td class=tdl>""" , sys.exec_prefix , """</td>
             </tr>
             <tr>
                 <td class=tdd><b>include paths:</b></td>
Example #8
0
    from distutils import sysconfig
    for var_name in 'LDSHARED', 'CC':
        value = sysconfig.get_config_var(var_name)
        assert value.split()[0] == 'gcc', value
    value = sysconfig.get_config_var('CXX')
    assert value.split()[0] == 'g++', value
    readline.clear_history()

if not (armv7l or ppc64le):
    import _tkinter
    import Tkinter
    import turtle
    print('TK_VERSION: %s' % _tkinter.TK_VERSION)
    print('TCL_VERSION: %s' % _tkinter.TCL_VERSION)
    assert _tkinter.TK_VERSION == _tkinter.TCL_VERSION == '8.5'

print('OPENSSL_VERSION: %s' % ssl.OPENSSL_VERSION)
if sys.platform != 'win32':
    assert '1.0.2l' in ssl.OPENSSL_VERSION

pprint(platform._sys_version())
sys.version = ('2.7.6 (#1, Jan  9 2013, 06:47:03)\n'
               '[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2')
assert platform._sys_version() == ('CPython', '2.7.6', '', '', '1',
                                   'Jan  9 2013 06:47:03',
                                   'GCC 4.1.2 20080704 (Red Hat 4.1.2-54)')

if int(os.getenv('GUI_TEST', 0)):
    turtle.forward(100)
Example #9
0
import platform


system_stat=[

   	
    platform.system(),
    platform._sys_version(),
    platform.version(),
    platform.python_compiler(),
    platform.machine(),
    platform.python_version(),
    platform.node(),

]


for system in system_stat:
    print(system)
Example #10
0
# coding=utf-8

import platform

print platform.system()
print platform.version()
print platform.release()
print platform.dist()
print platform.uname()
print platform.node()
print platform.platform()
print platform.machine()
print platform.processor()
print platform.architecture()
print platform._sys_version()
print platform.java_ver()
print platform.python_version()
print platform.python_implementation()
print platform.python_version_tuple()
print platform.python_branch()
print platform.python_compiler()
print platform.python_build()
print platform.win32_ver()
print platform.mac_ver()
print platform.linux_distribution()

print platform.popen('ifconfig', 'w')
Example #11
0
# coding=utf-8

import platform

print platform.system()
print platform.version()
print platform.release()
print platform.dist()
print platform.uname()
print platform.node()
print platform.platform()
print platform.machine()
print platform.processor()
print platform.architecture()
print platform._sys_version()
print platform.java_ver()
print platform.python_version()
print platform.python_implementation()
print platform.python_version_tuple()
print platform.python_branch()
print platform.python_compiler()
print platform.python_build()
print platform.win32_ver()
print platform.mac_ver()
print platform.linux_distribution()

print platform.popen('ifconfig','w')
Example #12
0
    import readline
    import termios

    from distutils import sysconfig
    for var_name in 'LDSHARED', 'CC':
        value = sysconfig.get_config_var(var_name)
        assert value.split()[0] == 'gcc', value
    value = sysconfig.get_config_var('CXX')
    assert value.split()[0] == 'g++', value
    readline.clear_history()

if not (armv7l or ppc64le):
    import _tkinter
    import Tkinter
    import turtle
    print('TK_VERSION:', _tkinter.TK_VERSION)
    print('TCL_VERSION:', _tkinter.TCL_VERSION)
    assert _tkinter.TK_VERSION == _tkinter.TCL_VERSION == '8.5'

print('OPENSSL_VERSION:', ssl.OPENSSL_VERSION)
if sys.platform != 'win32':
    assert '1.0.2h' in ssl.OPENSSL_VERSION

pprint(platform._sys_version())
sys.version = ('2.7.6 (#1, Jan  9 2013, 06:47:03)\n'
               '[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2')
pprint(platform._sys_version())

if int(os.getenv('GUI_TEST', 0)):
    turtle.forward(100)
Example #13
0
import platform
print("COMPILER     :", platform.python_compiler())
print("SYSTEM       :", platform.system())
print("PROCESSOR    :", platform.processor())
print("ARCHITECTURE :", platform.architecture())
print("MACHINE      :", platform.machine())
print("JAVA VERSION :", platform.java_ver())
print("PYTHON VER   :", platform.python_version())
print("SYSTEM VER   :", platform._sys_version())
Example #14
0
    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.6.1 (IronPython 2.6.1 (2.6.10920.0) on .NET 2.0.50727.1433)", None, "cli"): (
                "IronPython",
                "2.6.1",
                "",
                "",
                ("", ""),
                ".NET 2.0.50727.1433",
            ),
            ("2.7.4 (IronPython 2.7.4 (2.7.0.40) on Mono 4.0.30319.1 (32-bit))", None, "cli"): (
                "IronPython",
                "2.7.4",
                "",
                "",
                ("", ""),
                "Mono 4.0.30319.1 (32-bit)",
            ),
            (
                '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])