Package qm :: Module platform_win32
[hide private]
[frames] | no frames]

Source Code for Module qm.platform_win32

  1  ######################################################################## 
  2  # 
  3  # File:   platform_win32.py 
  4  # Author: Alex Samuel 
  5  # Date:   2001-05-13 
  6  # 
  7  # Contents: 
  8  #   Platform-specific function for Win32. 
  9  # 
 10  # Copyright (c) 2001, 2002 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 common 
 21  import os 
 22  import qm 
 23  import signal 
 24  import string 
 25  import sys 
 26   
 27  ######################################################################## 
 28  # constants 
 29  ######################################################################## 
 30   
 31  default_shell = [os.environ.get("COMSPEC", r"C:\WINNT\SYSTEM32\CMD.EXE")] 
 32   
 33  ######################################################################## 
 34  # classes 
 35  ######################################################################## 
 36   
 37  # Win32 doesn't provide signals, but we include this anyway so that code 
 38  # may attempt to catch this exception without conditionalizing. 
 39   
40 -class SignalException(Exception):
41
42 - def __init__(self, *args):
43 raise NotImplementedError, "No 'SignalException' on Win32."
44 45 46 47 ######################################################################## 48 # functions 49 ######################################################################## 50
51 -def get_host_name():
52 """Return the name of this computer.""" 53 54 # This function caches the result of '_get_host_name' by replacing 55 # itself with a lambda that returns the cached value. 56 global get_host_name 57 get_host_name = lambda host_name=_get_host_name(): host_name
58 59
60 -def _get_host_name():
61 """Return the name of this computer.""" 62 63 # First try to look up our own address in DNS. 64 try: 65 return socket.gethostbyname_ex(socket.gethostname())[0] 66 except socket.error: 67 pass 68 69 # That didn't work. Just use the local name. 70 try: 71 return socket.gethostname() 72 except socket.error: 73 pass 74 75 # That didn't work either. Check if the host name is stored in the 76 # environment. 77 try: 78 return os.environ["HOSTNAME"] 79 except KeyError: 80 pass 81 82 # We're stumped. Use something dumb. 83 return "localhost"
84 85
86 -def open_in_browser(url):
87 """Open a browser window and point it at 'url'. 88 89 The browser is run in a separate, independent process.""" 90 91 os.startfile(url)
92 93 94 ######################################################################## 95 # Local Variables: 96 # mode: python 97 # indent-tabs-mode: nil 98 # fill-column: 72 99 # End: 100