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

Source Code for Module ParselTongue

 1  # Copyright (C) 2005, 2006 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  This module provides support for starting an interactive ParselTongue 
19  session. 
20   
21  """ 
22   
23  # ParselTongue version 
24  import ptversion 
25   
26  # Global AIPS defaults 
27  import AIPS 
28   
29  # Global FITS defaults 
30  from FITS import FITS 
31   
32  # The main classes ParselTongue provides. 
33  from AIPSTask import * 
34  from AIPSData import * 
35  from AIPSTV import * 
36  from ObitTask import * 
37  from FITSData import * 
38    
39  # Use our own, somewhat restricted, rlcompleter.  Don't fall over if 
40  # readline isn't available though. 
41  try: 
42      import atexit, readline, ptcompleter 
43      if __name__ == "__main__" : 
44                  try: 
45                          path = os.environ['HOME'] + '/.ParselTongue/history' 
46                          readline.read_history_file(path) 
47                  except IOError: 
48                          pass 
49                  readline.parse_and_bind("tab: complete") 
50                  if not os.path.exists(os.path.dirname(path)): 
51                          os.makedirs(os.path.dirname(path)) 
52                          pass 
53                  atexit.register(readline.write_history_file, path) 
54  except: 
55      pass 
56   
57  # Override help() such that it prints something useful for instances 
58  # of AIPSTask. 
59  _help = help 
60 -def help(obj):
61 if isinstance(obj, AIPSTask): 62 obj.help() 63 else: 64 _help(obj) 65 pass 66 return
67
68 -def explain(obj):
69 obj.explain() 70 return
71 72 if __name__ == "__main__" : 73 # This is not a batch job. 74 AIPSTask.isbatch = 0 75 76 # Separate the blurb below from what the Python interpreter spits out. 77 print "" 78 79 print "Welcome to ParselTongue", ptversion.version 80 while True: 81 try: 82 input = raw_input("Please enter your AIPS user ID number: ") 83 AIPS.userno = int(input) 84 except KeyboardInterrupt: 85 print "" 86 print "AIPS user ID number is not set" 87 break 88 except: 89 print "That is not a valid AIPS user ID number" 90 continue 91 else: 92 break 93