Fairly portable uname interface. Returns a tuple of strings (system, node, release, version, machine, processor) identifying the underlying platform. Note that unlike the os.uname function this also returns possible processor information as an additional tuple
()
| 823 | |
| 824 | |
| 825 | def uname(): |
| 826 | |
| 827 | """ Fairly portable uname interface. Returns a tuple |
| 828 | of strings (system, node, release, version, machine, processor) |
| 829 | identifying the underlying platform. |
| 830 | |
| 831 | Note that unlike the os.uname function this also returns |
| 832 | possible processor information as an additional tuple entry. |
| 833 | |
| 834 | Entries which cannot be determined are set to ''. |
| 835 | |
| 836 | """ |
| 837 | global _uname_cache |
| 838 | |
| 839 | if _uname_cache is not None: |
| 840 | return _uname_cache |
| 841 | |
| 842 | # Get some infos from the builtin os.uname API... |
| 843 | try: |
| 844 | system, node, release, version, machine = infos = os.uname() |
| 845 | except AttributeError: |
| 846 | system = sys.platform |
| 847 | node = _node() |
| 848 | release = version = machine = '' |
| 849 | infos = () |
| 850 | |
| 851 | if not any(infos): |
| 852 | # uname is not available |
| 853 | |
| 854 | # Try win32_ver() on win32 platforms |
| 855 | if system == 'win32': |
| 856 | release, version, csd, ptype = win32_ver() |
| 857 | machine = machine or _get_machine_win32() |
| 858 | |
| 859 | # Try the 'ver' system command available on some |
| 860 | # platforms |
| 861 | if not (release and version): |
| 862 | system, release, version = _syscmd_ver(system) |
| 863 | # Normalize system to what win32_ver() normally returns |
| 864 | # (_syscmd_ver() tends to return the vendor name as well) |
| 865 | if system == 'Microsoft Windows': |
| 866 | system = 'Windows' |
| 867 | elif system == 'Microsoft' and release == 'Windows': |
| 868 | # Under Windows Vista and Windows Server 2008, |
| 869 | # Microsoft changed the output of the ver command. The |
| 870 | # release is no longer printed. This causes the |
| 871 | # system and release to be misidentified. |
| 872 | system = 'Windows' |
| 873 | if '6.0' == version[:3]: |
| 874 | release = 'Vista' |
| 875 | else: |
| 876 | release = '' |
| 877 | |
| 878 | # In case we still don't know anything useful, we'll try to |
| 879 | # help ourselves |
| 880 | if system in ('win32', 'win16'): |
| 881 | if not version: |
| 882 | if system == 'win32': |
no test coverage detected