~ubuntu-core-dev/unattended-upgrades/ubuntu

« back to all changes in this revision

Viewing changes to unattended-upgrade

  • Committer: Michael Vogt
  • Date: 2007-01-23 10:51:43 UTC
  • Revision ID: egon@tas-20070123105143-bd9f8ec3edb83222
* merged the latest ubuntu upload
* unattended-upgrade:
  - be more careful actually actually having a candidateOrigin (lp: #81055)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning)
15
15
import apt
16
16
import logging
 
17
import subprocess
17
18
 
18
19
class MyCache(apt.Cache):
19
20
    def __init__(self):
26
27
        
27
28
 
28
29
def is_allowed_origin(pkg, allowed_origins):
 
30
    if not pkg.candidateOrigin:
 
31
        return False
29
32
    for origin in pkg.candidateOrigin:
30
33
        for allowed in allowed_origins:
31
34
            if origin.origin == allowed[0] and origin.archive == allowed[1]:
243
246
    else:
244
247
        logging.info("All upgrades installed")
245
248
 
 
249
    # check if we need to send a mail
 
250
    email = apt_pkg.Config.Find("Unattended-Upgrade::Mail", "")
 
251
    if email != "":
 
252
        logging.debug("Sending mail with '%s' to '%s'" % (logfile_dpkg, email))
 
253
        mail = subprocess.Popen(["mail",
 
254
                                 "-s","unattended-upgrades result",email],
 
255
                                stdin=subprocess.PIPE)
 
256
        s = "Unattended upgrade returned: %s\n\n" % (res != pm.ResultFailed)
 
257
        s += open(logfile_dpkg).read()
 
258
        mail.stdin.write(s)
 
259
        mail.stdin.close()
 
260
        ret = mail.wait()
 
261
        logging.debug("mail returned: %s" % ret)
 
262