]> git.decadent.org.uk Git - dak.git/blob - dak/rm.py
dak/rm.py: add -B/--binary-only option
[dak.git] / dak / rm.py
1 #!/usr/bin/env python
2
3 """ General purpose package removal tool for ftpmaster """
4 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006  James Troup <james@nocrew.org>
5 # Copyright (C) 2010 Alexander Reichle-Schmehl <tolimar@debian.org>
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21 ################################################################################
22
23 # o OpenBSD team wants to get changes incorporated into IPF. Darren no
24 #    respond.
25 # o Ask again -> No respond. Darren coder supreme.
26 # o OpenBSD decide to make changes, but only in OpenBSD source
27 #    tree. Darren hears, gets angry! Decides: "LICENSE NO ALLOW!"
28 # o Insert Flame War.
29 # o OpenBSD team decide to switch to different packet filter under BSD
30 #    license. Because Project Goal: Every user should be able to make
31 #    changes to source tree. IPF license bad!!
32 # o Darren try get back: says, NetBSD, FreeBSD allowed! MUAHAHAHAH!!!
33 # o Theo say: no care, pf much better than ipf!
34 # o Darren changes mind: changes license. But OpenBSD will not change
35 #    back to ipf. Darren even much more bitter.
36 # o Darren so bitterbitter. Decides: I'LL GET BACK BY FORKING OPENBSD AND
37 #    RELEASING MY OWN VERSION. HEHEHEHEHE.
38
39 #                        http://slashdot.org/comments.pl?sid=26697&cid=2883271
40
41 ################################################################################
42
43 import commands
44 import os
45 import sys
46 import apt_pkg
47 import apt_inst
48 from re import sub
49
50 from daklib.config import Config
51 from daklib.dbconn import *
52 from daklib import utils
53 from daklib.dak_exceptions import *
54 from daklib.regexes import re_strip_source_version, re_bin_only_nmu
55 import debianbts as bts
56
57 ################################################################################
58
59 Options = None
60
61 ################################################################################
62
63 def usage (exit_code=0):
64     print """Usage: dak rm [OPTIONS] PACKAGE[...]
65 Remove PACKAGE(s) from suite(s).
66
67   -a, --architecture=ARCH    only act on this architecture
68   -b, --binary               PACKAGE are binary packages to remove
69   -B, --binary-only          remove binaries only
70   -c, --component=COMPONENT  act on this component
71   -C, --carbon-copy=EMAIL    send a CC of removal message to EMAIL
72   -d, --done=BUG#            send removal message as closure to bug#
73   -D, --do-close             also close all bugs associated to that package
74   -h, --help                 show this help and exit
75   -m, --reason=MSG           reason for removal
76   -n, --no-action            don't do anything
77   -p, --partial              don't affect override files
78   -R, --rdep-check           check reverse dependencies
79   -s, --suite=SUITE          act on this suite
80   -S, --source-only          remove source only
81
82 ARCH, BUG#, COMPONENT and SUITE can be comma (or space) separated lists, e.g.
83     --architecture=amd64,i386"""
84
85     sys.exit(exit_code)
86
87 ################################################################################
88
89 # "Hudson: What that's great, that's just fucking great man, now what
90 #  the fuck are we supposed to do? We're in some real pretty shit now
91 #  man...That's it man, game over man, game over, man! Game over! What
92 #  the fuck are we gonna do now? What are we gonna do?"
93
94 def game_over():
95     answer = utils.our_raw_input("Continue (y/N)? ").lower()
96     if answer != "y":
97         print "Aborted."
98         sys.exit(1)
99
100 ################################################################################
101
102 def reverse_depends_check(removals, suite, arches=None, session=None):
103     print "Checking reverse dependencies..."
104     if utils.check_reverse_depends(removals, suite, arches, session):
105         print "Dependency problem found."
106         if not Options["No-Action"]:
107             game_over()
108     else:
109         print "No dependency problem found."
110     print
111
112 ################################################################################
113
114 def main ():
115     global Options
116
117     cnf = Config()
118
119     Arguments = [('h',"help","Rm::Options::Help"),
120                  ('a',"architecture","Rm::Options::Architecture", "HasArg"),
121                  ('b',"binary", "Rm::Options::Binary"),
122                  ('B',"binary-only", "Rm::Options::Binary-Only"),
123                  ('c',"component", "Rm::Options::Component", "HasArg"),
124                  ('C',"carbon-copy", "Rm::Options::Carbon-Copy", "HasArg"), # Bugs to Cc
125                  ('d',"done","Rm::Options::Done", "HasArg"), # Bugs fixed
126                  ('D',"do-close","Rm::Options::Do-Close"),
127                  ('R',"rdep-check", "Rm::Options::Rdep-Check"),
128                  ('m',"reason", "Rm::Options::Reason", "HasArg"), # Hysterical raisins; -m is old-dinstall option for rejection reason
129                  ('n',"no-action","Rm::Options::No-Action"),
130                  ('p',"partial", "Rm::Options::Partial"),
131                  ('s',"suite","Rm::Options::Suite", "HasArg"),
132                  ('S',"source-only", "Rm::Options::Source-Only"),
133                  ]
134
135     for i in [ "architecture", "binary", "binary-only", "carbon-copy", "component",
136                "done", "help", "no-action", "partial", "rdep-check", "reason",
137                "source-only", "Do-Close" ]:
138         if not cnf.has_key("Rm::Options::%s" % (i)):
139             cnf["Rm::Options::%s" % (i)] = ""
140     if not cnf.has_key("Rm::Options::Suite"):
141         cnf["Rm::Options::Suite"] = "unstable"
142
143     arguments = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
144     Options = cnf.subtree("Rm::Options")
145
146     if Options["Help"]:
147         usage()
148
149     session = DBConn().session()
150
151     # Sanity check options
152     if not arguments:
153         utils.fubar("need at least one package name as an argument.")
154     if Options["Architecture"] and Options["Source-Only"]:
155         utils.fubar("can't use -a/--architecture and -S/--source-only options simultaneously.")
156     if ((Options["Binary"] and Options["Source-Only"])
157             or (Options["Binary"] and Options["Binary-Only"])
158             or (Options["Binary-Only"] and Options["Source-Only"])):
159         utils.fubar("Only one of -b/--binary, -B/--binary-only and -S/--source-only can be used.")
160     if Options.has_key("Carbon-Copy") and not Options.has_key("Done"):
161         utils.fubar("can't use -C/--carbon-copy without also using -d/--done option.")
162     if Options["Architecture"] and not Options["Partial"]:
163         utils.warn("-a/--architecture implies -p/--partial.")
164         Options["Partial"] = "true"
165     if Options["Do-Close"] and not Options["Done"]:
166         utils.fubar("No.")
167     if (Options["Do-Close"]
168            and (Options["Binary"] or Options["Binary-Only"] or Options["Source-Only"])):
169         utils.fubar("No.")
170     if Options["Do-Close"] and Options["Suite"] != 'unstable':
171         utils.fubar("No.")
172
173     # Force the admin to tell someone if we're not doing a 'dak
174     # cruft-report' inspired removal (or closing a bug, which counts
175     # as telling someone).
176     if not Options["No-Action"] and not Options["Carbon-Copy"] \
177            and not Options["Done"] and Options["Reason"].find("[auto-cruft]") == -1:
178         utils.fubar("Need a -C/--carbon-copy if not closing a bug and not doing a cruft removal.")
179
180     # Process -C/--carbon-copy
181     #
182     # Accept 3 types of arguments (space separated):
183     #  1) a number - assumed to be a bug number, i.e. nnnnn@bugs.debian.org
184     #  2) the keyword 'package' - cc's $package@packages.debian.org for every argument
185     #  3) contains a '@' - assumed to be an email address, used unmofidied
186     #
187     carbon_copy = []
188     for copy_to in utils.split_args(Options.get("Carbon-Copy")):
189         if copy_to.isdigit():
190             if cnf.has_key("Dinstall::BugServer"):
191                 carbon_copy.append(copy_to + "@" + cnf["Dinstall::BugServer"])
192             else:
193                 utils.fubar("Asked to send mail to #%s in BTS but Dinstall::BugServer is not configured" % copy_to)
194         elif copy_to == 'package':
195             for package in arguments:
196                 if cnf.has_key("Dinstall::PackagesServer"):
197                     carbon_copy.append(package + "@" + cnf["Dinstall::PackagesServer"])
198                 if cnf.has_key("Dinstall::TrackingServer"):
199                     carbon_copy.append(package + "@" + cnf["Dinstall::TrackingServer"])
200         elif '@' in copy_to:
201             carbon_copy.append(copy_to)
202         else:
203             utils.fubar("Invalid -C/--carbon-copy argument '%s'; not a bug number, 'package' or email address." % (copy_to))
204
205     if Options["Binary"]:
206         field = "b.package"
207     else:
208         field = "s.source"
209     con_packages = "AND %s IN (%s)" % (field, ", ".join([ repr(i) for i in arguments ]))
210
211     (con_suites, con_architectures, con_components, check_source) = \
212                  utils.parse_args(Options)
213
214     # Additional suite checks
215     suite_ids_list = []
216     whitelists = []
217     suites = utils.split_args(Options["Suite"])
218     suites_list = utils.join_with_commas_and(suites)
219     if not Options["No-Action"]:
220         for suite in suites:
221             s = get_suite(suite, session=session)
222             if s is not None:
223                 suite_ids_list.append(s.suite_id)
224                 whitelists.append(s.mail_whitelist)
225             if suite in ("oldstable", "stable"):
226                 print "**WARNING** About to remove from the (old)stable suite!"
227                 print "This should only be done just prior to a (point) release and not at"
228                 print "any other time."
229                 game_over()
230             elif suite == "testing":
231                 print "**WARNING About to remove from the testing suite!"
232                 print "There's no need to do this normally as removals from unstable will"
233                 print "propogate to testing automagically."
234                 game_over()
235
236     # Additional architecture checks
237     if Options["Architecture"] and check_source:
238         utils.warn("'source' in -a/--argument makes no sense and is ignored.")
239
240     # Additional component processing
241     over_con_components = con_components.replace("c.id", "component")
242
243     # Don't do dependency checks on multiple suites
244     if Options["Rdep-Check"] and len(suites) > 1:
245         utils.fubar("Reverse dependency check on multiple suites is not implemented.")
246
247     print "Working...",
248     sys.stdout.flush()
249     to_remove = []
250     maintainers = {}
251
252     # We have 3 modes of package selection: binary, source-only, binary-only
253     # and source+binary.
254
255     # XXX: TODO: This all needs converting to use placeholders or the object
256     #            API. It's an SQL injection dream at the moment
257
258     if Options["Binary"]:
259         # Removal by binary package name
260         q = session.execute("SELECT b.package, b.version, a.arch_string, b.id, b.maintainer FROM binaries b, bin_associations ba, architecture a, suite su, files f, files_archive_map af, component c WHERE ba.bin = b.id AND ba.suite = su.id AND b.architecture = a.id AND b.file = f.id AND af.file_id = f.id AND af.archive_id = su.archive_id AND af.component_id = c.id %s %s %s %s" % (con_packages, con_suites, con_components, con_architectures))
261         to_remove.extend(q)
262     else:
263         # Source-only
264         if not Options["Binary-Only"]:
265             q = session.execute("SELECT s.source, s.version, 'source', s.id, s.maintainer FROM source s, src_associations sa, suite su, archive, files f, files_archive_map af, component c WHERE sa.source = s.id AND sa.suite = su.id AND archive.id = su.archive_id AND s.file = f.id AND af.file_id = f.id AND af.archive_id = su.archive_id AND af.component_id = c.id %s %s %s" % (con_packages, con_suites, con_components))
266             to_remove.extend(q)
267         if not Options["Source-Only"]:
268             # Source + Binary
269             q = session.execute("""
270                     SELECT b.package, b.version, a.arch_string, b.id, b.maintainer
271                     FROM binaries b
272                          JOIN bin_associations ba ON b.id = ba.bin
273                          JOIN architecture a ON b.architecture = a.id
274                          JOIN suite su ON ba.suite = su.id
275                          JOIN archive ON archive.id = su.archive_id
276                          JOIN files_archive_map af ON b.file = af.file_id AND af.archive_id = archive.id
277                          JOIN component c ON af.component_id = c.id
278                          JOIN source s ON b.source = s.id
279                          JOIN src_associations sa ON s.id = sa.source AND sa.suite = su.id
280                     WHERE TRUE %s %s %s %s""" % (con_packages, con_suites, con_components, con_architectures))
281             to_remove.extend(q)
282     print "done."
283
284     if not to_remove:
285         print "Nothing to do."
286         sys.exit(0)
287
288     # If we don't have a reason; spawn an editor so the user can add one
289     # Write the rejection email out as the <foo>.reason file
290     if not Options["Reason"] and not Options["No-Action"]:
291         (fd, temp_filename) = utils.temp_filename()
292         editor = os.environ.get("EDITOR","vi")
293         result = os.system("%s %s" % (editor, temp_filename))
294         if result != 0:
295             utils.fubar ("vi invocation failed for `%s'!" % (temp_filename), result)
296         temp_file = utils.open_file(temp_filename)
297         for line in temp_file.readlines():
298             Options["Reason"] += line
299         temp_file.close()
300         os.unlink(temp_filename)
301
302     # Generate the summary of what's to be removed
303     d = {}
304     for i in to_remove:
305         package = i[0]
306         version = i[1]
307         architecture = i[2]
308         maintainer = i[4]
309         maintainers[maintainer] = ""
310         if not d.has_key(package):
311             d[package] = {}
312         if not d[package].has_key(version):
313             d[package][version] = []
314         if architecture not in d[package][version]:
315             d[package][version].append(architecture)
316
317     maintainer_list = []
318     for maintainer_id in maintainers.keys():
319         maintainer_list.append(get_maintainer(maintainer_id).name)
320     summary = ""
321     removals = d.keys()
322     removals.sort()
323     versions = []
324     for package in removals:
325         versions = d[package].keys()
326         versions.sort(apt_pkg.version_compare)
327         for version in versions:
328             d[package][version].sort(utils.arch_compare_sw)
329             summary += "%10s | %10s | %s\n" % (package, version, ", ".join(d[package][version]))
330     print "Will remove the following packages from %s:" % (suites_list)
331     print
332     print summary
333     print "Maintainer: %s" % ", ".join(maintainer_list)
334     if Options["Done"]:
335         print "Will also close bugs: "+Options["Done"]
336     if carbon_copy:
337         print "Will also send CCs to: " + ", ".join(carbon_copy)
338     if Options["Do-Close"]:
339         print "Will also close associated bug reports."
340     print
341     print "------------------- Reason -------------------"
342     print Options["Reason"]
343     print "----------------------------------------------"
344     print
345
346     if Options["Rdep-Check"]:
347         arches = utils.split_args(Options["Architecture"])
348         reverse_depends_check(removals, suites[0], arches, session)
349
350     # If -n/--no-action, drop out here
351     if Options["No-Action"]:
352         sys.exit(0)
353
354     print "Going to remove the packages now."
355     game_over()
356
357     whoami = utils.whoami()
358     date = commands.getoutput('date -R')
359
360     # Log first; if it all falls apart I want a record that we at least tried.
361     logfile = utils.open_file(cnf["Rm::LogFile"], 'a')
362     logfile.write("=========================================================================\n")
363     logfile.write("[Date: %s] [ftpmaster: %s]\n" % (date, whoami))
364     logfile.write("Removed the following packages from %s:\n\n%s" % (suites_list, summary))
365     if Options["Done"]:
366         logfile.write("Closed bugs: %s\n" % (Options["Done"]))
367     logfile.write("\n------------------- Reason -------------------\n%s\n" % (Options["Reason"]))
368     logfile.write("----------------------------------------------\n")
369
370     # Do the same in rfc822 format
371     logfile822 = utils.open_file(cnf["Rm::LogFile822"], 'a')
372     logfile822.write("Date: %s\n" % date)
373     logfile822.write("Ftpmaster: %s\n" % whoami)
374     logfile822.write("Suite: %s\n" % suites_list)
375     sources = []
376     binaries = []
377     for package in summary.split("\n"):
378         for row in package.split("\n"):
379             element = row.split("|")
380             if len(element) == 3:
381                 if element[2].find("source") > 0:
382                     sources.append("%s_%s" % tuple(elem.strip(" ") for elem in element[:2]))
383                     element[2] = sub("source\s?,?", "", element[2]).strip(" ")
384                 if element[2]:
385                     binaries.append("%s_%s [%s]" % tuple(elem.strip(" ") for elem in element))
386     if sources:
387         logfile822.write("Sources:\n")
388         for source in sources:
389             logfile822.write(" %s\n" % source)
390     if binaries:
391         logfile822.write("Binaries:\n")
392         for binary in binaries:
393             logfile822.write(" %s\n" % binary)
394     logfile822.write("Reason: %s\n" % Options["Reason"].replace('\n', '\n '))
395     if Options["Done"]:
396         logfile822.write("Bug: %s\n" % Options["Done"])
397
398     dsc_type_id = get_override_type('dsc', session).overridetype_id
399     deb_type_id = get_override_type('deb', session).overridetype_id
400
401     # Do the actual deletion
402     print "Deleting...",
403     sys.stdout.flush()
404
405     for i in to_remove:
406         package = i[0]
407         architecture = i[2]
408         package_id = i[3]
409         for suite_id in suite_ids_list:
410             if architecture == "source":
411                 session.execute("DELETE FROM src_associations WHERE source = :packageid AND suite = :suiteid",
412                                 {'packageid': package_id, 'suiteid': suite_id})
413                 #print "DELETE FROM src_associations WHERE source = %s AND suite = %s" % (package_id, suite_id)
414             else:
415                 session.execute("DELETE FROM bin_associations WHERE bin = :packageid AND suite = :suiteid",
416                                 {'packageid': package_id, 'suiteid': suite_id})
417                 #print "DELETE FROM bin_associations WHERE bin = %s AND suite = %s" % (package_id, suite_id)
418             # Delete from the override file
419             if not Options["Partial"]:
420                 if architecture == "source":
421                     type_id = dsc_type_id
422                 else:
423                     type_id = deb_type_id
424                 # TODO: Again, fix this properly to remove the remaining non-bind argument
425                 session.execute("DELETE FROM override WHERE package = :package AND type = :typeid AND suite = :suiteid %s" % (over_con_components), {'package': package, 'typeid': type_id, 'suiteid': suite_id})
426     session.commit()
427     print "done."
428
429     # If we don't have a Bug server configured, we're done
430     if not cnf.has_key("Dinstall::BugServer"):
431         if Options["Done"] or Options["Do-Close"]:
432             print "Cannot send mail to BugServer as Dinstall::BugServer is not configured"
433
434         logfile.write("=========================================================================\n")
435         logfile.close()
436
437         logfile822.write("\n")
438         logfile822.close()
439
440         return
441
442     # read common subst variables for all bug closure mails
443     Subst_common = {}
444     Subst_common["__RM_ADDRESS__"] = cnf["Dinstall::MyEmailAddress"]
445     Subst_common["__BUG_SERVER__"] = cnf["Dinstall::BugServer"]
446     Subst_common["__CC__"] = "X-DAK: dak rm"
447     if carbon_copy:
448         Subst_common["__CC__"] += "\nCc: " + ", ".join(carbon_copy)
449     Subst_common["__SUITE_LIST__"] = suites_list
450     Subst_common["__SUBJECT__"] = "Removed package(s) from %s" % (suites_list)
451     Subst_common["__ADMIN_ADDRESS__"] = cnf["Dinstall::MyAdminAddress"]
452     Subst_common["__DISTRO__"] = cnf["Dinstall::MyDistribution"]
453     Subst_common["__WHOAMI__"] = whoami
454
455     # Send the bug closing messages
456     if Options["Done"]:
457         Subst_close_rm = Subst_common
458         bcc = []
459         if cnf.find("Dinstall::Bcc") != "":
460             bcc.append(cnf["Dinstall::Bcc"])
461         if cnf.find("Rm::Bcc") != "":
462             bcc.append(cnf["Rm::Bcc"])
463         if bcc:
464             Subst_close_rm["__BCC__"] = "Bcc: " + ", ".join(bcc)
465         else:
466             Subst_close_rm["__BCC__"] = "X-Filler: 42"
467         summarymail = "%s\n------------------- Reason -------------------\n%s\n" % (summary, Options["Reason"])
468         summarymail += "----------------------------------------------\n"
469         Subst_close_rm["__SUMMARY__"] = summarymail
470
471         whereami = utils.where_am_i()
472         Archive = get_archive(whereami, session)
473         if Archive is None:
474             utils.warn("Cannot find archive %s.  Setting blank values for origin" % whereami)
475             Subst_close_rm["__PRIMARY_MIRROR__"] = ""
476         else:
477             Subst_close_rm["__PRIMARY_MIRROR__"] = Archive.primary_mirror
478
479         for bug in utils.split_args(Options["Done"]):
480             Subst_close_rm["__BUG_NUMBER__"] = bug
481             if Options["Do-Close"]:
482                 mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"]+"/rm.bug-close-with-related")
483             else:
484                 mail_message = utils.TemplateSubst(Subst_close_rm,cnf["Dir::Templates"]+"/rm.bug-close")
485             utils.send_mail(mail_message, whitelists=whitelists)
486
487     # close associated bug reports
488     if Options["Do-Close"]:
489         Subst_close_other = Subst_common
490         bcc = []
491         wnpp = utils.parse_wnpp_bug_file()
492         versions = list(set([re_bin_only_nmu.sub('', v) for v in versions]))
493         if len(versions) == 1:
494             Subst_close_other["__VERSION__"] = versions[0]
495         else:
496             utils.fubar("Closing bugs with multiple package versions is not supported.  Do it yourself.")
497         if bcc:
498             Subst_close_other["__BCC__"] = "Bcc: " + ", ".join(bcc)
499         else:
500             Subst_close_other["__BCC__"] = "X-Filler: 42"
501         # at this point, I just assume, that the first closed bug gives
502         # some useful information on why the package got removed
503         Subst_close_other["__BUG_NUMBER__"] = utils.split_args(Options["Done"])[0]
504         if len(sources) == 1:
505             source_pkg = source.split("_", 1)[0]
506         else:
507             utils.fubar("Closing bugs for multiple source packages is not supported.  Do it yourself.")
508         Subst_close_other["__BUG_NUMBER_ALSO__"] = ""
509         Subst_close_other["__SOURCE__"] = source_pkg
510         merged_bugs = set()
511         other_bugs = bts.get_bugs('src', source_pkg, 'status', 'open', 'status', 'forwarded')
512         if other_bugs:
513             for bugno in other_bugs:
514                 if bugno not in merged_bugs:
515                     for bug in bts.get_status(bugno):
516                         for merged in bug.mergedwith:
517                             other_bugs.remove(merged)
518                             merged_bugs.add(merged)
519             logfile.write("Also closing bug(s):")
520             logfile822.write("Also-Bugs:")
521             for bug in other_bugs:
522                 Subst_close_other["__BUG_NUMBER_ALSO__"] += str(bug) + "-done@" + cnf["Dinstall::BugServer"] + ","
523                 logfile.write(" " + str(bug))
524                 logfile822.write(" " + str(bug))
525             logfile.write("\n")
526             logfile822.write("\n")
527         if source_pkg in wnpp.keys():
528             logfile.write("Also closing WNPP bug(s):")
529             logfile822.write("Also-WNPP:")
530             for bug in wnpp[source_pkg]:
531                 # the wnpp-rm file we parse also contains our removal
532                 # bugs, filtering that out
533                 if bug != Subst_close_other["__BUG_NUMBER__"]:
534                     Subst_close_other["__BUG_NUMBER_ALSO__"] += str(bug) + "-done@" + cnf["Dinstall::BugServer"] + ","
535                     logfile.write(" " + str(bug))
536                     logfile822.write(" " + str(bug))
537             logfile.write("\n")
538             logfile822.write("\n")
539
540         mail_message = utils.TemplateSubst(Subst_close_other,cnf["Dir::Templates"]+"/rm.bug-close-related")
541         if Subst_close_other["__BUG_NUMBER_ALSO__"]:
542             utils.send_mail(mail_message)
543
544
545     logfile.write("=========================================================================\n")
546     logfile.close()
547
548     logfile822.write("\n")
549     logfile822.close()
550
551 #######################################################################################
552
553 if __name__ == '__main__':
554     main()