Changeset 4850


Ignore:
Timestamp:
Nov 22, 2007, 3:04:05 PM (16 years ago)
Author:
nick
Message:

cleaned up "screen_catcher" and made "copy_code_files" more flexible

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r4824 r4850  
    52565256       
    52575257def start_screen_catcher(dir_name, myid='', numprocs='', extra_info='',
    5258                          print_to_screen=False, verbose=False):
    5259     """
     5258                         verbose=False):
     5259    """ 
    52605260    Used to store screen output and errors to file, if run on multiple
    52615261    processes eachprocessor will have its own output and error file.
     
    52635263    extra_info - is used as a string that can identify outputs with another
    52645264    string eg. '_other'
     5265   
     5266    FIXME: Would be good if you could suppress all the screen output and
     5267    only save it to file... however it seems a bit tricky as this caputure
     5268    techique response to sys.stdout and by this time it is already printed out.
     5269   
    52655270    """
    52665271    import sys
    52675272    dir_name = dir_name
    52685273    if access(dir_name,W_OK) == 0:
    5269         if verbose: print 'Make directory %s' %dir_name
    5270         if verbose: print "myid", myid
     5274        if verbose: print 'Making directory %s' %dir_name
     5275      #  if verbose: print "myid", myid
    52715276        mkdir (dir_name,0777)
    52725277    if myid <>'':
     
    52825287                                                              numprocs,
    52835288                                                              extra_info)
    5284     print screen_output_name
     5289    if verbose: print screen_output_name
    52855290    #used to catch screen output to file
    52865291    sys.stdout = Screen_Catcher(screen_output_name)
     
    53025307        fid = open(self.filename, 'a')
    53035308        fid.write(stuff)
    5304 #        if print_to_screen: print stuff
    5305 
    5306 def copy_code_files(dir_name, filename1, filename2):
     5309
     5310def copy_code_files(dir_name, filename1, filename2=None):
    53075311    """Copies "filename1" and "filename2" to "dir_name". Very useful for
    53085312    information management
     
    53145318        mkdir (dir_name,0777)
    53155319    shutil.copy(filename1, dir_name + sep + basename(filename1))
    5316     shutil.copy(filename2, dir_name + sep + basename(filename2))
    5317 #    copy (__file__, project.output_run_time_dir + basename(__file__))
    5318     print 'Files %s and %s copied' %(filename1, filename2)
     5320    if filename2!=None:
     5321        shutil.copy(filename2, dir_name + sep + basename(filename2))
     5322        print 'Files %s and %s copied' %(filename1, filename2)
     5323    else:
     5324        print 'File %s copied' %(filename1)
    53195325
    53205326def get_data_from_file(filename,separator_value = ','):
Note: See TracChangeset for help on using the changeset viewer.