Changeset 62:80c58efcd37a in livinglogic.python.tipimaid

Show
Ignore:
Timestamp:
01/05/09 12:43:03 (10 years ago)
Author:
Nikolas Tautenhahn <nik@…>
Branch:
default
Message:

\"calculate\" filename only once

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • liaalh_sender.py

    r60 r62  
    104104            self.buffer.append(line) 
    105105        else: # this entry is too late - write it to a tempfile 
     106            filename = os.path.join(self.backuppath, datetime.datetime.now().strftime("%Y%m%d_recovery.log")) 
    106107            if self.f: 
    107                 if self.f.name != os.path.join(self.backuppath, datetime.datetime.now().strftime("%Y%m%d_recovery.log")): 
    108                     self.f.close() 
    109                     self.f = open(os.path.join(self.backuppath, datetime.datetime.now().strftime("%Y%m%d_recovery.log")), "a", 1) 
     108                if self.f.name != filename: 
     109                    self.f.close() 
     110                    self.f = open(filename, "a", 1) 
    110111            else: 
    111                 self.f = open(os.path.join(self.backuppath, datetime.datetime.now().strftime("%Y%m%d_recovery.log")), "a", 1) 
     112                self.f = open(filename, "a", 1) 
    112113            if self.buffer: # if we have buffered entries these must be handled before "line" 
    113114                sys.stderr.write("%s (%s): Dumping buffered data to local recovery file\n" % (self.progname, datetime.datetime.now().isoformat())) 
     
    186187                return 
    187188        if self.buffer: 
     189            filename = os.path.join(self.backuppath, datetime.datetime.now().strftime("%Y%m%d_recovery.log")) 
    188190            if self.f: 
    189                 if self.f.name != os.path.join(self.backuppath, datetime.datetime.now().strftime("%Y%m%d_recovery.log")): 
    190                     self.f.close() 
    191                     self.f = open(os.path.join(self.backuppath, datetime.datetime.now().strftime("%Y%m%d_recovery.log")), "a", 1) 
     191                if self.f.name != filename: 
     192                    self.f.close() 
     193                    self.f = open(filename, "a", 1) 
    192194            else: 
    193                 self.f = open(os.path.join(self.backuppath, datetime.datetime.now().strftime("%Y%m%d_recovery.log")), "a", 1) 
     195                self.f = open(filename, "a", 1) 
    194196            for oldline in self.buffer: 
    195197                self.f.write(oldline)