Ejemplo n.º 1
0
 def handle(self, songbook_id, layout_id, *args, **options):
     songbook = Songbook.objects.get(id=songbook_id)
     layout = Layout.objects.get(id=layout_id)
     try:
         generate_songbook(songbook, layout)
     except GeneratorError as e:
         raise CommandError(str(e))
Ejemplo n.º 2
0
def queue_render_task(task_id):

    task = GeneratorTask.objects.get(id=task_id)
    task.state = GeneratorTask.State.IN_PROCESS
    task.save()

    try:
        filename = generate_songbook(task.songbook, task.layout)
    except GeneratorError:
        task.state = GeneratorTask.State.ERROR
        task.save()
        LOGGER.error("Failed task {0} (state : {1})"\
                      .format(task.id, task.state))

        return

    task.state = GeneratorTask.State.FINISHED
    task.result = {"file": "{0}".format(filename)}
    task.save()

    LOGGER.info("Finished task {0} (state : {1}) with result {2}"\
                 .format(task.id, task.state, task.result))
Ejemplo n.º 3
0
def queue_render_task(task_id):

    gt = GeneratorTask.objects.get(id=task_id)
    gt.state = GeneratorTask.State.IN_PROCESS
    gt.save()

    try:
        fileh = generate_songbook(gt)
    except GeneratorError:
        gt.state = GeneratorTask.State.ERROR
        gt.save()
        print("Failed task {0} (state : {1})"\
          .format(gt.id, gt.state))

        return

    gt.state = GeneratorTask.State.FINISHED
    gt.result = {"file": "{0}".format(fileh)}
    gt.save()

    # TODO: write this in a log file
    print("Finished task {0} (state : {1}) with result {2}"\
          .format(gt.id, gt.state, gt.result))
Ejemplo n.º 4
0
 def handle(self, sb_id, *args, **options):
     try:
         generate_songbook(sb_id)
     except GeneratorError as e:
         raise CommandError(str(e))