5 Import known_changes files
7 @contact: Debian FTP Master <ftpmaster@debian.org>
8 @copyright: 2009 Mike O'Connor <stew@debian.org>
9 @license: GNU General Public License version 2 or later
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.
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.
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
26 ################################################################################
29 ################################################################################
36 from daklib.dbconn import DBConn, get_dbchange
37 from daklib.config import Config
39 # where in dak.conf all of our configuration will be stowed
40 options_prefix = "NewFiles"
41 options_prefix = "%s::Options" % options_prefix
43 log = logging.getLogger()
45 ################################################################################
48 def usage (exit_code=0):
49 print """Usage: dak import-new-files [options]
53 show verbose information messages
56 supress all output but errors
61 class ImportKnownChanges(object):
63 def __init__(self, session=None):
65 newq = get_policy_queue('new', session)
66 for changes_fn in glob.glob(newq.path + "/*.changes"):
67 changes_bn = os.path.basename(fn)
68 chg = session.query(DBChange).filter_by(changesname=changes_bn).one()
71 u.changes_file = changes_fn
72 u.load_changes(changes_fn)
74 for chg_fn in u.pkg.files.keys():
75 cpf = ChangePendingFile()
77 cpf.size = self.files[chg_fn]['size']
78 cpf.md5sum = self.files[chg_fn]['md5sum']
86 except KeyboardInterrupt:
87 print("Caught C-c; terminating.")
88 utils.warn("Caught C-c; terminating.")
95 arguments = [('h',"help", "%s::%s" % (options_prefix,"Help")),
96 ('q',"quiet", "%s::%s" % (options_prefix,"Quiet")),
97 ('v',"verbose", "%s::%s" % (options_prefix,"Verbose")),
100 args = apt_pkg.ParseCommandLine(cnf.Cnf, arguments,sys.argv)
107 if cnf.has_key("%s::%s" % (options_prefix,"Help")):
111 if cnf.has_key("%s::%s" % (options_prefix,"Quiet")):
114 elif cnf.has_key("%s::%s" % (options_prefix,"Verbose")):
118 logging.basicConfig( level=level,
119 format='%(asctime)s %(levelname)s %(message)s',
120 stream = sys.stderr )
125 if __name__ == '__main__':