Home | Trees | Indices | Help |
---|
|
1 ######################################################################## 2 # 3 # File: platform_unix.py 4 # Author: Alex Samuel 5 # Date: 2001-05-13 6 # 7 # Contents: 8 # Platform-specific function for UNIX and UNIX-like systems. 9 # 10 # Copyright (c) 2001, 2002, 2003 by CodeSourcery, LLC. All rights reserved. 11 # 12 # For license terms see the file COPYING. 13 # 14 ######################################################################## 15 16 ######################################################################## 17 # imports 18 ######################################################################## 19 20 import base64 21 import common 22 import cPickle 23 import cStringIO 24 import os 25 import posix 26 import qm 27 import quopri 28 import select 29 import signal 30 import string 31 import sys 32 import traceback 33 34 ######################################################################## 35 # constants 36 ######################################################################## 37 38 if sys.platform[:5] == "linux": 39 # GNU/Linux systems generally use 'bash' as the default shell. 40 # Invoke it with options to inhibit parsing of user startup files. 41 default_shell = ["/bin/bash", "-norc", "-noprofile"] 42 else: 43 # Other UNIX systems use the Bourne shell. 44 default_shell = ["/bin/sh"] 45 46 47 ######################################################################## 48 # classes 49 ######################################################################## 5052 """An exception raised in response to a signal.""" 5375 76 77 78 ######################################################################## 79 # functions 80 ######################################################################## 8155 """Create a new signal exception. 56 57 'signal_number' -- The signal number.""" 58 59 # Construct a text argument for the exception. 60 message = "Signal %d" % signal_number 61 # Include the signal name, if available. 62 signal_name = get_signal_name(signal_number) 63 if signal_name is not None: 64 message = message + " (%s)" % signal_name 65 # Initialize the base class. 66 common.QMException.__init__(self, message) 67 # Store the signal number. 68 self.__signal_number = signal_number69 7083 """Open a browser window and point it at 'url'. 84 85 The browser is run in a separate, independent process.""" 86 87 # Escape single quotes in the URL. 88 url = string.replace(url, "'", "%27") 89 # Which browser to use? 90 browser = common.rc.Get("browser", "mozilla", "common") 91 # Invoke the browser. 92 os.system("%s '%s' &" % (browser, url))93 9496 """Return the name for signal 'signal_number'. 97 98 returns -- The signal's name, or 'None'.""" 99 100 # A hack: look for an attribute in the 'signal' module whose 101 # name starts with "SIG" and whose value is the signal number. 102 for attribute_name in dir(signal): 103 if len(attribute_name) > 3 \ 104 and attribute_name[:3] == "SIG" \ 105 and getattr(signal, attribute_name) == signal_number: 106 return attribute_name 107 # No match. 108 return None109 110112 """Install a handler to translate a signal into an exception. 113 114 The signal handler raises a 'SignalException' exception in 115 response to a signal.""" 116 117 signal.signal(signal_number, _signal_handler)118 119121 """Generic signal handler that raises an exception.""" 122 123 raise SignalException(signal_number)124 125 130 131 ######################################################################## 132 # initialization 133 ######################################################################## 134136 """Perform module initialization.""" 137 138 # Install signal handlers for several common signals. 139 for s in (signal.SIGALRM, 140 signal.SIGHUP, 141 signal.SIGTERM, 142 signal.SIGUSR1, 143 signal.SIGUSR2): 144 install_signal_handler(s)145 146 _initialize() 147 148 ######################################################################## 149 # Local Variables: 150 # mode: python 151 # indent-tabs-mode: nil 152 # fill-column: 72 153 # End: 154
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Dec 23 12:30:47 2011 | http://epydoc.sourceforge.net |