Changeset 4924
- Timestamp:
- Jan 10, 2008, 10:48:21 AM (17 years ago)
- Location:
- anuga_core/source/anuga/shallow_water
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/data_manager.py
r4899 r4924 5257 5257 5258 5258 def start_screen_catcher(dir_name, myid='', numprocs='', extra_info='', 5259 verbose= False):5259 verbose=True): 5260 5260 """ 5261 5261 Used to store screen output and errors to file, if run on multiple … … 5276 5276 # if verbose: print "myid", myid 5277 5277 mkdir (dir_name,0777) 5278 # print 'helloa' 5278 5279 if myid <>'': 5279 5280 myid = '_'+str(myid) … … 5282 5283 if extra_info <>'': 5283 5284 extra_info = '_'+str(extra_info) 5285 # print 'hello1' 5284 5286 screen_output_name = dir_name + "screen_output%s%s%s.txt" %(myid, 5285 5287 numprocs, … … 5288 5290 numprocs, 5289 5291 extra_info) 5290 if verbose: print screen_output_name 5292 5293 if verbose: print 'Starting ScreenCatcher, all output will be stored in %s' \ 5294 %(screen_output_name) 5291 5295 #used to catch screen output to file 5292 5296 sys.stdout = Screen_Catcher(screen_output_name) … … 5300 5304 def __init__(self, filename): 5301 5305 self.filename = filename 5302 5306 # print 'init' 5303 5307 if exists(self.filename)is True: 5304 5308 print'Old existing file "%s" has been deleted' %(self.filename) … … 5308 5312 fid = open(self.filename, 'a') 5309 5313 fid.write(stuff) 5310 5314 fid.close() 5315 5311 5316 def copy_code_files(dir_name, filename1, filename2=None): 5312 5317 """Copies "filename1" and "filename2" to "dir_name". Very useful for -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r4899 r4924 7356 7356 assert len(iterate)==4 7357 7357 7358 def test_screen_catcher(self): 7359 7360 stdout_orginal = sys.stdout 7361 stderr_orginal = sys.stderr 7362 7363 output_dir = tempfile.mkdtemp('','output_test') 7364 #print output_dir 7365 start_screen_catcher(output_dir+sep,verbose=False) 7366 7367 print 'hello screen catcher' 7368 print 'goodbye screen catcher' 7369 7370 sys.stdout = stdout_orginal 7371 sys.stderr = stderr_orginal 7372 7373 output_file = output_dir+sep+'screen_output.txt' 7374 assert access(output_file,F_OK) 7375 7376 fid = open(output_file) 7377 file_line1 = fid.readline() 7378 file_line2 = fid.readline() 7379 7380 #print 'file contents',file_line1, file_line2 7381 assert (file_line1 == 'hello screen catcher\n') 7382 assert (file_line2 == 'goodbye screen catcher\n') 7358 7383 7359 7384 … … 7365 7390 7366 7391 #suite = unittest.makeSuite(Test_Data_Manager,'test_export_gridII') 7367 #suite = unittest.makeSuite(Test_Data_Manager,'test_sww_header')7392 # suite = unittest.makeSuite(Test_Data_Manager,'test_screen_catcher') 7368 7393 suite = unittest.makeSuite(Test_Data_Manager,'test') 7369 7394 #suite = unittest.makeSuite(Test_Data_Manager,'test_urs_ungridded_holeII')
Note: See TracChangeset
for help on using the changeset viewer.