Fred Drake | c817e27 | 1998-08-10 18:40:22 +0000 | [diff] [blame] | 1 | \section{\module{MacOS} --- |
Fred Drake | 30cf118 | 2001-08-03 17:11:33 +0000 | [diff] [blame] | 2 | Access to Mac OS interpreter features} |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 3 | |
Fred Drake | fe7f3bc | 1998-07-23 17:55:31 +0000 | [diff] [blame] | 4 | \declaremodule{builtin}{MacOS} |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 5 | \platform{Mac} |
Fred Drake | 30cf118 | 2001-08-03 17:11:33 +0000 | [diff] [blame] | 6 | \modulesynopsis{Access to Mac OS-specific interpreter features.} |
Fred Drake | fe7f3bc | 1998-07-23 17:55:31 +0000 | [diff] [blame] | 7 | |
Jack Jansen | ebed45f | 1995-08-14 13:40:05 +0000 | [diff] [blame] | 8 | |
Jack Jansen | ebed45f | 1995-08-14 13:40:05 +0000 | [diff] [blame] | 9 | This module provides access to MacOS specific functionality in the |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 10 | Python interpreter, such as how the interpreter eventloop functions |
Jack Jansen | ebed45f | 1995-08-14 13:40:05 +0000 | [diff] [blame] | 11 | and the like. Use with care. |
| 12 | |
Fred Drake | 30cf118 | 2001-08-03 17:11:33 +0000 | [diff] [blame] | 13 | Note the capitalization of the module name; this is a historical |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 14 | artifact. |
Fred Drake | 30cf118 | 2001-08-03 17:11:33 +0000 | [diff] [blame] | 15 | |
Jack Jansen | cb60dae | 2001-08-03 13:19:56 +0000 | [diff] [blame] | 16 | \begin{datadesc}{runtimemodel} |
Brett Cannon | 7706c2d | 2005-02-13 22:50:04 +0000 | [diff] [blame] | 17 | Always \code{'macho'}, from Python 2.4 on. |
| 18 | In earlier versions of Python the value could |
| 19 | also be \code{'ppc'} for the classic Mac OS 8 runtime model or |
| 20 | \code{'carbon'} for the Mac OS 9 runtime model. |
Jack Jansen | 5860dab | 2003-02-24 11:02:36 +0000 | [diff] [blame] | 21 | \end{datadesc} |
| 22 | |
| 23 | \begin{datadesc}{linkmodel} |
| 24 | The way the interpreter has been linked. As extension modules may be |
| 25 | incompatible between linking models, packages could use this information to give |
| 26 | more decent error messages. The value is one of \code{'static'} for a |
| 27 | statically linked Python, \code{'framework'} for Python in a Mac OS X framework, |
Fred Drake | e0d4aec | 2006-07-30 03:03:43 +0000 | [diff] [blame] | 28 | \code{'shared'} for Python in a standard \UNIX{} shared library. |
Brett Cannon | 7706c2d | 2005-02-13 22:50:04 +0000 | [diff] [blame] | 29 | Older Pythons could also have the value |
| 30 | \code{'cfm'} for Mac OS 9-compatible Python. |
Jack Jansen | cb60dae | 2001-08-03 13:19:56 +0000 | [diff] [blame] | 31 | \end{datadesc} |
Jack Jansen | ebed45f | 1995-08-14 13:40:05 +0000 | [diff] [blame] | 32 | |
| 33 | \begin{excdesc}{Error} |
| 34 | This exception is raised on MacOS generated errors, either from |
| 35 | functions in this module or from other mac-specific modules like the |
| 36 | toolbox interfaces. The arguments are the integer error code (the |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 37 | \cdata{OSErr} value) and a textual description of the error code. |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 38 | Symbolic names for all known error codes are defined in the standard |
Fred Drake | 30cf118 | 2001-08-03 17:11:33 +0000 | [diff] [blame] | 39 | module \refmodule{macerrors}.\refstmodindex{macerrors} |
Jack Jansen | ebed45f | 1995-08-14 13:40:05 +0000 | [diff] [blame] | 40 | \end{excdesc} |
| 41 | |
Jack Jansen | ebed45f | 1995-08-14 13:40:05 +0000 | [diff] [blame] | 42 | |
| 43 | \begin{funcdesc}{GetErrorString}{errno} |
| 44 | Return the textual description of MacOS error code \var{errno}. |
| 45 | \end{funcdesc} |
Guido van Rossum | 66774a9 | 1996-07-21 02:20:58 +0000 | [diff] [blame] | 46 | |
Fred Drake | 671fe9d | 1997-12-29 18:53:31 +0000 | [diff] [blame] | 47 | \begin{funcdesc}{DebugStr}{message \optional{, object}} |
Brett Cannon | 7706c2d | 2005-02-13 22:50:04 +0000 | [diff] [blame] | 48 | On Mac OS X the string is simply printed to stderr (on older |
| 49 | Mac OS systems more elaborate functionality was available), |
| 50 | but it provides a convenient location to attach a breakpoint |
| 51 | in a low-level debugger like \program{gdb}. |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 52 | \end{funcdesc} |
| 53 | |
Jack Jansen | 7aeba45 | 2003-02-12 09:58:33 +0000 | [diff] [blame] | 54 | \begin{funcdesc}{SysBeep}{} |
| 55 | Ring the bell. |
| 56 | \end{funcdesc} |
| 57 | |
| 58 | \begin{funcdesc}{GetTicks}{} |
| 59 | Get the number of clock ticks (1/60th of a second) since system boot. |
| 60 | \end{funcdesc} |
| 61 | |
| 62 | \begin{funcdesc}{GetCreatorAndType}{file} |
| 63 | Return the file creator and file type as two four-character strings. |
| 64 | The \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} |
| 69 | Set the file creator and file type. |
| 70 | The \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 |
| 72 | strings. |
| 73 | \end{funcdesc} |
| 74 | |
Fred Drake | 671fe9d | 1997-12-29 18:53:31 +0000 | [diff] [blame] | 75 | \begin{funcdesc}{openrf}{name \optional{, mode}} |
Guido van Rossum | 66774a9 | 1996-07-21 02:20:58 +0000 | [diff] [blame] | 76 | Open the resource fork of a file. Arguments are the same as for the |
Fred Drake | 6188592 | 1998-04-03 07:16:46 +0000 | [diff] [blame] | 77 | built-in function \function{open()}. The object returned has file-like |
| 78 | semantics, but it is not a Python file object, so there may be subtle |
Guido van Rossum | 66774a9 | 1996-07-21 02:20:58 +0000 | [diff] [blame] | 79 | differences. |
| 80 | \end{funcdesc} |
Jack Jansen | 5860dab | 2003-02-24 11:02:36 +0000 | [diff] [blame] | 81 | |
| 82 | \begin{funcdesc}{WMAvailable}{} |
Neal Norwitz | 360cd41 | 2003-12-14 15:01:35 +0000 | [diff] [blame] | 83 | Checks whether the current process has access to the window manager. |
Jack Jansen | 5860dab | 2003-02-24 11:02:36 +0000 | [diff] [blame] | 84 | The method will return \code{False} if the window manager is not available, |
| 85 | for instance when running on Mac OS X Server or when logged in via ssh, |
| 86 | or when the current interpreter is not running from a fullblown application |
| 87 | bundle. A script runs from an application bundle either when it has been |
Neal Norwitz | 1ecbd67 | 2003-12-14 15:02:54 +0000 | [diff] [blame] | 88 | started with \program{pythonw} instead of \program{python} or when running |
Jack Jansen | 5860dab | 2003-02-24 11:02:36 +0000 | [diff] [blame] | 89 | as an applet. |
Jack Jansen | 5860dab | 2003-02-24 11:02:36 +0000 | [diff] [blame] | 90 | \end{funcdesc} |