django-restit 4.2.111__py3-none-any.whl → 4.2.113__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.
- account/models/group.py +1 -1
- {django_restit-4.2.111.dist-info → django_restit-4.2.113.dist-info}/METADATA +1 -1
- {django_restit-4.2.111.dist-info → django_restit-4.2.113.dist-info}/RECORD +15 -15
- incident/tq.py +3 -3
- metrics/client.py +5 -1
- metrics/periodic.py +2 -2
- metrics/rpc.py +29 -17
- rest/__init__.py +1 -1
- rest/extra/hostinfo.py +11 -4
- rest/models/base.py +1 -1
- rest/rpc.py +23 -0
- taskqueue/periodic.py +2 -2
- ws4redis/client.py +4 -0
- {django_restit-4.2.111.dist-info → django_restit-4.2.113.dist-info}/LICENSE.md +0 -0
- {django_restit-4.2.111.dist-info → django_restit-4.2.113.dist-info}/WHEEL +0 -0
account/models/group.py
CHANGED
@@ -177,7 +177,7 @@ class Group(models.Model, RestModel, MetaDataModel):
|
|
177
177
|
parent = request.member.getGroup(child_of)
|
178
178
|
if parent:
|
179
179
|
request.group = None
|
180
|
-
return parent.getAllChildren(grand_children=True)
|
180
|
+
return parent.getAllChildren(grand_children=True, great_grand_children=True)
|
181
181
|
return qset
|
182
182
|
|
183
183
|
def on_rest_get(self, request):
|
@@ -28,7 +28,7 @@ account/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
28
28
|
account/models/__init__.py,sha256=cV_lMnT2vL_mjiYtT4hlcIHo52ocFbGSNVkOIHHLXZY,385
|
29
29
|
account/models/device.py,sha256=0AFeLMGk4im4KZVd3eGSyRbK4eQEXiFM2cdY8GUzihs,5934
|
30
30
|
account/models/feeds.py,sha256=vI7fG4ASY1M0Zjke24RdnfDcuWeATl_yR_25jPmT64g,2011
|
31
|
-
account/models/group.py,sha256=
|
31
|
+
account/models/group.py,sha256=KnLj0cOJBg1JYo33wL-7NehD4_PCsLyEjLdX6GZJZAo,22308
|
32
32
|
account/models/legacy.py,sha256=zYdtv4LC0ooxPVqWM-uToPwV-lYWQLorSE6p6yn1xDw,2720
|
33
33
|
account/models/member.py,sha256=JziyYNC13SFWX07Thtoe2V_YlrKNn2RHJZcRk15Zh-s,54205
|
34
34
|
account/models/membership.py,sha256=90EpAhOsGaqphDAkONP6j_qQ0OWSRaQsI8H7E7fgMkE,9249
|
@@ -126,7 +126,7 @@ incident/templates/email/incident_change.html,sha256=tQYphypwLukkVdwH0TB2Szz2VEJ
|
|
126
126
|
incident/templates/email/incident_msg.html,sha256=MZdKhTddUF2MpiH8Z3RTQEmW_ko1n3ajeZ11KLtiLlU,13780
|
127
127
|
incident/templates/email/incident_new.html,sha256=W6nwFQROnyDfMlXub8s02ws4hGnJp16pfgp9xTm_aEc,15185
|
128
128
|
incident/templates/email/incident_plain.html,sha256=AyTv_3ITUwHoAO7Tv_xCODzWQXTV61EdtlphFum0BnM,14739
|
129
|
-
incident/tq.py,sha256=
|
129
|
+
incident/tq.py,sha256=BO8OjH5UzLB97vOatMmsuMDeQ1ZYhXWENoomoVJ9QlY,5235
|
130
130
|
location/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
131
131
|
location/admin.py,sha256=6S97Rlgjkk0jM15sbT1OJRPZbgvKn2rn7duCSazOXq4,297
|
132
132
|
location/geolocate.py,sha256=UgV129vmSxnqYFBYJD2RQVOcC1-lJJ1zUaxDqOJRbG4,1694
|
@@ -333,7 +333,7 @@ medialib/youtube/upload.py,sha256=MTuPxm1ZC-y5pXAGtLNtp1hBSNZgCKYt1ewP5hwMQHI,28
|
|
333
333
|
medialib/youtube/uritemplate/__init__.py,sha256=ONWR_KRz9au0O-XUUTrO_UN7GHTmZCTKyvflUQb8wxM,4996
|
334
334
|
metrics/README.md,sha256=YwbCA2y6xJBlaO6yEtl1zWpqrQ4ZzkQSuQT-h6btET8,2307
|
335
335
|
metrics/__init__.py,sha256=70sdDZGOwGIEFWgDkHWPMVODFelo206jp1g-BFV2u_4,90
|
336
|
-
metrics/client.py,sha256
|
336
|
+
metrics/client.py,sha256=WXyyl4C4CUZECJHWrY154uTPMEoJTZoYocVK582i4co,25322
|
337
337
|
metrics/eod.py,sha256=gnq-tNE7xfm2ah52e2TUyERgUQNwkFuT2rtDv8XOUVQ,9182
|
338
338
|
metrics/examples/eod_example.py,sha256=gYtansjsKILVxe8XJD12XPaxmBJ-B6dOXGZG2JTGWA8,1664
|
339
339
|
metrics/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -352,10 +352,10 @@ metrics/migrations/0004_eodmetrics.py,sha256=Ky6ZVMZqa0F_SUp_QFWY7ZKBgVhy9CS4wZc
|
|
352
352
|
metrics/migrations/0005_alter_metrics_v1_alter_metrics_v10_alter_metrics_v11_and_more.py,sha256=pmwJfpPJ1RUX_CqM66l6vvV-nrAUPo_GIan0Pc9mQHs,2358
|
353
353
|
metrics/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
354
354
|
metrics/models.py,sha256=lD9nVzfwdav70ENulqJ8rE8Ui8EWlzdVp05rg8bAlMA,13444
|
355
|
-
metrics/periodic.py,sha256=
|
355
|
+
metrics/periodic.py,sha256=IayBLLat40D8FB-A3bYBW9lxm9-IzcugQunojThQ_OU,661
|
356
356
|
metrics/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
357
357
|
metrics/providers/aws.py,sha256=dIBGFE1Fvszy6rmVrn_Fm1zUDv345q4dBsg9Iit-XCc,8358
|
358
|
-
metrics/rpc.py,sha256=
|
358
|
+
metrics/rpc.py,sha256=gnyRFBW2KBA-TAiqVcwkoVviX4bPbZ2WZELlR9uEUlM,22213
|
359
359
|
metrics/settings.py,sha256=wwHA9Z7BAHNeu3tFVn8Fh5j46KR-eGx0E8r5dzCFlAU,132
|
360
360
|
metrics/tq.py,sha256=WHBRYSinmTuxF9l-_-lx0yfzEYkb0ffVMt_uvCj9bYo,825
|
361
361
|
metrics/utils.py,sha256=PSydxeI983udULUTcbeWG-_ulPSOac6Q_t_8k_Vjn1I,12606
|
@@ -374,7 +374,7 @@ pushit/utils.py,sha256=IeTCGa-164nmB1jIsK1lu1O1QzUhS3BKfuXHGjCW-ck,2121
|
|
374
374
|
rest/.gitignore,sha256=TbEvWRMnAiajCTOdhiNrd9eeCAaIjRp9PRjE_VkMM5g,118
|
375
375
|
rest/README.md,sha256=V3ETc-cJu8PZIbKr9xSe_pA4JEUpC8Dhw4bQeVCDJPw,5460
|
376
376
|
rest/RemoteEvents.py,sha256=nL46U7AuxIrlw2JunphR1tsXyqi-ep_gD9CYGpYbNgE,72
|
377
|
-
rest/__init__.py,sha256=
|
377
|
+
rest/__init__.py,sha256=i3s__yG9Z22yx1bmRS4KcS9xtQl2dT7xDnCCeUYFhos,122
|
378
378
|
rest/arc4.py,sha256=y644IbF1ec--e4cUJ3KEYsewTCITK0gmlwa5mJruFC0,1967
|
379
379
|
rest/cache.py,sha256=1Qg0rkaCJCaVP0-l5hZg2CIblTdeBSlj_0fP6vlKUpU,83
|
380
380
|
rest/crypto/__init__.py,sha256=Tl0U11rgj1eBYqd6OXJ2_XSdNLumW_JkBZnaJqI6Ldw,72
|
@@ -386,7 +386,7 @@ rest/decorators.py,sha256=ig0LATc3-2mhEJPAWHRbIRM-ZOFyjm6e_F9RhpRWidE,15082
|
|
386
386
|
rest/encryption.py,sha256=x6Kiez0tVqfxK26MSsRL3k8OS05ni1gEX2aj3I0S9V0,788
|
387
387
|
rest/errors.py,sha256=uKwG9OkLme36etabqK54DMjMQc1fgEoUIAUxXa7WFQw,612
|
388
388
|
rest/extra/__init__.py,sha256=YzmNsch5H5FFLkUK9mIAKyoRK_rJCA9HGb0kubp4h30,54
|
389
|
-
rest/extra/hostinfo.py,sha256=
|
389
|
+
rest/extra/hostinfo.py,sha256=5R23EafcNbFARyNEqdjBkqcpC8rPfmPd1zqNqle6-nM,4298
|
390
390
|
rest/extra/json_metadata.py,sha256=p_ffzmANmOFix_oC3voR6_NNTjcn7-T7aXcH-I4_Npg,1078
|
391
391
|
rest/fields.py,sha256=_v1TJVc6vyWlqmwFRJ6mtuR5Fo-lS0KcUhPWIrzKZUo,9719
|
392
392
|
rest/forms.py,sha256=66Wm5cdy8tKib_mGicjq_yd-gNVMFWRECnrDksnNnwU,6316
|
@@ -407,13 +407,13 @@ rest/middleware/request.py,sha256=JchRNy5L-bGd-7h-KFYekGRvREe2eCkZXKOYqIkP2hI,41
|
|
407
407
|
rest/middleware/session.py,sha256=zHSoQpIzRLmpqr_JvW406wzpvU3W3gDbm5JhtzLAMlE,10240
|
408
408
|
rest/middleware/session_store.py,sha256=1nSdeXK8PyuYgGgIufqrS6j6QpIrQ7zbMNT0ol75e6U,1901
|
409
409
|
rest/models/__init__.py,sha256=M8pvFDq-WCF-QcM58X7pMufYYe0aaQ3U0PwGe9TKbbY,130
|
410
|
-
rest/models/base.py,sha256
|
410
|
+
rest/models/base.py,sha256=6mqDcuVVFm610V5RLO8yfr0vY-I4sBN_QW69OkejsJQ,70655
|
411
411
|
rest/models/cacher.py,sha256=eKz8TINVhWEqKhJGMsRkKZTtBUIv5rN3NHbZwOC56Uk,578
|
412
412
|
rest/models/metadata.py,sha256=1nQ7CYo9bJHoaXE_hVNaj1-Y7yqhHlf2ZlaD1IfTzic,12904
|
413
413
|
rest/net.py,sha256=LcB2QV6VNRtsSdmiQvYZgwQUDwOPMn_VBdRiZ6OpI-I,2974
|
414
414
|
rest/regexes.yaml,sha256=VoGb4E-P_K9f82Yzcpltgzekpt9usRtwu9PYlo46nUw,149463
|
415
415
|
rest/requestex.py,sha256=N56056vV3zWkAP-QrYsCu7SdpPzE5kLuPoxGIuZAKt0,16127
|
416
|
-
rest/rpc.py,sha256=
|
416
|
+
rest/rpc.py,sha256=xun-HuaEqm1Lwg-9Xm4Y2JwOf8wTdpoagHuIUNlqTlI,2891
|
417
417
|
rest/search.py,sha256=QVjk2b5tZLgf1zM2MHvJTyRjwUbY5ZD7HXSTmSPXtvU,8362
|
418
418
|
rest/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
419
419
|
rest/serializers/collection.py,sha256=V9O4qxw26VX9dSYdbsN0-RNnXEi347Ln8eFLZ003LhA,4646
|
@@ -457,7 +457,7 @@ taskqueue/admin.py,sha256=E6zXoToS_ea3MdoGjZzF1JiepWFtDSoZUQdan8H-pXI,208
|
|
457
457
|
taskqueue/migrations/0001_initial.py,sha256=JwYib8CK5ftSXlfxKZUcKEEVsXktNB5q3h-2tu9inGk,4738
|
458
458
|
taskqueue/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
459
459
|
taskqueue/models.py,sha256=i8v0vQqlz4X3rVFVJsUSldA-26NEPWnsMZF2Kly_1Qo,22398
|
460
|
-
taskqueue/periodic.py,sha256=
|
460
|
+
taskqueue/periodic.py,sha256=hpXnunJL_cuVQLAKpjTbABbsQ4fvdsV9_gyyK-_53Sk,3844
|
461
461
|
taskqueue/rpc.py,sha256=Lf5VUoqCRkfWUAIvx_s508mjAtDPwpiWyxg0ryqWbQA,5793
|
462
462
|
taskqueue/tq.py,sha256=PzSoDrawYcqZylruEgsK95gcJ4J_VhdM6rxg9V6_X8E,942
|
463
463
|
taskqueue/transports/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -498,7 +498,7 @@ wiki/rpc/wiki.py,sha256=RQY1gtqxdNhp13n3SkZL9WZ6RatrtCIh7QOYta6-UUU,1327
|
|
498
498
|
wiki/tq.py,sha256=wvuBZ3OMV_D2o4kpJhVLIOwpEUfwlglqLJQvpncAwtk,313
|
499
499
|
ws4redis/README.md,sha256=QvwdsauPKxx4qQqnJ991xeU8DgFQCj3CeQt-nCE4s-w,3624
|
500
500
|
ws4redis/__init__.py,sha256=teNfv83A_ke1CBt9BB7NsnWCcFBhnUFPsPESjF554_k,46
|
501
|
-
ws4redis/client.py,sha256=
|
501
|
+
ws4redis/client.py,sha256=kElPtVMVObLUXAfu32v_PHd0HyygrW-ukk37_Tuo7ZM,7062
|
502
502
|
ws4redis/connection.py,sha256=QGjzalYrx1y4o6sb6P1akL-Y2fjf2qil0JCo-ona5F8,13431
|
503
503
|
ws4redis/exceptions.py,sha256=EGLoRTdqJVwz900pwhciqPuSjBBd08hhLgFu6umHrI4,636
|
504
504
|
ws4redis/redis.py,sha256=IfT4p3bUtlqso9rryNliH9Ebzlx8-Q2VJcs1kFioeGA,6093
|
@@ -509,7 +509,7 @@ ws4redis/servers/uwsgi.py,sha256=VyhoCI1DnVFqBiJYHoxqn5Idlf6uJPHvfBKgkjs34mo,172
|
|
509
509
|
ws4redis/settings.py,sha256=K0yBiLUuY81iDM4Yr-k8hbvjn5VVHu5zQhmMK8Dtz0s,1536
|
510
510
|
ws4redis/utf8validator.py,sha256=S0OlfjeGRP75aO6CzZsF4oTjRQAgR17OWE9rgZdMBZA,5122
|
511
511
|
ws4redis/websocket.py,sha256=R0TUyPsoVRD7Y_oU7w2I6NL4fPwiz5Vl94-fUkZgLHA,14848
|
512
|
-
django_restit-4.2.
|
513
|
-
django_restit-4.2.
|
514
|
-
django_restit-4.2.
|
515
|
-
django_restit-4.2.
|
512
|
+
django_restit-4.2.113.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
|
513
|
+
django_restit-4.2.113.dist-info/METADATA,sha256=GpwHy5Fu9GlB1SztkmqX22MGSuVoAOVvfN3Iv9zgGCQ,7663
|
514
|
+
django_restit-4.2.113.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
515
|
+
django_restit-4.2.113.dist-info/RECORD,,
|
incident/tq.py
CHANGED
@@ -118,16 +118,16 @@ def on_incoming_email(task):
|
|
118
118
|
def run_cleanup(task):
|
119
119
|
stale = datetime.now() - timedelta(days=90)
|
120
120
|
# delete all ossec alerts older then 90 days
|
121
|
-
count = ia.ServerOssecAlert.objects.filter(created__lte=stale).delete()
|
121
|
+
count = ia.ServerOssecAlert.objects.filter(created__lte=stale).delete()[0]
|
122
122
|
if count:
|
123
123
|
task.log(f"deleted {count} old ServerOssecAlert")
|
124
124
|
# delete all events older then 90 days
|
125
125
|
count = ia.Event.objects.filter(created__lte=stale).filter(
|
126
|
-
Q(incident__state=ia.INCIDENT_STATE_IGNORE) | Q(incident__isnull=True)).delete()
|
126
|
+
Q(incident__state=ia.INCIDENT_STATE_IGNORE) | Q(incident__isnull=True)).delete()[0]
|
127
127
|
if count:
|
128
128
|
task.log(f"deleted {count} old Events")
|
129
129
|
|
130
|
-
count = ia.Incident.objects.filter(created__lte=stale).filter(state=ia.INCIDENT_STATE_IGNORE).delete()
|
130
|
+
count = ia.Incident.objects.filter(created__lte=stale).filter(state=ia.INCIDENT_STATE_IGNORE).delete()[0]
|
131
131
|
if count:
|
132
132
|
task.log(f"deleted {count} old Incidents")
|
133
133
|
|
metrics/client.py
CHANGED
@@ -329,8 +329,12 @@ class R(object):
|
|
329
329
|
for s in slug:
|
330
330
|
self.metric(s, num, category, expire, date)
|
331
331
|
return
|
332
|
+
|
332
333
|
# Add the slug to the set of metric slugs
|
333
|
-
|
334
|
+
try:
|
335
|
+
self.r.sadd(self._metric_slugs_key, slug)
|
336
|
+
except Exception:
|
337
|
+
return
|
334
338
|
|
335
339
|
if category:
|
336
340
|
self._categorize(slug, category)
|
metrics/periodic.py
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
from datetime import datetime, timedelta
|
2
2
|
from taskqueue.models import Task
|
3
|
-
from .models import Metrics
|
3
|
+
from metrics.models import Metrics
|
4
4
|
from rest import log
|
5
5
|
from rest import decorators as rd
|
6
6
|
|
7
7
|
|
8
8
|
@rd.periodic(minute=15, hour=10)
|
9
9
|
def run_cleanup(force=False, verbose=False, now=None):
|
10
|
-
count = Metrics.objects.filter(expires__lte=datetime.now()).delete()
|
10
|
+
count = Metrics.objects.filter(expires__lte=datetime.now()).delete()[0]
|
11
11
|
if count > 0:
|
12
12
|
logger = log.getLogger("auditlog", filename="auditlog.log")
|
13
13
|
logger.info(f"METRICS.CLEANUP {count} expired records deleted")
|
metrics/rpc.py
CHANGED
@@ -301,32 +301,44 @@ def rest_on_ec2_domains(request):
|
|
301
301
|
@rd.urlGET('restit/servers')
|
302
302
|
@rd.login_required
|
303
303
|
def rest_on_ec2_restit_stats(request):
|
304
|
-
|
305
|
-
|
306
|
-
hostname = settings.SERVER_NAME
|
304
|
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
305
|
+
hostname = settings.SERVER_ROOT or settings.SERVER_NAME
|
307
306
|
if hostname.count(".") == 2:
|
308
|
-
hostname = hostname
|
307
|
+
hostname = hostname.split(".")[1] # Corrected to get the second part
|
308
|
+
|
309
309
|
instances = aws.getAllEC2()
|
310
310
|
hosts = [inst.name for inst in instances]
|
311
|
-
|
312
|
-
|
311
|
+
path = "versions"
|
312
|
+
params = {"detailed": 1}
|
313
|
+
if request.DATA.get("sysinfo"):
|
314
|
+
path = "system/info"
|
315
|
+
params["key"] = settings.SYS_INFO_KEY
|
316
|
+
|
317
|
+
def fetch_host_data(name):
|
313
318
|
if settings.SERVER_NAME_MAP and name in settings.SERVER_NAME_MAP:
|
314
319
|
host = settings.SERVER_NAME_MAP[name]
|
315
320
|
if "." not in host:
|
316
321
|
host = f"{name}.{hostname}"
|
317
322
|
else:
|
318
323
|
host = f"{name}.{hostname}"
|
319
|
-
|
320
|
-
|
321
|
-
f"/{REST_PREFIX}
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
324
|
+
|
325
|
+
try:
|
326
|
+
resp = net.REQUEST("GET", host, f"/{REST_PREFIX}{path}", params=params, timeout=5.0)
|
327
|
+
if resp.status:
|
328
|
+
resp.data.id = host
|
329
|
+
resp.data.hostname = host
|
330
|
+
return resp.data
|
331
|
+
else:
|
332
|
+
return dict(id=host, hostname=host)
|
333
|
+
except requests.RequestException:
|
334
|
+
return dict(id=host, hostname=host)
|
335
|
+
|
336
|
+
data = []
|
337
|
+
with ThreadPoolExecutor(max_workers=10) as executor: # Adjust max_workers as needed
|
338
|
+
futures = {executor.submit(fetch_host_data, name): name for name in hosts}
|
339
|
+
for future in as_completed(futures):
|
340
|
+
data.append(future.result())
|
341
|
+
|
330
342
|
return rv.restReturn(request, dict(data=data))
|
331
343
|
|
332
344
|
|
rest/__init__.py
CHANGED
rest/extra/hostinfo.py
CHANGED
@@ -6,6 +6,7 @@ import django
|
|
6
6
|
import version
|
7
7
|
import platform
|
8
8
|
import socket
|
9
|
+
import subprocess
|
9
10
|
|
10
11
|
|
11
12
|
try:
|
@@ -36,13 +37,19 @@ def getTcpEstablished(filter=None):
|
|
36
37
|
|
37
38
|
def filterConnections(cons, filter):
|
38
39
|
if filter == "https":
|
39
|
-
return [c for c in cons if
|
40
|
+
return [c for c in cons if c.laddr.port == 443]
|
40
41
|
elif filter == "redis":
|
41
|
-
return [c for c in cons if
|
42
|
+
return [c for c in cons if c.raddr.port == 6379]
|
42
43
|
elif filter == "postgres":
|
43
|
-
return [c for c in cons if
|
44
|
+
return [c for c in cons if c.raddr.port == 5432]
|
44
45
|
elif filter == "unknown":
|
45
|
-
return [c for c in cons if
|
46
|
+
return [c for c in cons if c.raddr.port not in [5432, 6379] and c.laddr.port != 443]
|
47
|
+
elif filter and ":" in filter:
|
48
|
+
addr, port = filter.split(':')
|
49
|
+
if addr == "raddr":
|
50
|
+
return [c for c in cons if c.raddr.port == port]
|
51
|
+
elif addr == "laddr":
|
52
|
+
return [c for c in cons if c.laddr.port == port]
|
46
53
|
return cons
|
47
54
|
|
48
55
|
|
rest/models/base.py
CHANGED
@@ -1197,7 +1197,7 @@ class RestModel(object):
|
|
1197
1197
|
can_delete = getattr(cls.RestMeta, "CAN_DELETE", False)
|
1198
1198
|
if not can_delete:
|
1199
1199
|
raise re.PermissionDeniedException(f"deletion not allowed for {cls.get_class_name()}", 438)
|
1200
|
-
count = qset.delete()
|
1200
|
+
count = qset.delete()[0]
|
1201
1201
|
return GRAPH_HELPERS.restStatus(request, True, error="delete {} items".format(count))
|
1202
1202
|
elif action == "update":
|
1203
1203
|
update_fields = request.DATA.get(["batch_data", "batch_update"])
|
rest/rpc.py
CHANGED
@@ -10,6 +10,8 @@ from django.conf import settings
|
|
10
10
|
|
11
11
|
from .decorators import url
|
12
12
|
from rest.extra import hostinfo
|
13
|
+
from ws4redis import client as redis
|
14
|
+
from django.db import connections
|
13
15
|
|
14
16
|
|
15
17
|
URL_PREFIX = ""
|
@@ -49,6 +51,27 @@ def on_get_joke(request):
|
|
49
51
|
return views.restGet(request, {"joke": joke.getRandomJoke()})
|
50
52
|
|
51
53
|
|
54
|
+
@url('status')
|
55
|
+
def on_get_status(request):
|
56
|
+
flag = True
|
57
|
+
try:
|
58
|
+
flag = redis.ping()
|
59
|
+
except Exception:
|
60
|
+
flag = False
|
61
|
+
status = dict(redis=flag, database={})
|
62
|
+
for alias in settings.DATABASES.keys():
|
63
|
+
db_conn = connections[alias]
|
64
|
+
try:
|
65
|
+
# Ensure connection with a timeout
|
66
|
+
db_conn.ensure_connection()
|
67
|
+
status["database"][alias] = True
|
68
|
+
except Exception:
|
69
|
+
flag = False
|
70
|
+
status["database"][alias] = False
|
71
|
+
if flag:
|
72
|
+
return views.restGet(request, status)
|
73
|
+
return views.restResult(request, status, 417)
|
74
|
+
|
52
75
|
@url('system/info')
|
53
76
|
def on_get_system_info(request):
|
54
77
|
key = request.DATA.get("key")
|
taskqueue/periodic.py
CHANGED
@@ -95,11 +95,11 @@ def run_cleanup(force=False, verbose=False, now=None):
|
|
95
95
|
if not settings.TQ_MASTER:
|
96
96
|
return
|
97
97
|
stale = datetime.now() - timedelta(days=TQ_DELETE_AFTER)
|
98
|
-
count = Task.objects.filter(created__lte=stale).delete()
|
98
|
+
count = Task.objects.filter(created__lte=stale).delete()[0]
|
99
99
|
if count:
|
100
100
|
logger.info("deleted {} old tasks".format(count))
|
101
101
|
stale = datetime.now() - timedelta(days=TQ_DELETE_COMPLETED_AFTER)
|
102
|
-
count = Task.objects.filter(created__lte=stale, state=TASK_STATE_COMPLETED).delete()
|
102
|
+
count = Task.objects.filter(created__lte=stale, state=TASK_STATE_COMPLETED).delete()[0]
|
103
103
|
if count:
|
104
104
|
logger.info("deleted {} old completed tasks".format(count))
|
105
105
|
|
ws4redis/client.py
CHANGED
@@ -21,6 +21,10 @@ def buildEventMessage(name=None, message=None, priority=0, model=None, model_pk=
|
|
21
21
|
return msg.toJSON(as_string=True)
|
22
22
|
|
23
23
|
|
24
|
+
def ping():
|
25
|
+
return getRedisClient().ping()
|
26
|
+
|
27
|
+
|
24
28
|
def exists(key, default=None):
|
25
29
|
c = getRedisClient()
|
26
30
|
return c.exists(key)
|
File without changes
|
File without changes
|