Changeset 58:2bdd948a3b21 in livinglogic.python.tipimaid

Show
Ignore:
Timestamp:
12/23/08 17:16:07 (10 years ago)
Author:
Nikolas Tautenhahn <nik@…>
Branch:
default
Message:

create a file only when it is needed

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • liaalh_sender.py

    r57 r58  
    177177                    self.buffer = self.buffer[i:] 
    178178                    break 
    179         if self.f: 
    180             if self.f.name != os.path.join(self.backuppath, datetime.datetime.now().strftime("%Y%m%d_recovery.log")): 
    181                 self.f.close() 
     179        if self.buffer: 
     180            if self.f: 
     181                if self.f.name != os.path.join(self.backuppath, datetime.datetime.now().strftime("%Y%m%d_recovery.log")): 
     182                    self.f.close() 
     183                    self.f = open(os.path.join(self.backuppath, datetime.datetime.now().strftime("%Y%m%d_recovery.log")), "a", 1) 
     184            else: 
    182185                self.f = open(os.path.join(self.backuppath, datetime.datetime.now().strftime("%Y%m%d_recovery.log")), "a", 1) 
    183         else: 
    184             self.f = open(os.path.join(self.backuppath, datetime.datetime.now().strftime("%Y%m%d_recovery.log")), "a", 1) 
    185         for oldline in self.buffer: 
    186             self.f.write(oldline) 
    187         self.buffer = [] 
    188         self.f.close() 
    189         self.f = None 
     186            for oldline in self.buffer: 
     187                self.f.write(oldline) 
     188            self.buffer = [] 
     189            self.f.close() 
     190            self.f = None 
    190191 
    191192    def send(self):