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