]> git.decadent.org.uk Git - dak.git/blob - dak/process_new.py
oops
[dak.git] / dak / process_new.py
1 #!/usr/bin/env python
2 # vim:set et ts=4 sw=4:
3
4 """ Handles NEW and BYHAND packages
5
6 @contact: Debian FTP Master <ftpmaster@debian.org>
7 @copyright: 2001, 2002, 2003, 2004, 2005, 2006  James Troup <james@nocrew.org>
8 @copyright: 2009 Joerg Jaspert <joerg@debian.org>
9 @copyright: 2009 Frank Lichtenheld <djpig@debian.org>
10 @license: GNU General Public License version 2 or later
11 """
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
16
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
26 ################################################################################
27
28 # 23:12|<aj> I will not hush!
29 # 23:12|<elmo> :>
30 # 23:12|<aj> Where there is injustice in the world, I shall be there!
31 # 23:13|<aj> I shall not be silenced!
32 # 23:13|<aj> The world shall know!
33 # 23:13|<aj> The world *must* know!
34 # 23:13|<elmo> oh dear, he's gone back to powerpuff girls... ;-)
35 # 23:13|<aj> yay powerpuff girls!!
36 # 23:13|<aj> buttercup's my favourite, who's yours?
37 # 23:14|<aj> you're backing away from the keyboard right now aren't you?
38 # 23:14|<aj> *AREN'T YOU*?!
39 # 23:15|<aj> I will not be treated like this.
40 # 23:15|<aj> I shall have my revenge.
41 # 23:15|<aj> I SHALL!!!
42
43 ################################################################################
44
45 from __future__ import with_statement
46
47 import copy
48 import errno
49 import os
50 import readline
51 import stat
52 import sys
53 import time
54 import contextlib
55 import pwd
56 import apt_pkg, apt_inst
57 import examine_package
58
59 from daklib.dbconn import *
60 from daklib.queue import *
61 from daklib import daklog
62 from daklib import utils
63 from daklib.regexes import re_no_epoch, re_default_answer, re_isanum, re_package
64 from daklib.dak_exceptions import CantOpenError, AlreadyLockedError, CantGetLockError
65 from daklib.summarystats import SummaryStats
66 from daklib.config import Config
67 from daklib.changesutils import *
68
69 # Globals
70 Options = None
71 Logger = None
72
73 Priorities = None
74 Sections = None
75
76 ################################################################################
77 ################################################################################
78 ################################################################################
79
80 def recheck(upload, session):
81 # STU: I'm not sure, but I don't thin kthis is necessary any longer:    upload.recheck(session)
82     if len(upload.rejects) > 0:
83         answer = "XXX"
84         if Options["No-Action"] or Options["Automatic"] or Options["Trainee"]:
85             answer = 'S'
86
87         print "REJECT\n%s" % '\n'.join(upload.rejects)
88         prompt = "[R]eject, Skip, Quit ?"
89
90         while prompt.find(answer) == -1:
91             answer = utils.our_raw_input(prompt)
92             m = re_default_answer.match(prompt)
93             if answer == "":
94                 answer = m.group(1)
95             answer = answer[:1].upper()
96
97         if answer == 'R':
98             upload.do_reject(manual=0, reject_message='\n'.join(upload.rejects))
99             upload.pkg.remove_known_changes(session=session)
100             session.commit()
101             return 0
102         elif answer == 'S':
103             return 0
104         elif answer == 'Q':
105             end()
106             sys.exit(0)
107
108     return 1
109
110 ################################################################################
111
112 class Section_Completer:
113     def __init__ (self, session):
114         self.sections = []
115         self.matches = []
116         for s, in session.query(Section.section):
117             self.sections.append(s)
118
119     def complete(self, text, state):
120         if state == 0:
121             self.matches = []
122             n = len(text)
123             for word in self.sections:
124                 if word[:n] == text:
125                     self.matches.append(word)
126         try:
127             return self.matches[state]
128         except IndexError:
129             return None
130
131 ############################################################
132
133 class Priority_Completer:
134     def __init__ (self, session):
135         self.priorities = []
136         self.matches = []
137         for p, in session.query(Priority.priority):
138             self.priorities.append(p)
139
140     def complete(self, text, state):
141         if state == 0:
142             self.matches = []
143             n = len(text)
144             for word in self.priorities:
145                 if word[:n] == text:
146                     self.matches.append(word)
147         try:
148             return self.matches[state]
149         except IndexError:
150             return None
151
152 ################################################################################
153
154 def print_new (new, upload, indexed, file=sys.stdout):
155     check_valid(new)
156     broken = False
157     index = 0
158     for pkg in new.keys():
159         index += 1
160         section = new[pkg]["section"]
161         priority = new[pkg]["priority"]
162         if new[pkg]["section id"] == -1:
163             section += "[!]"
164             broken = True
165         if new[pkg]["priority id"] == -1:
166             priority += "[!]"
167             broken = True
168         if indexed:
169             line = "(%s): %-20s %-20s %-20s" % (index, pkg, priority, section)
170         else:
171             line = "%-20s %-20s %-20s" % (pkg, priority, section)
172         line = line.strip()+'\n'
173         file.write(line)
174     notes = get_new_comments(upload.pkg.changes.get("source"))
175     for note in notes:
176         print "\nAuthor: %s\nVersion: %s\nTimestamp: %s\n\n%s" \
177               % (note.author, note.version, note.notedate, note.comment)
178         print "-" * 72
179     return broken, len(notes) > 0
180
181 ################################################################################
182
183 def index_range (index):
184     if index == 1:
185         return "1"
186     else:
187         return "1-%s" % (index)
188
189 ################################################################################
190 ################################################################################
191
192 def edit_new (new, upload):
193     # Write the current data to a temporary file
194     (fd, temp_filename) = utils.temp_filename()
195     temp_file = os.fdopen(fd, 'w')
196     print_new (new, upload, indexed=0, file=temp_file)
197     temp_file.close()
198     # Spawn an editor on that file
199     editor = os.environ.get("EDITOR","vi")
200     result = os.system("%s %s" % (editor, temp_filename))
201     if result != 0:
202         utils.fubar ("%s invocation failed for %s." % (editor, temp_filename), result)
203     # Read the edited data back in
204     temp_file = utils.open_file(temp_filename)
205     lines = temp_file.readlines()
206     temp_file.close()
207     os.unlink(temp_filename)
208     # Parse the new data
209     for line in lines:
210         line = line.strip()
211         if line == "":
212             continue
213         s = line.split()
214         # Pad the list if necessary
215         s[len(s):3] = [None] * (3-len(s))
216         (pkg, priority, section) = s[:3]
217         if not new.has_key(pkg):
218             utils.warn("Ignoring unknown package '%s'" % (pkg))
219         else:
220             # Strip off any invalid markers, print_new will readd them.
221             if section.endswith("[!]"):
222                 section = section[:-3]
223             if priority.endswith("[!]"):
224                 priority = priority[:-3]
225             for f in new[pkg]["files"]:
226                 upload.pkg.files[f]["section"] = section
227                 upload.pkg.files[f]["priority"] = priority
228             new[pkg]["section"] = section
229             new[pkg]["priority"] = priority
230
231 ################################################################################
232
233 def edit_index (new, upload, index):
234     priority = new[index]["priority"]
235     section = new[index]["section"]
236     ftype = new[index]["type"]
237     done = 0
238     while not done:
239         print "\t".join([index, priority, section])
240
241         answer = "XXX"
242         if ftype != "dsc":
243             prompt = "[B]oth, Priority, Section, Done ? "
244         else:
245             prompt = "[S]ection, Done ? "
246         edit_priority = edit_section = 0
247
248         while prompt.find(answer) == -1:
249             answer = utils.our_raw_input(prompt)
250             m = re_default_answer.match(prompt)
251             if answer == "":
252                 answer = m.group(1)
253             answer = answer[:1].upper()
254
255         if answer == 'P':
256             edit_priority = 1
257         elif answer == 'S':
258             edit_section = 1
259         elif answer == 'B':
260             edit_priority = edit_section = 1
261         elif answer == 'D':
262             done = 1
263
264         # Edit the priority
265         if edit_priority:
266             readline.set_completer(Priorities.complete)
267             got_priority = 0
268             while not got_priority:
269                 new_priority = utils.our_raw_input("New priority: ").strip()
270                 if new_priority not in Priorities.priorities:
271                     print "E: '%s' is not a valid priority, try again." % (new_priority)
272                 else:
273                     got_priority = 1
274                     priority = new_priority
275
276         # Edit the section
277         if edit_section:
278             readline.set_completer(Sections.complete)
279             got_section = 0
280             while not got_section:
281                 new_section = utils.our_raw_input("New section: ").strip()
282                 if new_section not in Sections.sections:
283                     print "E: '%s' is not a valid section, try again." % (new_section)
284                 else:
285                     got_section = 1
286                     section = new_section
287
288         # Reset the readline completer
289         readline.set_completer(None)
290
291     for f in new[index]["files"]:
292         upload.pkg.files[f]["section"] = section
293         upload.pkg.files[f]["priority"] = priority
294     new[index]["priority"] = priority
295     new[index]["section"] = section
296     return new
297
298 ################################################################################
299
300 def edit_overrides (new, upload, session):
301     print
302     done = 0
303     while not done:
304         print_new (new, upload, indexed=1)
305         new_index = {}
306         index = 0
307         for i in new.keys():
308             index += 1
309             new_index[index] = i
310
311         prompt = "(%s) edit override <n>, Editor, Done ? " % (index_range(index))
312
313         got_answer = 0
314         while not got_answer:
315             answer = utils.our_raw_input(prompt)
316             if not answer.isdigit():
317                 answer = answer[:1].upper()
318             if answer == "E" or answer == "D":
319                 got_answer = 1
320             elif re_isanum.match (answer):
321                 answer = int(answer)
322                 if (answer < 1) or (answer > index):
323                     print "%s is not a valid index (%s).  Please retry." % (answer, index_range(index))
324                 else:
325                     got_answer = 1
326
327         if answer == 'E':
328             edit_new(new, upload)
329         elif answer == 'D':
330             done = 1
331         else:
332             edit_index (new, upload, new_index[answer])
333
334     return new
335
336
337 ################################################################################
338
339 def check_pkg (upload):
340     try:
341         less_fd = os.popen("less -R -", 'w', 0)
342         stdout_fd = sys.stdout
343         try:
344             sys.stdout = less_fd
345             changes = utils.parse_changes (upload.pkg.changes_file)
346             print examine_package.display_changes(changes['distribution'], upload.pkg.changes_file)
347             files = upload.pkg.files
348             for f in files.keys():
349                 if files[f].has_key("new"):
350                     ftype = files[f]["type"]
351                     if ftype == "deb":
352                         print examine_package.check_deb(changes['distribution'], f)
353                     elif ftype == "dsc":
354                         print examine_package.check_dsc(changes['distribution'], f)
355         finally:
356             print examine_package.output_package_relations()
357             sys.stdout = stdout_fd
358     except IOError, e:
359         if e.errno == errno.EPIPE:
360             utils.warn("[examine_package] Caught EPIPE; skipping.")
361             pass
362         else:
363             raise
364     except KeyboardInterrupt:
365         utils.warn("[examine_package] Caught C-c; skipping.")
366         pass
367
368 ################################################################################
369
370 ## FIXME: horribly Debian specific
371
372 def do_bxa_notification(upload):
373     files = upload.pkg.files
374     summary = ""
375     for f in files.keys():
376         if files[f]["type"] == "deb":
377             control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(f)))
378             summary += "\n"
379             summary += "Package: %s\n" % (control.Find("Package"))
380             summary += "Description: %s\n" % (control.Find("Description"))
381     upload.Subst["__BINARY_DESCRIPTIONS__"] = summary
382     bxa_mail = utils.TemplateSubst(upload.Subst,Config()["Dir::Templates"]+"/process-new.bxa_notification")
383     utils.send_mail(bxa_mail)
384
385 ################################################################################
386
387 def add_overrides (new, upload, session):
388     changes = upload.pkg.changes
389     files = upload.pkg.files
390     srcpkg = changes.get("source")
391
392     for suite in changes["suite"].keys():
393         suite_id = get_suite(suite).suite_id
394         for pkg in new.keys():
395             component_id = get_component(new[pkg]["component"]).component_id
396             type_id = get_override_type(new[pkg]["type"]).overridetype_id
397             priority_id = new[pkg]["priority id"]
398             section_id = new[pkg]["section id"]
399             Logger.log(["%s overrides" % (srcpkg), suite, new[pkg]["component"], new[pkg]["type"], new[pkg]["priority"], new[pkg]["section"]])
400             session.execute("INSERT INTO override (suite, component, type, package, priority, section, maintainer) VALUES (:sid, :cid, :tid, :pkg, :pid, :sectid, '')",
401                             { 'sid': suite_id, 'cid': component_id, 'tid':type_id, 'pkg': pkg, 'pid': priority_id, 'sectid': section_id})
402             for f in new[pkg]["files"]:
403                 if files[f].has_key("new"):
404                     del files[f]["new"]
405             del new[pkg]
406
407     session.commit()
408
409     if Config().FindB("Dinstall::BXANotify"):
410         do_bxa_notification(upload)
411
412 ################################################################################
413
414 def do_new(upload, session):
415     print "NEW\n"
416     files = upload.pkg.files
417     upload.check_files(not Options["No-Action"])
418     changes = upload.pkg.changes
419     cnf = Config()
420
421     # Check for a valid distribution
422     upload.check_distributions()
423
424     # Make a copy of distribution we can happily trample on
425     changes["suite"] = copy.copy(changes["distribution"])
426
427     # The main NEW processing loop
428     done = 0
429     while not done:
430         # Find out what's new
431         new = determine_new(changes, files)
432
433         if not new:
434             break
435
436         answer = "XXX"
437         if Options["No-Action"] or Options["Automatic"]:
438             answer = 'S'
439
440         (broken, note) = print_new(new, upload, indexed=0)
441         prompt = ""
442
443         if not broken and not note:
444             prompt = "Add overrides, "
445         if broken:
446             print "W: [!] marked entries must be fixed before package can be processed."
447         if note:
448             print "W: note must be removed before package can be processed."
449             prompt += "RemOve all notes, Remove note, "
450
451         prompt += "Edit overrides, Check, Manual reject, Note edit, Prod, [S]kip, Quit ?"
452
453         while prompt.find(answer) == -1:
454             answer = utils.our_raw_input(prompt)
455             m = re_default_answer.search(prompt)
456             if answer == "":
457                 answer = m.group(1)
458             answer = answer[:1].upper()
459
460         if answer in ( 'A', 'E', 'M', 'O', 'R' ) and Options["Trainee"]:
461             utils.warn("Trainees can't do that")
462             continue
463
464         if answer == 'A' and not Options["Trainee"]:
465             try:
466                 check_daily_lock()
467                 done = add_overrides (new, upload, session)
468                 new_accept(upload, Options["No-Action"], session)
469                 Logger.log(["NEW ACCEPT: %s" % (upload.pkg.changes_file)])
470             except CantGetLockError:
471                 print "Hello? Operator! Give me the number for 911!"
472                 print "Dinstall in the locked area, cant process packages, come back later"
473         elif answer == 'C':
474             check_pkg(upload)
475         elif answer == 'E' and not Options["Trainee"]:
476             new = edit_overrides (new, upload, session)
477         elif answer == 'M' and not Options["Trainee"]:
478             aborted = upload.do_reject(manual=1,
479                                        reject_message=Options["Manual-Reject"],
480                                        notes=get_new_comments(changes.get("source", ""), session=session))
481             if not aborted:
482                 upload.pkg.remove_known_changes(session=session)
483                 session.commit()
484                 Logger.log(["NEW REJECT: %s" % (upload.pkg.changes_file)])
485                 done = 1
486         elif answer == 'N':
487             edit_note(get_new_comments(changes.get("source", ""), session=session),
488                       upload, session)
489         elif answer == 'P' and not Options["Trainee"]:
490             prod_maintainer(get_new_comments(changes.get("source", ""), session=session),
491                             upload)
492             Logger.log(["NEW PROD: %s" % (upload.pkg.changes_file)])
493         elif answer == 'R' and not Options["Trainee"]:
494             confirm = utils.our_raw_input("Really clear note (y/N)? ").lower()
495             if confirm == "y":
496                 for c in get_new_comments(changes.get("source", ""), changes.get("version", ""), session=session):
497                     session.delete(c)
498                 session.commit()
499         elif answer == 'O' and not Options["Trainee"]:
500             confirm = utils.our_raw_input("Really clear all notes (y/N)? ").lower()
501             if confirm == "y":
502                 for c in get_new_comments(changes.get("source", ""), session=session):
503                     session.delete(c)
504                 session.commit()
505
506         elif answer == 'S':
507             done = 1
508         elif answer == 'Q':
509             end()
510             sys.exit(0)
511
512 ################################################################################
513 ################################################################################
514 ################################################################################
515
516 def usage (exit_code=0):
517     print """Usage: dak process-new [OPTION]... [CHANGES]...
518   -a, --automatic           automatic run
519   -h, --help                show this help and exit.
520   -m, --manual-reject=MSG   manual reject with `msg'
521   -n, --no-action           don't do anything
522   -t, --trainee             FTP Trainee mode
523   -V, --version             display the version number and exit"""
524     sys.exit(exit_code)
525
526 ################################################################################
527
528 def do_byhand(upload, session):
529     done = 0
530     while not done:
531         files = upload.pkg.files
532         will_install = 1
533         byhand = []
534
535         for f in files.keys():
536             if files[f]["type"] == "byhand":
537                 if os.path.exists(f):
538                     print "W: %s still present; please process byhand components and try again." % (f)
539                     will_install = 0
540                 else:
541                     byhand.append(f)
542
543         answer = "XXXX"
544         if Options["No-Action"]:
545             answer = "S"
546         if will_install:
547             if Options["Automatic"] and not Options["No-Action"]:
548                 answer = 'A'
549             prompt = "[A]ccept, Manual reject, Skip, Quit ?"
550         else:
551             prompt = "Manual reject, [S]kip, Quit ?"
552
553         while prompt.find(answer) == -1:
554             answer = utils.our_raw_input(prompt)
555             m = re_default_answer.search(prompt)
556             if answer == "":
557                 answer = m.group(1)
558             answer = answer[:1].upper()
559
560         if answer == 'A':
561             try:
562                 check_daily_lock()
563                 done = 1
564                 for f in byhand:
565                     del files[f]
566                 Logger.log(["BYHAND ACCEPT: %s" % (upload.pkg.changes_file)])
567             except CantGetLockError:
568                 print "Hello? Operator! Give me the number for 911!"
569                 print "Dinstall in the locked area, cant process packages, come back later"
570         elif answer == 'M':
571             Logger.log(["BYHAND REJECT: %s" % (upload.pkg.changes_file)])
572             upload.do_reject(manual=1, reject_message=Options["Manual-Reject"])
573             upload.pkg.remove_known_changes(session=session)
574             session.commit()
575             done = 1
576         elif answer == 'S':
577             done = 1
578         elif answer == 'Q':
579             end()
580             sys.exit(0)
581
582 ################################################################################
583
584 def check_daily_lock():
585     """
586     Raises CantGetLockError if the dinstall daily.lock exists.
587     """
588
589     cnf = Config()
590     try:
591         os.open(cnf["Process-New::DinstallLockFile"],
592                 os.O_RDONLY | os.O_CREAT | os.O_EXCL)
593     except OSError, e:
594         if e.errno == errno.EEXIST or e.errno == errno.EACCES:
595             raise CantGetLockError
596
597     os.unlink(cnf["Process-New::DinstallLockFile"])
598
599
600 @contextlib.contextmanager
601 def lock_package(package):
602     """
603     Lock C{package} so that noone else jumps in processing it.
604
605     @type package: string
606     @param package: source package name to lock
607     """
608
609     path = os.path.join(Config()["Process-New::LockDir"], package)
610     try:
611         fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_RDONLY)
612     except OSError, e:
613         if e.errno == errno.EEXIST or e.errno == errno.EACCES:
614             user = pwd.getpwuid(os.stat(path)[stat.ST_UID])[4].split(',')[0].replace('.', '')
615             raise AlreadyLockedError, user
616
617     try:
618         yield fd
619     finally:
620         os.unlink(path)
621
622 class clean_holding(object):
623     def __init__(self,pkg):
624         self.pkg = pkg
625
626     def __enter__(self):
627         pass
628
629     def __exit__(self, type, value, traceback):
630         h = Holding()
631
632         for f in self.pkg.files.keys():
633             if os.path.exists(os.path.join(h.holding_dir, f)):
634                 os.unlink(os.path.join(h.holding_dir, f))
635
636
637 def do_pkg(changes_file, session):
638     new_queue = get_policy_queue('new', session );
639     u = Upload()
640     u.pkg.changes_file = changes_file
641     (u.pkg.changes["fingerprint"], rejects) = utils.check_signature(changes_file)
642     u.load_changes(changes_file)
643     u.pkg.directory = new_queue.path
644     u.update_subst()
645     u.logger = Logger
646     origchanges = os.path.abspath(u.pkg.changes_file)
647
648     cnf = Config()
649     bcc = "X-DAK: dak process-new"
650     if cnf.has_key("Dinstall::Bcc"):
651         u.Subst["__BCC__"] = bcc + "\nBcc: %s" % (cnf["Dinstall::Bcc"])
652     else:
653         u.Subst["__BCC__"] = bcc
654
655     files = u.pkg.files
656     for deb_filename, f in files.items():
657         if deb_filename.endswith(".udeb") or deb_filename.endswith(".deb"):
658             u.binary_file_checks(deb_filename, session)
659             u.check_binary_against_db(deb_filename, session)
660         else:
661             u.source_file_checks(deb_filename, session)
662             u.check_source_against_db(deb_filename, session)
663
664         u.pkg.changes["suite"] = copy.copy(u.pkg.changes["distribution"])
665
666     try:
667         with lock_package(u.pkg.changes["source"]):
668             with clean_holding(u.pkg):
669                 if not recheck(u, session):
670                     return
671
672                 new, byhand = determine_new(u.pkg.changes, files)
673                 if byhand:
674                     # TODO: Fix this and make sure it doesn't complain when we've
675                     #       got already processed byhand components
676                     print "Warning: This has byhand components and probably shouldn't be in NEW."
677                     print "Contact an ftpmaster as this needs to be dealt with by them"
678                 elif new:
679                     do_new(u, session)
680                 else:
681                     try:
682                         check_daily_lock()
683                         new_accept(u, Options["No-Action"], session)
684                     except CantGetLockError:
685                         print "Hello? Operator! Give me the number for 911!"
686                         print "Dinstall in the locked area, cant process packages, come back later"
687
688     except AlreadyLockedError, e:
689         print "Seems to be locked by %s already, skipping..." % (e)
690
691 ################################################################################
692
693 def end():
694     accept_count = SummaryStats().accept_count
695     accept_bytes = SummaryStats().accept_bytes
696
697     if accept_count:
698         sets = "set"
699         if accept_count > 1:
700             sets = "sets"
701         sys.stderr.write("Accepted %d package %s, %s.\n" % (accept_count, sets, utils.size_type(int(accept_bytes))))
702         Logger.log(["total",accept_count,accept_bytes])
703
704     if not Options["No-Action"] and not Options["Trainee"]:
705         Logger.close()
706
707 ################################################################################
708
709 def main():
710     global Options, Logger, Sections, Priorities
711
712     cnf = Config()
713     session = DBConn().session()
714
715     Arguments = [('a',"automatic","Process-New::Options::Automatic"),
716                  ('h',"help","Process-New::Options::Help"),
717                  ('m',"manual-reject","Process-New::Options::Manual-Reject", "HasArg"),
718                  ('t',"trainee","Process-New::Options::Trainee"),
719                  ('n',"no-action","Process-New::Options::No-Action")]
720
721     for i in ["automatic", "help", "manual-reject", "no-action", "version", "trainee"]:
722         if not cnf.has_key("Process-New::Options::%s" % (i)):
723             cnf["Process-New::Options::%s" % (i)] = ""
724
725     changes_files = apt_pkg.ParseCommandLine(cnf.Cnf,Arguments,sys.argv)
726     if len(changes_files) == 0:
727         new_queue = get_policy_queue('new', session );
728         changes_files = utils.get_changes_files(new_queue.path)
729
730     Options = cnf.SubTree("Process-New::Options")
731
732     if Options["Help"]:
733         usage()
734
735     if not Options["No-Action"]:
736         try:
737             Logger = daklog.Logger(cnf, "process-new")
738         except CantOpenError, e:
739             Options["Trainee"] = "True"
740
741     Sections = Section_Completer(session)
742     Priorities = Priority_Completer(session)
743     readline.parse_and_bind("tab: complete")
744
745     if len(changes_files) > 1:
746         sys.stderr.write("Sorting changes...\n")
747     changes_files = sort_changes(changes_files, session)
748
749     for changes_file in changes_files:
750         changes_file = utils.validate_changes_file_arg(changes_file, 0)
751         if not changes_file:
752             continue
753         print "\n" + changes_file
754
755         do_pkg (changes_file, session)
756
757     end()
758
759 ################################################################################
760
761 if __name__ == '__main__':
762     main()