- try:
- with lock_package(u.pkg.changes["source"]):
- with clean_holding(u.pkg):
- if not recheck(u, session):
- return
-
- # FIXME: This does need byhand checks added!
- new = determine_new(u.pkg.changes, files)
- if new:
- do_new(u, session)
- else:
- try:
- check_daily_lock()
- new_accept(u, Options["No-Action"], session)
- except CantGetLockError:
- print "Hello? Operator! Give me the number for 911!"
- print "Dinstall in the locked area, cant process packages, come back later"
-# (new, byhand) = check_status(files)
-# if new or byhand:
-# if new:
-# do_new(u, session)
-# if byhand:
-# do_byhand(u, session)
-# (new, byhand) = check_status(files)
-
-# if not new and not byhand:
-# try:
-# check_daily_lock()
-# do_accept(u)
-# except CantGetLockError:
-# print "Hello? Operator! Give me the number for 911!"
-# print "Dinstall in the locked area, cant process packages, come back later"
- except AlreadyLockedError, e:
- print "Seems to be locked by %s already, skipping..." % (e)
+################################################################################
+
+def sort_uploads(new_queue, uploads, session, nobinaries=False):
+ sources = {}
+ sorteduploads = []
+ suitesrc = [s.source for s in session.query(DBSource.source). \
+ filter(DBSource.suites.any(Suite.suite_name.in_(['unstable', 'experimental'])))]
+ comments = [p.package for p in session.query(NewComment.package). \
+ filter_by(trainee=False, policy_queue=new_queue).distinct()]
+ for upload in uploads:
+ source = upload.changes.source
+ if not source in sources:
+ sources[source] = []
+ sources[source].append({'upload': upload,
+ 'date': upload.changes.created,
+ 'stack': 1,
+ 'binary': True if source in suitesrc else False,
+ 'comments': True if source in comments else False})
+ for src in sources:
+ if len(sources[src]) > 1:
+ changes = sources[src]
+ firstseen = sorted(changes, key=lambda k: (k['date']))[0]['date']
+ changes.sort(key=lambda item:item['date'])
+ for i in range (0, len(changes)):
+ changes[i]['date'] = firstseen
+ changes[i]['stack'] = i + 1
+ sorteduploads += sources[src]
+ if nobinaries:
+ sorteduploads = [u["upload"] for u in sorted(sorteduploads,
+ key=lambda k: (k["comments"], k["binary"],
+ k["date"], -k["stack"]))]
+ else:
+ sorteduploads = [u["upload"] for u in sorted(sorteduploads,
+ key=lambda k: (k["comments"], -k["binary"],
+ k["date"], -k["stack"]))]
+ return sorteduploads