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 ################################################################################
37 from daklib.dbconn import DBConn, get_dbchange, get_policy_queue, session_wrapper, ChangePendingFile
38 from daklib.config import Config
39 from daklib.queue import Upload
41 # where in dak.conf all of our configuration will be stowed
42 options_prefix = "NewFiles"
43 options_prefix = "%s::Options" % options_prefix
45 log = logging.getLogger()
47 ################################################################################
50 def usage (exit_code=0):
51 print """Usage: dak import-new-files [options]
55 show verbose information messages
58 supress all output but errors
63 class ImportNewFiles(object):
65 def __init__(self, session=None):
67 newq = get_policy_queue('new', session)
68 for changes_fn in glob.glob(newq.path + "/*.changes"):
69 changes_bn = os.path.basename(changes_fn)
70 chg = get_dbchange(changes_bn, session)
73 success = u.load_changes(changes_fn)
74 u.pkg.changes_file = changes_bn
78 chg = u.pkg.add_known_changes(newq.path, newq.policy_queue_id, session)
82 log.critical("failed to load %s" % changes_fn)
85 log.critical("ACCLAIM: %s" % changes_fn)
88 for chg_fn in u.pkg.files.keys():
89 cpf = ChangePendingFile()
91 cpf.size = u.pkg.files[chg_fn]['size']
92 cpf.md5sum = u.pkg.files[chg_fn]['md5sum']
93 cpf.sha1sum = u.pkg.files[chg_fn]['sha1sum']
94 cpf.sha256sum = u.pkg.files[chg_fn]['sha256sum']
104 except KeyboardInterrupt:
105 print("Caught C-c; terminating.")
106 utils.warn("Caught C-c; terminating.")
113 arguments = [('h',"help", "%s::%s" % (options_prefix,"Help")),
114 ('q',"quiet", "%s::%s" % (options_prefix,"Quiet")),
115 ('v',"verbose", "%s::%s" % (options_prefix,"Verbose")),
118 args = apt_pkg.ParseCommandLine(cnf.Cnf, arguments,sys.argv)
125 if cnf.has_key("%s::%s" % (options_prefix,"Help")):
129 if cnf.has_key("%s::%s" % (options_prefix,"Quiet")):
132 elif cnf.has_key("%s::%s" % (options_prefix,"Verbose")):
136 logging.basicConfig( level=level,
137 format='%(asctime)s %(levelname)s %(message)s',
138 stream = sys.stderr )
143 if __name__ == '__main__':