finally:
os.unlink(path)
-def changes_to_unchecked(upload, session):
- """move a changes file to unchecked"""
- unchecked = get_policy_queue('unchecked', session );
+def changes_to_newstage(upload, session):
+ """move a changes file to newstage"""
+ newstage = get_policy_queue('newstage', session );
-# changes.in_queue = unchecked
+ # changes.in_queue = newstage
chg = session.query(DBChange).filter_by(changesname=os.path.basename(upload.pkg.changes_file)).one()
- chg.approved_for = unchecked.policy_queue_id
+ chg.approved_for = newstage.policy_queue_id
- for f in upload.pkg.files:
+ for f in chg.files:
# update the changes_pending_files row
- f.queue = unchecked
+ f.queue = newstage
# actually move files
- upload.move_to_queue(unchecked)
+ upload.move_to_queue(newstage)
def _accept(upload, session):
if Options["No-Action"]:
return
(summary, short_summary) = upload.build_summaries()
-# upload.accept(summary, short_summary, targetqueue)
- changes_to_unchecked(upload, session)
+ # upload.accept(summary, short_summary, targetqueue)
+
+ changes_to_newstage(upload, session)
def do_accept(upload, session):
print "ACCEPT"
else:
multivalues[key] = self.changes[key]
- # TODO: Use ORM
- session.execute(
- """INSERT INTO changes
- (changesname, in_queue, seen, source, binaries, architecture, version,
- distribution, urgency, maintainer, fingerprint, changedby, date)
- VALUES (:changesfile,:in_queue,:filetime,:source,:binary, :architecture,
- :version,:distribution,:urgency,:maintainer,:fingerprint,:changedby,:date)""",
- { 'changesfile': self.changes_file,
- 'filetime': filetime,
- 'in_queue': in_queue,
- 'source': self.changes["source"],
- 'binary': multivalues["binary"],
- 'architecture': multivalues["architecture"],
- 'version': self.changes["version"],
- 'distribution': multivalues["distribution"],
- 'urgency': self.changes["urgency"],
- 'maintainer': self.changes["maintainer"],
- 'fingerprint': self.changes["fingerprint"],
- 'changedby': self.changes["changed-by"],
- 'date': self.changes["date"]} )
+ chg = DBChange()
+ chg.chagnesfile = self.change_file
+ chg.seen = filetime
+ chg.in_queue_id = in_queue
+ chg.source = self.chagnes["source"]
+ chg.binaries = multivalues["binary"]
+ chg.architecture = multivalues["architecture"]
+ chg.version = self.changes["version"]
+ chg.distribution = multivalues["distribution"]
+ chg.urgency = self.changes["urgency"]
+ chg.maintainer = self.changes["maintainer"]
+ chg.fingerprint = self.changes["fingerprint"]
+ chg.changedby = self.changes["changed-by"]
+ chg.date = self.changes["date"]
+
+ session.add(chg)
+
+ chg_files = []
+ for chg_fn in self.files.keys():
+ cpf = ChangePendingFile()
+ cpf.filename = chg_fn
+ cpf.size = self.files[chg_fn]['size']
+ cpf.md5sum = self.files[chg_fn]['md5sum']
+
+ session.add(cpf)
+ chg_files.append(cpf)
+
+ chg.files = chg_files
session.commit()
-
- return session.query(DBChange).filter_by(changesname = self.changes_file).one()
+ chg = session.query(DBChange).filter_by(changesname = self.changes_file).one();
+
+ return chg
def unknown_files_fields(self, name):
return sorted(list( set(self.files[name].keys()) -