Changeset 5634

Show
Ignore:
Timestamp:
08/04/12 22:40:11 (7 years ago)
Author:
albert
Message:

Use shutil.copyfile instead of shutil.copy (we are only copying files, not directories, anyway). shutil.copy has problems on Android, too, cf. r4853

Location:
seattle/trunk/nodemanager
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • seattle/trunk/nodemanager/nmAPI.mix

    r4458 r5634  
    459459  firstOK=False 
    460460  try: 
    461     shutil.copy(vesseldict[vesselname]['logfilename']+'.old', "tmplog") 
     461    shutil.copyfile(vesseldict[vesselname]['logfilename']+'.old', "tmplog") 
    462462  except IOError, e: 
    463463    if e[0] == 2: 
     
    475475  # minimized (I'll read both after) 
    476476  try: 
    477     shutil.copy(vesseldict[vesselname]['logfilename']+'.new', "tmplog.new") 
     477    shutil.copyfile(vesseldict[vesselname]['logfilename']+'.new', "tmplog.new") 
    478478  except IOError, e: 
    479479    if e[0] == 2: 
  • seattle/trunk/nodemanager/persist.py

    r4903 r5634  
    7373import shutil 
    7474 
    75 # AR: Determine whether we're running on Android 
    76 try: 
    77   import android 
    78   is_android = True 
    79 except ImportError: 
    80   is_android = False 
    8175 
    82  
    83 def _copy(orig_filename, copy_filename): 
    84   # AR: Wrap Android-specific shutil.copy() quirks. They seem to have a problem  
    85   # setting the file access mode bits there, and shutil.copyfile() suffices  
    86   # for the task at hand. 
    87  
    88   if not is_android: 
    89     shutil.copy(orig_filename, copy_filename) 
    90   else: 
    91     shutil.copyfile(orig_filename, copy_filename) 
    9276 
    9377 
     
    161145    # 2) try to copy filename to filename+".tmp"  
    162146    try: 
    163       _copy(filename, filename+'.tmp') 
     147      shutil.copyfile(filename, filename+'.tmp') 
    164148    except IOError, e: 
    165149      if e[0] == 2: # file not found 
     
    177161    # 5) try to copy filename+'.new' to filename+'.tmp' 
    178162    try: 
    179       _copy(filename+'.new', filename+'.tmp') 
     163      shutil.copyfile(filename+'.new', filename+'.tmp') 
    180164    except IOError, e: 
    181165      if e[0] == 2: # file not found