def restart_package(): """ restart a Package :return: "" """ package_id = request.form["package_id"] package = Package.query.filter_by(id=package_id).first() if not package: abort(404) # cancel all currently running processes that belong to this package for file in package.files: if ProcessRepository.is_running(file.id): ProcessRepository.cancel_process(file.id) else: # clear progress, cancel_process() also does this file.clear() # set status of each file to "queued" file.status = StatusMap.queued.value db.session.commit() # check if it's necessary to start new processes ProcessRepository.check_and_start_processes() return ""
def delete_package(): """ delete a Package :return: "" """ package_id = request.form["package_id"] package = Package.query.filter_by(id=package_id).first() if not package: abort(404) # cancel all currently running processes that belong to this package for file in package.files: if ProcessRepository.is_running(file.id): ProcessRepository.cancel_process(file.id) # mark this file to be deleted (even though SQLAlchemy handles this already) db.session.delete(file) db.session.delete(package) db.session.commit() # check if it's necessary to start new processes ProcessRepository.check_and_start_processes() return ""
def restart_file(): """ restart a File :return: "" """ file_id = request.form["file_id"] file = File.query.filter_by(id=file_id).first() if not file: abort(404) if ProcessRepository.is_running(file.id): ProcessRepository.cancel_process(file.id) else: # clear progress, cancel_process() also does this file.clear() # set status of file to "queued" file.status = StatusMap.queued.value db.session.commit() # check if it's necessary to start new processes ProcessRepository.check_and_start_processes() return ""
def delete_file(): """ delete a File :return: "" """ file_id = request.form["file_id"] file = File.query.filter_by(id=file_id).first() if not file: abort(404) # cancel the currently running processes that if ProcessRepository.is_running(file.id): ProcessRepository.cancel_process(file.id) db.session.delete(file) db.session.commit() # check if it's necessary to start new processes ProcessRepository.check_and_start_processes() return ""