Changeset 204 for trunk/RetroStatus


Ignore:
Timestamp:
11/27/05 22:00:38 (19 years ago)
Author:
Nicholas Riley
Message:

formatflowed.py: Removed; no longer used.

RetroStatus.py: Remove format=flowed support, it doesn't work nicely
with UTF-8 encoded email. Fix sendMail bugs; it works now. Handle
volumestart event on clients (parameter is misspelled). Standardize
RSS titles to be of the form "name: status". Fixed scriptcheckfailed
to pull out the requested disk and actually check for it (mounted or
not). Add an example of the aformentioned volumestart event variant.
Fixed repeated typo of StringIO.getvalue in event exception handler.

Location:
trunk/RetroStatus
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/RetroStatus/RetroStatus.py

    r202 r204  
    1313from email.MIMEText import MIMEText
    1414from email.Utils import formataddr, formatdate
    15 from formatflowed import convertToFlowed
    16 import os, sys
     15import os, re, sys
    1716import objc # XXX should switch to public DADiskMount/Eject functions
    1817objc.loadBundle('DiskManagement', globals(),
     
    7675
    7776def sendMail(subject, text):
    78     message = MIMEText(convertToFlowed(text), 'plain; format=flowed')
     77    message = MIMEText(text.encode('utf8'), _charset='utf8')
    7978    message.set_unixfrom(FROM_ADDR)
    8079    message['From'] = formataddr((FROM_NAME, FROM_ADDR))
    81     message['To'] = TO_ADDR
     80    message['To'] = ', '.join(TO_ADDR)
    8281    message['Date'] = formatdate(localtime=True)
    8382    message['Subject'] = subject
     
    135134def retrospectstart(autolaunchboolean): pass
    136135def scriptstart(scriptname, startdate): pass
    137 def volumestart(volumename): pass
     136# yes, this really should be "remotetname"
     137def volumestart(volumename, clientname='', remotetname=''): pass
    138138def volumeend(volumename, kbcopied, filecount, durationinseconds, backupdate,
    139139              enddate, startdate, destinationname, clientname, scriptname,
     
    143143    growlNotify(NOTIFICATION_BACKUP, scriptname,
    144144                '%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))
    147147
    148148def mediarequest(mediatypestring, requestedmembername, mediaisknownboolean):
     
    164164        growlNotify(NOTIFICATION_MEDIA, disk.volumeName(),
    165165                    'Disk no longer in use: OK to swap')
    166     addEvent('Completed: scriptname',
     166    addEvent(scriptname + ': script completed',
    167167             '%s; %s error(s)' % (scripterrormessage, errorcount))
    168168
    169169# 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
    170172def 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)):
    173179        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.")
    175181
    176182def retrospectquit():
     
    185191                                                 in params.iteritems()]))
    186192    if not eventHandler:
    187         addEvent('Unhandled Retrospect event', eventStr)
     193        addEvent('%s: unhandled event' % eventName, eventStr)
    188194        if DEBUG: NSLog('unhandled event: ' + eventStr)
    189195        return
     
    193199        s = StringIO()
    194200        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)
    197203        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()))
    199205
    200206installeventhandler(handleEvent, 'ascrpsbr',
     
    215221# scriptstart(scriptname='Boston Backup', startdate=datetime.datetime(2005, 11, 23, 2, 31, 51))
    216222# volumestart(volumename='Backup Clients:Babs')
     223
    217224# 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')
    218225# volumestart(volumename=' Local Desktop:Bookworm')
     226# volumestart(volumename='Backup Clients:Concord:Mac OS X', remotetname='Backup Clients:Concord', clientname='Backup Clients:Concord')
    219227# mediarequest: appears even if media is available
    220228# mediarequest(mediatypestring='disk', requestedmembername='1-Boston backup A', mediaisknownboolean=True)
Note: See TracChangeset for help on using the changeset viewer.