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