blob: b22b39cadb760314ec4e0a2667e5ec21d144911b [file] [log] [blame]
Fred Drakec817e271998-08-10 18:40:22 +00001\section{\module{MacOS} ---
Fred Drake30cf1182001-08-03 17:11:33 +00002 Access to Mac OS interpreter features}
Fred Drakef6863c11999-03-02 16:37:17 +00003
Fred Drakefe7f3bc1998-07-23 17:55:31 +00004\declaremodule{builtin}{MacOS}
Fred Drakef6863c11999-03-02 16:37:17 +00005 \platform{Mac}
Fred Drake30cf1182001-08-03 17:11:33 +00006\modulesynopsis{Access to Mac OS-specific interpreter features.}
Fred Drakefe7f3bc1998-07-23 17:55:31 +00007
Jack Jansenebed45f1995-08-14 13:40:05 +00008
Jack Jansenebed45f1995-08-14 13:40:05 +00009This module provides access to MacOS specific functionality in the
Fred Drake61885921998-04-03 07:16:46 +000010Python interpreter, such as how the interpreter eventloop functions
Jack Jansenebed45f1995-08-14 13:40:05 +000011and the like. Use with care.
12
Fred Drake30cf1182001-08-03 17:11:33 +000013Note the capitalization of the module name; this is a historical
Fred Drake61885921998-04-03 07:16:46 +000014artifact.
Fred Drake30cf1182001-08-03 17:11:33 +000015
Jack Jansencb60dae2001-08-03 13:19:56 +000016\begin{datadesc}{runtimemodel}
Brett Cannon7706c2d2005-02-13 22:50:04 +000017Always \code{'macho'}, from Python 2.4 on.
18In earlier versions of Python the value could
19also be \code{'ppc'} for the classic Mac OS 8 runtime model or
20\code{'carbon'} for the Mac OS 9 runtime model.
Jack Jansen5860dab2003-02-24 11:02:36 +000021\end{datadesc}
22
23\begin{datadesc}{linkmodel}
24The way the interpreter has been linked. As extension modules may be
25incompatible between linking models, packages could use this information to give
26more decent error messages. The value is one of \code{'static'} for a
27statically linked Python, \code{'framework'} for Python in a Mac OS X framework,
Brett Cannon7706c2d2005-02-13 22:50:04 +000028\code{'shared'} for Python in a standard unix shared library.
29Older Pythons could also have the value
30\code{'cfm'} for Mac OS 9-compatible Python.
Jack Jansencb60dae2001-08-03 13:19:56 +000031\end{datadesc}
Jack Jansenebed45f1995-08-14 13:40:05 +000032
33\begin{excdesc}{Error}
34This exception is raised on MacOS generated errors, either from
35functions in this module or from other mac-specific modules like the
36toolbox interfaces. The arguments are the integer error code (the
Fred Drake61885921998-04-03 07:16:46 +000037\cdata{OSErr} value) and a textual description of the error code.
Guido van Rossum7e42cab1996-10-15 14:37:31 +000038Symbolic names for all known error codes are defined in the standard
Fred Drake30cf1182001-08-03 17:11:33 +000039module \refmodule{macerrors}.\refstmodindex{macerrors}
Jack Jansenebed45f1995-08-14 13:40:05 +000040\end{excdesc}
41
Jack Jansenebed45f1995-08-14 13:40:05 +000042
43\begin{funcdesc}{GetErrorString}{errno}
44Return the textual description of MacOS error code \var{errno}.
45\end{funcdesc}
Guido van Rossum66774a91996-07-21 02:20:58 +000046
Fred Drake671fe9d1997-12-29 18:53:31 +000047\begin{funcdesc}{DebugStr}{message \optional{, object}}
Brett Cannon7706c2d2005-02-13 22:50:04 +000048On Mac OS X the string is simply printed to stderr (on older
49Mac OS systems more elaborate functionality was available),
50but it provides a convenient location to attach a breakpoint
51in a low-level debugger like \program{gdb}.
Guido van Rossum7e42cab1996-10-15 14:37:31 +000052\end{funcdesc}
53
Jack Jansen7aeba452003-02-12 09:58:33 +000054\begin{funcdesc}{SysBeep}{}
55Ring the bell.
56\end{funcdesc}
57
58\begin{funcdesc}{GetTicks}{}
59Get the number of clock ticks (1/60th of a second) since system boot.
60\end{funcdesc}
61
62\begin{funcdesc}{GetCreatorAndType}{file}
63Return the file creator and file type as two four-character strings.
64The \var{file} parameter can be a pathname or an \code{FSSpec} or
65\code{FSRef} object.
66\end{funcdesc}
67
68\begin{funcdesc}{SetCreatorAndType}{file, creator, type}
69Set the file creator and file type.
70The \var{file} parameter can be a pathname or an \code{FSSpec} or
71\code{FSRef} object. \var{creator} and \var{type} must be four character
72strings.
73\end{funcdesc}
74
Fred Drake671fe9d1997-12-29 18:53:31 +000075\begin{funcdesc}{openrf}{name \optional{, mode}}
Guido van Rossum66774a91996-07-21 02:20:58 +000076Open the resource fork of a file. Arguments are the same as for the
Fred Drake61885921998-04-03 07:16:46 +000077built-in function \function{open()}. The object returned has file-like
78semantics, but it is not a Python file object, so there may be subtle
Guido van Rossum66774a91996-07-21 02:20:58 +000079differences.
80\end{funcdesc}
Jack Jansen5860dab2003-02-24 11:02:36 +000081
82\begin{funcdesc}{WMAvailable}{}
Neal Norwitz360cd412003-12-14 15:01:35 +000083Checks whether the current process has access to the window manager.
Jack Jansen5860dab2003-02-24 11:02:36 +000084The method will return \code{False} if the window manager is not available,
85for instance when running on Mac OS X Server or when logged in via ssh,
86or when the current interpreter is not running from a fullblown application
87bundle. A script runs from an application bundle either when it has been
Neal Norwitz1ecbd672003-12-14 15:02:54 +000088started with \program{pythonw} instead of \program{python} or when running
Jack Jansen5860dab2003-02-24 11:02:36 +000089as an applet.
Jack Jansen5860dab2003-02-24 11:02:36 +000090\end{funcdesc}