From 8298f401d95405af200547c3c7dc9db3663ae0e5 Mon Sep 17 00:00:00 2001 From: marxzuckerburg Date: Mon, 5 Oct 2020 09:21:13 +0100 Subject: [PATCH] !!! --- comrad/__init__.py | 2 +- comrad/backend/crypt.py | 23 +++++++++++++++++++---- comrad/utils.py | 2 +- requirements.txt | 1 - 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/comrad/__init__.py b/comrad/__init__.py index 4df33fa..3c8c65a 100644 --- a/comrad/__init__.py +++ b/comrad/__init__.py @@ -7,7 +7,7 @@ from .cli.artcode import * import os,sys from collections import defaultdict from base64 import b64encode,b64decode -import ujson as json +import json import binascii,asyncio from pprint import pprint diff --git a/comrad/backend/crypt.py b/comrad/backend/crypt.py index 27a8fb8..5e31826 100644 --- a/comrad/backend/crypt.py +++ b/comrad/backend/crypt.py @@ -210,6 +210,12 @@ class CryptList(Crypt): # like inbox # res = self.db.lpush(self.keyname,val_x) # res = self.db.command('rpush',self.keyname,val_x) oldval = self.db.get(self.keyname) + if oldval: + newval = oldval + [val_x] + else: + newval = [val_x] + res=self.db.set(self.keyname, newval) + self.log('-->',res) return res @@ -217,13 +223,20 @@ class CryptList(Crypt): # like inbox self.log('<--val',val) if type(val)==list: return [self.prepend(x) for x in val] val_x = self.package_val(val) - res = self.db.command('lpush',self.keyname,val_x) + # res = self.db.command('lpush',self.keyname,val_x) + oldval = self.db.get(self.keyname) + if oldval: + newval = [val_x] + oldval + else: + newval = [val_x] + res=self.db.set(self.keyname, newval) self.log('-->',res) return res @property def values(self): - l = self.db.command('lrange',self.keyname, '0', '-1') + #l = self.db.command('lrange',self.keyname, '0', '-1') + l=self.db.get(self.keyname) self.log('<-- l',l) if not l: return [] vals = [self.unpackage_val(x) for x in l] @@ -234,8 +247,10 @@ class CryptList(Crypt): # like inbox self.log('<--',val) if type(val)==list: return [self.remove(x) for x in val] val_x = self.package_val(val) - self.db.command('lrem',self.keyname,'0',val_x) - + #self.db.command('lrem',self.keyname,'0',val_x) + l = self.db.get(self.keyname) + l = [x for x in l if x!=val_x] + self.db.set(self.keyname,l) diff --git a/comrad/utils.py b/comrad/utils.py index c9ba282..089e539 100644 --- a/comrad/utils.py +++ b/comrad/utils.py @@ -307,8 +307,8 @@ def hasher(dat,secret=None): from base64 import b64encode,b64decode -import ujson as json import pickle +import json def package_for_transmission(data_json): # print('package_for_transmission.data_json =',data_json) diff --git a/requirements.txt b/requirements.txt index da1aae4..cd43658 100644 --- a/requirements.txt +++ b/requirements.txt @@ -60,7 +60,6 @@ toml==0.10.1 torpy==1.1.3 typed-ast u-msgpack-python==2.7.0 -ujson urllib3==1.25.10 utm==0.6.0 watchdog==0.10.3