Remove commentjson entirely

main
Bob Mottram 2019-11-23 10:28:36 +00:00
parent ac2ab89aa6
commit ae1ce9080f
3 changed files with 6 additions and 28 deletions

View File

@ -20,7 +20,6 @@ On Arch/Parabola:
sudo pacman -S tor python-pip python-pysocks python-pycryptodome \
python-beautifulsoup4 imagemagick python-pillow \
python-numpy python-dateutil certbot
sudo pip install commentjson
```
Or on Debian:
@ -30,7 +29,7 @@ sudo apt-get -y install tor python3-pip python3-socks imagemagick \
python3-numpy python3-setuptools python3-crypto \
python3-dateutil python3-pil.imagetk python3-idna \
certbot nginx
sudo pip3 install requests commentjson beautifulsoup4 pycryptodome
sudo pip3 install requests beautifulsoup4 pycryptodome
```
## Installation

View File

@ -11,7 +11,6 @@ import time
import shutil
import datetime
import json
import commentjson
def saveJson(jsonObject: {},filename: str) -> bool:
"""Saves json to a file
@ -36,7 +35,8 @@ def loadJson(filename: str,delaySec=2) -> {}:
while tries<5:
try:
with open(filename, 'r') as fp:
jsonObject=commentjson.load(fp)
data=fp.read()
jsonObject=json.loads(data)
break
except:
print('WARN: loadJson exception')
@ -122,17 +122,7 @@ def getDisplayName(baseDir: str,actor: str,personCache: {}) -> str:
# Try to obtain from the cached actors
cachedActorFilename=baseDir+'/cache/actors/'+actor.replace('/','#')+'.json'
if os.path.isfile(cachedActorFilename):
actorJson=None
tries=0
while tries<5:
try:
with open(cachedActorFilename, 'r') as fp:
actorJson=commentjson.load(fp)
break
except:
print('WARN: getDisplayName')
time.sleep(1)
tries+=1
actorJson=loadJson(cachedActorFilename,1)
if actorJson:
if actorJson.get('name'):
return(actorJson['name'])
@ -310,18 +300,7 @@ def removeModerationPostFromIndex(baseDir: str,postUrl: str,debug: bool) -> None
def deletePost(baseDir: str,httpPrefix: str,nickname: str,domain: str,postFilename: str,debug: bool) -> None:
"""Recursively deletes a post and its replies and attachments
"""
postJsonObject=None
tries=0
while tries<5:
try:
with open(postFilename, 'r') as fp:
postJsonObject=commentjson.load(fp)
break
except:
print('WARN: deletePost')
time.sleep(1)
tries+=1
postJsonObject=loadJson(postFilename,1)
if postJsonObject:
# don't allow deletion of bookmarked posts
bookmarksIndexFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/bookmarks.index'

View File

@ -1226,7 +1226,7 @@
<p class="intro">On a Debian based system:</p>
<div class="shell">
<p>sudo apt-get -y install tor python3-pip python3-socks imagemagick python3-numpy python3-setuptools python3-crypto python3-dateutil python3-pil.imagetk python3-idna certbot nginx</p>
<p>sudo pip3 install commentjson beautifulsoup4 pycryptodome</p>
<p>sudo pip3 install beautifulsoup4 pycryptodome</p>
</div>
<p class="intro">