forked from indymedia/epicyon
Remove commentjson entirely
parent
ac2ab89aa6
commit
ae1ce9080f
|
@ -20,7 +20,6 @@ On Arch/Parabola:
|
||||||
sudo pacman -S tor python-pip python-pysocks python-pycryptodome \
|
sudo pacman -S tor python-pip python-pysocks python-pycryptodome \
|
||||||
python-beautifulsoup4 imagemagick python-pillow \
|
python-beautifulsoup4 imagemagick python-pillow \
|
||||||
python-numpy python-dateutil certbot
|
python-numpy python-dateutil certbot
|
||||||
sudo pip install commentjson
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Or on Debian:
|
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-numpy python3-setuptools python3-crypto \
|
||||||
python3-dateutil python3-pil.imagetk python3-idna \
|
python3-dateutil python3-pil.imagetk python3-idna \
|
||||||
certbot nginx
|
certbot nginx
|
||||||
sudo pip3 install requests commentjson beautifulsoup4 pycryptodome
|
sudo pip3 install requests beautifulsoup4 pycryptodome
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
29
utils.py
29
utils.py
|
@ -11,7 +11,6 @@ import time
|
||||||
import shutil
|
import shutil
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import commentjson
|
|
||||||
|
|
||||||
def saveJson(jsonObject: {},filename: str) -> bool:
|
def saveJson(jsonObject: {},filename: str) -> bool:
|
||||||
"""Saves json to a file
|
"""Saves json to a file
|
||||||
|
@ -36,7 +35,8 @@ def loadJson(filename: str,delaySec=2) -> {}:
|
||||||
while tries<5:
|
while tries<5:
|
||||||
try:
|
try:
|
||||||
with open(filename, 'r') as fp:
|
with open(filename, 'r') as fp:
|
||||||
jsonObject=commentjson.load(fp)
|
data=fp.read()
|
||||||
|
jsonObject=json.loads(data)
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
print('WARN: loadJson exception')
|
print('WARN: loadJson exception')
|
||||||
|
@ -122,17 +122,7 @@ def getDisplayName(baseDir: str,actor: str,personCache: {}) -> str:
|
||||||
# Try to obtain from the cached actors
|
# Try to obtain from the cached actors
|
||||||
cachedActorFilename=baseDir+'/cache/actors/'+actor.replace('/','#')+'.json'
|
cachedActorFilename=baseDir+'/cache/actors/'+actor.replace('/','#')+'.json'
|
||||||
if os.path.isfile(cachedActorFilename):
|
if os.path.isfile(cachedActorFilename):
|
||||||
actorJson=None
|
actorJson=loadJson(cachedActorFilename,1)
|
||||||
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
|
|
||||||
if actorJson:
|
if actorJson:
|
||||||
if actorJson.get('name'):
|
if actorJson.get('name'):
|
||||||
return(actorJson['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:
|
def deletePost(baseDir: str,httpPrefix: str,nickname: str,domain: str,postFilename: str,debug: bool) -> None:
|
||||||
"""Recursively deletes a post and its replies and attachments
|
"""Recursively deletes a post and its replies and attachments
|
||||||
"""
|
"""
|
||||||
postJsonObject=None
|
postJsonObject=loadJson(postFilename,1)
|
||||||
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
|
|
||||||
|
|
||||||
if postJsonObject:
|
if postJsonObject:
|
||||||
# don't allow deletion of bookmarked posts
|
# don't allow deletion of bookmarked posts
|
||||||
bookmarksIndexFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/bookmarks.index'
|
bookmarksIndexFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/bookmarks.index'
|
||||||
|
|
|
@ -1226,7 +1226,7 @@
|
||||||
<p class="intro">On a Debian based system:</p>
|
<p class="intro">On a Debian based system:</p>
|
||||||
<div class="shell">
|
<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 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>
|
</div>
|
||||||
|
|
||||||
<p class="intro">
|
<p class="intro">
|
||||||
|
|
Loading…
Reference in New Issue