diff --git a/comrad/backend/crypt.py b/comrad/backend/crypt.py index 5e31826..de076ae 100644 --- a/comrad/backend/crypt.py +++ b/comrad/backend/crypt.py @@ -61,10 +61,8 @@ class Crypt(Logger): # self.store = RedisStore(redis.StrictRedis()) # self.db = Vedis(self.fn) # self.db = WalrusLite(self.fn) - # import hirlite - # self.db = hirlite.Rlite(path=self.fn) - from pupdb.core import PupDB - self.db = PupDB(self.fn) + import hirlite + self.db = hirlite.Rlite(path=self.fn) def log(self,*x,**y): @@ -127,8 +125,7 @@ class Crypt(Logger): #self.store.put(k_b_hash,v_b) #with self.db.transaction(): # self.db[k_b_hash]=v_b - # return self.db.command('set',k_b_hash,v_b) - return self.db.set(k_b_hash,v_b) + return self.db.command('set',k_b_hash,v_b) # return True def exists(self,k,prefix=''): @@ -145,8 +142,7 @@ class Crypt(Logger): k_b=self.package_key(k,prefix=prefix) k_b_hash = self.hash(k_b) - # v = self.db.command('del',k_b_hash) - v = self.db.remove(k_b_hash) + v = self.db.command('del',k_b_hash) self.log('<--',v) return v @@ -160,8 +156,7 @@ class Crypt(Logger): self.log('getting k_b',k_b) self.log('getting k_b_hash',k_b_hash) - # v = self.db.command('get',k_b_hash) - v = self.db.get(k_b_hash) + v = self.db.command('get',k_b_hash) self.log('<--',v) v_b=self.unpackage_val(v) @@ -208,14 +203,7 @@ class CryptList(Crypt): # like inbox val_x = self.package_val(val) # with self.db.transaction(): # 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) - + res = self.db.command('rpush',self.keyname,val_x) self.log('-->',res) return res @@ -223,20 +211,13 @@ 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) - oldval = self.db.get(self.keyname) - if oldval: - newval = [val_x] + oldval - else: - newval = [val_x] - res=self.db.set(self.keyname, newval) + res = self.db.command('lpush',self.keyname,val_x) self.log('-->',res) return res @property def values(self): - #l = self.db.command('lrange',self.keyname, '0', '-1') - l=self.db.get(self.keyname) + l = self.db.command('lrange',self.keyname, '0', '-1') self.log('<-- l',l) if not l: return [] vals = [self.unpackage_val(x) for x in l] @@ -247,10 +228,8 @@ 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) - l = self.db.get(self.keyname) - l = [x for x in l if x!=val_x] - self.db.set(self.keyname,l) + self.db.command('lrem',self.keyname,'0',val_x) + diff --git a/comrad/backend/crypt1.py b/comrad/backend/crypt0.py similarity index 85% rename from comrad/backend/crypt1.py rename to comrad/backend/crypt0.py index de076ae..5e31826 100644 --- a/comrad/backend/crypt1.py +++ b/comrad/backend/crypt0.py @@ -61,8 +61,10 @@ class Crypt(Logger): # self.store = RedisStore(redis.StrictRedis()) # self.db = Vedis(self.fn) # self.db = WalrusLite(self.fn) - import hirlite - self.db = hirlite.Rlite(path=self.fn) + # import hirlite + # self.db = hirlite.Rlite(path=self.fn) + from pupdb.core import PupDB + self.db = PupDB(self.fn) def log(self,*x,**y): @@ -125,7 +127,8 @@ class Crypt(Logger): #self.store.put(k_b_hash,v_b) #with self.db.transaction(): # self.db[k_b_hash]=v_b - return self.db.command('set',k_b_hash,v_b) + # return self.db.command('set',k_b_hash,v_b) + return self.db.set(k_b_hash,v_b) # return True def exists(self,k,prefix=''): @@ -142,7 +145,8 @@ class Crypt(Logger): k_b=self.package_key(k,prefix=prefix) k_b_hash = self.hash(k_b) - v = self.db.command('del',k_b_hash) + # v = self.db.command('del',k_b_hash) + v = self.db.remove(k_b_hash) self.log('<--',v) return v @@ -156,7 +160,8 @@ class Crypt(Logger): self.log('getting k_b',k_b) self.log('getting k_b_hash',k_b_hash) - v = self.db.command('get',k_b_hash) + # v = self.db.command('get',k_b_hash) + v = self.db.get(k_b_hash) self.log('<--',v) v_b=self.unpackage_val(v) @@ -203,7 +208,14 @@ class CryptList(Crypt): # like inbox val_x = self.package_val(val) # with self.db.transaction(): # res = self.db.lpush(self.keyname,val_x) - res = self.db.command('rpush',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 @@ -211,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] @@ -228,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/requirements.txt b/requirements.txt index 268e199..01c3787 100644 --- a/requirements.txt +++ b/requirements.txt @@ -62,4 +62,4 @@ utm==0.6.0 watchdog==0.10.3 Werkzeug==1.0.1 wrapt==1.12.1 -pupdb \ No newline at end of file +hirlite \ No newline at end of file diff --git a/script/install b/script/install index 87302c5..60ce3b6 100644 --- a/script/install +++ b/script/install @@ -297,19 +297,18 @@ python -m pip install -r requirements.txt ############################################################# -# echo ' -# Installing other requirements - -# Rlite, hardware based redis database +echo ' +Installing other requirements -# ' +Rlite, hardware based redis database -# cd $path_lib -# git clone https://github.com/seppo0010/rlite.git -# cd rlite -# make -# make all +' +cd $path_lib +git clone https://github.com/seppo0010/rlite.git +cd rlite +make +make all # exit 1 @@ -393,8 +392,15 @@ else fi -echo -e "Installation successful! +echo -e "Installation successful!" +if [ "$machine" = "Mac" ] +then + cd /Applications + unzip -q -o "$path_bin/Comrad.app.zip" + echo "You may run the app by looking for 'Comrad.app' in your /Applications folder." +else + echo -e " You can run Comrad with: @@ -416,13 +422,6 @@ or: ~/comrad/code/bin/comrad-cli " - - -if [ "$machine" = "Mac" ] -then - cd /Applications - unzip -q -o "$path_bin/Comrad.app.zip" - echo "You may run the app by looking for 'Comrad.app' in your /Applications folder." fi