#NEWLINE# def getJob( conn ) : #NEWLINE# #INDENT# '\n    Get the next available sandbox request and set its status to pending.\n    ' #NEWLINE# cur = conn . execute ( "SELECT cocreate_sandboxrequest.id, cocreate_sandboxrequest.sandbox_id, cocreate_sandboxrequest.requested_by_id, cocreate_sandboxrequest.sandbox_name, cocreate_sandboxtemplate.recipe FROM cocreate_sandboxrequest, cocreate_sandboxtemplate WHERE cocreate_sandboxrequest.request_status = 'app' AND cocreate_sandboxrequest.template_id = cocreate_sandboxtemplate.id LIMIT 1" ) #NEWLINE# try : #NEWLINE# #INDENT# ( request_id , sandbox_id , requested_by_id , sandbox_name , sandbox_recipe ) = cur . fetchone ( ) #NEWLINE# conn . execute ( "UPDATE cocreate_sandboxrequest SET request_status = 'pen' WHERE id = ?" , ( request_id , ) ) #NEWLINE# conn . commit ( ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'request_id' : request_id , #NEWLINE# 'sandbox_id' : sandbox_id , #NEWLINE# 'requested_by_id' : sandbox_recipe , #NEWLINE# 'sandbox_name' : sandbox_name , #NEWLINE# 'sandbox_recipe' : sandbox_recipe , #NEWLINE# #UNINDENT# }