- Timestamp:
- 11/27/05 22:00:38 (19 years ago)
- Location:
- trunk/RetroStatus
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/RetroStatus/RetroStatus.py
r202 r204 13 13 from email.MIMEText import MIMEText 14 14 from email.Utils import formataddr, formatdate 15 from formatflowed import convertToFlowed 16 import os, sys 15 import os, re, sys 17 16 import objc # XXX should switch to public DADiskMount/Eject functions 18 17 objc.loadBundle('DiskManagement', globals(), … … 76 75 77 76 def sendMail(subject, text): 78 message = MIMEText( convertToFlowed(text), 'plain; format=flowed')77 message = MIMEText(text.encode('utf8'), _charset='utf8') 79 78 message.set_unixfrom(FROM_ADDR) 80 79 message['From'] = formataddr((FROM_NAME, FROM_ADDR)) 81 message['To'] = TO_ADDR80 message['To'] = ', '.join(TO_ADDR) 82 81 message['Date'] = formatdate(localtime=True) 83 82 message['Subject'] = subject … … 135 134 def retrospectstart(autolaunchboolean): pass 136 135 def scriptstart(scriptname, startdate): pass 137 def volumestart(volumename): pass 136 # yes, this really should be "remotetname" 137 def volumestart(volumename, clientname='', remotetname=''): pass 138 138 def volumeend(volumename, kbcopied, filecount, durationinseconds, backupdate, 139 139 enddate, startdate, destinationname, clientname, scriptname, … … 143 143 growlNotify(NOTIFICATION_BACKUP, scriptname, 144 144 '%s\n%s' % (volumename, volumeerrormessage)) 145 addEvent( volumename, '%s\n\n%d file(s) copied; %d had errors.' %146 (volumeerrormessage,filecount, fileerrorcount))145 addEvent('%s: %s' % (volumename, volumeerrormessage), 146 '%d file(s) copied; %d had errors.' % (filecount, fileerrorcount)) 147 147 148 148 def mediarequest(mediatypestring, requestedmembername, mediaisknownboolean): … … 164 164 growlNotify(NOTIFICATION_MEDIA, disk.volumeName(), 165 165 'Disk no longer in use: OK to swap') 166 addEvent( 'Completed: scriptname',166 addEvent(scriptname + ': script completed', 167 167 '%s; %s error(s)' % (scripterrormessage, errorcount)) 168 168 169 169 # XXX does this get sent when it's supposed to? 170 # XXX if not, we could ask for quit on script end if Retrospect was started 171 # XXX by a script, and lengthen the lookahead interval 170 172 def scriptcheckfailed(scriptname, failuremessage, scheduledate): 171 disk = lastUsedDisk() 172 if not disk or not diskIsMounted(disk): 173 failuremessage = failuremessage.replace('\r', '\n').decode('macroman') 174 m = re.search(u'\u201c([^\u201d]+)\u201d', failuremessage) 175 if not m: 176 addEvent(scriptname + ': check failed', failuremessage) 177 return 178 if not diskWithName(m.group(1)): 173 179 sendMail("Please swap backup media before %s" % scheduledate.ctime(), 174 "%s\nEject the old disk, if any, and check that the correct disk is inserted." % failuremessage.replace('\r', '\n'))180 failuremessage + "\n\nEject the old disk, if any, and check that the correct disk is inserted.") 175 181 176 182 def retrospectquit(): … … 185 191 in params.iteritems()])) 186 192 if not eventHandler: 187 addEvent(' Unhandled Retrospect event', eventStr)193 addEvent('%s: unhandled event' % eventName, eventStr) 188 194 if DEBUG: NSLog('unhandled event: ' + eventStr) 189 195 return … … 193 199 s = StringIO() 194 200 print_exc(file=s) 195 addEvent(' Retrospect event handler failed',196 '%s\n\n%s' % (eventStr, s.getval ()), True)201 addEvent('%s: event handler failed' % eventName, 202 '%s\n\n%s' % (eventStr, s.getvalue()), True) 197 203 if DEBUG: 198 NSLog('event handler failed for %s:\n%s' % (eventStr, s.getval ())204 NSLog('event handler failed for %s:\n%s' % (eventStr, s.getvalue())) 199 205 200 206 installeventhandler(handleEvent, 'ascrpsbr', … … 215 221 # scriptstart(scriptname='Boston Backup', startdate=datetime.datetime(2005, 11, 23, 2, 31, 51)) 216 222 # volumestart(volumename='Backup Clients:Babs') 223 217 224 # volumeend(startdate=datetime.datetime(2005, 11, 23, 2, 31, 51), kbcopied=0, enddate=datetime.datetime(2005, 11, 23, 2, 32, 5), backuptypestring='Normal', volumename='Backup Clients:Babs', clientname='Babs', destinationname='Boston backup A', scriptname='Boston Backup', volumeerrormessage='client is not visible on network', backupdate=datetime.datetime(2005, 11, 23, 2, 32, 5), durationinseconds=0, volumeerrorcode=-1028, fileerrorcount=0, remotename='Babs', filecount=0, zonename='10.0.0.9') 218 225 # volumestart(volumename=' Local Desktop:Bookworm') 226 # volumestart(volumename='Backup Clients:Concord:Mac OS X', remotetname='Backup Clients:Concord', clientname='Backup Clients:Concord') 219 227 # mediarequest: appears even if media is available 220 228 # mediarequest(mediatypestring='disk', requestedmembername='1-Boston backup A', mediaisknownboolean=True)
Note:
See TracChangeset
for help on using the changeset viewer.