~ubuntu-archive/ubuntu-archive-scripts/trunk

« back to all changes in this revision

Viewing changes to auto-accept

  • Committer: Ubuntu Archive
  • Date: 2010-09-09 13:21:06 UTC
  • Revision ID: ubuntu-archive@lillypilly-20100909132106-vf90hsui7r781cky
rrsync: update to example script from rsync 3.0.7-1ubuntu1, to deal with options passed by newer rsync versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
import subprocess
3
 
import sys
4
 
import time
5
 
 
6
 
from launchpadlib.launchpad import Launchpad
7
 
 
8
 
SERIES = "cosmic"
9
 
POCKET = "Proposed"
10
 
QUEUE = "Unapproved"
11
 
SEED_WHITELIST = ["ubuntu-desktop-next"]
12
 
SEEDED_IN_UBUNTU = "/home/ubuntu-archive/ubuntu-dev-tools/seeded-in-ubuntu"
13
 
PACKAGE_WHITELIST = ["upstart-app-launch", "click", "click-apparmor",
14
 
                     "apparmor-easyprof-ubuntu", "ubuntuone-credentials"]
15
 
 
16
 
DEBUG = 0
17
 
if len(sys.argv) > 1 and sys.argv[1] == "debug":
18
 
    DEBUG = 1
19
 
 
20
 
# Connect to Launchpad
21
 
lp = Launchpad.login_with("auto-accept", "production", version="devel")
22
 
ubuntu = lp.distributions['ubuntu']
23
 
 
24
 
# Get the primary archive
25
 
archive = ubuntu.getArchive(name="primary")
26
 
 
27
 
# Get the series
28
 
series = ubuntu.getSeries(name_or_version=SERIES)
29
 
 
30
 
 
31
 
# Process the packages
32
 
for pkg in series.getPackageUploads(status=QUEUE, pocket=POCKET,
33
 
                                    archive=archive):
34
 
 
35
 
    # Whitelisted packages
36
 
    if pkg.package_name in PACKAGE_WHITELIST:
37
 
        if DEBUG:
38
 
            print("%s: Accepting due to whitelist: %s (%s)" %
39
 
                  (time.asctime(), pkg.package_name, pkg.package_version))
40
 
        pkg.acceptFromQueue()
41
 
 
42
 
    # Extract all the packagesets and skip if in any
43
 
    package_sets = set()
44
 
    for pkgset in lp.packagesets.setsIncludingSource(
45
 
            distroseries=series, sourcepackagename=pkg.package_name):
46
 
        package_sets.add(pkgset.name)
47
 
 
48
 
    if package_sets:
49
 
        if DEBUG:
50
 
            print("Skipping '%s' because it's in the following packagesets: %s" %
51
 
                  (pkg.package_name, ", ".join(package_sets)))
52
 
        continue
53
 
 
54
 
    # Extract all the seeds and skip if in any
55
 
    seed = subprocess.Popen([SEEDED_IN_UBUNTU, pkg.package_name],
56
 
                            universal_newlines=True, stdout=subprocess.PIPE,
57
 
                            stderr=subprocess.PIPE)
58
 
    if seed.wait() != 0 or seed.stderr.read():
59
 
        if DEBUG:
60
 
            print("Skipping '%s' due to Invalid output from seeded-in-ubuntu: %s" %
61
 
                  (pkg.package_name, seed.stderr.read().strip()))
62
 
        continue
63
 
 
64
 
    seeds = set()
65
 
    for line in seed.stdout:
66
 
        if not line.startswith("  "):
67
 
            continue
68
 
 
69
 
        line = line.strip()
70
 
        seed = line.split(":")[0]
71
 
        if seed in SEED_WHITELIST:
72
 
            continue
73
 
        seeds.add(seed)
74
 
 
75
 
    if seeds:
76
 
        if DEBUG:
77
 
            print("Skipping '%s' because it's seeded on: %s" %
78
 
                  (pkg.package_name, ", ".join(seeds)))
79
 
        continue
80
 
 
81
 
    print("%s: Accepting: %s (%s)" % (time.asctime(), pkg.package_name,
82
 
                                 pkg.package_version))
83
 
    pkg.acceptFromQueue()