~pythonregexp2.7/python/issue2636-11

« back to all changes in this revision

Viewing changes to Lib/platform.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-21 17:53:26 UTC
  • mfrom: (39025.1.14 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080921175326-92vaej2hc3yuecxb
Merged in changes from the core Regexp branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
933
933
    filepath = _abspath(filepath)
934
934
    while os.path.islink(filepath):
935
935
        filepath = os.path.normpath(
936
 
            os.path.join(filepath,os.readlink(filepath)))
 
936
            os.path.join(os.path.dirname(filepath),os.readlink(filepath)))
937
937
    return filepath
938
938
 
939
939
def _syscmd_uname(option,default=''):
964
964
        case the command should fail.
965
965
 
966
966
    """
 
967
    if sys.platform in ('dos','win32','win16','os2'):
 
968
        # XXX Others too ?
 
969
        return default
967
970
    target = _follow_symlinks(target)
968
971
    try:
969
 
        f = os.popen('file %s 2> /dev/null' % target)
 
972
        f = os.popen('file "%s" 2> /dev/null' % target)
970
973
    except (AttributeError,os.error):
971
974
        return default
972
975
    output = string.strip(f.read())
1090
1093
 
1091
1094
    """
1092
1095
    global _uname_cache
 
1096
    no_os_uname = 0
1093
1097
 
1094
1098
    if _uname_cache is not None:
1095
1099
        return _uname_cache
1096
1100
 
 
1101
    processor = ''
 
1102
 
1097
1103
    # Get some infos from the builtin os.uname API...
1098
1104
    try:
1099
1105
        system,node,release,version,machine = os.uname()
1100
 
 
1101
1106
    except AttributeError:
1102
 
        # Hmm, no uname... we'll have to poke around the system then.
1103
 
        system = sys.platform
1104
 
        release = ''
1105
 
        version = ''
1106
 
        node = _node()
1107
 
        machine = ''
1108
 
        processor = ''
1109
 
        use_syscmd_ver = 1
 
1107
        no_os_uname = 1
 
1108
 
 
1109
    if no_os_uname or not filter(None, (system, node, release, version, machine)):
 
1110
        # Hmm, no there is either no uname or uname has returned
 
1111
        #'unknowns'... we'll have to poke around the system then.
 
1112
        if no_os_uname:
 
1113
            system = sys.platform
 
1114
            release = ''
 
1115
            version = ''
 
1116
            node = _node()
 
1117
            machine = ''
 
1118
 
 
1119
        use_syscmd_ver = 01
1110
1120
 
1111
1121
        # Try win32_ver() on win32 platforms
1112
1122
        if system == 'win32':
1117
1127
            # available on Win XP and later; see
1118
1128
            # http://support.microsoft.com/kb/888731 and
1119
1129
            # http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM
1120
 
            machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
1121
 
            processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
 
1130
            if not machine:
 
1131
                machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
 
1132
            if not processor:
 
1133
                processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
1122
1134
 
1123
1135
        # Try the 'ver' system command available on some
1124
1136
        # platforms
1160
1172
            release,(version,stage,nonrel),machine = mac_ver()
1161
1173
            system = 'MacOS'
1162
1174
 
1163
 
    else:
1164
 
        # System specific extensions
1165
 
        if system == 'OpenVMS':
1166
 
            # OpenVMS seems to have release and version mixed up
1167
 
            if not release or release == '0':
1168
 
                release = version
1169
 
                version = ''
1170
 
            # Get processor information
1171
 
            try:
1172
 
                import vms_lib
1173
 
            except ImportError:
1174
 
                pass
 
1175
    # System specific extensions
 
1176
    if system == 'OpenVMS':
 
1177
        # OpenVMS seems to have release and version mixed up
 
1178
        if not release or release == '0':
 
1179
            release = version
 
1180
            version = ''
 
1181
        # Get processor information
 
1182
        try:
 
1183
            import vms_lib
 
1184
        except ImportError:
 
1185
            pass
 
1186
        else:
 
1187
            csid, cpu_number = vms_lib.getsyi('SYI$_CPU',0)
 
1188
            if (cpu_number >= 128):
 
1189
                processor = 'Alpha'
1175
1190
            else:
1176
 
                csid, cpu_number = vms_lib.getsyi('SYI$_CPU',0)
1177
 
                if (cpu_number >= 128):
1178
 
                    processor = 'Alpha'
1179
 
                else:
1180
 
                    processor = 'VAX'
1181
 
        else:
1182
 
            # Get processor information from the uname system command
1183
 
            processor = _syscmd_uname('-p','')
 
1191
                processor = 'VAX'
 
1192
    if not processor:
 
1193
        # Get processor information from the uname system command
 
1194
        processor = _syscmd_uname('-p','')
1184
1195
 
1185
 
    # 'unknown' is not really any useful as information; we'll convert
1186
 
    # it to '' which is more portable
 
1196
    #If any unknowns still exist, replace them with ''s, which are more portable
1187
1197
    if system == 'unknown':
1188
1198
        system = ''
1189
1199
    if node == 'unknown':