u.pkg.write_dot_dak(dir)
u.move_to_dir(dir, perms=perms)
if build:
- get_queue(queue.lower()).autobuild_upload(u.pkg, dir)
+ get_or_set_queue(queue.lower()).autobuild_upload(u.pkg, dir)
# Check for override disparities
u.check_override()
__all__.append('Queue')
@session_wrapper
-def get_queue(queuename, session=None):
+def get_or_set_queue(queuename, session=None):
"""
- Returns Queue object for given C{queue name}.
+ Returns Queue object for given C{queue name}, creating it if it does not
+ exist.
@type queuename: string
@param queuename: The name of the queue
q = session.query(Queue).filter_by(queue_name=queuename)
try:
- return q.one()
+ ret = q.one()
except NoResultFound:
- return None
+ queue = Queue()
+ queue.queue_name = queuename
+ session.add(queue)
+ session.commit_or_flush()
+ ret = queue
+
+ return ret
-__all__.append('get_queue')
+__all__.append('get_or_set_queue')
################################################################################
# <Ganneff> yes
# This routine returns None on success or an error on failure
- res = get_queue('accepted').autobuild_upload(self.pkg, cnf["Dir::Queue::Accepted"])
+ res = get_or_set_queue('accepted').autobuild_upload(self.pkg, cnf["Dir::Queue::Accepted"])
if res:
utils.fubar(res)