~debian-lptools/debian/sid/lptools/sid

« back to all changes in this revision

Viewing changes to bin/lp-set-dup

  • Committer: Jelmer Vernooij
  • Date: 2023-09-28 12:07:22 UTC
  • mfrom: (2.18.8)
  • Revision ID: jelmer@jelmer.uk-20230928120722-704pws90v7e943dk
* New upstream snapshot.
 + Drop patches for conversion to python 3 and breezy; now merged upstream.
+ debian/upstream/metadata: Drop unknown Homepage field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
 
1
#!/usr/bin/python3
2
2
# -*- coding: UTF-8 -*-
3
3
"""Sets the "duplicate of" bug of a bug and its dups."""
4
4
 
30
30
from lptools import config
31
31
 
32
32
def die(message):
33
 
    print >> sys.stderr, "Fatal: " + message
 
33
    print("Fatal: " + message, file=sys.stderr)
34
34
    sys.exit(1)
35
35
 
36
36
def main():
57
57
    # check that the new main bug isn't a duplicate
58
58
    try:
59
59
        new_main_bug = launchpad.bugs[args[0]]
60
 
    except HTTPError, error:
 
60
    except HTTPError as error:
61
61
        if error.response.status == 401:
62
 
            print >> sys.stderr, ("E: Don't have enough permissions to access "
63
 
                                  "bug %s") % (args[0])
 
62
            print(("E: Don't have enough permissions to access "
 
63
                                  "bug %s") % (args[0]), file=sys.stderr)
64
64
            die(error.content)
65
65
        else:
66
66
            raise
68
68
    if new_main_dup_of is not None:
69
69
        answer = None
70
70
        try:
71
 
            answer = raw_input("Bug %s is a duplicate of %s; would you like to "
 
71
            answer = input("Bug %s is a duplicate of %s; would you like to "
72
72
                               "use %s as the new main bug instead? [y/N]" % \
73
73
                               (new_main_bug.id, new_main_dup_of.id,
74
74
                                new_main_dup_of.id))
81
81
    # build list of bugs to process, first the dups then the bug
82
82
    bugs_to_process = []
83
83
    for bug_number in args[1:]:
84
 
        print "Processing %s" % (bug_number)
 
84
        print("Processing %s" % (bug_number))
85
85
        try:
86
86
            bug = launchpad.bugs[bug_number]
87
 
        except HTTPError, error:
 
87
        except HTTPError as error:
88
88
            if error.response.status == 401:
89
 
                print >> sys.stderr, ("W: Don't have enough permissions to "
90
 
                                      "access bug %s") % (bug_number)
91
 
                print >> sys.stderr, "W: %s" % (error.content)
 
89
                print(("W: Don't have enough permissions to "
 
90
                                      "access bug %s") % (bug_number), file=sys.stderr)
 
91
                print("W: %s" % (error.content), file=sys.stderr)
92
92
                continue
93
93
            else:
94
94
                raise
95
95
        dups = bug.duplicates
96
96
        if dups is not None:
97
97
            bugs_to_process.extend(dups)
98
 
            print "Found %i dups for %s" % (len(dups), bug_number)
 
98
            print("Found %i dups for %s" % (len(dups), bug_number))
99
99
        bugs_to_process.append(bug)
100
100
 
101
101
    # process dups first, then their main bug
102
 
    print "Would set the following bugs as duplicates of %s: %s" % \
103
 
          (new_main_bug.id, " ".join([str(b.id) for b in bugs_to_process]))
 
102
    print("Would set the following bugs as duplicates of %s: %s" % \
 
103
          (new_main_bug.id, " ".join([str(b.id) for b in bugs_to_process])))
104
104
 
105
105
    if not options.force:
106
106
        answer = None
107
107
        try:
108
 
            answer = raw_input("Proceed? [y/N]")
 
108
            answer = input("Proceed? [y/N]")
109
109
        except:
110
110
            die("Aborted")
111
111
        if answer.lower() not in ("y", "yes"):
112
112
            die("User aborted")
113
113
 
114
114
    for bug in bugs_to_process:
115
 
        print "Marking bug %s as a duplicate of %s" % (bug.id, new_main_bug.id)
 
115
        print("Marking bug %s as a duplicate of %s" % (bug.id, new_main_bug.id))
116
116
        bug.duplicate_of = new_main_bug
117
117
        bug.lp_save()
118
118