Package invocations :: Package cu8 :: Module getPartLogFile
[hide private]

Source Code for Module invocations.cu8.getPartLogFile

 1  #! /usr/bin/env python 
 2  #------------------------------------------------------------------------------ 
 3  #$Id: getPartLogFile.py 5610 2009-04-02 20:51:06Z RossCollins $ 
 4  """ 
 5     Extracts a single file from a recalibration log. 
 6   
 7     @author: N.J. Cross 
 8     @org:    WFAU, IfA, University of Edinburgh 
 9  """ 
10  #------------------------------------------------------------------------------ 
11  import sys 
12   
13  # Allow module to be imported as well as executed from the command line 
14  if __name__ == '__main__': 
15      logFilePath=sys.argv[1] 
16      testFileName=sys.argv[2] 
17      testLogFilePath=sys.argv[3] 
18   
19      lines = open(logFilePath).readlines() 
20      for index, line in enumerate(lines): 
21          if testFileName in line: 
22              break 
23      else: 
24          raise SystemExit(testFileName + " not found in " + logFilePath) 
25   
26      open(testLogFilePath, 'w').writelines(lines[index:index+32]) 
27