[2] | 1 | :mod:`MacOS` --- Access to Mac OS interpreter features
|
---|
| 2 | ======================================================
|
---|
| 3 |
|
---|
| 4 | .. module:: MacOS
|
---|
| 5 | :platform: Mac
|
---|
| 6 | :synopsis: Access to Mac OS-specific interpreter features.
|
---|
| 7 | :deprecated:
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | This module provides access to MacOS specific functionality in the Python
|
---|
| 11 | interpreter, such as how the interpreter eventloop functions and the like. Use
|
---|
| 12 | with care.
|
---|
| 13 |
|
---|
| 14 | .. note::
|
---|
| 15 |
|
---|
| 16 | This module has been removed in Python 3.x.
|
---|
| 17 |
|
---|
| 18 | Note the capitalization of the module name; this is a historical artifact.
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | .. data:: runtimemodel
|
---|
| 22 |
|
---|
| 23 | Always ``'macho'``, from Python 2.4 on. In earlier versions of Python the value
|
---|
| 24 | could also be ``'ppc'`` for the classic Mac OS 8 runtime model or ``'carbon'``
|
---|
| 25 | for the Mac OS 9 runtime model.
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | .. data:: linkmodel
|
---|
| 29 |
|
---|
| 30 | The way the interpreter has been linked. As extension modules may be
|
---|
| 31 | incompatible between linking models, packages could use this information to give
|
---|
| 32 | more decent error messages. The value is one of ``'static'`` for a statically
|
---|
| 33 | linked Python, ``'framework'`` for Python in a Mac OS X framework, ``'shared'``
|
---|
| 34 | for Python in a standard Unix shared library. Older Pythons could also have the
|
---|
| 35 | value ``'cfm'`` for Mac OS 9-compatible Python.
|
---|
| 36 |
|
---|
| 37 |
|
---|
| 38 | .. exception:: Error
|
---|
| 39 |
|
---|
| 40 | .. index:: module: macerrors
|
---|
| 41 |
|
---|
| 42 | This exception is raised on MacOS generated errors, either from functions in
|
---|
| 43 | this module or from other mac-specific modules like the toolbox interfaces. The
|
---|
[391] | 44 | arguments are the integer error code (the :c:data:`OSErr` value) and a textual
|
---|
[2] | 45 | description of the error code. Symbolic names for all known error codes are
|
---|
| 46 | defined in the standard module :mod:`macerrors`.
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | .. function:: GetErrorString(errno)
|
---|
| 50 |
|
---|
| 51 | Return the textual description of MacOS error code *errno*.
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | .. function:: DebugStr(message [, object])
|
---|
| 55 |
|
---|
| 56 | On Mac OS X the string is simply printed to stderr (on older Mac OS systems more
|
---|
| 57 | elaborate functionality was available), but it provides a convenient location to
|
---|
| 58 | attach a breakpoint in a low-level debugger like :program:`gdb`.
|
---|
| 59 |
|
---|
| 60 | .. note::
|
---|
| 61 |
|
---|
| 62 | Not available in 64-bit mode.
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | .. function:: SysBeep()
|
---|
| 66 |
|
---|
| 67 | Ring the bell.
|
---|
| 68 |
|
---|
| 69 | .. note::
|
---|
| 70 |
|
---|
| 71 | Not available in 64-bit mode.
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 | .. function:: GetTicks()
|
---|
| 75 |
|
---|
| 76 | Get the number of clock ticks (1/60th of a second) since system boot.
|
---|
| 77 |
|
---|
| 78 |
|
---|
| 79 | .. function:: GetCreatorAndType(file)
|
---|
| 80 |
|
---|
| 81 | Return the file creator and file type as two four-character strings. The *file*
|
---|
| 82 | parameter can be a pathname or an ``FSSpec`` or ``FSRef`` object.
|
---|
| 83 |
|
---|
| 84 | .. note::
|
---|
| 85 |
|
---|
| 86 | It is not possible to use an ``FSSpec`` in 64-bit mode.
|
---|
| 87 |
|
---|
| 88 |
|
---|
| 89 | .. function:: SetCreatorAndType(file, creator, type)
|
---|
| 90 |
|
---|
| 91 | Set the file creator and file type. The *file* parameter can be a pathname or an
|
---|
| 92 | ``FSSpec`` or ``FSRef`` object. *creator* and *type* must be four character
|
---|
| 93 | strings.
|
---|
| 94 |
|
---|
| 95 | .. note::
|
---|
| 96 |
|
---|
| 97 | It is not possible to use an ``FSSpec`` in 64-bit mode.
|
---|
| 98 |
|
---|
| 99 | .. function:: openrf(name [, mode])
|
---|
| 100 |
|
---|
| 101 | Open the resource fork of a file. Arguments are the same as for the built-in
|
---|
| 102 | function :func:`open`. The object returned has file-like semantics, but it is
|
---|
| 103 | not a Python file object, so there may be subtle differences.
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 | .. function:: WMAvailable()
|
---|
| 107 |
|
---|
| 108 | Checks whether the current process has access to the window manager. The method
|
---|
| 109 | will return ``False`` if the window manager is not available, for instance when
|
---|
| 110 | running on Mac OS X Server or when logged in via ssh, or when the current
|
---|
| 111 | interpreter is not running from a fullblown application bundle. A script runs
|
---|
| 112 | from an application bundle either when it has been started with
|
---|
| 113 | :program:`pythonw` instead of :program:`python` or when running as an applet.
|
---|
| 114 |
|
---|
| 115 | .. function:: splash([resourceid])
|
---|
| 116 |
|
---|
| 117 | Opens a splash screen by resource id. Use resourceid ``0`` to close
|
---|
| 118 | the splash screen.
|
---|
| 119 |
|
---|
| 120 | .. note::
|
---|
| 121 |
|
---|
| 122 | Not available in 64-bit mode.
|
---|
| 123 |
|
---|