django-nativemojo 0.1.10__py3-none-any.whl → 0.1.15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. django_nativemojo-0.1.15.dist-info/METADATA +136 -0
  2. {django_nativemojo-0.1.10.dist-info → django_nativemojo-0.1.15.dist-info}/RECORD +105 -65
  3. mojo/__init__.py +1 -1
  4. mojo/apps/account/management/__init__.py +5 -0
  5. mojo/apps/account/management/commands/__init__.py +6 -0
  6. mojo/apps/account/management/commands/serializer_admin.py +531 -0
  7. mojo/apps/account/migrations/0004_user_avatar.py +20 -0
  8. mojo/apps/account/migrations/0005_group_last_activity.py +18 -0
  9. mojo/apps/account/models/group.py +25 -7
  10. mojo/apps/account/models/member.py +15 -4
  11. mojo/apps/account/models/user.py +197 -20
  12. mojo/apps/account/rest/group.py +1 -0
  13. mojo/apps/account/rest/user.py +6 -2
  14. mojo/apps/aws/rest/__init__.py +1 -0
  15. mojo/apps/aws/rest/s3.py +64 -0
  16. mojo/apps/fileman/README.md +8 -8
  17. mojo/apps/fileman/backends/base.py +76 -70
  18. mojo/apps/fileman/backends/filesystem.py +86 -86
  19. mojo/apps/fileman/backends/s3.py +200 -108
  20. mojo/apps/fileman/migrations/0001_initial.py +106 -0
  21. mojo/apps/fileman/migrations/0002_filemanager_parent_alter_filemanager_max_file_size.py +24 -0
  22. mojo/apps/fileman/migrations/0003_remove_file_fileman_fil_upload__c4bc35_idx_and_more.py +25 -0
  23. mojo/apps/fileman/migrations/0004_remove_file_original_filename_and_more.py +39 -0
  24. mojo/apps/fileman/migrations/0005_alter_file_upload_token.py +18 -0
  25. mojo/apps/fileman/migrations/0006_file_download_url_filemanager_forever_urls.py +23 -0
  26. mojo/apps/fileman/migrations/0007_remove_filemanager_forever_urls_and_more.py +22 -0
  27. mojo/apps/fileman/migrations/0008_file_category.py +18 -0
  28. mojo/apps/fileman/migrations/0009_rename_file_path_file_storage_file_path.py +18 -0
  29. mojo/apps/fileman/migrations/0010_filerendition.py +33 -0
  30. mojo/apps/fileman/migrations/0011_alter_filerendition_original_file.py +19 -0
  31. mojo/apps/fileman/models/__init__.py +1 -5
  32. mojo/apps/fileman/models/file.py +204 -58
  33. mojo/apps/fileman/models/manager.py +161 -31
  34. mojo/apps/fileman/models/rendition.py +118 -0
  35. mojo/apps/fileman/renderer/__init__.py +111 -0
  36. mojo/apps/fileman/renderer/audio.py +403 -0
  37. mojo/apps/fileman/renderer/base.py +205 -0
  38. mojo/apps/fileman/renderer/document.py +404 -0
  39. mojo/apps/fileman/renderer/image.py +222 -0
  40. mojo/apps/fileman/renderer/utils.py +297 -0
  41. mojo/apps/fileman/renderer/video.py +304 -0
  42. mojo/apps/fileman/rest/__init__.py +1 -18
  43. mojo/apps/fileman/rest/upload.py +22 -32
  44. mojo/apps/fileman/signals.py +58 -0
  45. mojo/apps/fileman/tasks.py +254 -0
  46. mojo/apps/fileman/utils/__init__.py +40 -16
  47. mojo/apps/incident/migrations/0005_incidenthistory.py +39 -0
  48. mojo/apps/incident/migrations/0006_alter_incident_state.py +18 -0
  49. mojo/apps/incident/models/__init__.py +1 -0
  50. mojo/apps/incident/models/history.py +36 -0
  51. mojo/apps/incident/models/incident.py +1 -1
  52. mojo/apps/incident/reporter.py +3 -1
  53. mojo/apps/incident/rest/event.py +7 -1
  54. mojo/apps/logit/migrations/0004_alter_log_level.py +18 -0
  55. mojo/apps/logit/models/log.py +4 -1
  56. mojo/apps/metrics/utils.py +2 -2
  57. mojo/apps/notify/handlers/ses/message.py +1 -1
  58. mojo/apps/notify/providers/aws.py +2 -2
  59. mojo/apps/tasks/__init__.py +34 -1
  60. mojo/apps/tasks/manager.py +200 -45
  61. mojo/apps/tasks/rest/tasks.py +24 -10
  62. mojo/apps/tasks/runner.py +283 -18
  63. mojo/apps/tasks/task.py +99 -0
  64. mojo/apps/tasks/tq_handlers.py +118 -0
  65. mojo/decorators/auth.py +6 -1
  66. mojo/decorators/http.py +7 -2
  67. mojo/helpers/aws/__init__.py +41 -0
  68. mojo/helpers/aws/ec2.py +804 -0
  69. mojo/helpers/aws/iam.py +748 -0
  70. mojo/helpers/aws/s3.py +451 -11
  71. mojo/helpers/aws/ses.py +483 -0
  72. mojo/helpers/aws/sns.py +461 -0
  73. mojo/helpers/crypto/__pycache__/hash.cpython-310.pyc +0 -0
  74. mojo/helpers/crypto/__pycache__/sign.cpython-310.pyc +0 -0
  75. mojo/helpers/crypto/__pycache__/utils.cpython-310.pyc +0 -0
  76. mojo/helpers/dates.py +18 -0
  77. mojo/helpers/response.py +6 -2
  78. mojo/helpers/settings/__init__.py +2 -0
  79. mojo/helpers/{settings.py → settings/helper.py} +1 -37
  80. mojo/helpers/settings/parser.py +132 -0
  81. mojo/middleware/logging.py +1 -1
  82. mojo/middleware/mojo.py +5 -0
  83. mojo/models/rest.py +261 -46
  84. mojo/models/secrets.py +13 -4
  85. mojo/serializers/__init__.py +100 -0
  86. mojo/serializers/advanced/README.md +363 -0
  87. mojo/serializers/advanced/__init__.py +247 -0
  88. mojo/serializers/advanced/formats/__init__.py +28 -0
  89. mojo/serializers/advanced/formats/csv.py +416 -0
  90. mojo/serializers/advanced/formats/excel.py +516 -0
  91. mojo/serializers/advanced/formats/json.py +239 -0
  92. mojo/serializers/advanced/formats/localizers.py +509 -0
  93. mojo/serializers/advanced/formats/response.py +485 -0
  94. mojo/serializers/advanced/serializer.py +568 -0
  95. mojo/serializers/manager.py +501 -0
  96. mojo/serializers/optimized.py +618 -0
  97. mojo/serializers/settings_example.py +322 -0
  98. mojo/serializers/{models.py → simple.py} +38 -15
  99. testit/helpers.py +21 -4
  100. django_nativemojo-0.1.10.dist-info/METADATA +0 -96
  101. mojo/apps/metrics/rest/db.py +0 -0
  102. mojo/helpers/aws/setup_email.py +0 -0
  103. mojo/ws4redis/README.md +0 -174
  104. mojo/ws4redis/__init__.py +0 -2
  105. mojo/ws4redis/client.py +0 -283
  106. mojo/ws4redis/connection.py +0 -327
  107. mojo/ws4redis/exceptions.py +0 -32
  108. mojo/ws4redis/redis.py +0 -183
  109. mojo/ws4redis/servers/base.py +0 -86
  110. mojo/ws4redis/servers/django.py +0 -171
  111. mojo/ws4redis/servers/uwsgi.py +0 -63
  112. mojo/ws4redis/settings.py +0 -45
  113. mojo/ws4redis/utf8validator.py +0 -128
  114. mojo/ws4redis/websocket.py +0 -403
  115. {django_nativemojo-0.1.10.dist-info → django_nativemojo-0.1.15.dist-info}/LICENSE +0 -0
  116. {django_nativemojo-0.1.10.dist-info → django_nativemojo-0.1.15.dist-info}/NOTICE +0 -0
  117. {django_nativemojo-0.1.10.dist-info → django_nativemojo-0.1.15.dist-info}/WHEEL +0 -0
  118. /mojo/{ws4redis/servers → apps/aws}/__init__.py +0 -0
  119. /mojo/apps/{fileman/models/render.py → aws/models/__init__.py} +0 -0
  120. /mojo/apps/fileman/{rest/__init__ → migrations/__init__.py} +0 -0
@@ -1,3 +1,4 @@
1
+ from posix import lockf
1
2
  from venv import create
2
3
  from mojo.helpers import redis
3
4
  from objict import objict
@@ -6,7 +7,7 @@ import time
6
7
 
7
8
 
8
9
  class TaskManager:
9
- def __init__(self, channels, prefix="taskit"):
10
+ def __init__(self, channels, prefix="mojo:tasks"):
10
11
  """
11
12
  Initialize the TaskManager with Redis connection, channels, and a key prefix.
12
13
 
@@ -17,11 +18,13 @@ class TaskManager:
17
18
  self.channels = channels
18
19
  self.prefix = prefix
19
20
 
20
- def take_out_the_dead(self):
21
- for channel in self.channels:
21
+ def take_out_the_dead(self, local=False):
22
+ # Get channels from Redis instead of using self.channels
23
+ channels = self.channels if local else self.get_all_channels()
24
+ for channel in channels:
22
25
  # this will remove all expired tasks by default
23
- self.get_pending()
24
- self.get_running()
26
+ self.get_pending(channel)
27
+ self.get_running(channel)
25
28
 
26
29
  def get_completed_key(self, channel):
27
30
  """
@@ -41,6 +44,23 @@ class TaskManager:
41
44
  """
42
45
  return f"{self.prefix}:p:{channel}"
43
46
 
47
+ def get_global_pending_key(self):
48
+ """
49
+ Get the Redis key for pending tasks in a channel.
50
+
51
+ :param channel: Channel name.
52
+ :return: Redis key for pending tasks.
53
+ """
54
+ return f"{self.prefix}:pending"
55
+
56
+ def get_channels_key(self):
57
+ """
58
+ Get the Redis key for tracking all channels.
59
+
60
+ :return: Redis key for channels set.
61
+ """
62
+ return f"{self.prefix}:channels"
63
+
44
64
  def get_error_key(self, channel):
45
65
  """
46
66
  Get the Redis key for tasks with errors in a channel.
@@ -77,6 +97,40 @@ class TaskManager:
77
97
  """
78
98
  return f"{self.prefix}:c:{channel}"
79
99
 
100
+ def get_runners_key(self):
101
+ return f"{self.prefix}:runners"
102
+
103
+ def add_channel(self, channel):
104
+ """
105
+ Add a channel to the global channels set.
106
+
107
+ :param channel: Channel name.
108
+ """
109
+ self.redis.sadd(self.get_channels_key(), channel)
110
+
111
+ def remove_channel(self, channel):
112
+ """
113
+ Remove a channel from the global channels set.
114
+
115
+ :param channel: Channel name.
116
+ """
117
+ self.redis.srem(self.get_channels_key(), channel)
118
+
119
+ def remove_all_channels(self):
120
+ """
121
+ Remove all channels from the global channels set.
122
+ """
123
+ self.redis.delete(self.get_channels_key())
124
+
125
+ def get_all_channels(self):
126
+ """
127
+ Get all channels from the global channels set.
128
+
129
+ :return: List of channel names.
130
+ """
131
+ channels = self.redis.smembers(self.get_channels_key())
132
+ return [channel.decode('utf-8') for channel in channels]
133
+
80
134
  def get_task(self, task_id):
81
135
  """
82
136
  Retrieve a task from Redis using its task ID.
@@ -85,6 +139,8 @@ class TaskManager:
85
139
  :return: Task data as an objict, or None if not found.
86
140
  """
87
141
  task_data_raw = self.redis.get(self.get_task_key(task_id))
142
+ if not task_data_raw:
143
+ return None
88
144
  return objict.from_json(task_data_raw, ignore_errors=True)
89
145
 
90
146
  def save_task(self, task_data, expires=1800):
@@ -114,6 +170,8 @@ class TaskManager:
114
170
  :param channel: Channel name. Default is "default".
115
171
  :return: True if operation is successful.
116
172
  """
173
+ # Add channel to global channels set
174
+ self.add_channel(channel)
117
175
  self.redis.sadd(self.get_pending_key(channel), task_id)
118
176
  return True
119
177
 
@@ -208,8 +266,8 @@ class TaskManager:
208
266
  """
209
267
  task_data = self.get_task(task_id)
210
268
  if task_data:
211
- self.redis.srem(self.get_running_key(task_data.channel), task_data.id)
212
- self.redis.srem(self.get_pending_key(task_data.channel), task_data.id)
269
+ self.remove_from_running(task_data.id, task_data.channel)
270
+ self.remove_from_pending(task_data.id, task_data.channel)
213
271
  self.redis.delete(self.get_task_key(task_id))
214
272
  return True
215
273
  return False
@@ -223,9 +281,11 @@ class TaskManager:
223
281
  task_data_raw = self.redis.get(self.get_task_key(task_id))
224
282
  task_data = objict.from_json(task_data_raw, ignore_errors=True)
225
283
  if task_data:
226
- self.redis.srem(self.get_running_key(task_data.channel), task_data.id)
227
- self.redis.srem(self.get_pending_key(task_data.channel), task_data.id)
228
- self.redis.delete(self.get_task_key(task_id))
284
+ task_data.status = "cancelled"
285
+ self.remove_from_pending(task_data.id, task_data.channel)
286
+ self.save_task(task_data)
287
+ return True
288
+ return False
229
289
 
230
290
  def get_running_ids(self, channel="default"):
231
291
  """
@@ -337,6 +397,8 @@ class TaskManager:
337
397
  :param expires: Expiration time in seconds. Default is 1800.
338
398
  :return: Task ID of the published task.
339
399
  """
400
+ from mojo.apps import metrics
401
+
340
402
  task_data = objict(channel=channel, function=function, data=objict.from_dict(data))
341
403
  task_data.id = str(uuid.uuid4()).replace('-', '')
342
404
  task_data.created = time.time()
@@ -345,62 +407,66 @@ class TaskManager:
345
407
  self.add_to_pending(task_data.id, channel)
346
408
  self.save_task(task_data, expires)
347
409
  self.redis.publish(self.get_channel_key(channel), task_data.id)
348
- # metrics.record("taskit:p:global", category="taskit")
349
- # metrics.record(f"taskit:p:{channel}", category="taskit_channels")
410
+ metrics.record("tasks_pub", category="tasks")
411
+ metrics.record(f"tasks_pub_{channel}", category=f"tasks_{channel}")
350
412
  return task_data.id
351
413
 
352
- def get_all_pending_ids(self):
414
+ def get_all_pending_ids(self, local=False):
353
415
  """
354
416
  Get all pending task IDs across all channels.
355
417
 
356
418
  :return: List of all pending task IDs.
357
419
  """
358
420
  pending_ids = []
359
- for channel in self.channels:
421
+ channels = self.channels if local else self.get_all_channels()
422
+ for channel in channels:
360
423
  pending_ids.extend(self.get_pending_ids(channel))
361
424
  return pending_ids
362
425
 
363
- def get_all_running_ids(self):
426
+ def get_all_running_ids(self, local=False):
364
427
  """
365
428
  Get all running task IDs across all channels.
366
429
 
367
430
  :return: List of all running task IDs.
368
431
  """
369
432
  running_ids = []
370
- for channel in self.channels:
433
+ channels = self.channels if local else self.get_all_channels()
434
+ for channel in channels:
371
435
  running_ids.extend(self.get_running_ids(channel))
372
436
  return running_ids
373
437
 
374
- def get_all_completed_ids(self):
438
+ def get_all_completed_ids(self, local=False):
375
439
  """
376
440
  Get all completed task IDs across all channels.
377
441
 
378
442
  :return: List of all completed task IDs.
379
443
  """
380
444
  completed_ids = []
381
- for channel in self.channels:
445
+ channels = self.channels if local else self.get_all_channels()
446
+ for channel in channels:
382
447
  completed_ids.extend(self.get_completed_ids(channel))
383
448
  return completed_ids
384
449
 
385
- def get_all_error_ids(self):
450
+ def get_all_error_ids(self, local=False):
386
451
  """
387
452
  Get all error task IDs across all channels.
388
453
 
389
454
  :return: List of all error task IDs.
390
455
  """
391
456
  error_ids = []
392
- for channel in self.channels:
457
+ channels = self.channels if local else self.get_all_channels()
458
+ for channel in channels:
393
459
  error_ids.extend(self.get_error_ids(channel))
394
460
  return error_ids
395
461
 
396
- def get_all_pending(self, include_data=False):
462
+ def get_all_pending(self, include_data=False, local=False):
397
463
  """
398
464
  Get all pending tasks as objects.
399
465
 
400
466
  :return: List of pending task objects.
401
467
  """
402
468
  pending_tasks = []
403
- for task_id in self.get_all_pending_ids():
469
+ for task_id in self.get_all_pending_ids(local=local):
404
470
  task = self.get_task(task_id)
405
471
  if task:
406
472
  if not include_data:
@@ -410,14 +476,14 @@ class TaskManager:
410
476
  self.remove_from_pending(task_id)
411
477
  return pending_tasks
412
478
 
413
- def get_all_running(self, include_data=False):
479
+ def get_all_running(self, include_data=False, local=False):
414
480
  """
415
481
  Get all running tasks as objects.
416
482
 
417
483
  :return: List of running task objects.
418
484
  """
419
485
  running_tasks = []
420
- for task_id in self.get_all_running_ids():
486
+ for task_id in self.get_all_running_ids(local=local):
421
487
  task = self.get_task(task_id)
422
488
  if task:
423
489
  if not include_data:
@@ -427,14 +493,14 @@ class TaskManager:
427
493
  self.remove_from_running(task_id)
428
494
  return running_tasks
429
495
 
430
- def get_all_completed(self, include_data=False):
496
+ def get_all_completed(self, include_data=False, local=False):
431
497
  """
432
498
  Get all completed tasks as objects.
433
499
 
434
500
  :return: List of completed task objects.
435
501
  """
436
502
  completed_tasks = []
437
- for task_id in self.get_all_completed_ids():
503
+ for task_id in self.get_all_completed_ids(local=local):
438
504
  task = self.get_task(task_id)
439
505
  if task:
440
506
  if not include_data:
@@ -446,14 +512,14 @@ class TaskManager:
446
512
  completed_tasks.sort(key=lambda x: x.created, reverse=True)
447
513
  return completed_tasks
448
514
 
449
- def get_all_errors(self):
515
+ def get_all_errors(self, local=False):
450
516
  """
451
517
  Get all error tasks as objects.
452
518
 
453
519
  :return: List of error task objects.
454
520
  """
455
521
  error_tasks = []
456
- for task_id in self.get_all_error_ids():
522
+ for task_id in self.get_all_error_ids(local=local):
457
523
  task = self.get_task(task_id)
458
524
  if task:
459
525
  error_tasks.append(task)
@@ -463,27 +529,116 @@ class TaskManager:
463
529
  error_tasks.sort(key=lambda x: x.created, reverse=True)
464
530
  return error_tasks
465
531
 
466
- def get_status(self, simple=False):
532
+ def get_channel_status(self, channel):
533
+ status = objict()
534
+ status.pending = len(self.get_pending_ids(channel))
535
+ status.running = len(self.get_running_ids(channel))
536
+ status.completed = len(self.get_completed_ids(channel))
537
+ status.errors = len(self.get_error_ids(channel))
538
+ return status
539
+
540
+ def get_status(self, simple=False, local=False):
467
541
  """
468
542
  Get the status of tasks across all channels, including pending and running tasks.
469
543
 
470
544
  :return: Status object containing counts of pending and running tasks per channel.
471
545
  """
472
- status = objict(pending=0, running=0, completed=0, errors=0, channels=objict())
473
- for channel in self.channels:
474
- pending = self.get_pending_ids(channel)
475
- running = self.get_running_ids(channel)
476
- completed = self.get_completed_ids(channel)
477
- errors = self.get_error_ids(channel)
478
- status.pending += len(pending)
479
- status.running += len(running)
480
- status.completed += len(completed)
481
- status.errors += len(errors)
546
+ status = objict(pending=0, running=0, completed=0, errors=0)
547
+ if not simple:
548
+ status.channels = objict()
549
+ channels = self.channels if local else self.get_all_channels()
550
+ # Use channels from Redis instead of self.channels
551
+ for channel in channels:
552
+ cstatus = self.get_channel_status(channel)
553
+ status.pending += cstatus.pending
554
+ status.running += cstatus.running
555
+ status.completed += cstatus.completed
556
+ status.errors += cstatus.errors
482
557
  if not simple:
483
- cstats = objict()
484
- cstats.pending = len(pending)
485
- cstats.running = len(running)
486
- cstats.completed = len(completed)
487
- cstats.errors = len(errors)
488
- status.channels[channel] = cstats
558
+ status.channels[channel] = cstatus
559
+ status["runners"] = self.get_active_runners()
489
560
  return status
561
+
562
+ def get_all_runners(self):
563
+ """
564
+ Get all runners.
565
+
566
+ Returns:
567
+ dict: Dictionary of runners with their status.
568
+ """
569
+ runners = {}
570
+ raw_runners = self.redis.hgetall(self.get_runners_key())
571
+ for hostname, data in raw_runners.items():
572
+ try:
573
+ runner = objict.from_json(data.decode())
574
+ runner["ping_age"] = time.time() - runner["last_ping"]
575
+ if runner["ping_age"] > 30:
576
+ runner["status"] = "timeout"
577
+ runners[hostname.decode()] = runner
578
+ except Exception:
579
+ continue
580
+ return runners
581
+
582
+ def get_active_runners(self):
583
+ """
584
+ Get all active runners.
585
+
586
+ Returns:
587
+ dict: Dictionary of active runners with their status.
588
+ """
589
+ return self.get_all_runners()
590
+
591
+ def remove_runner(self, hostname):
592
+ """
593
+ Remove a runner from the list of active runners.
594
+
595
+ Args:
596
+ hostname (str): The hostname of the runner to remove.
597
+ """
598
+ self.redis.hdel(self.get_runners_key(), hostname)
599
+
600
+ def clear_runners(self, ping_age=30):
601
+ raw_runners = self.get_all_runners()
602
+ for runner in raw_runners.values():
603
+ try:
604
+ runner["ping_age"] = time.time() - runner["last_ping"]
605
+ if runner["ping_age"] > ping_age:
606
+ self.remove_runner(runner["hostname"])
607
+ except Exception:
608
+ continue
609
+
610
+ def clear_running_tasks(self):
611
+ """
612
+ Reset tasks that are stuck in a running state by moving them back to the pending state.
613
+ """
614
+ for channel in self.channels:
615
+ for task_id in self.get_running_ids(channel):
616
+ # self.logger.info(f"moving task {task_id} from running to pending")
617
+ self.remove_from_running(task_id, channel)
618
+ self.add_to_pending(task_id, channel)
619
+
620
+ def clear_pending_tasks(self):
621
+ """
622
+ Reset tasks that are stuck in a pending state by moving them back to the pending state.
623
+ """
624
+ for channel in self.channels:
625
+ for task_id in self.get_pending_ids(channel):
626
+ # self.logger.info(f"moving task {task_id} from running to pending")
627
+ self.remove_from_pending(task_id, channel)
628
+
629
+ def clear_channel(self, channel):
630
+ for task_id in self.get_running_ids(channel):
631
+ self.remove_from_running(task_id, channel)
632
+ for task_id in self.get_pending_ids(channel):
633
+ self.remove_from_pending(task_id, channel)
634
+ for task_id in self.get_completed_ids(channel):
635
+ self.remove_from_completed(task_id, channel)
636
+ for task_id in self.get_error_ids(channel):
637
+ self.remove_from_errors(task_id, channel)
638
+
639
+ def clear_local_queues(self):
640
+ """
641
+ Reset tasks that are stuck in a pending state by moving them back to the pending state.
642
+ """
643
+ for channel in self.channels:
644
+ self.clear_channel(channel)
@@ -1,19 +1,30 @@
1
1
  from mojo import decorators as md
2
2
  from mojo.helpers.response import JsonResponse
3
3
  # from django.http import JsonResponse
4
- import mojo.tasks
4
+ from mojo.apps import tasks
5
5
 
6
- @md.URL('status')
6
+ @md.GET('status')
7
7
  def api_status(request):
8
- tman = mojo.tasks.get_manager()
9
- return JsonResponse(tman.get_status())
8
+ tman = tasks.get_manager()
9
+ return JsonResponse(dict(status=True, data=tman.get_status()))
10
+
11
+
12
+ @md.GET('runners')
13
+ def api_task_runners(request):
14
+ tman = tasks.get_manager()
15
+ runners = [r for r in tman.get_active_runners().values()]
16
+ for r in runners:
17
+ r['id'] = r['hostname']
18
+ return JsonResponse(dict(status=True, data=runners, size=len(runners), count=len(runners)))
19
+
10
20
 
11
21
  @md.URL('pending')
12
22
  def api_pending(request):
13
- tman = mojo.tasks.get_manager()
23
+ tman = tasks.get_manager()
14
24
  pending = tman.get_all_pending()
15
25
  size = len(pending)
16
26
  response = {
27
+ 'status': True,
17
28
  'count': size,
18
29
  'page': 0,
19
30
  'size': size,
@@ -23,10 +34,11 @@ def api_pending(request):
23
34
 
24
35
  @md.URL('completed')
25
36
  def api_completed(request):
26
- tman = mojo.tasks.get_manager()
27
- completed = tman.get_all_completed()
37
+ tman = tasks.get_manager()
38
+ completed = tman.get_all_completed(include_data=True)
28
39
  size = len(completed)
29
40
  response = {
41
+ 'status': True,
30
42
  'count': size,
31
43
  'page': 0,
32
44
  'size': size,
@@ -36,10 +48,11 @@ def api_completed(request):
36
48
 
37
49
  @md.URL('running')
38
50
  def api_running(request):
39
- tman = mojo.tasks.get_manager()
40
- running = tman.get_all_running()
51
+ tman = tasks.get_manager()
52
+ running = tman.get_all_running(include_data=True)
41
53
  size = len(running)
42
54
  response = {
55
+ 'status': True,
43
56
  'count': size,
44
57
  'page': 0,
45
58
  'size': size,
@@ -50,10 +63,11 @@ def api_running(request):
50
63
 
51
64
  @md.URL('errors')
52
65
  def api_errors(request):
53
- tman = mojo.tasks.get_manager()
66
+ tman = tasks.get_manager()
54
67
  errors = tman.get_all_errors()
55
68
  size = len(errors)
56
69
  response = {
70
+ 'status': True,
57
71
  'count': size,
58
72
  'page': 0,
59
73
  'size': size,