Module AIPS
[hide private]
[frames] | no frames]

Source Code for Module AIPS

  1  # Copyright (C) 2005 Joint Institute for VLBI in Europe 
  2  # 
  3  # This program is free software; you can redistribute it and/or modify 
  4  # it under the terms of the GNU General Public License as published by 
  5  # the Free Software Foundation; either version 2 of the License, or 
  6  # (at your option) any later version. 
  7  # 
  8  # This program is distributed in the hope that it will be useful, 
  9  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 10  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 11  # GNU General Public License for more details. 
 12   
 13  # You should have received a copy of the GNU General Public License 
 14  # along with this program; if not, write to the Free Software 
 15  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 16   
 17  """ 
 18   
 19  This module provides the AIPSDisk class and serves as a container for 
 20  several AIPS-related defaults.  It provides some basic infrastructure 
 21  used by the AIPSTask and AIPSData modules. 
 22   
 23  """ 
 24   
 25  # Generic Python stuff. 
 26  import os, sys 
 27   
 28  # Generic AIPS functionality. 
 29  from AIPSUtil import ehex 
 30   
 31  # Debug log.  Define before including proxies. 
 32  debuglog = None 
 33   
 34  # Available proxies. 
 35  import LocalProxy 
 36  from xmlrpclib import ServerProxy 
 37   
 38   
39 -class AIPSDisk:
40 41 """Class representing a (possibly remote) AIPS disk. An instance 42 of this class stores an AIPS disk number and the URL of the 43 proxy through which it can be accessed. For local AIPS disks 44 the URL will be None.""" 45
46 - def __init__(self, url, disk):
47 self.url = url 48 self.disk = disk 49 return
50
51 - def proxy(self):
52 """Return the proxy through which this AIPS disk can be 53 accessed.""" 54 if self.url: 55 return ServerProxy(self.url, allow_none=True) 56 return LocalProxy
57 58 pass # class AIPSDisk
59 60 61 # Default AIPS user ID. 62 userno = 0 63 64 # List of available proxies. 65 proxies = [ LocalProxy ] 66 67 # AIPS disk mapping. 68 disks = [ None ] # Disk numbers are one-based. 69 70 # AIPS seems to support a maximum of 35 disks. 71 for disk in xrange(1, 36): 72 area = 'DA' + ehex(disk, 2, '0') 73 if not area in os.environ: 74 break 75 disks.append(AIPSDisk(None, disk)) 76 continue 77 78 # Message log. 79 log = None 80 81 82 # The code below is the result of a serious design flaw. It should 83 # really die, but removing it will probably affect most scripts. 84
85 -class _AIPS(object):
86 87 """Backwards compatibility gunk.""" 88
89 - def _get_userno(self):
90 return sys.modules[__name__].userno
91 - def _set_userno(self, value):
92 sys.modules[__name__].userno = value
93 userno = property(_get_userno, _set_userno) 94
95 - def _get_disks(self):
96 return sys.modules[__name__].disks
97 - def _set_disks(self, value):
98 sys.modules[__name__].disks = value
99 disks = property(_get_disks, _set_disks) 100
101 - def _get_log(self):
102 return sys.modules[__name__].log
103 - def _set_log(self, value):
104 sys.modules[__name__].log = value
105 log = property(_get_log, _set_log) 106
107 - def _get_debuglog(self):
108 return sys.modules[__name__].debuglog
109 - def _set_debuglog(self, value):
110 sys.modules[__name__].debuglog = value
111 debuglog = property(_get_debuglog, _set_debuglog) 112 113 pass # class _AIPS
114 115 AIPS = _AIPS() 116