Ubuntu Pastebin

Paste from paelzer at Thu, 22 Sep 2016 11:21:42 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
import getpass
import os

from launchpadlib.launchpad import Launchpad

def subset_sum(numbers, target, partial=[]):
    s = sum(partial)

    # check if the partial sum is equals to target
    if s == target:
        print "sum(%s)=%s" % (partial, target)
    if s >= target:
        return  # if we reach the number why bother to continue

    for i in range(len(numbers)):
       n = numbers[i]
       remaining = numbers[i+1:]
       subset_sum(remaining, target, partial + [n])

username = getpass.getuser()
cachedir = os.path.join('/home', username, '.launchpadlib/cache/')
launchpad = Launchpad.login_with(username, 'production', cachedir)
project = launchpad.distributions['Ubuntu']
team = launchpad.people['ubuntu-server']
sub_bugs = project.searchTasks(bug_subscriber=team)
print('Default search subscribed to %d bugs' % len(sub_bugs))
nums=[]
for st in ["New", "Incomplete", "Opinion", "Invalid", "Won't Fix", "Expired",
        "Confirmed", "Triaged", "In Progress", "Fix Committed",
        "Fix Released"]:
    sub_bugs = project.searchTasks(bug_subscriber=team,
            status=[st])
    print('status %s subscribed to %d bugs' % (st, len(sub_bugs)))
    nums.append(len(sub_bugs))

subset_sum(nums, 308)
Download as text