Back to index

python3.2  3.2.2
Functions | Variables
platform Namespace Reference

Functions

def libc_ver
def _dist_try_harder

Variables

string __copyright__
string __version__ = '1.0.7'
 DEV_NULL = os.devnull
 Globals & Constants.
tuple _libc_search
 Platform specific APIs.
tuple _release_filename = re.compile(r'(\w+)[-_](release|version)', re.ASCII)

Function Documentation

def platform._dist_try_harder (   distname,
  version,
  id 
) [private]
Tries some special tricks to get the distribution
    information in case the default method fails.

    Currently supports older SuSE Linux, Caldera OpenLinux and
    Slackware Linux distributions.

Definition at line 192 of file platform.py.

00192 
00193 def _dist_try_harder(distname,version,id):
00194 
00195     """ Tries some special tricks to get the distribution
00196         information in case the default method fails.
00197 
00198         Currently supports older SuSE Linux, Caldera OpenLinux and
00199         Slackware Linux distributions.
00200 
00201     """
00202     if os.path.exists('/var/adm/inst-log/info'):
00203         # SuSE Linux stores distribution information in that file
00204         distname = 'SuSE'
00205         for line in open('/var/adm/inst-log/info'):
00206             tv = line.split()
00207             if len(tv) == 2:
00208                 tag,value = tv
00209             else:
00210                 continue
00211             if tag == 'MIN_DIST_VERSION':
00212                 version = value.strip()
00213             elif tag == 'DIST_IDENT':
00214                 values = value.split('-')
00215                 id = values[2]
00216         return distname,version,id
00217 
00218     if os.path.exists('/etc/.installed'):
00219         # Caldera OpenLinux has some infos in that file (thanks to Colin Kong)
00220         for line in open('/etc/.installed'):
00221             pkg = line.split('-')
00222             if len(pkg) >= 2 and pkg[0] == 'OpenLinux':
00223                 # XXX does Caldera support non Intel platforms ? If yes,
00224                 #     where can we find the needed id ?
00225                 return 'OpenLinux',pkg[1],id
00226 
00227     if os.path.isdir('/usr/lib/setup'):
00228         # Check for slackware verson tag file (thanks to Greg Andruk)
00229         verfiles = os.listdir('/usr/lib/setup')
00230         for n in range(len(verfiles)-1, -1, -1):
00231             if verfiles[n][:14] != 'slack-version-':
00232                 del verfiles[n]
00233         if verfiles:
00234             verfiles.sort()
00235             distname = 'slackware'
00236             version = verfiles[-1][14:]
00237             return distname,version,id
00238 
00239     return distname,version,id

def platform.libc_ver (   executable = sys.executable,
  lib = '',
  version = '',
  chunksize = 2048 
)
Tries to determine the libc version that the file executable
    (which defaults to the Python interpreter) is linked against.

    Returns a tuple of strings (lib,version) which default to the
    given parameters in case the lookup fails.

    Note that the function has intimate knowledge of how different
    libc versions add symbols to the executable and thus is probably
    only useable for executables compiled using gcc.

    The file is read and scanned in chunks of chunksize bytes.

Definition at line 141 of file platform.py.

00141 
00142              chunksize=2048):
00143 
00144     """ Tries to determine the libc version that the file executable
00145         (which defaults to the Python interpreter) is linked against.
00146 
00147         Returns a tuple of strings (lib,version) which default to the
00148         given parameters in case the lookup fails.
00149 
00150         Note that the function has intimate knowledge of how different
00151         libc versions add symbols to the executable and thus is probably
00152         only useable for executables compiled using gcc.
00153 
00154         The file is read and scanned in chunks of chunksize bytes.
00155 
00156     """
00157     if hasattr(os.path, 'realpath'):
00158         # Python 2.2 introduced os.path.realpath(); it is used
00159         # here to work around problems with Cygwin not being
00160         # able to open symlinks for reading
00161         executable = os.path.realpath(executable)
00162     f = open(executable,'rb')
00163     binary = f.read(chunksize).decode('latin-1')
00164     pos = 0
00165     while 1:
00166         m = _libc_search.search(binary,pos)
00167         if not m:
00168             binary = f.read(chunksize).decode('latin-1')
00169             if not binary:
00170                 break
00171             pos = 0
00172             continue
00173         libcinit,glibc,glibcversion,so,threads,soversion = m.groups()
00174         if libcinit and not lib:
00175             lib = 'libc'
00176         elif glibc:
00177             if lib != 'glibc':
00178                 lib = 'glibc'
00179                 version = glibcversion
00180             elif glibcversion > version:
00181                 version = glibcversion
00182         elif so:
00183             if lib != 'glibc':
00184                 lib = 'libc'
00185                 if soversion > version:
00186                     version = soversion
00187                 if threads and version[-len(threads):] != threads:
00188                     version = version + threads
00189         pos = m.end()
00190     f.close()
00191     return lib,version

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
00001 """
00002     Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
00003     Copyright (c) 2000-2010, eGenix.com Software GmbH; mailto:info@egenix.com
00004 
00005     Permission to use, copy, modify, and distribute this software and its
00006     documentation for any purpose and without fee or royalty is hereby granted,
00007     provided that the above copyright notice appear in all copies and that
00008     both that copyright notice and this permission notice appear in
00009     supporting documentation or portions thereof, including modifications,
00010     that you make.
00011 
00012     EGENIX.COM SOFTWARE GMBH DISCLAIMS ALL WARRANTIES WITH REGARD TO
00013     THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
00014     FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
00015     INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
00016     FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
00017     NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
00018     WITH THE USE OR PERFORMANCE OF THIS SOFTWARE !
00019 
00020 """

Definition at line 91 of file platform.py.

Definition at line 112 of file platform.py.

Initial value:
00001 re.compile(r'(__libc_init)'
00002                           '|'
00003                           '(GLIBC_([0-9.]+))'
00004                           '|'
00005                           '(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)', re.ASCII)

Platform specific APIs.

Definition at line 133 of file platform.py.

tuple platform._release_filename = re.compile(r'(\w+)[-_](release|version)', re.ASCII)

Definition at line 240 of file platform.py.

string platform.DEV_NULL = os.devnull

Globals & Constants.

Definition at line 120 of file platform.py.