def delete_department(request): """deletes the department with the given id """ department_id = request.matchdict.get('id') department = Department.query.get(department_id) name = department.name if not department: transaction.abort() return Response( 'Can not find a Department with id: %s' % department_id, 500 ) try: DBSession.delete(department) transaction.commit() except Exception as e: transaction.abort() c = StdErrToHTMLConverter(e) transaction.abort() return Response(c.html(), 500) request.session.flash( 'success: <strong>%s Department</strong> is deleted ' 'successfully' % name ) return Response('Successfully deleted department: %s' % department_id)
def test_list_input(self): """testing if the class is working with lists as the error message """ test_data = [ '/tmp/Stalker_3coLKi.tjp:1909: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1359.Task_1356.Task_1357 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1949: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1367.Task_1370.Task_1371 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1989: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1368.Task_1369.Task_1375 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:2029: \x1b[35mWarning: The total effort (2.0d or 18.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1381.Task_1391.Task_1394 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:2070: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1382.Task_1392.Task_1393 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1320: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following tasks stole resources from Project_23.Task_108.Task_109.Asset_130.Task_605 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1735: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_581.Task_583\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1762: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_585.Task_587\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1797: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_589.Task_591\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1442: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following task stole resources from Project_23.Task_108.Task_109.Asset_135.Task_552 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1398: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_133.Task_545\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1450: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following tasks stole resources from Project_23.Task_108.Task_109.Asset_135.Task_553 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1743: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_581.Task_584\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1485: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_136.Task_558\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1770: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_585.Task_588\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1805: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_589.Task_598\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1485: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following task stole resources from Project_23.Task_108.Task_109.Asset_136.Task_558 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1743: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_581.Task_584\x1b[0m\n' ] expected_result = '/tmp/Stalker_3coLKi.tjp:1909: <div class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> The total effort (1.0d or 9.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1359.Task_1356.Task_1357 exceeds the specified effort of 0.1111111111111111d or 1.0h.</div>/tmp/Stalker_3coLKi.tjp:1949: <div class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> The total effort (1.0d or 9.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1367.Task_1370.Task_1371 exceeds the specified effort of 0.1111111111111111d or 1.0h.</div>/tmp/Stalker_3coLKi.tjp:1989: <div class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> The total effort (1.0d or 9.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1368.Task_1369.Task_1375 exceeds the specified effort of 0.1111111111111111d or 1.0h.</div>/tmp/Stalker_3coLKi.tjp:2029: <div class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> The total effort (2.0d or 18.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1381.Task_1391.Task_1394 exceeds the specified effort of 0.1111111111111111d or 1.0h.</div>/tmp/Stalker_3coLKi.tjp:2070: <div class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> The total effort (1.0d or 9.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1382.Task_1392.Task_1393 exceeds the specified effort of 0.1111111111111111d or 1.0h.</div>/tmp/Stalker_3coLKi.tjp:1320: <div class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following tasks stole resources from Project_23.Task_108.Task_109.Asset_130.Task_605 despite having a lower priority:</div>/tmp/Stalker_3coLKi.tjp:1735: <div class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Project_23.Task_108.Task_109.Asset_581.Task_583</div>/tmp/Stalker_3coLKi.tjp:1762: <div class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Project_23.Task_108.Task_109.Asset_585.Task_587</div>/tmp/Stalker_3coLKi.tjp:1797: <div class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Project_23.Task_108.Task_109.Asset_589.Task_591</div>/tmp/Stalker_3coLKi.tjp:1442: <div class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following task stole resources from Project_23.Task_108.Task_109.Asset_135.Task_552 despite having a lower priority:</div>/tmp/Stalker_3coLKi.tjp:1398: <div class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Project_23.Task_108.Task_109.Asset_133.Task_545</div>/tmp/Stalker_3coLKi.tjp:1450: <div class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following tasks stole resources from Project_23.Task_108.Task_109.Asset_135.Task_553 despite having a lower priority:</div>/tmp/Stalker_3coLKi.tjp:1743: <div class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Project_23.Task_108.Task_109.Asset_581.Task_584</div>/tmp/Stalker_3coLKi.tjp:1485: <div class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Project_23.Task_108.Task_109.Asset_136.Task_558</div>/tmp/Stalker_3coLKi.tjp:1770: <div class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Project_23.Task_108.Task_109.Asset_585.Task_588</div>/tmp/Stalker_3coLKi.tjp:1805: <div class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Project_23.Task_108.Task_109.Asset_589.Task_598</div>/tmp/Stalker_3coLKi.tjp:1485: <div class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following task stole resources from Project_23.Task_108.Task_109.Asset_136.Task_558 despite having a lower priority:</div>/tmp/Stalker_3coLKi.tjp:1743: <div class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Project_23.Task_108.Task_109.Asset_581.Task_584</div>' c = StdErrToHTMLConverter(test_data) self.assertEqual( expected_result, c.html() )
def upload_files(request): """uploads a list of files to the server, creates Link instances in server and returns the created link ids with a response to let the front end request a linkage between the entity and the uploaded files """ # decide if it is single or multiple files file_params = request.POST.getall('file') logger.debug('file_params: %s ' % file_params) try: new_links = upload_files_to_server(request, file_params) except IOError as e: c = StdErrToHTMLConverter(e) response = Response(c.html()) response.status_int = 500 transaction.abort() return response else: # store the link object DBSession.add_all(new_links) logger.debug('created links for uploaded files: %s' % new_links) return { 'link_ids': [link.id for link in new_links] }
def delete_group(request): """deletes the group with the given id """ group_id = request.matchdict.get('id') group = Group.query.get(group_id) name = group.name if not group: transaction.abort() return Response('Can not find a Group with id: %s' % group_id, 500) try: DBSession.delete(group) transaction.commit() except Exception as e: transaction.abort() c = StdErrToHTMLConverter(e) transaction.abort() return Response(c.html(), 500) request.session.flash( 'success:<strong>%s Group</strong> is deleted successfully' % name ) return Response('Successfully deleted group: %s' % group_id)
def delete_user(request): """deletes the user with the given id """ user_id = request.matchdict.get('id') user = User.query.get(user_id) if not user: transaction.abort() return Response('Can not find a User with id: %s' % user_id, 500) try: DBSession.delete(user) transaction.commit() request.session.flash( 'success: %s is deleted' % user.name ) except Exception as e: transaction.abort() c = StdErrToHTMLConverter(e) transaction.abort() request.session.flash( c.html() ) return Response(c.html(), 500) return Response('Successfully deleted user: %s' % user_id)
def create_time_log(request): """runs when creating a time_log """ logger.debug('create_time_log method starts') task_id = request.params.get('task_id') logger.debug('task_id : %s' % task_id) task = Task.query.filter(Task.id == task_id).first() if not task: return Response('No task with id %s found' % task_id, 500) #************************************************************************** # collect data resource_id = request.params.get('resource_id', None) resource = User.query.filter(User.id == resource_id).first() start_date = get_date(request, 'start') end_date = get_date(request, 'end') description = request.params.get('description', '') logger.debug('task_id : %s' % task_id) logger.debug('task : %s' % task) logger.debug('resource_id : %s' % resource_id) logger.debug('start_date : %s' % start_date) logger.debug('end_date : %s' % end_date) if task and resource and start_date and end_date: # we are ready to create the time log # TimeLog should handle the extension of the effort logger.debug('got all the data') try: assert isinstance(task, Task) task.create_time_log(resource, start_date, end_date) except (OverBookedError, TypeError, DependencyViolationError) as e: converter = StdErrToHTMLConverter(e) response = Response(converter.html(), 500) transaction.abort() return response else: request.session.flash( 'success: Time log for <strong>%s</strong> is saved for ' 'resource <strong>%s</strong>.' % (task.name,resource.name) ) logger.debug('no problem here!') else: response = Response( 'There are missing parameters: ' 'task_id: %s, resource_id: %s' % (task_id, resource_id), 500 ) transaction.abort() return response logger.debug('successfully created time log!') response = Response('successfully created time log!') return response
def test_list_input(self): """testing if the class is working with lists as the error message """ test_data = [ '/tmp/Stalker_3coLKi.tjp:1909: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1359.Task_1356.Task_1357 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1949: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1367.Task_1370.Task_1371 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1989: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1368.Task_1369.Task_1375 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:2029: \x1b[35mWarning: The total effort (2.0d or 18.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1381.Task_1391.Task_1394 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:2070: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1382.Task_1392.Task_1393 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1320: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following tasks stole resources from Task_108.Task_109.Asset_130.Task_605 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1735: \x1b[34mInfo: Task Task_108.Task_109.Asset_581.Task_583\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1762: \x1b[34mInfo: Task Task_108.Task_109.Asset_585.Task_587\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1797: \x1b[34mInfo: Task Task_108.Task_109.Asset_589.Task_591\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1442: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following task stole resources from Task_108.Task_109.Asset_135.Task_552 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1398: \x1b[34mInfo: Task Task_108.Task_109.Asset_133.Task_545\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1450: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following tasks stole resources from Task_108.Task_109.Asset_135.Task_553 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1743: \x1b[34mInfo: Task Task_108.Task_109.Asset_581.Task_584\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1485: \x1b[34mInfo: Task Task_108.Task_109.Asset_136.Task_558\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1770: \x1b[34mInfo: Task Task_108.Task_109.Asset_585.Task_588\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1805: \x1b[34mInfo: Task Task_108.Task_109.Asset_589.Task_598\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1485: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following task stole resources from Task_108.Task_109.Asset_136.Task_558 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1743: \x1b[34mInfo: Task Task_108.Task_109.Asset_581.Task_584\x1b[0m\n' ] expected_result = \ '<p>/tmp/Stalker_3coLKi.tjp:1909: <span class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> The total effort (1.0d or 9.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1359.Task_1356.Task_1357 exceeds the specified effort of 0.1111111111111111d or 1.0h.</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1949: <span class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> The total effort (1.0d or 9.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1367.Task_1370.Task_1371 exceeds the specified effort of 0.1111111111111111d or 1.0h.</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1989: <span class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> The total effort (1.0d or 9.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1368.Task_1369.Task_1375 exceeds the specified effort of 0.1111111111111111d or 1.0h.</span><br>' \ '/tmp/Stalker_3coLKi.tjp:2029: <span class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> The total effort (2.0d or 18.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1381.Task_1391.Task_1394 exceeds the specified effort of 0.1111111111111111d or 1.0h.</span><br>' \ '/tmp/Stalker_3coLKi.tjp:2070: <span class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> The total effort (1.0d or 9.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1382.Task_1392.Task_1393 exceeds the specified effort of 0.1111111111111111d or 1.0h.</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1320: <span class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following tasks stole resources from Task_108.Task_109.Asset_130.Task_605 despite having a lower priority:</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1735: <span class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Task_108.Task_109.Asset_581.Task_583</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1762: <span class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Task_108.Task_109.Asset_585.Task_587</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1797: <span class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Task_108.Task_109.Asset_589.Task_591</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1442: <span class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following task stole resources from Task_108.Task_109.Asset_135.Task_552 despite having a lower priority:</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1398: <span class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Task_108.Task_109.Asset_133.Task_545</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1450: <span class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following tasks stole resources from Task_108.Task_109.Asset_135.Task_553 despite having a lower priority:</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1743: <span class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Task_108.Task_109.Asset_581.Task_584</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1485: <span class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Task_108.Task_109.Asset_136.Task_558</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1770: <span class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Task_108.Task_109.Asset_585.Task_588</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1805: <span class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Task_108.Task_109.Asset_589.Task_598</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1485: <span class="alert alert-warning" style="overflow-wrap: break-word"><strong>Warning:</strong> Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following task stole resources from Task_108.Task_109.Asset_136.Task_558 despite having a lower priority:</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1743: <span class="alert alert-info" style="overflow-wrap: break-word"><strong>Info:</strong> Task Task_108.Task_109.Asset_581.Task_584</span></p>' c = StdErrToHTMLConverter(test_data) self.assertEqual(expected_result, c.html())
def delete_time_log(request): """deletes the time_log with the given id """ time_log_id = request.matchdict.get('id') time_log = TimeLog.query.get(time_log_id) logger.debug('delete_time_log: %s' % time_log_id) if not time_log: transaction.abort() return Response( 'Can not find a Time_log with id: %s' % time_log_id, 500 ) status_cmpl = Status.query.filter(Status.code == 'CMPL').first() if time_log.task.status in [status_cmpl]: transaction.abort() return Response( 'Error: You can not delete a TimeLog of a Task with status CMPL', 500 ) task_id = time_log.task.id try: DBSession.delete(time_log) transaction.commit() except Exception as e: transaction.abort() c = StdErrToHTMLConverter(e) transaction.abort() return Response(c.html(), 500) else: # update the status of the task if there is no time log any more task = Task.query.get(task_id) assert isinstance(task, Task) if not task.time_logs: status_new = Status.query.filter(Status.code == 'NEW').first() task.status = status_new return Response('Successfully deleted time_log: %s' % time_log_id)
def delete_budgetentry_action(budgetentry): logger.debug('delete_budgetentry_action %s' % budgetentry.name) budgetentry_name = budgetentry.name try: DBSession.delete(budgetentry) transaction.commit() except Exception as e: transaction.abort() c = StdErrToHTMLConverter(e) transaction.abort()
def delete_good(request): """deletes the good with data from request """ logger.debug('***delete good method starts ***') good_id = request.params.get('id') good = Good.query.filter_by(id=good_id).first() if not good: transaction.abort() return Response('There is no good with id: %s' % good_id, 500) good_name = good.name try: DBSession.delete(good) transaction.commit() except Exception as e: transaction.abort() c = StdErrToHTMLConverter(e) transaction.abort() return Response(c.html(), 500) return Response('Successfully deleted good with name %s' % good_name)
def delete_note(request): """deletes the task with the given id """ logger.debug('delete_note is starts') note_id = request.matchdict.get('id') note = Note.query.filter_by(id=note_id).first() if not note: transaction.abort() return Response('Can not find an Note with id: %s' % note_id, 500) try: DBSession.delete(note) transaction.commit() except Exception as e: transaction.abort() c = StdErrToHTMLConverter(e) transaction.abort() return Response(c.html(), 500) return Response('Successfully deleted note')
def delete_entity(request): """deletes the task with the given id """ logger.debug('delete_entity is starts') entity_id = request.matchdict.get('id') entity = Entity.query.filter_by(id=entity_id).first() if not entity: transaction.abort() return Response('Can not find an Entity with id: %s' % entity_id, 500) try: DBSession.delete(entity) transaction.commit() except Exception as e: transaction.abort() c = StdErrToHTMLConverter(e) transaction.abort() return Response(c.html(), 500) return Response('Successfully deleted %s: %s' % (entity.entity_type,entity.name))
def auto_schedule_tasks(request): """schedules all the tasks of active projects """ logged_in_user = get_logged_in_user(request) # get the studio studio = Studio.query.first() if not studio: transaction.abort() return Response("There is no Studio instance\n" "Please create a studio first", 500) project_id = request.params.get('project', -1) project = Project.query.filter(Project.id == project_id).first() logger.debug('project_id: %s' % project_id) tj_scheduler = TaskJugglerScheduler() studio.scheduler = tj_scheduler if project: studio.scheduler.projects = [project] try: stderr = studio.schedule(scheduled_by=logged_in_user) # update schedule timings to UTC studio.scheduling_started_at = \ local_to_utc(studio.scheduling_started_at) studio.last_scheduled_at = local_to_utc(studio.last_scheduled_at) # invalidate cache regions from stalker_pyramid.views.task import cached_query_tasks,\ get_cached_user_tasks, get_cached_tasks_count invalidate_all_caches() check_all_tasks_status_by_schedule_model() c = StdErrToHTMLConverter(stderr) return Response(c.html(replace_links=True)) except RuntimeError as e: c = StdErrToHTMLConverter(e) transaction.abort() return Response(c.html(replace_links=True), 500)
def test_replace_links(self): """testing if the class is working with lists as the error message """ test_data = [ '/tmp/Stalker_3coLKi.tjp:1909: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1359.Task_1356.Task_1357 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1949: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1367.Task_1370.Task_1371 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1989: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1368.Task_1369.Task_1375 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:2029: \x1b[35mWarning: The total effort (2.0d or 18.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1381.Task_1391.Task_1394 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:2070: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Project_23.Task_108.Task_1350.Task_1351.Task_1353.Asset_1382.Task_1392.Task_1393 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1320: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following tasks stole resources from Project_23.Task_108.Task_109.Asset_130.Task_605 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1735: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_581.Task_583\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1762: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_585.Task_587\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1797: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_589.Task_591\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1442: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following task stole resources from Project_23.Task_108.Task_109.Asset_135.Task_552 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1398: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_133.Task_545\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1450: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following tasks stole resources from Project_23.Task_108.Task_109.Asset_135.Task_553 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1743: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_581.Task_584\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1485: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_136.Task_558\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1770: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_585.Task_588\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1805: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_589.Task_598\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1485: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following task stole resources from Project_23.Task_108.Task_109.Asset_136.Task_558 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1743: \x1b[34mInfo: Task Project_23.Task_108.Task_109.Asset_581.Task_584\x1b[0m\n' ] expected_result = \ '/tmp/Stalker_3coLKi.tjp:1909: <div class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'The total effort (1.0d or 9.0h) of the provided bookings for ' \ 'task <a href="/tasks/1357/view">Task_1357</a> exceeds the ' \ 'specified effort of 0.1111111111111111d or 1.0h.</div>' \ '/tmp/Stalker_3coLKi.tjp:1949: <div class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'The total effort (1.0d or 9.0h) of the provided bookings for ' \ 'task <a href="/tasks/1371/view">Task_1371</a> exceeds the ' \ 'specified effort of 0.1111111111111111d or 1.0h.</div>' \ '/tmp/Stalker_3coLKi.tjp:1989: <div class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'The total effort (1.0d or 9.0h) of the provided bookings for ' \ 'task <a href="/tasks/1375/view">Task_1375</a> exceeds the ' \ 'specified effort of 0.1111111111111111d or 1.0h.</div>' \ '/tmp/Stalker_3coLKi.tjp:2029: <div class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'The total effort (2.0d or 18.0h) of the provided bookings for ' \ 'task <a href="/tasks/1394/view">Task_1394</a> exceeds the ' \ 'specified effort of 0.1111111111111111d or 1.0h.</div>' \ '/tmp/Stalker_3coLKi.tjp:2070: <div class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'The total effort (1.0d or 9.0h) of the provided bookings for ' \ 'task <a href="/tasks/1393/view">Task_1393</a> exceeds the ' \ 'specified effort of 0.1111111111111111d or 1.0h.</div>' \ '/tmp/Stalker_3coLKi.tjp:1320: <div class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'Due to a mix of ALAP and ASAP scheduled tasks or a dependency ' \ 'on a lower priority tasks the following tasks stole resources ' \ 'from <a href="/tasks/605/view">Task_605</a> despite having a ' \ 'lower priority:</div>/tmp/Stalker_3coLKi.tjp:1735: ' \ '<div class="alert alert-info" style="overflow-wrap: ' \ 'break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/583/view">Task_583</a></div>' \ '/tmp/Stalker_3coLKi.tjp:1762: <div class="alert alert-info" ' \ 'style="overflow-wrap: break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/587/view">Task_587</a></div>' \ '/tmp/Stalker_3coLKi.tjp:1797: <div class="alert alert-info" ' \ 'style="overflow-wrap: break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/591/view">Task_591</a></div>' \ '/tmp/Stalker_3coLKi.tjp:1442: <div class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> Due ' \ 'to a mix of ALAP and ASAP scheduled tasks or a dependency on a ' \ 'lower priority tasks the following task stole resources from ' \ '<a href="/tasks/552/view">Task_552</a> despite having a lower ' \ 'priority:</div>/tmp/Stalker_3coLKi.tjp:1398: ' \ '<div class="alert alert-info" style="overflow-wrap: ' \ 'break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/545/view">Task_545</a></div>' \ '/tmp/Stalker_3coLKi.tjp:1450: <div class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'Due to a mix of ALAP and ASAP scheduled tasks or a dependency ' \ 'on a lower priority tasks the following tasks stole resources ' \ 'from <a href="/tasks/553/view">Task_553</a> despite having a ' \ 'lower priority:</div>/tmp/Stalker_3coLKi.tjp:1743: ' \ '<div class="alert alert-info" style="overflow-wrap: ' \ 'break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/584/view">Task_584</a></div>' \ '/tmp/Stalker_3coLKi.tjp:1485: <div class="alert alert-info" ' \ 'style="overflow-wrap: break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/558/view">Task_558</a></div>' \ '/tmp/Stalker_3coLKi.tjp:1770: <div class="alert alert-info" ' \ 'style="overflow-wrap: break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/588/view">Task_588</a></div>' \ '/tmp/Stalker_3coLKi.tjp:1805: <div class="alert alert-info" ' \ 'style="overflow-wrap: break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/598/view">Task_598</a></div>' \ '/tmp/Stalker_3coLKi.tjp:1485: <div class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'Due to a mix of ALAP and ASAP scheduled tasks or a dependency ' \ 'on a lower priority tasks the following task stole resources ' \ 'from <a href="/tasks/558/view">Task_558</a> despite having a ' \ 'lower priority:</div>/tmp/Stalker_3coLKi.tjp:1743: <div ' \ 'class="alert alert-info" style="overflow-wrap: break-word">' \ '<strong>Info:</strong> Task ' \ '<a href="/tasks/584/view">Task_584</a>' \ '</div>' c = StdErrToHTMLConverter(test_data) self.maxDiff = None self.assertEqual( expected_result, c.html(replace_links=True) )
def test_replace_links(self): """testing if the class is working with lists as the error message """ test_data = [ '/tmp/Stalker_3coLKi.tjp:1909: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1359.Task_1356.Task_1357 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1949: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1367.Task_1370.Task_1371 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1989: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1368.Task_1369.Task_1375 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:2029: \x1b[35mWarning: The total effort (2.0d or 18.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1381.Task_1391.Task_1394 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:2070: \x1b[35mWarning: The total effort (1.0d or 9.0h) of the provided bookings for task Task_108.Task_1350.Task_1351.Task_1353.Asset_1382.Task_1392.Task_1393 exceeds the specified effort of 0.1111111111111111d or 1.0h.\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1320: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following tasks stole resources from Task_108.Task_109.Asset_130.Task_605 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1735: \x1b[34mInfo: Task Task_108.Task_109.Asset_581.Task_583\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1762: \x1b[34mInfo: Task Task_108.Task_109.Asset_585.Task_587\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1797: \x1b[34mInfo: Task Task_108.Task_109.Asset_589.Task_591\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1442: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following task stole resources from Task_108.Task_109.Asset_135.Task_552 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1398: \x1b[34mInfo: Task Task_108.Task_109.Asset_133.Task_545\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1450: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following tasks stole resources from Task_108.Task_109.Asset_135.Task_553 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1743: \x1b[34mInfo: Task Task_108.Task_109.Asset_581.Task_584\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1485: \x1b[34mInfo: Task Task_108.Task_109.Asset_136.Task_558\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1770: \x1b[34mInfo: Task Task_108.Task_109.Asset_585.Task_588\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1805: \x1b[34mInfo: Task Task_108.Task_109.Asset_589.Task_598\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1485: \x1b[35mWarning: Due to a mix of ALAP and ASAP scheduled tasks or a dependency on a lower priority tasks the following task stole resources from Task_108.Task_109.Asset_136.Task_558 despite having a lower priority:\x1b[0m\n', '/tmp/Stalker_3coLKi.tjp:1743: \x1b[34mInfo: Task Task_108.Task_109.Asset_581.Task_584\x1b[0m\n' ] expected_result = \ '<p>/tmp/Stalker_3coLKi.tjp:1909: <span class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'The total effort (1.0d or 9.0h) of the provided bookings for ' \ 'task <a href="/tasks/1357/view">Task_1357</a> exceeds the ' \ 'specified effort of 0.1111111111111111d or 1.0h.</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1949: <span class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'The total effort (1.0d or 9.0h) of the provided bookings for ' \ 'task <a href="/tasks/1371/view">Task_1371</a> exceeds the ' \ 'specified effort of 0.1111111111111111d or 1.0h.</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1989: <span class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'The total effort (1.0d or 9.0h) of the provided bookings for ' \ 'task <a href="/tasks/1375/view">Task_1375</a> exceeds the ' \ 'specified effort of 0.1111111111111111d or 1.0h.</span><br>' \ '/tmp/Stalker_3coLKi.tjp:2029: <span class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'The total effort (2.0d or 18.0h) of the provided bookings for ' \ 'task <a href="/tasks/1394/view">Task_1394</a> exceeds the ' \ 'specified effort of 0.1111111111111111d or 1.0h.</span><br>' \ '/tmp/Stalker_3coLKi.tjp:2070: <span class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'The total effort (1.0d or 9.0h) of the provided bookings for ' \ 'task <a href="/tasks/1393/view">Task_1393</a> exceeds the ' \ 'specified effort of 0.1111111111111111d or 1.0h.</span><br>' \ '/tmp/Stalker_3coLKi.tjp:1320: <span class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'Due to a mix of ALAP and ASAP scheduled tasks or a dependency ' \ 'on a lower priority tasks the following tasks stole resources ' \ 'from <a href="/tasks/605/view">Task_605</a> despite having a ' \ 'lower priority:</span><br>/tmp/Stalker_3coLKi.tjp:1735: ' \ '<span class="alert alert-info" style="overflow-wrap: ' \ 'break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/583/view">Task_583</a></span><br>' \ '/tmp/Stalker_3coLKi.tjp:1762: <span class="alert alert-info" ' \ 'style="overflow-wrap: break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/587/view">Task_587</a></span><br>' \ '/tmp/Stalker_3coLKi.tjp:1797: <span class="alert alert-info" ' \ 'style="overflow-wrap: break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/591/view">Task_591</a></span><br>' \ '/tmp/Stalker_3coLKi.tjp:1442: <span class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> Due ' \ 'to a mix of ALAP and ASAP scheduled tasks or a dependency on a ' \ 'lower priority tasks the following task stole resources from ' \ '<a href="/tasks/552/view">Task_552</a> despite having a lower ' \ 'priority:</span><br>/tmp/Stalker_3coLKi.tjp:1398: ' \ '<span class="alert alert-info" style="overflow-wrap: ' \ 'break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/545/view">Task_545</a></span><br>' \ '/tmp/Stalker_3coLKi.tjp:1450: <span class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'Due to a mix of ALAP and ASAP scheduled tasks or a dependency ' \ 'on a lower priority tasks the following tasks stole resources ' \ 'from <a href="/tasks/553/view">Task_553</a> despite having a ' \ 'lower priority:</span><br>/tmp/Stalker_3coLKi.tjp:1743: ' \ '<span class="alert alert-info" style="overflow-wrap: ' \ 'break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/584/view">Task_584</a></span><br>' \ '/tmp/Stalker_3coLKi.tjp:1485: <span class="alert alert-info" ' \ 'style="overflow-wrap: break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/558/view">Task_558</a></span><br>' \ '/tmp/Stalker_3coLKi.tjp:1770: <span class="alert alert-info" ' \ 'style="overflow-wrap: break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/588/view">Task_588</a></span><br>' \ '/tmp/Stalker_3coLKi.tjp:1805: <span class="alert alert-info" ' \ 'style="overflow-wrap: break-word"><strong>Info:</strong> Task ' \ '<a href="/tasks/598/view">Task_598</a></span><br>' \ '/tmp/Stalker_3coLKi.tjp:1485: <span class="alert alert-warning" ' \ 'style="overflow-wrap: break-word"><strong>Warning:</strong> ' \ 'Due to a mix of ALAP and ASAP scheduled tasks or a dependency ' \ 'on a lower priority tasks the following task stole resources ' \ 'from <a href="/tasks/558/view">Task_558</a> despite having a ' \ 'lower priority:</span><br>/tmp/Stalker_3coLKi.tjp:1743: <span ' \ 'class="alert alert-info" style="overflow-wrap: break-word">' \ '<strong>Info:</strong> Task ' \ '<a href="/tasks/584/view">Task_584</a>' \ '</span></p>' c = StdErrToHTMLConverter(test_data) self.maxDiff = None self.assertEqual(expected_result, c.html(replace_links=True))