mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of gitlab.com:bashrc2/epicyon
commit
453761f56e
3
auth.py
3
auth.py
|
|
@ -203,7 +203,7 @@ def authorize(baseDir: str, path: str, authHeader: str, debug: bool) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def createPassword(length: int = 10):
|
def createPassword(length: int):
|
||||||
validChars = 'abcdefghijklmnopqrstuvwxyz' + \
|
validChars = 'abcdefghijklmnopqrstuvwxyz' + \
|
||||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
|
||||||
return ''.join((secrets.choice(validChars) for i in range(length)))
|
return ''.join((secrets.choice(validChars) for i in range(length)))
|
||||||
|
|
@ -255,4 +255,5 @@ def recordLoginFailure(baseDir: str, ipAddress: str,
|
||||||
ipAddress + ' port 443: ' +
|
ipAddress + ' port 443: ' +
|
||||||
'Too many authentication failures [preauth]\n')
|
'Too many authentication failures [preauth]\n')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: recordLoginFailure failed ' + str(failureLog))
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
22
blocking.py
22
blocking.py
|
|
@ -517,6 +517,8 @@ def mutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
print('MUTE: cached post removed ' + cachedPostFilename)
|
print('MUTE: cached post removed ' + cachedPostFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: MUTE cached post not removed ' +
|
||||||
|
cachedPostFilename)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
print('MUTE: cached post not found ' + cachedPostFilename)
|
print('MUTE: cached post not found ' + cachedPostFilename)
|
||||||
|
|
@ -554,6 +556,9 @@ def mutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
print('MUTE: cached referenced post removed ' +
|
print('MUTE: cached referenced post removed ' +
|
||||||
cachedPostFilename)
|
cachedPostFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: ' +
|
||||||
|
'MUTE cached referenced post not removed ' +
|
||||||
|
cachedPostFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if recentPostsCache.get('json'):
|
if recentPostsCache.get('json'):
|
||||||
|
|
@ -583,6 +588,9 @@ def unmutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
try:
|
try:
|
||||||
os.remove(muteFilename)
|
os.remove(muteFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
|
print('EX: unmutePost mute filename not deleted ' +
|
||||||
|
str(muteFilename))
|
||||||
pass
|
pass
|
||||||
print('UNMUTE: ' + muteFilename + ' file removed')
|
print('UNMUTE: ' + muteFilename + ' file removed')
|
||||||
|
|
||||||
|
|
@ -631,6 +639,9 @@ def unmutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
|
print('EX: unmutePost cached post not deleted ' +
|
||||||
|
str(cachedPostFilename))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# if the post is in the recent posts cache then mark it as unmuted
|
# if the post is in the recent posts cache then mark it as unmuted
|
||||||
|
|
@ -661,6 +672,10 @@ def unmutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
print('MUTE: cached referenced post removed ' +
|
print('MUTE: cached referenced post removed ' +
|
||||||
cachedPostFilename)
|
cachedPostFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
|
print('EX: ' +
|
||||||
|
'unmutePost cached ref post not removed ' +
|
||||||
|
str(cachedPostFilename))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if recentPostsCache.get('json'):
|
if recentPostsCache.get('json'):
|
||||||
|
|
@ -804,6 +819,8 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(allowFilename)
|
os.remove(allowFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: setBrochMode allow file not deleted ' +
|
||||||
|
str(allowFilename))
|
||||||
pass
|
pass
|
||||||
print('Broch mode turned off')
|
print('Broch mode turned off')
|
||||||
else:
|
else:
|
||||||
|
|
@ -844,7 +861,7 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None:
|
||||||
setConfigParam(baseDir, "brochMode", enabled)
|
setConfigParam(baseDir, "brochMode", enabled)
|
||||||
|
|
||||||
|
|
||||||
def brochModeLapses(baseDir: str, lapseDays: int = 7) -> bool:
|
def brochModeLapses(baseDir: str, lapseDays: int) -> bool:
|
||||||
"""After broch mode is enabled it automatically
|
"""After broch mode is enabled it automatically
|
||||||
elapses after a period of time
|
elapses after a period of time
|
||||||
"""
|
"""
|
||||||
|
|
@ -857,6 +874,7 @@ def brochModeLapses(baseDir: str, lapseDays: int = 7) -> bool:
|
||||||
modifiedDate = \
|
modifiedDate = \
|
||||||
datetime.strptime(lastModified, "%Y-%m-%dT%H:%M:%SZ")
|
datetime.strptime(lastModified, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: brochModeLapses date not parsed ' + str(lastModified))
|
||||||
return False
|
return False
|
||||||
if not modifiedDate:
|
if not modifiedDate:
|
||||||
return False
|
return False
|
||||||
|
|
@ -868,6 +886,8 @@ def brochModeLapses(baseDir: str, lapseDays: int = 7) -> bool:
|
||||||
os.remove(allowFilename)
|
os.remove(allowFilename)
|
||||||
removed = True
|
removed = True
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: brochModeLapses allow file not deleted ' +
|
||||||
|
str(allowFilename))
|
||||||
pass
|
pass
|
||||||
if removed:
|
if removed:
|
||||||
setConfigParam(baseDir, "brochMode", False)
|
setConfigParam(baseDir, "brochMode", False)
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,10 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
|
print('EX: undoBookmarksCollectionEntry ' +
|
||||||
|
'unable to delete cached post file ' +
|
||||||
|
str(cachedPostFilename))
|
||||||
pass
|
pass
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
|
|
@ -160,6 +164,10 @@ def updateBookmarksCollection(recentPostsCache: {},
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
|
print('EX: updateBookmarksCollection ' +
|
||||||
|
'unable to delete cached post ' +
|
||||||
|
str(cachedPostFilename))
|
||||||
pass
|
pass
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
|
|
|
||||||
1
cache.py
1
cache.py
|
|
@ -27,6 +27,7 @@ def _removePersonFromCache(baseDir: str, personUrl: str,
|
||||||
try:
|
try:
|
||||||
os.remove(cacheFilename)
|
os.remove(cacheFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: unable to delete cached actor ' + str(cacheFilename))
|
||||||
pass
|
pass
|
||||||
if personCache.get(personUrl):
|
if personCache.get(personUrl):
|
||||||
del personCache[personUrl]
|
del personCache[personUrl]
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,9 @@ def updateHashtagCategories(baseDir: str) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(categoryListFilename)
|
os.remove(categoryListFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: updateHashtagCategories ' +
|
||||||
|
'unable to delete cached category list ' +
|
||||||
|
categoryListFilename)
|
||||||
pass
|
pass
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
16
content.py
16
content.py
|
|
@ -272,6 +272,8 @@ def replaceEmojiFromTags(content: str, tag: [], messageType: str) -> str:
|
||||||
content = content.replace(tagItem['name'],
|
content = content.replace(tagItem['name'],
|
||||||
replaceChar)
|
replaceChar)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: replaceEmojiFromTags name ' +
|
||||||
|
str(iconName))
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# sequence of codes
|
# sequence of codes
|
||||||
|
|
@ -283,6 +285,8 @@ def replaceEmojiFromTags(content: str, tag: [], messageType: str) -> str:
|
||||||
icode, 16))
|
icode, 16))
|
||||||
except BaseException:
|
except BaseException:
|
||||||
iconCodeSequence = ''
|
iconCodeSequence = ''
|
||||||
|
print('EX: replaceEmojiFromTags code ' +
|
||||||
|
str(icode))
|
||||||
break
|
break
|
||||||
if iconCodeSequence:
|
if iconCodeSequence:
|
||||||
content = content.replace(tagItem['name'],
|
content = content.replace(tagItem['name'],
|
||||||
|
|
@ -943,11 +947,19 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
try:
|
try:
|
||||||
os.remove(possibleOtherFormat)
|
os.remove(possibleOtherFormat)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
|
print('EX: saveMediaInFormPOST ' +
|
||||||
|
'unable to delete other ' +
|
||||||
|
str(possibleOtherFormat))
|
||||||
pass
|
pass
|
||||||
if os.path.isfile(filenameBase):
|
if os.path.isfile(filenameBase):
|
||||||
try:
|
try:
|
||||||
os.remove(filenameBase)
|
os.remove(filenameBase)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
|
print('EX: saveMediaInFormPOST ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
str(filenameBase))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
|
|
@ -1017,6 +1029,10 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
try:
|
try:
|
||||||
os.remove(possibleOtherFormat)
|
os.remove(possibleOtherFormat)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
|
print('EX: saveMediaInFormPOST ' +
|
||||||
|
'unable to delete other 2 ' +
|
||||||
|
str(possibleOtherFormat))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# don't allow scripts within svg files
|
# don't allow scripts within svg files
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ def updateConversation(baseDir: str, nickname: str, domain: str,
|
||||||
fp.write(postId + '\n')
|
fp.write(postId + '\n')
|
||||||
return True
|
return True
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: updateConversation ' +
|
||||||
|
'unable to write to ' + conversationFilename)
|
||||||
pass
|
pass
|
||||||
elif postId + '\n' not in open(conversationFilename).read():
|
elif postId + '\n' not in open(conversationFilename).read():
|
||||||
try:
|
try:
|
||||||
|
|
@ -53,6 +55,8 @@ def updateConversation(baseDir: str, nickname: str, domain: str,
|
||||||
fp.write(postId + '\n')
|
fp.write(postId + '\n')
|
||||||
return True
|
return True
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: updateConversation 2 ' +
|
||||||
|
'unable to write to ' + conversationFilename)
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@ -86,4 +90,6 @@ def unmuteConversation(baseDir: str, nickname: str, domain: str,
|
||||||
try:
|
try:
|
||||||
os.remove(conversationFilename + '.muted')
|
os.remove(conversationFilename + '.muted')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: unmuteConversation unable to delete ' +
|
||||||
|
conversationFilename + '.muted')
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
124
daemon.py
124
daemon.py
|
|
@ -53,6 +53,7 @@ from donate import getDonationUrl
|
||||||
from donate import setDonationUrl
|
from donate import setDonationUrl
|
||||||
from donate import getWebsite
|
from donate import getWebsite
|
||||||
from donate import setWebsite
|
from donate import setWebsite
|
||||||
|
from person import addActorUpdateTimestamp
|
||||||
from person import setPersonNotes
|
from person import setPersonNotes
|
||||||
from person import getDefaultPersonContext
|
from person import getDefaultPersonContext
|
||||||
from person import getActorUpdateJson
|
from person import getActorUpdateJson
|
||||||
|
|
@ -540,6 +541,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _sendReplyToQuestion ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
cachedPostFilename)
|
||||||
pass
|
pass
|
||||||
# remove from memory cache
|
# remove from memory cache
|
||||||
removePostFromCache(postJsonObject,
|
removePostFromCache(postJsonObject,
|
||||||
|
|
@ -822,6 +826,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(mediaFilename + '.etag', 'r') as etagFile:
|
with open(mediaFilename + '.etag', 'r') as etagFile:
|
||||||
etag = etagFile.read()
|
etag = etagFile.read()
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _set_headers_etag ' +
|
||||||
|
'unable to read ' + mediaFilename + '.etag')
|
||||||
pass
|
pass
|
||||||
if not etag:
|
if not etag:
|
||||||
etag = md5(data).hexdigest() # nosec
|
etag = md5(data).hexdigest() # nosec
|
||||||
|
|
@ -829,6 +835,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(mediaFilename + '.etag', 'w+') as etagFile:
|
with open(mediaFilename + '.etag', 'w+') as etagFile:
|
||||||
etagFile.write(etag)
|
etagFile.write(etag)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _set_headers_etag ' +
|
||||||
|
'unable to write ' + mediaFilename + '.etag')
|
||||||
pass
|
pass
|
||||||
# if etag:
|
# if etag:
|
||||||
# self.send_header('ETag', '"' + etag + '"')
|
# self.send_header('ETag', '"' + etag + '"')
|
||||||
|
|
@ -854,6 +862,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(mediaFilename, 'r') as etagFile:
|
with open(mediaFilename, 'r') as etagFile:
|
||||||
currEtag = etagFile.read()
|
currEtag = etagFile.read()
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _etag_exists unable to read ' +
|
||||||
|
str(mediaFilename))
|
||||||
pass
|
pass
|
||||||
if currEtag and oldEtag == currEtag:
|
if currEtag and oldEtag == currEtag:
|
||||||
# The file has not changed
|
# The file has not changed
|
||||||
|
|
@ -984,17 +994,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
tries += 1
|
tries += 1
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _robotsTxt(self) -> bool:
|
|
||||||
if not self.path.lower().startswith('/robot'):
|
|
||||||
return False
|
|
||||||
msg = 'User-agent: *\nDisallow: /'
|
|
||||||
msg = msg.encode('utf-8')
|
|
||||||
msglen = len(msg)
|
|
||||||
self._set_headers('text/plain; charset=utf-8', msglen,
|
|
||||||
None, self.server.domainFull, True)
|
|
||||||
self._write(msg)
|
|
||||||
return True
|
|
||||||
|
|
||||||
def _hasAccept(self, callingDomain: str) -> bool:
|
def _hasAccept(self, callingDomain: str) -> bool:
|
||||||
"""Do the http headers have an Accept field?
|
"""Do the http headers have an Accept field?
|
||||||
"""
|
"""
|
||||||
|
|
@ -2339,6 +2338,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(newswireBlockedFilename)
|
os.remove(newswireBlockedFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _personOptions unable to delete ' +
|
||||||
|
newswireBlockedFilename)
|
||||||
pass
|
pass
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
else:
|
else:
|
||||||
|
|
@ -2377,6 +2378,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(featuresBlockedFilename)
|
os.remove(featuresBlockedFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _personOptions unable to delete ' +
|
||||||
|
featuresBlockedFilename)
|
||||||
pass
|
pass
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
else:
|
else:
|
||||||
|
|
@ -2415,6 +2418,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(newswireModFilename)
|
os.remove(newswireModFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _personOptions unable to delete ' +
|
||||||
|
newswireModFilename)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(accountDir):
|
if os.path.isdir(accountDir):
|
||||||
|
|
@ -3848,6 +3853,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(linksFilename)
|
os.remove(linksFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _linksUpdate unable to delete ' +
|
||||||
|
linksFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
adminNickname = \
|
adminNickname = \
|
||||||
|
|
@ -3864,6 +3871,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(aboutFilename)
|
os.remove(aboutFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _linksUpdate unable to delete ' +
|
||||||
|
aboutFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if fields.get('editedTOS'):
|
if fields.get('editedTOS'):
|
||||||
|
|
@ -3877,6 +3886,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(TOSFilename)
|
os.remove(TOSFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _linksUpdate unable to delete ' +
|
||||||
|
TOSFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
|
|
@ -3978,6 +3989,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(categoryFilename)
|
os.remove(categoryFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setHashtagCategory unable to delete ' +
|
||||||
|
categoryFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
|
|
@ -4059,6 +4072,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(newswireFilename)
|
os.remove(newswireFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _newswireUpdate unable to delete ' +
|
||||||
|
newswireFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# save filtered words list for the newswire
|
# save filtered words list for the newswire
|
||||||
|
|
@ -4073,6 +4088,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(filterNewswireFilename)
|
os.remove(filterNewswireFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _newswireUpdate unable to delete ' +
|
||||||
|
filterNewswireFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# save news tagging rules
|
# save news tagging rules
|
||||||
|
|
@ -4086,6 +4103,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(hashtagRulesFilename)
|
os.remove(hashtagRulesFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _newswireUpdate unable to delete ' +
|
||||||
|
hashtagRulesFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
newswireTrustedFilename = baseDir + '/accounts/newswiretrusted.txt'
|
newswireTrustedFilename = baseDir + '/accounts/newswiretrusted.txt'
|
||||||
|
|
@ -4100,6 +4119,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(newswireTrustedFilename)
|
os.remove(newswireTrustedFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _newswireUpdate unable to delete ' +
|
||||||
|
newswireTrustedFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
|
|
@ -4128,6 +4149,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(citationsFilename)
|
os.remove(citationsFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _citationsUpdate unable to delete ' +
|
||||||
|
citationsFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if newswire and \
|
if newswire and \
|
||||||
|
|
@ -4433,6 +4456,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(filenameBase)
|
os.remove(filenameBase)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate unable to delete ' +
|
||||||
|
filenameBase)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
filenameBase = \
|
filenameBase = \
|
||||||
|
|
@ -4468,6 +4493,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(postImageFilename + '.etag')
|
os.remove(postImageFilename + '.etag')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate unable to delete ' +
|
||||||
|
postImageFilename + '.etag')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
city = getSpoofedCity(self.server.city,
|
city = getSpoofedCity(self.server.city,
|
||||||
|
|
@ -5503,6 +5530,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
os.remove(baseDir +
|
os.remove(baseDir +
|
||||||
'/fonts/custom.' + ext)
|
'/fonts/custom.' + ext)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
baseDir + '/fonts/custom.' + ext)
|
||||||
pass
|
pass
|
||||||
if os.path.isfile(baseDir +
|
if os.path.isfile(baseDir +
|
||||||
'/fonts/custom.' + ext +
|
'/fonts/custom.' + ext +
|
||||||
|
|
@ -5512,6 +5542,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'/fonts/custom.' + ext +
|
'/fonts/custom.' + ext +
|
||||||
'.etag')
|
'.etag')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
baseDir + '/fonts/custom.' +
|
||||||
|
ext + '.etag')
|
||||||
pass
|
pass
|
||||||
currTheme = getTheme(baseDir)
|
currTheme = getTheme(baseDir)
|
||||||
if currTheme:
|
if currTheme:
|
||||||
|
|
@ -5563,6 +5597,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(followDMsFilename)
|
os.remove(followDMsFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
followDMsFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# remove Twitter retweets
|
# remove Twitter retweets
|
||||||
|
|
@ -5581,6 +5618,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(removeTwitterFilename)
|
os.remove(removeTwitterFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
removeTwitterFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# hide Like button
|
# hide Like button
|
||||||
|
|
@ -5601,12 +5641,18 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(notifyLikesFilename)
|
os.remove(notifyLikesFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
notifyLikesFilename)
|
||||||
pass
|
pass
|
||||||
if not hideLikeButtonActive:
|
if not hideLikeButtonActive:
|
||||||
if os.path.isfile(hideLikeButtonFile):
|
if os.path.isfile(hideLikeButtonFile):
|
||||||
try:
|
try:
|
||||||
os.remove(hideLikeButtonFile)
|
os.remove(hideLikeButtonFile)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
hideLikeButtonFile)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# notify about new Likes
|
# notify about new Likes
|
||||||
|
|
@ -5628,6 +5674,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(notifyLikesFilename)
|
os.remove(notifyLikesFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
notifyLikesFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# this account is a bot
|
# this account is a bot
|
||||||
|
|
@ -5690,6 +5739,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(filterFilename)
|
os.remove(filterFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
filterFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# word replacements
|
# word replacements
|
||||||
|
|
@ -5704,6 +5756,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(switchFilename)
|
os.remove(switchFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
switchFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# autogenerated tags
|
# autogenerated tags
|
||||||
|
|
@ -5718,6 +5773,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(autoTagsFilename)
|
os.remove(autoTagsFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
autoTagsFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# autogenerated content warnings
|
# autogenerated content warnings
|
||||||
|
|
@ -5732,6 +5790,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(autoCWFilename)
|
os.remove(autoCWFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
autoCWFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# save blocked accounts list
|
# save blocked accounts list
|
||||||
|
|
@ -5746,6 +5807,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(blockedFilename)
|
os.remove(blockedFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
blockedFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Save DM allowed instances list.
|
# Save DM allowed instances list.
|
||||||
|
|
@ -5762,6 +5826,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(dmAllowedInstancesFilename)
|
os.remove(dmAllowedInstancesFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
dmAllowedInstancesFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# save allowed instances list
|
# save allowed instances list
|
||||||
|
|
@ -5777,6 +5844,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(allowedInstancesFilename)
|
os.remove(allowedInstancesFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
allowedInstancesFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if isModerator(self.server.baseDir, nickname):
|
if isModerator(self.server.baseDir, nickname):
|
||||||
|
|
@ -5840,6 +5910,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(peertubeInstancesFile)
|
os.remove(peertubeInstancesFile)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
peertubeInstancesFile)
|
||||||
pass
|
pass
|
||||||
self.server.peertubeInstances.clear()
|
self.server.peertubeInstances.clear()
|
||||||
|
|
||||||
|
|
@ -5855,6 +5928,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(gitProjectsFilename)
|
os.remove(gitProjectsFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _profileUpdate ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
gitProjectsFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# save actor json file within accounts
|
# save actor json file within accounts
|
||||||
|
|
@ -5874,13 +5950,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
actorJson['featuredTags'] = \
|
actorJson['featuredTags'] = \
|
||||||
actorJson['id'] + '/collections/tags'
|
actorJson['id'] + '/collections/tags'
|
||||||
randomizeActorImages(actorJson)
|
randomizeActorImages(actorJson)
|
||||||
# add an updated timestamp to the actor
|
addActorUpdateTimestamp(actorJson)
|
||||||
updatedTime = datetime.datetime.utcnow()
|
|
||||||
actorJson['updated'] = \
|
|
||||||
updatedTime.strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
||||||
# add updated timestamp to avatar and banner
|
|
||||||
actorJson['icon']['updated'] = actorJson['updated']
|
|
||||||
actorJson['image']['updated'] = actorJson['updated']
|
|
||||||
# save the actor
|
# save the actor
|
||||||
saveJson(actorJson, actorFilename)
|
saveJson(actorJson, actorFilename)
|
||||||
webfingerUpdate(baseDir,
|
webfingerUpdate(baseDir,
|
||||||
|
|
@ -13300,14 +13370,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'_GET', 'show about screen done',
|
'_GET', 'show about screen done',
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
|
|
||||||
# send robots.txt if asked
|
|
||||||
if self._robotsTxt():
|
|
||||||
return
|
|
||||||
|
|
||||||
fitnessPerformance(GETstartTime, self.server.fitness,
|
|
||||||
'_GET', 'robots txt',
|
|
||||||
self.server.debug)
|
|
||||||
|
|
||||||
# the initial welcome screen after first logging in
|
# the initial welcome screen after first logging in
|
||||||
if htmlGET and authorized and \
|
if htmlGET and authorized and \
|
||||||
'/users/' in self.path and self.path.endswith('/welcome'):
|
'/users/' in self.path and self.path.endswith('/welcome'):
|
||||||
|
|
@ -15106,6 +15168,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(mediaTagFilename, 'r') as etagFile:
|
with open(mediaTagFilename, 'r') as etagFile:
|
||||||
etag = etagFile.read()
|
etag = etagFile.read()
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: do_HEAD unable to read ' +
|
||||||
|
mediaTagFilename)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
with open(mediaFilename, 'rb') as avFile:
|
with open(mediaFilename, 'rb') as avFile:
|
||||||
|
|
@ -15115,6 +15179,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(mediaTagFilename, 'w+') as etagFile:
|
with open(mediaTagFilename, 'w+') as etagFile:
|
||||||
etagFile.write(etag)
|
etagFile.write(etag)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: do_HEAD unable to write ' +
|
||||||
|
mediaTagFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
mediaFileType = mediaFileMimeType(checkPath)
|
mediaFileType = mediaFileMimeType(checkPath)
|
||||||
|
|
@ -15281,6 +15347,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(lastUsedFilename, 'w+') as lastUsedFile:
|
with open(lastUsedFilename, 'w+') as lastUsedFile:
|
||||||
lastUsedFile.write(str(int(time.time())))
|
lastUsedFile.write(str(int(time.time())))
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _receiveNewPostProcess unable to write ' +
|
||||||
|
lastUsedFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
mentionsStr = ''
|
mentionsStr = ''
|
||||||
|
|
@ -15444,6 +15512,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedFilename)
|
os.remove(cachedFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _receiveNewPostProcess ' +
|
||||||
|
'unable to delete ' + cachedFilename)
|
||||||
pass
|
pass
|
||||||
# remove from memory cache
|
# remove from memory cache
|
||||||
removePostFromCache(postJsonObject,
|
removePostFromCache(postJsonObject,
|
||||||
|
|
@ -15867,6 +15937,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _receiveNewPostProcess ' +
|
||||||
|
'unable to delete ' + filename)
|
||||||
pass
|
pass
|
||||||
self.postToNickname = nickname
|
self.postToNickname = nickname
|
||||||
return 1
|
return 1
|
||||||
|
|
|
||||||
|
|
@ -202,4 +202,5 @@ def removeOldHashtags(baseDir: str, maxMonths: int) -> str:
|
||||||
try:
|
try:
|
||||||
os.remove(removeFilename)
|
os.remove(removeFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: removeOldHashtags unable to delete ' + removeFilename)
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -954,9 +954,9 @@ def _desktopShowBox(indent: str,
|
||||||
yourActor: str, boxName: str, boxJson: {},
|
yourActor: str, boxName: str, boxJson: {},
|
||||||
translate: {},
|
translate: {},
|
||||||
screenreader: str, systemLanguage: str, espeak,
|
screenreader: str, systemLanguage: str, espeak,
|
||||||
pageNumber: int = 1,
|
pageNumber: int,
|
||||||
newReplies: bool = False,
|
newReplies: bool,
|
||||||
newDMs: bool = False) -> bool:
|
newDMs: bool) -> bool:
|
||||||
"""Shows online timeline
|
"""Shows online timeline
|
||||||
"""
|
"""
|
||||||
numberWidth = 2
|
numberWidth = 2
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ def E2EEremoveDevice(baseDir: str, nickname: str, domain: str,
|
||||||
try:
|
try:
|
||||||
os.remove(deviceFilename)
|
os.remove(deviceFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: E2EEremoveDevice unable to delete ' + deviceFilename)
|
||||||
pass
|
pass
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
19
epicyon.py
19
epicyon.py
|
|
@ -883,6 +883,7 @@ if args.socnet:
|
||||||
fp.write(dotGraph)
|
fp.write(dotGraph)
|
||||||
print('Saved to socnet.dot')
|
print('Saved to socnet.dot')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: commandline unable to write socnet.dot')
|
||||||
pass
|
pass
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
@ -2100,7 +2101,7 @@ if args.followers:
|
||||||
'Accept': 'application/activity+json; profile="' + profileStr + '"'
|
'Accept': 'application/activity+json; profile="' + profileStr + '"'
|
||||||
}
|
}
|
||||||
if not personUrl:
|
if not personUrl:
|
||||||
personUrl = getUserUrl(wfRequest)
|
personUrl = getUserUrl(wfRequest, 0, args.debug)
|
||||||
if nickname == domain:
|
if nickname == domain:
|
||||||
personUrl = personUrl.replace('/users/', '/actor/')
|
personUrl = personUrl.replace('/users/', '/actor/')
|
||||||
personUrl = personUrl.replace('/accounts/', '/actor/')
|
personUrl = personUrl.replace('/accounts/', '/actor/')
|
||||||
|
|
@ -2126,7 +2127,7 @@ if args.followers:
|
||||||
followersList = \
|
followersList = \
|
||||||
downloadFollowCollection(signingPrivateKeyPem,
|
downloadFollowCollection(signingPrivateKeyPem,
|
||||||
'followers', session,
|
'followers', session,
|
||||||
httpPrefix, personUrl, 1, 3)
|
httpPrefix, personUrl, 1, 3, args.debug)
|
||||||
if followersList:
|
if followersList:
|
||||||
for actor in followersList:
|
for actor in followersList:
|
||||||
print(actor)
|
print(actor)
|
||||||
|
|
@ -2673,17 +2674,19 @@ if args.testdata:
|
||||||
print('Generating some test data for user: ' + nickname)
|
print('Generating some test data for user: ' + nickname)
|
||||||
|
|
||||||
if os.path.isdir(baseDir + '/tags'):
|
if os.path.isdir(baseDir + '/tags'):
|
||||||
shutil.rmtree(baseDir + '/tags')
|
shutil.rmtree(baseDir + '/tags', ignore_errors=False, onerror=None)
|
||||||
if os.path.isdir(baseDir + '/accounts'):
|
if os.path.isdir(baseDir + '/accounts'):
|
||||||
shutil.rmtree(baseDir + '/accounts')
|
shutil.rmtree(baseDir + '/accounts', ignore_errors=False, onerror=None)
|
||||||
if os.path.isdir(baseDir + '/keys'):
|
if os.path.isdir(baseDir + '/keys'):
|
||||||
shutil.rmtree(baseDir + '/keys')
|
shutil.rmtree(baseDir + '/keys', ignore_errors=False, onerror=None)
|
||||||
if os.path.isdir(baseDir + '/media'):
|
if os.path.isdir(baseDir + '/media'):
|
||||||
shutil.rmtree(baseDir + '/media')
|
shutil.rmtree(baseDir + '/media', ignore_errors=False, onerror=None)
|
||||||
if os.path.isdir(baseDir + '/sharefiles'):
|
if os.path.isdir(baseDir + '/sharefiles'):
|
||||||
shutil.rmtree(baseDir + '/sharefiles')
|
shutil.rmtree(baseDir + '/sharefiles',
|
||||||
|
ignore_errors=False, onerror=None)
|
||||||
if os.path.isdir(baseDir + '/wfendpoints'):
|
if os.path.isdir(baseDir + '/wfendpoints'):
|
||||||
shutil.rmtree(baseDir + '/wfendpoints')
|
shutil.rmtree(baseDir + '/wfendpoints',
|
||||||
|
ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
setConfigParam(baseDir, 'registrationsRemaining',
|
setConfigParam(baseDir, 'registrationsRemaining',
|
||||||
str(maxRegistrations))
|
str(maxRegistrations))
|
||||||
|
|
|
||||||
|
|
@ -319,6 +319,7 @@ def clearFollows(baseDir: str, nickname: str, domain: str,
|
||||||
try:
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: clearFollows unable to delete ' + filename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -390,6 +391,8 @@ def getFollowingFeed(baseDir: str, domain: str, port: int, path: str,
|
||||||
try:
|
try:
|
||||||
pageNumber = int(pageNumber)
|
pageNumber = int(pageNumber)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: getFollowingFeed unable to convert to int ' +
|
||||||
|
str(pageNumber))
|
||||||
pass
|
pass
|
||||||
path = path.split('?page=')[0]
|
path = path.split('?page=')[0]
|
||||||
headerOnly = False
|
headerOnly = False
|
||||||
|
|
@ -883,6 +886,8 @@ def followedAccountAccepts(session, baseDir: str, httpPrefix: str,
|
||||||
try:
|
try:
|
||||||
os.remove(followActivityfilename)
|
os.remove(followActivityfilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: followedAccountAccepts unable to delete ' +
|
||||||
|
followActivityfilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
groupAccount = False
|
groupAccount = False
|
||||||
|
|
@ -956,6 +961,8 @@ def followedAccountRejects(session, baseDir: str, httpPrefix: str,
|
||||||
try:
|
try:
|
||||||
os.remove(followActivityfilename)
|
os.remove(followActivityfilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: followedAccountRejects unable to delete ' +
|
||||||
|
followActivityfilename)
|
||||||
pass
|
pass
|
||||||
# send the reject activity
|
# send the reject activity
|
||||||
return sendSignedJson(rejectJson, session, baseDir,
|
return sendSignedJson(rejectJson, session, baseDir,
|
||||||
|
|
|
||||||
10
happening.py
10
happening.py
|
|
@ -20,7 +20,7 @@ from utils import hasObjectDict
|
||||||
from utils import acctDir
|
from utils import acctDir
|
||||||
|
|
||||||
|
|
||||||
def _validUuid(testUuid: str, version: int = 4):
|
def _validUuid(testUuid: str, version: int):
|
||||||
"""Check if uuid_to_test is a valid UUID
|
"""Check if uuid_to_test is a valid UUID
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
|
@ -42,7 +42,7 @@ def _removeEventFromTimeline(eventId: str, tlEventsFilename: str) -> None:
|
||||||
with open(tlEventsFilename, 'w+') as fp2:
|
with open(tlEventsFilename, 'w+') as fp2:
|
||||||
fp2.write(eventsTimeline)
|
fp2.write(eventsTimeline)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('ERROR: unable to save events timeline')
|
print('EX: ERROR: unable to save events timeline')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ def saveEventPost(baseDir: str, handle: str, postId: str,
|
||||||
|
|
||||||
if eventJson.get('name') and eventJson.get('actor') and \
|
if eventJson.get('name') and eventJson.get('actor') and \
|
||||||
eventJson.get('uuid') and eventJson.get('content'):
|
eventJson.get('uuid') and eventJson.get('content'):
|
||||||
if not _validUuid(eventJson['uuid']):
|
if not _validUuid(eventJson['uuid'], 4):
|
||||||
return False
|
return False
|
||||||
print('Mobilizon type event')
|
print('Mobilizon type event')
|
||||||
# if this is a full description of an event then save it
|
# if this is a full description of an event then save it
|
||||||
|
|
@ -166,8 +166,8 @@ def _isHappeningPost(postJsonObject: {}) -> bool:
|
||||||
|
|
||||||
|
|
||||||
def getTodaysEvents(baseDir: str, nickname: str, domain: str,
|
def getTodaysEvents(baseDir: str, nickname: str, domain: str,
|
||||||
currYear: int = None, currMonthNumber: int = None,
|
currYear: int, currMonthNumber: int,
|
||||||
currDayOfMonth: int = None) -> {}:
|
currDayOfMonth: int) -> {}:
|
||||||
"""Retrieves calendar events for today
|
"""Retrieves calendar events for today
|
||||||
Returns a dictionary of lists containing Event and Place activities
|
Returns a dictionary of lists containing Event and Place activities
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -467,5 +467,5 @@ def verifyPostHeaders(httpPrefix: str, publicKeyPem: str, headers: dict,
|
||||||
return True
|
return True
|
||||||
except BaseException:
|
except BaseException:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: verifyPostHeaders pkcs1_15 verify failure')
|
print('EX: verifyPostHeaders pkcs1_15 verify failure')
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
49
inbox.py
49
inbox.py
|
|
@ -136,7 +136,7 @@ def _storeLastPostId(baseDir: str, nickname: str, domain: str,
|
||||||
with open(actorFilename, 'w+') as fp:
|
with open(actorFilename, 'w+') as fp:
|
||||||
fp.write(postId)
|
fp.write(postId)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('Unable to write last post id to ' + actorFilename)
|
print('EX: Unable to write last post id to ' + actorFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -155,7 +155,7 @@ def _updateCachedHashtagSwarm(baseDir: str, nickname: str, domain: str,
|
||||||
modifiedDate = \
|
modifiedDate = \
|
||||||
datetime.datetime.strptime(lastModified, "%Y-%m-%dT%H:%M:%SZ")
|
datetime.datetime.strptime(lastModified, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('WARN: unable to parse last modified cache date ' +
|
print('EX: unable to parse last modified cache date ' +
|
||||||
str(lastModified))
|
str(lastModified))
|
||||||
pass
|
pass
|
||||||
if modifiedDate:
|
if modifiedDate:
|
||||||
|
|
@ -180,7 +180,7 @@ def _updateCachedHashtagSwarm(baseDir: str, nickname: str, domain: str,
|
||||||
fp.write(newSwarmStr)
|
fp.write(newSwarmStr)
|
||||||
return True
|
return True
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('WARN: unable to write cached hashtag swarm ' +
|
print('EX: unable to write cached hashtag swarm ' +
|
||||||
cachedHashtagSwarmFilename)
|
cachedHashtagSwarmFilename)
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
@ -911,6 +911,8 @@ def _receiveUpdateToQuestion(recentPostsCache: {}, messageJson: {},
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _receiveUpdateToQuestion unable to delete ' +
|
||||||
|
cachedPostFilename)
|
||||||
pass
|
pass
|
||||||
# remove from memory cache
|
# remove from memory cache
|
||||||
removePostFromCache(messageJson, recentPostsCache)
|
removePostFromCache(messageJson, recentPostsCache)
|
||||||
|
|
@ -1659,6 +1661,8 @@ def _receiveAnnounce(recentPostsCache: {},
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _receiveAnnounce unable to delete ' +
|
||||||
|
str(postFilename))
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if debug:
|
if debug:
|
||||||
|
|
@ -1684,7 +1688,7 @@ def _receiveAnnounce(recentPostsCache: {},
|
||||||
if '/statuses/' in lookupActor:
|
if '/statuses/' in lookupActor:
|
||||||
lookupActor = lookupActor.split('/statuses/')[0]
|
lookupActor = lookupActor.split('/statuses/')[0]
|
||||||
|
|
||||||
if isRecentPost(postJsonObject):
|
if isRecentPost(postJsonObject, 3):
|
||||||
if not os.path.isfile(postFilename + '.tts'):
|
if not os.path.isfile(postFilename + '.tts'):
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
updateSpeaker(baseDir, httpPrefix,
|
updateSpeaker(baseDir, httpPrefix,
|
||||||
|
|
@ -1772,6 +1776,8 @@ def _receiveUndoAnnounce(recentPostsCache: {},
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _receiveUndoAnnounce unable to delete ' +
|
||||||
|
str(postFilename))
|
||||||
pass
|
pass
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
@ -2113,14 +2119,14 @@ def _likeNotify(baseDir: str, domain: str, onionDomain: str,
|
||||||
with open(prevLikeFile, 'w+') as fp:
|
with open(prevLikeFile, 'w+') as fp:
|
||||||
fp.write(likeStr)
|
fp.write(likeStr)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('ERROR: unable to save previous like notification ' +
|
print('EX: ERROR: unable to save previous like notification ' +
|
||||||
prevLikeFile)
|
prevLikeFile)
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
with open(likeFile, 'w+') as fp:
|
with open(likeFile, 'w+') as fp:
|
||||||
fp.write(likeStr)
|
fp.write(likeStr)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('ERROR: unable to write like notification file ' +
|
print('EX: ERROR: unable to write like notification file ' +
|
||||||
likeFile)
|
likeFile)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -2939,7 +2945,7 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
print('ERROR: unable to update ' + boxname + ' index')
|
print('ERROR: unable to update ' + boxname + ' index')
|
||||||
else:
|
else:
|
||||||
if boxname == 'inbox':
|
if boxname == 'inbox':
|
||||||
if isRecentPost(postJsonObject):
|
if isRecentPost(postJsonObject, 3):
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
updateSpeaker(baseDir, httpPrefix,
|
updateSpeaker(baseDir, httpPrefix,
|
||||||
nickname, domain, domainFull,
|
nickname, domain, domainFull,
|
||||||
|
|
@ -3036,6 +3042,7 @@ def clearQueueItems(baseDir: str, queue: []) -> None:
|
||||||
os.remove(os.path.join(queueDir, qfile))
|
os.remove(os.path.join(queueDir, qfile))
|
||||||
ctr += 1
|
ctr += 1
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: clearQueueItems unable to delete ' + qfile)
|
||||||
pass
|
pass
|
||||||
break
|
break
|
||||||
break
|
break
|
||||||
|
|
@ -3102,6 +3109,8 @@ def _inboxQuotaExceeded(queue: {}, queueFilename: str,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _inboxQuotaExceeded unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
return True
|
return True
|
||||||
|
|
@ -3123,6 +3132,8 @@ def _inboxQuotaExceeded(queue: {}, queueFilename: str,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _inboxQuotaExceeded unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
return True
|
return True
|
||||||
|
|
@ -3143,6 +3154,8 @@ def _inboxQuotaExceeded(queue: {}, queueFilename: str,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _inboxQuotaExceeded unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
return True
|
return True
|
||||||
|
|
@ -3165,6 +3178,8 @@ def _inboxQuotaExceeded(queue: {}, queueFilename: str,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _inboxQuotaExceeded unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
return True
|
return True
|
||||||
|
|
@ -3348,6 +3363,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: runInboxQueue 1 unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -3421,6 +3438,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: runInboxQueue 2 unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
|
|
@ -3472,6 +3491,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: runInboxQueue 3 unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
|
|
@ -3492,6 +3513,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: runInboxQueue 4 unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
|
|
@ -3521,6 +3544,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: runInboxQueue 5 unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
|
|
@ -3542,6 +3567,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: runInboxQueue 6 unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
|
|
@ -3563,6 +3590,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: runInboxQueue 7 unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
|
|
@ -3584,6 +3613,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: runInboxQueue 8 unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
|
|
@ -3602,6 +3633,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: runInboxQueue 9 unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
|
|
@ -3680,6 +3713,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: runInboxQueue 10 unable to delete ' +
|
||||||
|
str(queueFilename))
|
||||||
pass
|
pass
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ def libretranslate(url: str, text: str,
|
||||||
try:
|
try:
|
||||||
response = request.urlopen(req)
|
response = request.urlopen(req)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('Unable to translate: ' + text)
|
print('EX: Unable to translate: ' + text)
|
||||||
return originalText
|
return originalText
|
||||||
|
|
||||||
response_str = response.read().decode()
|
response_str = response.read().decode()
|
||||||
|
|
|
||||||
2
like.py
2
like.py
|
|
@ -431,6 +431,8 @@ def updateLikesCollection(recentPostsCache: {},
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: updateLikesCollection unable to delete ' +
|
||||||
|
cachedPostFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
obj = postJsonObject
|
obj = postJsonObject
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ def verifyJsonSignature(doc: {}, publicKeyPem: str) -> bool:
|
||||||
hazutils.Prehashed(hashes.SHA256()))
|
hazutils.Prehashed(hashes.SHA256()))
|
||||||
return True
|
return True
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: verifyJsonSignature unable to verify')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -255,11 +255,15 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
try:
|
try:
|
||||||
os.remove(followActivityfilename)
|
os.remove(followActivityfilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: manualApproveFollowRequest unable to delete ' +
|
||||||
|
followActivityfilename)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
os.remove(approveFollowsFilename + '.new')
|
os.remove(approveFollowsFilename + '.new')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: manualApproveFollowRequest unable to delete ' +
|
||||||
|
approveFollowsFilename + '.new')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
15
media.py
15
media.py
|
|
@ -126,6 +126,7 @@ def _spoofMetaData(baseDir: str, nickname: str, domain: str,
|
||||||
with open(decoySeedFilename, 'w+') as fp:
|
with open(decoySeedFilename, 'w+') as fp:
|
||||||
fp.write(str(decoySeed))
|
fp.write(str(decoySeed))
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: unable to write ' + decoySeedFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if os.path.isfile('/usr/bin/exiftool'):
|
if os.path.isfile('/usr/bin/exiftool'):
|
||||||
|
|
@ -166,6 +167,8 @@ def convertImageToLowBandwidth(imageFilename: str) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(lowBandwidthFilename)
|
os.remove(lowBandwidthFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: convertImageToLowBandwidth unable to delete ' +
|
||||||
|
lowBandwidthFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
cmd = \
|
cmd = \
|
||||||
|
|
@ -187,6 +190,8 @@ def convertImageToLowBandwidth(imageFilename: str) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(imageFilename)
|
os.remove(imageFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: convertImageToLowBandwidth unable to delete ' +
|
||||||
|
imageFilename)
|
||||||
pass
|
pass
|
||||||
os.rename(lowBandwidthFilename, imageFilename)
|
os.rename(lowBandwidthFilename, imageFilename)
|
||||||
if os.path.isfile(imageFilename):
|
if os.path.isfile(imageFilename):
|
||||||
|
|
@ -273,6 +278,7 @@ def _updateEtag(mediaFilename: str) -> None:
|
||||||
with open(mediaFilename, 'rb') as mediaFile:
|
with open(mediaFilename, 'rb') as mediaFile:
|
||||||
data = mediaFile.read()
|
data = mediaFile.read()
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _updateEtag unable to read ' + str(mediaFilename))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not data:
|
if not data:
|
||||||
|
|
@ -284,6 +290,8 @@ def _updateEtag(mediaFilename: str) -> None:
|
||||||
with open(mediaFilename + '.etag', 'w+') as etagFile:
|
with open(mediaFilename + '.etag', 'w+') as etagFile:
|
||||||
etagFile.write(etag)
|
etagFile.write(etag)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _updateEtag unable to write ' +
|
||||||
|
str(mediaFilename) + '.etag')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -357,8 +365,7 @@ def attachMedia(baseDir: str, httpPrefix: str,
|
||||||
return postJson
|
return postJson
|
||||||
|
|
||||||
|
|
||||||
def archiveMedia(baseDir: str, archiveDirectory: str,
|
def archiveMedia(baseDir: str, archiveDirectory: str, maxWeeks: int) -> None:
|
||||||
maxWeeks: int = 4) -> None:
|
|
||||||
"""Any media older than the given number of weeks gets archived
|
"""Any media older than the given number of weeks gets archived
|
||||||
"""
|
"""
|
||||||
if maxWeeks == 0:
|
if maxWeeks == 0:
|
||||||
|
|
@ -382,7 +389,8 @@ def archiveMedia(baseDir: str, archiveDirectory: str,
|
||||||
archiveDirectory + '/media')
|
archiveDirectory + '/media')
|
||||||
else:
|
else:
|
||||||
# archive to /dev/null
|
# archive to /dev/null
|
||||||
rmtree(os.path.join(baseDir + '/media', weekDir))
|
rmtree(os.path.join(baseDir + '/media', weekDir),
|
||||||
|
ignore_errors=False, onerror=None)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -407,6 +415,7 @@ def getImageDimensions(imageFilename: str) -> (int, int):
|
||||||
result = subprocess.run(['identify', '-format', '"%wx%h"',
|
result = subprocess.run(['identify', '-format', '"%wx%h"',
|
||||||
imageFilename], stdout=subprocess.PIPE)
|
imageFilename], stdout=subprocess.PIPE)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: getImageDimensions unable to run identify command')
|
||||||
return None, None
|
return None, None
|
||||||
if not result:
|
if not result:
|
||||||
return None, None
|
return None, None
|
||||||
|
|
|
||||||
|
|
@ -471,7 +471,7 @@ def _createNewsMirror(baseDir: str, domain: str,
|
||||||
postId = postId.strip()
|
postId = postId.strip()
|
||||||
mirrorArticleDir = mirrorDir + '/' + postId
|
mirrorArticleDir = mirrorDir + '/' + postId
|
||||||
if os.path.isdir(mirrorArticleDir):
|
if os.path.isdir(mirrorArticleDir):
|
||||||
rmtree(mirrorArticleDir)
|
rmtree(mirrorArticleDir, ignore_errors=False, onerror=None)
|
||||||
removals.append(postId)
|
removals.append(postId)
|
||||||
noOfDirs -= 1
|
noOfDirs -= 1
|
||||||
|
|
||||||
|
|
@ -555,12 +555,12 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
dateStrWithOffset = \
|
dateStrWithOffset = \
|
||||||
datetime.datetime.strptime(dateStr, "%Y-%m-%d %H:%M:%S%z")
|
datetime.datetime.strptime(dateStr, "%Y-%m-%d %H:%M:%S%z")
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('Newswire strptime failed ' + str(dateStr))
|
print('EX: Newswire strptime failed ' + str(dateStr))
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
dateStr = dateStrWithOffset.strftime("%Y-%m-%dT%H:%M:%SZ")
|
dateStr = dateStrWithOffset.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('Newswire dateStrWithOffset failed ' +
|
print('EX: Newswire dateStrWithOffset failed ' +
|
||||||
str(dateStrWithOffset))
|
str(dateStrWithOffset))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -726,6 +726,8 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
try:
|
try:
|
||||||
os.remove(filename + '.arrived')
|
os.remove(filename + '.arrived')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _convertRSStoActivityPub ' +
|
||||||
|
'unable to delete ' + filename + '.arrived')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# setting the url here links to the activitypub object
|
# setting the url here links to the activitypub object
|
||||||
|
|
@ -839,6 +841,8 @@ def runNewswireDaemon(baseDir: str, httpd,
|
||||||
try:
|
try:
|
||||||
os.remove(refreshFilename)
|
os.remove(refreshFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: runNewswireDaemon unable to delete ' +
|
||||||
|
str(refreshFilename))
|
||||||
pass
|
pass
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
||||||
21
newswire.py
21
newswire.py
|
|
@ -132,8 +132,8 @@ def _addNewswireDictEntry(baseDir: str, domain: str,
|
||||||
votesStatus: str, postFilename: str,
|
votesStatus: str, postFilename: str,
|
||||||
description: str, moderated: bool,
|
description: str, moderated: bool,
|
||||||
mirrored: bool,
|
mirrored: bool,
|
||||||
tags: [] = [],
|
tags: [],
|
||||||
maxTags: int = 32) -> None:
|
maxTags: int) -> None:
|
||||||
"""Update the newswire dictionary
|
"""Update the newswire dictionary
|
||||||
"""
|
"""
|
||||||
# remove any markup
|
# remove any markup
|
||||||
|
|
@ -229,8 +229,7 @@ def parseFeedDate(pubDate: str) -> str:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
publishedDate = \
|
publishedDate = datetime.strptime(pubDate, dateFormat)
|
||||||
datetime.strptime(pubDate, dateFormat)
|
|
||||||
except BaseException:
|
except BaseException:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -384,7 +383,7 @@ def _xml2StrToDict(baseDir: str, domain: str, xmlStr: str,
|
||||||
title, link,
|
title, link,
|
||||||
votesStatus, postFilename,
|
votesStatus, postFilename,
|
||||||
description, moderated,
|
description, moderated,
|
||||||
mirrored)
|
mirrored, [], 32)
|
||||||
postCtr += 1
|
postCtr += 1
|
||||||
if postCtr >= maxPostsPerSource:
|
if postCtr >= maxPostsPerSource:
|
||||||
break
|
break
|
||||||
|
|
@ -471,7 +470,7 @@ def _xml1StrToDict(baseDir: str, domain: str, xmlStr: str,
|
||||||
title, link,
|
title, link,
|
||||||
votesStatus, postFilename,
|
votesStatus, postFilename,
|
||||||
description, moderated,
|
description, moderated,
|
||||||
mirrored)
|
mirrored, [], 32)
|
||||||
postCtr += 1
|
postCtr += 1
|
||||||
if postCtr >= maxPostsPerSource:
|
if postCtr >= maxPostsPerSource:
|
||||||
break
|
break
|
||||||
|
|
@ -546,7 +545,7 @@ def _atomFeedToDict(baseDir: str, domain: str, xmlStr: str,
|
||||||
title, link,
|
title, link,
|
||||||
votesStatus, postFilename,
|
votesStatus, postFilename,
|
||||||
description, moderated,
|
description, moderated,
|
||||||
mirrored)
|
mirrored, [], 32)
|
||||||
postCtr += 1
|
postCtr += 1
|
||||||
if postCtr >= maxPostsPerSource:
|
if postCtr >= maxPostsPerSource:
|
||||||
break
|
break
|
||||||
|
|
@ -568,6 +567,7 @@ def _jsonFeedV1ToDict(baseDir: str, domain: str, xmlStr: str,
|
||||||
try:
|
try:
|
||||||
feedJson = json.loads(xmlStr)
|
feedJson = json.loads(xmlStr)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _jsonFeedV1ToDict unable to load json ' + str(xmlStr))
|
||||||
return {}
|
return {}
|
||||||
maxBytes = maxFeedItemSizeKb * 1024
|
maxBytes = maxFeedItemSizeKb * 1024
|
||||||
if not feedJson.get('version'):
|
if not feedJson.get('version'):
|
||||||
|
|
@ -656,7 +656,7 @@ def _jsonFeedV1ToDict(baseDir: str, domain: str, xmlStr: str,
|
||||||
title, link,
|
title, link,
|
||||||
votesStatus, postFilename,
|
votesStatus, postFilename,
|
||||||
description, moderated,
|
description, moderated,
|
||||||
mirrored)
|
mirrored, [], 32)
|
||||||
postCtr += 1
|
postCtr += 1
|
||||||
if postCtr >= maxPostsPerSource:
|
if postCtr >= maxPostsPerSource:
|
||||||
break
|
break
|
||||||
|
|
@ -727,7 +727,8 @@ def _atomFeedYTToDict(baseDir: str, domain: str, xmlStr: str,
|
||||||
result, pubDateStr,
|
result, pubDateStr,
|
||||||
title, link,
|
title, link,
|
||||||
votesStatus, postFilename,
|
votesStatus, postFilename,
|
||||||
description, moderated, mirrored)
|
description, moderated, mirrored,
|
||||||
|
[], 32)
|
||||||
postCtr += 1
|
postCtr += 1
|
||||||
if postCtr >= maxPostsPerSource:
|
if postCtr >= maxPostsPerSource:
|
||||||
break
|
break
|
||||||
|
|
@ -1045,6 +1046,8 @@ def _addBlogsToNewswire(baseDir: str, domain: str, newswire: {},
|
||||||
try:
|
try:
|
||||||
os.remove(newswireModerationFilename)
|
os.remove(newswireModerationFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _addBlogsToNewswire unable to delete ' +
|
||||||
|
str(newswireModerationFilename))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -397,6 +397,8 @@ def postMessageToOutbox(session, translate: {},
|
||||||
try:
|
try:
|
||||||
os.remove(citationsFilename)
|
os.remove(citationsFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: postMessageToOutbox unable to delete ' +
|
||||||
|
citationsFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# The following activity types get added to the index files
|
# The following activity types get added to the index files
|
||||||
|
|
|
||||||
40
person.py
40
person.py
|
|
@ -11,6 +11,7 @@ import time
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
|
import datetime
|
||||||
import pyqrcode
|
import pyqrcode
|
||||||
from random import randint
|
from random import randint
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
@ -894,6 +895,8 @@ def personBoxJson(recentPostsCache: {},
|
||||||
try:
|
try:
|
||||||
pageNumber = int(pageNumber)
|
pageNumber = int(pageNumber)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: personBoxJson unable to convert to int ' +
|
||||||
|
str(pageNumber))
|
||||||
pass
|
pass
|
||||||
path = path.split('?page=')[0]
|
path = path.split('?page=')[0]
|
||||||
headerOnly = False
|
headerOnly = False
|
||||||
|
|
@ -1034,12 +1037,14 @@ def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(saltFilename)
|
os.remove(saltFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: suspendAccount unable to delete ' + saltFilename)
|
||||||
pass
|
pass
|
||||||
tokenFilename = acctDir(baseDir, nickname, domain) + '/.token'
|
tokenFilename = acctDir(baseDir, nickname, domain) + '/.token'
|
||||||
if os.path.isfile(tokenFilename):
|
if os.path.isfile(tokenFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(tokenFilename)
|
os.remove(tokenFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: suspendAccount unable to delete ' + tokenFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
||||||
|
|
@ -1100,6 +1105,8 @@ def _removeTagsForNickname(baseDir: str, nickname: str,
|
||||||
try:
|
try:
|
||||||
tagFilename = os.path.join(directory, filename)
|
tagFilename = os.path.join(directory, filename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _removeTagsForNickname unable to join ' +
|
||||||
|
str(directory) + ' ' + str(filename))
|
||||||
continue
|
continue
|
||||||
if not os.path.isfile(tagFilename):
|
if not os.path.isfile(tagFilename):
|
||||||
continue
|
continue
|
||||||
|
|
@ -1139,38 +1146,52 @@ def removeAccount(baseDir: str, nickname: str,
|
||||||
removePassword(baseDir, nickname)
|
removePassword(baseDir, nickname)
|
||||||
_removeTagsForNickname(baseDir, nickname, domain, port)
|
_removeTagsForNickname(baseDir, nickname, domain, port)
|
||||||
if os.path.isdir(baseDir + '/deactivated/' + handle):
|
if os.path.isdir(baseDir + '/deactivated/' + handle):
|
||||||
shutil.rmtree(baseDir + '/deactivated/' + handle)
|
shutil.rmtree(baseDir + '/deactivated/' + handle,
|
||||||
|
ignore_errors=False, onerror=None)
|
||||||
if os.path.isdir(baseDir + '/accounts/' + handle):
|
if os.path.isdir(baseDir + '/accounts/' + handle):
|
||||||
shutil.rmtree(baseDir + '/accounts/' + handle)
|
shutil.rmtree(baseDir + '/accounts/' + handle,
|
||||||
|
ignore_errors=False, onerror=None)
|
||||||
if os.path.isfile(baseDir + '/accounts/' + handle + '.json'):
|
if os.path.isfile(baseDir + '/accounts/' + handle + '.json'):
|
||||||
try:
|
try:
|
||||||
os.remove(baseDir + '/accounts/' + handle + '.json')
|
os.remove(baseDir + '/accounts/' + handle + '.json')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: removeAccount unable to delete ' +
|
||||||
|
baseDir + '/accounts/' + handle + '.json')
|
||||||
pass
|
pass
|
||||||
if os.path.isfile(baseDir + '/wfendpoints/' + handle + '.json'):
|
if os.path.isfile(baseDir + '/wfendpoints/' + handle + '.json'):
|
||||||
try:
|
try:
|
||||||
os.remove(baseDir + '/wfendpoints/' + handle + '.json')
|
os.remove(baseDir + '/wfendpoints/' + handle + '.json')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: removeAccount unable to delete ' +
|
||||||
|
baseDir + '/wfendpoints/' + handle + '.json')
|
||||||
pass
|
pass
|
||||||
if os.path.isfile(baseDir + '/keys/private/' + handle + '.key'):
|
if os.path.isfile(baseDir + '/keys/private/' + handle + '.key'):
|
||||||
try:
|
try:
|
||||||
os.remove(baseDir + '/keys/private/' + handle + '.key')
|
os.remove(baseDir + '/keys/private/' + handle + '.key')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: removeAccount unable to delete ' +
|
||||||
|
baseDir + '/keys/private/' + handle + '.key')
|
||||||
pass
|
pass
|
||||||
if os.path.isfile(baseDir + '/keys/public/' + handle + '.pem'):
|
if os.path.isfile(baseDir + '/keys/public/' + handle + '.pem'):
|
||||||
try:
|
try:
|
||||||
os.remove(baseDir + '/keys/public/' + handle + '.pem')
|
os.remove(baseDir + '/keys/public/' + handle + '.pem')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: removeAccount unable to delete ' +
|
||||||
|
baseDir + '/keys/public/' + handle + '.pem')
|
||||||
pass
|
pass
|
||||||
if os.path.isdir(baseDir + '/sharefiles/' + nickname):
|
if os.path.isdir(baseDir + '/sharefiles/' + nickname):
|
||||||
shutil.rmtree(baseDir + '/sharefiles/' + nickname)
|
shutil.rmtree(baseDir + '/sharefiles/' + nickname,
|
||||||
|
ignore_errors=False, onerror=None)
|
||||||
if os.path.isfile(baseDir + '/wfdeactivated/' + handle + '.json'):
|
if os.path.isfile(baseDir + '/wfdeactivated/' + handle + '.json'):
|
||||||
try:
|
try:
|
||||||
os.remove(baseDir + '/wfdeactivated/' + handle + '.json')
|
os.remove(baseDir + '/wfdeactivated/' + handle + '.json')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: removeAccount unable to delete ' +
|
||||||
|
baseDir + '/wfdeactivated/' + handle + '.json')
|
||||||
pass
|
pass
|
||||||
if os.path.isdir(baseDir + '/sharefilesdeactivated/' + nickname):
|
if os.path.isdir(baseDir + '/sharefilesdeactivated/' + nickname):
|
||||||
shutil.rmtree(baseDir + '/sharefilesdeactivated/' + nickname)
|
shutil.rmtree(baseDir + '/sharefilesdeactivated/' + nickname,
|
||||||
|
ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
refreshNewswire(baseDir)
|
refreshNewswire(baseDir)
|
||||||
|
|
||||||
|
|
@ -1559,3 +1580,14 @@ def getPersonAvatarUrl(baseDir: str, personUrl: str, personCache: {},
|
||||||
if '.svg' not in personJson['icon']['url'].lower():
|
if '.svg' not in personJson['icon']['url'].lower():
|
||||||
return personJson['icon']['url']
|
return personJson['icon']['url']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def addActorUpdateTimestamp(actorJson: {}) -> None:
|
||||||
|
"""Adds 'updated' fields with a timestamp
|
||||||
|
"""
|
||||||
|
updatedTime = datetime.datetime.utcnow()
|
||||||
|
currDateStr = updatedTime.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
actorJson['updated'] = currDateStr
|
||||||
|
# add updated timestamp to avatar and banner
|
||||||
|
actorJson['icon']['updated'] = currDateStr
|
||||||
|
actorJson['image']['updated'] = currDateStr
|
||||||
|
|
|
||||||
46
posts.py
46
posts.py
|
|
@ -196,7 +196,7 @@ def _cleanHtml(rawHtml: str) -> str:
|
||||||
return html.unescape(text)
|
return html.unescape(text)
|
||||||
|
|
||||||
|
|
||||||
def getUserUrl(wfRequest: {}, sourceId: int = 0, debug: bool = False) -> str:
|
def getUserUrl(wfRequest: {}, sourceId: int, debug: bool) -> str:
|
||||||
"""Gets the actor url from a webfinger request
|
"""Gets the actor url from a webfinger request
|
||||||
"""
|
"""
|
||||||
if not wfRequest.get('links'):
|
if not wfRequest.get('links'):
|
||||||
|
|
@ -893,7 +893,7 @@ def deleteAllPosts(baseDir: str,
|
||||||
if os.path.isfile(filePath):
|
if os.path.isfile(filePath):
|
||||||
os.unlink(filePath)
|
os.unlink(filePath)
|
||||||
elif os.path.isdir(filePath):
|
elif os.path.isdir(filePath):
|
||||||
shutil.rmtree(filePath)
|
shutil.rmtree(filePath, ignore_errors=False, onerror=None)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('ERROR: deleteAllPosts ' + str(e))
|
print('ERROR: deleteAllPosts ' + str(e))
|
||||||
|
|
||||||
|
|
@ -1569,6 +1569,7 @@ def undoPinnedPost(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(pinnedFilename)
|
os.remove(pinnedFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: undoPinnedPost unable to delete ' + pinnedFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2094,6 +2095,7 @@ def createReportPost(baseDir: str,
|
||||||
with open(newReportFile, 'w+') as fp:
|
with open(newReportFile, 'w+') as fp:
|
||||||
fp.write(toUrl + '/moderation')
|
fp.write(toUrl + '/moderation')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: createReportPost unable to write ' + newReportFile)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return postJsonObject
|
return postJsonObject
|
||||||
|
|
@ -2534,7 +2536,7 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
|
||||||
toDomain = getFullDomain(toDomain, toPort)
|
toDomain = getFullDomain(toDomain, toPort)
|
||||||
|
|
||||||
toDomainUrl = httpPrefix + '://' + toDomain
|
toDomainUrl = httpPrefix + '://' + toDomain
|
||||||
if not siteIsActive(toDomainUrl):
|
if not siteIsActive(toDomainUrl, 10):
|
||||||
print('Domain is inactive: ' + toDomainUrl)
|
print('Domain is inactive: ' + toDomainUrl)
|
||||||
return 9
|
return 9
|
||||||
print('Domain is active: ' + toDomainUrl)
|
print('Domain is active: ' + toDomainUrl)
|
||||||
|
|
@ -3041,7 +3043,7 @@ def sendToFollowers(session, baseDir: str,
|
||||||
|
|
||||||
# check that the follower's domain is active
|
# check that the follower's domain is active
|
||||||
followerDomainUrl = httpPrefix + '://' + followerDomain
|
followerDomainUrl = httpPrefix + '://' + followerDomain
|
||||||
if not siteIsActive(followerDomainUrl):
|
if not siteIsActive(followerDomainUrl, 10):
|
||||||
print('Sending post to followers domain is inactive: ' +
|
print('Sending post to followers domain is inactive: ' +
|
||||||
followerDomainUrl)
|
followerDomainUrl)
|
||||||
continue
|
continue
|
||||||
|
|
@ -3195,7 +3197,7 @@ def sendToFollowersThread(session, baseDir: str,
|
||||||
def createInbox(recentPostsCache: {},
|
def createInbox(recentPostsCache: {},
|
||||||
session, baseDir: str, nickname: str, domain: str, port: int,
|
session, baseDir: str, nickname: str, domain: str, port: int,
|
||||||
httpPrefix: str, itemsPerPage: int, headerOnly: bool,
|
httpPrefix: str, itemsPerPage: int, headerOnly: bool,
|
||||||
pageNumber: int = None) -> {}:
|
pageNumber: int) -> {}:
|
||||||
return _createBoxIndexed(recentPostsCache,
|
return _createBoxIndexed(recentPostsCache,
|
||||||
session, baseDir, 'inbox',
|
session, baseDir, 'inbox',
|
||||||
nickname, domain, port, httpPrefix,
|
nickname, domain, port, httpPrefix,
|
||||||
|
|
@ -3205,7 +3207,7 @@ def createInbox(recentPostsCache: {},
|
||||||
|
|
||||||
def createBookmarksTimeline(session, baseDir: str, nickname: str, domain: str,
|
def createBookmarksTimeline(session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str, itemsPerPage: int,
|
port: int, httpPrefix: str, itemsPerPage: int,
|
||||||
headerOnly: bool, pageNumber: int = None) -> {}:
|
headerOnly: bool, pageNumber: int) -> {}:
|
||||||
return _createBoxIndexed({}, session, baseDir, 'tlbookmarks',
|
return _createBoxIndexed({}, session, baseDir, 'tlbookmarks',
|
||||||
nickname, domain,
|
nickname, domain,
|
||||||
port, httpPrefix, itemsPerPage, headerOnly,
|
port, httpPrefix, itemsPerPage, headerOnly,
|
||||||
|
|
@ -3215,7 +3217,7 @@ def createBookmarksTimeline(session, baseDir: str, nickname: str, domain: str,
|
||||||
def createDMTimeline(recentPostsCache: {},
|
def createDMTimeline(recentPostsCache: {},
|
||||||
session, baseDir: str, nickname: str, domain: str,
|
session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str, itemsPerPage: int,
|
port: int, httpPrefix: str, itemsPerPage: int,
|
||||||
headerOnly: bool, pageNumber: int = None) -> {}:
|
headerOnly: bool, pageNumber: int) -> {}:
|
||||||
return _createBoxIndexed(recentPostsCache,
|
return _createBoxIndexed(recentPostsCache,
|
||||||
session, baseDir, 'dm', nickname,
|
session, baseDir, 'dm', nickname,
|
||||||
domain, port, httpPrefix, itemsPerPage,
|
domain, port, httpPrefix, itemsPerPage,
|
||||||
|
|
@ -3225,7 +3227,7 @@ def createDMTimeline(recentPostsCache: {},
|
||||||
def createRepliesTimeline(recentPostsCache: {},
|
def createRepliesTimeline(recentPostsCache: {},
|
||||||
session, baseDir: str, nickname: str, domain: str,
|
session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str, itemsPerPage: int,
|
port: int, httpPrefix: str, itemsPerPage: int,
|
||||||
headerOnly: bool, pageNumber: int = None) -> {}:
|
headerOnly: bool, pageNumber: int) -> {}:
|
||||||
return _createBoxIndexed(recentPostsCache, session, baseDir, 'tlreplies',
|
return _createBoxIndexed(recentPostsCache, session, baseDir, 'tlreplies',
|
||||||
nickname, domain, port, httpPrefix,
|
nickname, domain, port, httpPrefix,
|
||||||
itemsPerPage, headerOnly, True,
|
itemsPerPage, headerOnly, True,
|
||||||
|
|
@ -3234,7 +3236,7 @@ def createRepliesTimeline(recentPostsCache: {},
|
||||||
|
|
||||||
def createBlogsTimeline(session, baseDir: str, nickname: str, domain: str,
|
def createBlogsTimeline(session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str, itemsPerPage: int,
|
port: int, httpPrefix: str, itemsPerPage: int,
|
||||||
headerOnly: bool, pageNumber: int = None) -> {}:
|
headerOnly: bool, pageNumber: int) -> {}:
|
||||||
return _createBoxIndexed({}, session, baseDir, 'tlblogs', nickname,
|
return _createBoxIndexed({}, session, baseDir, 'tlblogs', nickname,
|
||||||
domain, port, httpPrefix,
|
domain, port, httpPrefix,
|
||||||
itemsPerPage, headerOnly, True,
|
itemsPerPage, headerOnly, True,
|
||||||
|
|
@ -3243,7 +3245,7 @@ def createBlogsTimeline(session, baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
def createFeaturesTimeline(session, baseDir: str, nickname: str, domain: str,
|
def createFeaturesTimeline(session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str, itemsPerPage: int,
|
port: int, httpPrefix: str, itemsPerPage: int,
|
||||||
headerOnly: bool, pageNumber: int = None) -> {}:
|
headerOnly: bool, pageNumber: int) -> {}:
|
||||||
return _createBoxIndexed({}, session, baseDir, 'tlfeatures', nickname,
|
return _createBoxIndexed({}, session, baseDir, 'tlfeatures', nickname,
|
||||||
domain, port, httpPrefix,
|
domain, port, httpPrefix,
|
||||||
itemsPerPage, headerOnly, True,
|
itemsPerPage, headerOnly, True,
|
||||||
|
|
@ -3252,7 +3254,7 @@ def createFeaturesTimeline(session, baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
def createMediaTimeline(session, baseDir: str, nickname: str, domain: str,
|
def createMediaTimeline(session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str, itemsPerPage: int,
|
port: int, httpPrefix: str, itemsPerPage: int,
|
||||||
headerOnly: bool, pageNumber: int = None) -> {}:
|
headerOnly: bool, pageNumber: int) -> {}:
|
||||||
return _createBoxIndexed({}, session, baseDir, 'tlmedia', nickname,
|
return _createBoxIndexed({}, session, baseDir, 'tlmedia', nickname,
|
||||||
domain, port, httpPrefix,
|
domain, port, httpPrefix,
|
||||||
itemsPerPage, headerOnly, True,
|
itemsPerPage, headerOnly, True,
|
||||||
|
|
@ -3263,7 +3265,7 @@ def createNewsTimeline(session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str, itemsPerPage: int,
|
port: int, httpPrefix: str, itemsPerPage: int,
|
||||||
headerOnly: bool, newswireVotesThreshold: int,
|
headerOnly: bool, newswireVotesThreshold: int,
|
||||||
positiveVoting: bool, votingTimeMins: int,
|
positiveVoting: bool, votingTimeMins: int,
|
||||||
pageNumber: int = None) -> {}:
|
pageNumber: int) -> {}:
|
||||||
return _createBoxIndexed({}, session, baseDir, 'outbox', 'news',
|
return _createBoxIndexed({}, session, baseDir, 'outbox', 'news',
|
||||||
domain, port, httpPrefix,
|
domain, port, httpPrefix,
|
||||||
itemsPerPage, headerOnly, True,
|
itemsPerPage, headerOnly, True,
|
||||||
|
|
@ -3274,7 +3276,7 @@ def createNewsTimeline(session, baseDir: str, nickname: str, domain: str,
|
||||||
def createOutbox(session, baseDir: str, nickname: str, domain: str,
|
def createOutbox(session, baseDir: str, nickname: str, domain: str,
|
||||||
port: int, httpPrefix: str,
|
port: int, httpPrefix: str,
|
||||||
itemsPerPage: int, headerOnly: bool, authorized: bool,
|
itemsPerPage: int, headerOnly: bool, authorized: bool,
|
||||||
pageNumber: int = None) -> {}:
|
pageNumber: int) -> {}:
|
||||||
return _createBoxIndexed({}, session, baseDir, 'outbox',
|
return _createBoxIndexed({}, session, baseDir, 'outbox',
|
||||||
nickname, domain, port, httpPrefix,
|
nickname, domain, port, httpPrefix,
|
||||||
itemsPerPage, headerOnly, authorized,
|
itemsPerPage, headerOnly, authorized,
|
||||||
|
|
@ -3283,7 +3285,7 @@ def createOutbox(session, baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
def createModeration(baseDir: str, nickname: str, domain: str, port: int,
|
def createModeration(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
httpPrefix: str, itemsPerPage: int, headerOnly: bool,
|
httpPrefix: str, itemsPerPage: int, headerOnly: bool,
|
||||||
pageNumber: int = None) -> {}:
|
pageNumber: int) -> {}:
|
||||||
boxDir = createPersonDir(nickname, domain, baseDir, 'inbox')
|
boxDir = createPersonDir(nickname, domain, baseDir, 'inbox')
|
||||||
boxname = 'moderation'
|
boxname = 'moderation'
|
||||||
|
|
||||||
|
|
@ -3545,7 +3547,7 @@ def _createBoxIndexed(recentPostsCache: {},
|
||||||
nickname: str, domain: str, port: int, httpPrefix: str,
|
nickname: str, domain: str, port: int, httpPrefix: str,
|
||||||
itemsPerPage: int, headerOnly: bool, authorized: bool,
|
itemsPerPage: int, headerOnly: bool, authorized: bool,
|
||||||
newswireVotesThreshold: int, positiveVoting: bool,
|
newswireVotesThreshold: int, positiveVoting: bool,
|
||||||
votingTimeMins: int, pageNumber: int = None) -> {}:
|
votingTimeMins: int, pageNumber: int) -> {}:
|
||||||
"""Constructs the box feed for a person with the given nickname
|
"""Constructs the box feed for a person with the given nickname
|
||||||
"""
|
"""
|
||||||
if not authorized or not pageNumber:
|
if not authorized or not pageNumber:
|
||||||
|
|
@ -3584,6 +3586,8 @@ def _createBoxIndexed(recentPostsCache: {},
|
||||||
try:
|
try:
|
||||||
pageStr = '?page=' + str(pageNumber)
|
pageStr = '?page=' + str(pageNumber)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _createBoxIndexed ' +
|
||||||
|
'unable to convert page number to string')
|
||||||
pass
|
pass
|
||||||
boxUrl = localActorUrl(httpPrefix, nickname, domain) + '/' + boxname
|
boxUrl = localActorUrl(httpPrefix, nickname, domain) + '/' + boxname
|
||||||
boxHeader = {
|
boxHeader = {
|
||||||
|
|
@ -3743,6 +3747,7 @@ def _createBoxIndexed(recentPostsCache: {},
|
||||||
try:
|
try:
|
||||||
p = json.loads(postStr)
|
p = json.loads(postStr)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _createBoxIndexed unable to load json ' + postStr)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Does this post have replies?
|
# Does this post have replies?
|
||||||
|
|
@ -3925,6 +3930,8 @@ def archivePostsForPerson(httpPrefix: str, nickname: str, domain: str,
|
||||||
try:
|
try:
|
||||||
os.remove(postCacheFilename)
|
os.remove(postCacheFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: archivePostsForPerson unable to delete ' +
|
||||||
|
postCacheFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
noOfPosts -= 1
|
noOfPosts -= 1
|
||||||
|
|
@ -4065,8 +4072,8 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str,
|
||||||
def downloadFollowCollection(signingPrivateKeyPem: str,
|
def downloadFollowCollection(signingPrivateKeyPem: str,
|
||||||
followType: str,
|
followType: str,
|
||||||
session, httpPrefix: str,
|
session, httpPrefix: str,
|
||||||
actor: str, pageNumber: int = 1,
|
actor: str, pageNumber: int,
|
||||||
noOfPages: int = 1, debug: bool = False) -> []:
|
noOfPages: int, debug: bool) -> []:
|
||||||
"""Returns a list of following/followers for the given actor
|
"""Returns a list of following/followers for the given actor
|
||||||
by downloading the json for their following/followers collection
|
by downloading the json for their following/followers collection
|
||||||
"""
|
"""
|
||||||
|
|
@ -5037,11 +5044,15 @@ def secondsBetweenPublished(published1: str, published2: str) -> int:
|
||||||
published1Time = \
|
published1Time = \
|
||||||
datetime.datetime.strptime(published1, '%Y-%m-%dT%H:%M:%SZ')
|
datetime.datetime.strptime(published1, '%Y-%m-%dT%H:%M:%SZ')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: secondsBetweenPublished unable to parse date 1 ' +
|
||||||
|
str(published1))
|
||||||
return -1
|
return -1
|
||||||
try:
|
try:
|
||||||
published2Time = \
|
published2Time = \
|
||||||
datetime.datetime.strptime(published2, '%Y-%m-%dT%H:%M:%SZ')
|
datetime.datetime.strptime(published2, '%Y-%m-%dT%H:%M:%SZ')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: secondsBetweenPublished unable to parse date 2 ' +
|
||||||
|
str(published2))
|
||||||
return -1
|
return -1
|
||||||
return (published2Time - published1Time).seconds
|
return (published2Time - published1Time).seconds
|
||||||
|
|
||||||
|
|
@ -5079,6 +5090,7 @@ def editedPostFilename(baseDir: str, nickname: str, domain: str,
|
||||||
with open(actorFilename, 'r') as fp:
|
with open(actorFilename, 'r') as fp:
|
||||||
lastpostId = fp.read()
|
lastpostId = fp.read()
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: editedPostFilename unable to read ' + actorFilename)
|
||||||
return ''
|
return ''
|
||||||
if not lastpostId:
|
if not lastpostId:
|
||||||
return ''
|
return ''
|
||||||
|
|
|
||||||
11
schedule.py
11
schedule.py
|
|
@ -49,6 +49,8 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _updatePostSchedule unable to delete ' +
|
||||||
|
str(postFilename))
|
||||||
pass
|
pass
|
||||||
continue
|
continue
|
||||||
# create the new index file
|
# create the new index file
|
||||||
|
|
@ -131,6 +133,8 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _updatePostSchedule unable to delete ' +
|
||||||
|
str(postFilename))
|
||||||
pass
|
pass
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -202,6 +206,8 @@ def removeScheduledPosts(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(scheduleIndexFilename)
|
os.remove(scheduleIndexFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: removeScheduledPosts unable to delete ' +
|
||||||
|
scheduleIndexFilename)
|
||||||
pass
|
pass
|
||||||
# remove the scheduled posts
|
# remove the scheduled posts
|
||||||
scheduledDir = acctDir(baseDir, nickname, domain) + '/scheduled'
|
scheduledDir = acctDir(baseDir, nickname, domain) + '/scheduled'
|
||||||
|
|
@ -209,11 +215,10 @@ def removeScheduledPosts(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
return
|
return
|
||||||
for scheduledPostFilename in os.listdir(scheduledDir):
|
for scheduledPostFilename in os.listdir(scheduledDir):
|
||||||
filePath = os.path.join(scheduledDir, scheduledPostFilename)
|
filePath = os.path.join(scheduledDir, scheduledPostFilename)
|
||||||
try:
|
|
||||||
if os.path.isfile(filePath):
|
if os.path.isfile(filePath):
|
||||||
try:
|
try:
|
||||||
os.remove(filePath)
|
os.remove(filePath)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
pass
|
print('EX: removeScheduledPosts unable to delete ' +
|
||||||
except BaseException:
|
filePath)
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ def urlExists(session, url: str, timeoutSec: int = 3,
|
||||||
print('urlExists for ' + url + ' returned ' +
|
print('urlExists for ' + url + ' returned ' +
|
||||||
str(result.status_code))
|
str(result.status_code))
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: urlExists GET failed ' + str(url))
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
||||||
14
shares.py
14
shares.py
|
|
@ -149,6 +149,8 @@ def removeSharedItem(baseDir: str, nickname: str, domain: str,
|
||||||
try:
|
try:
|
||||||
os.remove(itemIDfile + '.' + ext)
|
os.remove(itemIDfile + '.' + ext)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: removeSharedItem unable to delete ' +
|
||||||
|
itemIDfile + '.' + ext)
|
||||||
pass
|
pass
|
||||||
# remove the item itself
|
# remove the item itself
|
||||||
del sharesJson[itemID]
|
del sharesJson[itemID]
|
||||||
|
|
@ -293,6 +295,8 @@ def _indicateNewShareAvailable(baseDir: str, httpPrefix: str,
|
||||||
else:
|
else:
|
||||||
fp.write(localActor + '/tlwanted')
|
fp.write(localActor + '/tlwanted')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _indicateNewShareAvailable unable to write ' +
|
||||||
|
str(newShareFile))
|
||||||
pass
|
pass
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
@ -364,6 +368,8 @@ def addShare(baseDir: str,
|
||||||
try:
|
try:
|
||||||
os.remove(imageFilename)
|
os.remove(imageFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: addShare unable to delete ' +
|
||||||
|
str(imageFilename))
|
||||||
pass
|
pass
|
||||||
imageUrl = \
|
imageUrl = \
|
||||||
httpPrefix + '://' + domainFull + \
|
httpPrefix + '://' + domainFull + \
|
||||||
|
|
@ -436,6 +442,8 @@ def _expireSharesForAccount(baseDir: str, nickname: str, domain: str,
|
||||||
try:
|
try:
|
||||||
os.remove(itemIDfile + '.' + ext)
|
os.remove(itemIDfile + '.' + ext)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _expireSharesForAccount unable to delete ' +
|
||||||
|
itemIDfile + '.' + ext)
|
||||||
pass
|
pass
|
||||||
saveJson(sharesJson, sharesFilename)
|
saveJson(sharesJson, sharesFilename)
|
||||||
|
|
||||||
|
|
@ -444,7 +452,7 @@ def getSharesFeedForPerson(baseDir: str,
|
||||||
domain: str, port: int,
|
domain: str, port: int,
|
||||||
path: str, httpPrefix: str,
|
path: str, httpPrefix: str,
|
||||||
sharesFileType: str,
|
sharesFileType: str,
|
||||||
sharesPerPage: int = 12) -> {}:
|
sharesPerPage: int) -> {}:
|
||||||
"""Returns the shares for an account from GET requests
|
"""Returns the shares for an account from GET requests
|
||||||
"""
|
"""
|
||||||
if '/' + sharesFileType not in path:
|
if '/' + sharesFileType not in path:
|
||||||
|
|
@ -460,6 +468,8 @@ def getSharesFeedForPerson(baseDir: str,
|
||||||
try:
|
try:
|
||||||
pageNumber = int(pageNumber)
|
pageNumber = int(pageNumber)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: getSharesFeedForPerson unable to convert to int ' +
|
||||||
|
str(pageNumber))
|
||||||
pass
|
pass
|
||||||
path = path.split('?page=')[0]
|
path = path.split('?page=')[0]
|
||||||
headerOnly = False
|
headerOnly = False
|
||||||
|
|
@ -1564,7 +1574,7 @@ def _updateFederatedSharesCache(session, sharedItemsFederatedDomains: [],
|
||||||
if not tokensJson.get(federatedDomainFull):
|
if not tokensJson.get(federatedDomainFull):
|
||||||
# token has been obtained for the other domain
|
# token has been obtained for the other domain
|
||||||
continue
|
continue
|
||||||
if not siteIsActive(httpPrefix + '://' + federatedDomainFull):
|
if not siteIsActive(httpPrefix + '://' + federatedDomainFull, 10):
|
||||||
continue
|
continue
|
||||||
if sharesFileType == 'shares':
|
if sharesFileType == 'shares':
|
||||||
url = httpPrefix + '://' + federatedDomainFull + '/catalog'
|
url = httpPrefix + '://' + federatedDomainFull + '/catalog'
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ def _siteActiveHttpRequest(loc, timeout: int):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def siteIsActive(url: str, timeout: int = 10) -> bool:
|
def siteIsActive(url: str, timeout: int) -> bool:
|
||||||
"""Returns true if the current url is resolvable.
|
"""Returns true if the current url is resolvable.
|
||||||
This can be used to check that an instance is online before
|
This can be used to check that an instance is online before
|
||||||
trying to send posts to it.
|
trying to send posts to it.
|
||||||
|
|
@ -118,5 +118,6 @@ def siteIsActive(url: str, timeout: int = 10) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: siteIsActive ' + str(loc))
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
85
tests.py
85
tests.py
|
|
@ -245,7 +245,7 @@ def _testHttpSignedGET(baseDir: str):
|
||||||
|
|
||||||
path = baseDir + '/.testHttpsigGET'
|
path = baseDir + '/.testHttpsigGET'
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
|
|
||||||
|
|
@ -290,7 +290,7 @@ def _testHttpSignedGET(baseDir: str):
|
||||||
boxpath, GETmethod, None,
|
boxpath, GETmethod, None,
|
||||||
messageBodyJsonStr, debug, noRecencyCheck)
|
messageBodyJsonStr, debug, noRecencyCheck)
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
|
|
||||||
def _testSignAndVerify() -> None:
|
def _testSignAndVerify() -> None:
|
||||||
|
|
@ -561,7 +561,7 @@ def _testHttpsigBase(withDigest: bool, baseDir: str):
|
||||||
|
|
||||||
path = baseDir + '/.testHttpsigBase'
|
path = baseDir + '/.testHttpsigBase'
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
|
|
||||||
|
|
@ -662,7 +662,7 @@ def _testHttpsigBase(withDigest: bool, baseDir: str):
|
||||||
messageBodyJsonStr, False) is False
|
messageBodyJsonStr, False) is False
|
||||||
|
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
|
|
||||||
def _testHttpsig(baseDir: str):
|
def _testHttpsig(baseDir: str):
|
||||||
|
|
@ -709,7 +709,7 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
sendThreads: []):
|
sendThreads: []):
|
||||||
print('Creating test server: Alice on port ' + str(port))
|
print('Creating test server: Alice on port ' + str(port))
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
sharedItemsFederatedDomains = []
|
sharedItemsFederatedDomains = []
|
||||||
|
|
@ -850,7 +850,7 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
sendThreads: []):
|
sendThreads: []):
|
||||||
print('Creating test server: Bob on port ' + str(port))
|
print('Creating test server: Bob on port ' + str(port))
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
sharedItemsFederatedDomains = []
|
sharedItemsFederatedDomains = []
|
||||||
|
|
@ -988,7 +988,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
|
||||||
sendThreads: []):
|
sendThreads: []):
|
||||||
print('Creating test server: Eve on port ' + str(port))
|
print('Creating test server: Eve on port ' + str(port))
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
sharedItemsFederatedDomains = []
|
sharedItemsFederatedDomains = []
|
||||||
|
|
@ -1055,7 +1055,7 @@ def createServerGroup(path: str, domain: str, port: int,
|
||||||
sendThreads: []):
|
sendThreads: []):
|
||||||
print('Creating test server: Group on port ' + str(port))
|
print('Creating test server: Group on port ' + str(port))
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
sharedItemsFederatedDomains = []
|
sharedItemsFederatedDomains = []
|
||||||
|
|
@ -1134,7 +1134,7 @@ def testPostMessageBetweenServers(baseDir: str) -> None:
|
||||||
proxyType = None
|
proxyType = None
|
||||||
|
|
||||||
if os.path.isdir(baseDir + '/.tests'):
|
if os.path.isdir(baseDir + '/.tests'):
|
||||||
shutil.rmtree(baseDir + '/.tests')
|
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||||
os.mkdir(baseDir + '/.tests')
|
os.mkdir(baseDir + '/.tests')
|
||||||
|
|
||||||
# create the servers
|
# create the servers
|
||||||
|
|
@ -1417,8 +1417,8 @@ def testPostMessageBetweenServers(baseDir: str) -> None:
|
||||||
assert thrBob.is_alive() is False
|
assert thrBob.is_alive() is False
|
||||||
|
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
shutil.rmtree(aliceDir)
|
shutil.rmtree(aliceDir, ignore_errors=False, onerror=None)
|
||||||
shutil.rmtree(bobDir)
|
shutil.rmtree(bobDir, ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
|
|
||||||
def testFollowBetweenServers(baseDir: str) -> None:
|
def testFollowBetweenServers(baseDir: str) -> None:
|
||||||
|
|
@ -1435,7 +1435,7 @@ def testFollowBetweenServers(baseDir: str) -> None:
|
||||||
federationList = []
|
federationList = []
|
||||||
|
|
||||||
if os.path.isdir(baseDir + '/.tests'):
|
if os.path.isdir(baseDir + '/.tests'):
|
||||||
shutil.rmtree(baseDir + '/.tests')
|
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||||
os.mkdir(baseDir + '/.tests')
|
os.mkdir(baseDir + '/.tests')
|
||||||
|
|
||||||
# create the servers
|
# create the servers
|
||||||
|
|
@ -1605,7 +1605,7 @@ def testFollowBetweenServers(baseDir: str) -> None:
|
||||||
if os.path.isfile(os.path.join(queuePath, name))]) == 0
|
if os.path.isfile(os.path.join(queuePath, name))]) == 0
|
||||||
|
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
shutil.rmtree(baseDir + '/.tests')
|
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
|
|
||||||
def testSharedItemsFederation(baseDir: str) -> None:
|
def testSharedItemsFederation(baseDir: str) -> None:
|
||||||
|
|
@ -1622,7 +1622,7 @@ def testSharedItemsFederation(baseDir: str) -> None:
|
||||||
federationList = []
|
federationList = []
|
||||||
|
|
||||||
if os.path.isdir(baseDir + '/.tests'):
|
if os.path.isdir(baseDir + '/.tests'):
|
||||||
shutil.rmtree(baseDir + '/.tests')
|
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||||
os.mkdir(baseDir + '/.tests')
|
os.mkdir(baseDir + '/.tests')
|
||||||
|
|
||||||
# create the servers
|
# create the servers
|
||||||
|
|
@ -1767,7 +1767,7 @@ def testSharedItemsFederation(baseDir: str) -> None:
|
||||||
print('\n\n*********************************************************')
|
print('\n\n*********************************************************')
|
||||||
print('Bob publishes some shared items')
|
print('Bob publishes some shared items')
|
||||||
if os.path.isdir(bobDir + '/ontology'):
|
if os.path.isdir(bobDir + '/ontology'):
|
||||||
shutil.rmtree(bobDir + '/ontology')
|
shutil.rmtree(bobDir + '/ontology', ignore_errors=False, onerror=None)
|
||||||
os.mkdir(bobDir + '/ontology')
|
os.mkdir(bobDir + '/ontology')
|
||||||
copyfile(baseDir + '/img/logo.png', bobDir + '/logo.png')
|
copyfile(baseDir + '/img/logo.png', bobDir + '/logo.png')
|
||||||
copyfile(baseDir + '/ontology/foodTypes.json',
|
copyfile(baseDir + '/ontology/foodTypes.json',
|
||||||
|
|
@ -2004,7 +2004,7 @@ def testSharedItemsFederation(baseDir: str) -> None:
|
||||||
assert thrBob.is_alive() is False
|
assert thrBob.is_alive() is False
|
||||||
|
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
shutil.rmtree(baseDir + '/.tests')
|
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||||
print('Testing federation of shared items between ' +
|
print('Testing federation of shared items between ' +
|
||||||
'Alice and Bob is complete')
|
'Alice and Bob is complete')
|
||||||
|
|
||||||
|
|
@ -2026,7 +2026,7 @@ def testGroupFollow(baseDir: str) -> None:
|
||||||
federationList = []
|
federationList = []
|
||||||
|
|
||||||
if os.path.isdir(baseDir + '/.tests'):
|
if os.path.isdir(baseDir + '/.tests'):
|
||||||
shutil.rmtree(baseDir + '/.tests')
|
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||||
os.mkdir(baseDir + '/.tests')
|
os.mkdir(baseDir + '/.tests')
|
||||||
|
|
||||||
# create the servers
|
# create the servers
|
||||||
|
|
@ -2412,7 +2412,7 @@ def testGroupFollow(baseDir: str) -> None:
|
||||||
if os.path.isfile(os.path.join(queuePath, name))]) == 0
|
if os.path.isfile(os.path.join(queuePath, name))]) == 0
|
||||||
|
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
shutil.rmtree(baseDir + '/.tests')
|
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||||
print('Testing following of a group is complete')
|
print('Testing following of a group is complete')
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2427,7 +2427,7 @@ def _testFollowersOfPerson(baseDir: str) -> None:
|
||||||
federationList = []
|
federationList = []
|
||||||
baseDir = currDir + '/.tests_followersofperson'
|
baseDir = currDir + '/.tests_followersofperson'
|
||||||
if os.path.isdir(baseDir):
|
if os.path.isdir(baseDir):
|
||||||
shutil.rmtree(baseDir)
|
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(baseDir)
|
os.mkdir(baseDir)
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
createPerson(baseDir, nickname, domain, port,
|
createPerson(baseDir, nickname, domain, port,
|
||||||
|
|
@ -2462,7 +2462,7 @@ def _testFollowersOfPerson(baseDir: str) -> None:
|
||||||
assert 'drokk@' + domain in followList
|
assert 'drokk@' + domain in followList
|
||||||
assert 'sausagedog@' + domain in followList
|
assert 'sausagedog@' + domain in followList
|
||||||
os.chdir(currDir)
|
os.chdir(currDir)
|
||||||
shutil.rmtree(baseDir)
|
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
|
|
||||||
def _testNoOfFollowersOnDomain(baseDir: str) -> None:
|
def _testNoOfFollowersOnDomain(baseDir: str) -> None:
|
||||||
|
|
@ -2477,7 +2477,7 @@ def _testNoOfFollowersOnDomain(baseDir: str) -> None:
|
||||||
federationList = []
|
federationList = []
|
||||||
baseDir = currDir + '/.tests_nooffollowersOndomain'
|
baseDir = currDir + '/.tests_nooffollowersOndomain'
|
||||||
if os.path.isdir(baseDir):
|
if os.path.isdir(baseDir):
|
||||||
shutil.rmtree(baseDir)
|
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(baseDir)
|
os.mkdir(baseDir)
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
createPerson(baseDir, nickname, domain, port, httpPrefix, True,
|
createPerson(baseDir, nickname, domain, port, httpPrefix, True,
|
||||||
|
|
@ -2524,7 +2524,7 @@ def _testNoOfFollowersOnDomain(baseDir: str) -> None:
|
||||||
assert followersOnOtherDomain == 2
|
assert followersOnOtherDomain == 2
|
||||||
|
|
||||||
os.chdir(currDir)
|
os.chdir(currDir)
|
||||||
shutil.rmtree(baseDir)
|
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
|
|
||||||
def _testGroupFollowers(baseDir: str) -> None:
|
def _testGroupFollowers(baseDir: str) -> None:
|
||||||
|
|
@ -2539,7 +2539,7 @@ def _testGroupFollowers(baseDir: str) -> None:
|
||||||
federationList = []
|
federationList = []
|
||||||
baseDir = currDir + '/.tests_testgroupfollowers'
|
baseDir = currDir + '/.tests_testgroupfollowers'
|
||||||
if os.path.isdir(baseDir):
|
if os.path.isdir(baseDir):
|
||||||
shutil.rmtree(baseDir)
|
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(baseDir)
|
os.mkdir(baseDir)
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
createPerson(baseDir, nickname, domain, port, httpPrefix, True,
|
createPerson(baseDir, nickname, domain, port, httpPrefix, True,
|
||||||
|
|
@ -2569,7 +2569,7 @@ def _testGroupFollowers(baseDir: str) -> None:
|
||||||
assert len(grouped['clutterly.domain']) == 1
|
assert len(grouped['clutterly.domain']) == 1
|
||||||
|
|
||||||
os.chdir(currDir)
|
os.chdir(currDir)
|
||||||
shutil.rmtree(baseDir)
|
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
|
|
||||||
def _testFollows(baseDir: str) -> None:
|
def _testFollows(baseDir: str) -> None:
|
||||||
|
|
@ -2583,7 +2583,7 @@ def _testFollows(baseDir: str) -> None:
|
||||||
federationList = ['wild.com', 'mesh.com']
|
federationList = ['wild.com', 'mesh.com']
|
||||||
baseDir = currDir + '/.tests_testfollows'
|
baseDir = currDir + '/.tests_testfollows'
|
||||||
if os.path.isdir(baseDir):
|
if os.path.isdir(baseDir):
|
||||||
shutil.rmtree(baseDir)
|
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(baseDir)
|
os.mkdir(baseDir)
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
createPerson(baseDir, nickname, domain, port, httpPrefix, True,
|
createPerson(baseDir, nickname, domain, port, httpPrefix, True,
|
||||||
|
|
@ -2647,7 +2647,7 @@ def _testFollows(baseDir: str) -> None:
|
||||||
assert(False)
|
assert(False)
|
||||||
|
|
||||||
os.chdir(currDir)
|
os.chdir(currDir)
|
||||||
shutil.rmtree(baseDir)
|
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
|
|
||||||
def _testCreatePerson(baseDir: str):
|
def _testCreatePerson(baseDir: str):
|
||||||
|
|
@ -2662,7 +2662,7 @@ def _testCreatePerson(baseDir: str):
|
||||||
clientToServer = False
|
clientToServer = False
|
||||||
baseDir = currDir + '/.tests_createperson'
|
baseDir = currDir + '/.tests_createperson'
|
||||||
if os.path.isdir(baseDir):
|
if os.path.isdir(baseDir):
|
||||||
shutil.rmtree(baseDir)
|
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(baseDir)
|
os.mkdir(baseDir)
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
|
|
||||||
|
|
@ -2703,7 +2703,7 @@ def _testCreatePerson(baseDir: str):
|
||||||
lowBandwidth)
|
lowBandwidth)
|
||||||
|
|
||||||
os.chdir(currDir)
|
os.chdir(currDir)
|
||||||
shutil.rmtree(baseDir)
|
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
|
|
||||||
def showTestBoxes(name: str, inboxPath: str, outboxPath: str) -> None:
|
def showTestBoxes(name: str, inboxPath: str, outboxPath: str) -> None:
|
||||||
|
|
@ -2726,7 +2726,7 @@ def _testAuthentication(baseDir: str) -> None:
|
||||||
|
|
||||||
baseDir = currDir + '/.tests_authentication'
|
baseDir = currDir + '/.tests_authentication'
|
||||||
if os.path.isdir(baseDir):
|
if os.path.isdir(baseDir):
|
||||||
shutil.rmtree(baseDir)
|
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(baseDir)
|
os.mkdir(baseDir)
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
|
|
||||||
|
|
@ -2755,7 +2755,7 @@ def _testAuthentication(baseDir: str) -> None:
|
||||||
authHeader, False)
|
authHeader, False)
|
||||||
|
|
||||||
os.chdir(currDir)
|
os.chdir(currDir)
|
||||||
shutil.rmtree(baseDir)
|
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
|
|
||||||
def testClientToServer(baseDir: str):
|
def testClientToServer(baseDir: str):
|
||||||
|
|
@ -2773,7 +2773,7 @@ def testClientToServer(baseDir: str):
|
||||||
lowBandwidth = False
|
lowBandwidth = False
|
||||||
|
|
||||||
if os.path.isdir(baseDir + '/.tests'):
|
if os.path.isdir(baseDir + '/.tests'):
|
||||||
shutil.rmtree(baseDir + '/.tests')
|
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||||
os.mkdir(baseDir + '/.tests')
|
os.mkdir(baseDir + '/.tests')
|
||||||
|
|
||||||
# create the servers
|
# create the servers
|
||||||
|
|
@ -3163,8 +3163,8 @@ def testClientToServer(baseDir: str):
|
||||||
assert thrBob.is_alive() is False
|
assert thrBob.is_alive() is False
|
||||||
|
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
# shutil.rmtree(aliceDir)
|
# shutil.rmtree(aliceDir, ignore_errors=False, onerror=None)
|
||||||
# shutil.rmtree(bobDir)
|
# shutil.rmtree(bobDir, ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
|
|
||||||
def _testActorParsing():
|
def _testActorParsing():
|
||||||
|
|
@ -3356,12 +3356,12 @@ def _testAddEmoji(baseDir: str):
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
path = baseDir + '/.tests/emoji'
|
path = baseDir + '/.tests/emoji'
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
baseDir = path
|
baseDir = path
|
||||||
path = baseDir + '/emoji'
|
path = baseDir + '/emoji'
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
copytree(baseDirOriginal + '/emoji', baseDir + '/emoji')
|
copytree(baseDirOriginal + '/emoji', baseDir + '/emoji')
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
|
|
@ -3384,7 +3384,8 @@ def _testAddEmoji(baseDir: str):
|
||||||
assert contentModified == '<p>Emoji 🍋 🍓 🍌</p>'
|
assert contentModified == '<p>Emoji 🍋 🍓 🍌</p>'
|
||||||
|
|
||||||
os.chdir(baseDirOriginal)
|
os.chdir(baseDirOriginal)
|
||||||
shutil.rmtree(baseDirOriginal + '/.tests')
|
shutil.rmtree(baseDirOriginal + '/.tests',
|
||||||
|
ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
|
|
||||||
def _testGetStatusNumber():
|
def _testGetStatusNumber():
|
||||||
|
|
@ -3578,9 +3579,10 @@ def _testJsonld():
|
||||||
|
|
||||||
def _testSiteIsActive():
|
def _testSiteIsActive():
|
||||||
print('testSiteIsActive')
|
print('testSiteIsActive')
|
||||||
assert(siteIsActive('https://archive.org'))
|
timeout = 10
|
||||||
assert(siteIsActive('https://mastodon.social'))
|
assert(siteIsActive('https://archive.org', timeout))
|
||||||
assert(not siteIsActive('https://notarealwebsite.a.b.c'))
|
assert(siteIsActive('https://mastodon.social', timeout))
|
||||||
|
assert(not siteIsActive('https://notarealwebsite.a.b.c', timeout))
|
||||||
|
|
||||||
|
|
||||||
def _testRemoveHtml():
|
def _testRemoveHtml():
|
||||||
|
|
@ -4987,7 +4989,8 @@ def testUpdateActor(baseDir: str):
|
||||||
federationList = []
|
federationList = []
|
||||||
|
|
||||||
if os.path.isdir(baseDir + '/.tests'):
|
if os.path.isdir(baseDir + '/.tests'):
|
||||||
shutil.rmtree(baseDir + '/.tests')
|
shutil.rmtree(baseDir + '/.tests',
|
||||||
|
ignore_errors=False, onerror=None)
|
||||||
os.mkdir(baseDir + '/.tests')
|
os.mkdir(baseDir + '/.tests')
|
||||||
|
|
||||||
# create the server
|
# create the server
|
||||||
|
|
@ -5089,7 +5092,7 @@ def testUpdateActor(baseDir: str):
|
||||||
|
|
||||||
os.chdir(baseDir)
|
os.chdir(baseDir)
|
||||||
if os.path.isdir(baseDir + '/.tests'):
|
if os.path.isdir(baseDir + '/.tests'):
|
||||||
shutil.rmtree(baseDir + '/.tests')
|
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||||
|
|
||||||
|
|
||||||
def _testRemovePostInteractions() -> None:
|
def _testRemovePostInteractions() -> None:
|
||||||
|
|
|
||||||
55
theme.py
55
theme.py
|
|
@ -30,7 +30,7 @@ def importTheme(baseDir: str, filename: str) -> bool:
|
||||||
return False
|
return False
|
||||||
tempThemeDir = baseDir + '/imports/files'
|
tempThemeDir = baseDir + '/imports/files'
|
||||||
if os.path.isdir(tempThemeDir):
|
if os.path.isdir(tempThemeDir):
|
||||||
rmtree(tempThemeDir)
|
rmtree(tempThemeDir, ignore_errors=False, onerror=None)
|
||||||
os.mkdir(tempThemeDir)
|
os.mkdir(tempThemeDir)
|
||||||
unpack_archive(filename, tempThemeDir, 'zip')
|
unpack_archive(filename, tempThemeDir, 'zip')
|
||||||
essentialThemeFiles = ('name.txt', 'theme.json')
|
essentialThemeFiles = ('name.txt', 'theme.json')
|
||||||
|
|
@ -71,9 +71,9 @@ def importTheme(baseDir: str, filename: str) -> bool:
|
||||||
os.mkdir(themeDir)
|
os.mkdir(themeDir)
|
||||||
copytree(tempThemeDir, themeDir)
|
copytree(tempThemeDir, themeDir)
|
||||||
if os.path.isdir(tempThemeDir):
|
if os.path.isdir(tempThemeDir):
|
||||||
rmtree(tempThemeDir)
|
rmtree(tempThemeDir, ignore_errors=False, onerror=None)
|
||||||
if scanThemesForScripts(themeDir):
|
if scanThemesForScripts(themeDir):
|
||||||
rmtree(themeDir)
|
rmtree(themeDir, ignore_errors=False, onerror=None)
|
||||||
return False
|
return False
|
||||||
return os.path.isfile(themeDir + '/theme.json')
|
return os.path.isfile(themeDir + '/theme.json')
|
||||||
|
|
||||||
|
|
@ -91,10 +91,13 @@ def exportTheme(baseDir: str, theme: str) -> bool:
|
||||||
try:
|
try:
|
||||||
os.remove(exportFilename)
|
os.remove(exportFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: exportTheme unable to delete ' + str(exportFilename))
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
make_archive(baseDir + '/exports/' + theme, 'zip', themeDir)
|
make_archive(baseDir + '/exports/' + theme, 'zip', themeDir)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: exportTheme unable to archive ' +
|
||||||
|
baseDir + '/exports/' + str(theme))
|
||||||
pass
|
pass
|
||||||
return os.path.isfile(exportFilename)
|
return os.path.isfile(exportFilename)
|
||||||
|
|
||||||
|
|
@ -257,10 +260,13 @@ def _removeTheme(baseDir: str):
|
||||||
"""
|
"""
|
||||||
themeFiles = _getThemeFiles()
|
themeFiles = _getThemeFiles()
|
||||||
for filename in themeFiles:
|
for filename in themeFiles:
|
||||||
if os.path.isfile(baseDir + '/' + filename):
|
if not os.path.isfile(baseDir + '/' + filename):
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
os.remove(baseDir + '/' + filename)
|
os.remove(baseDir + '/' + filename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _removeTheme unable to delete ' +
|
||||||
|
baseDir + '/' + filename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -446,6 +452,8 @@ def disableGrayscale(baseDir: str) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(grayscaleFilename)
|
os.remove(grayscaleFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: disableGrayscale unable to delete ' +
|
||||||
|
grayscaleFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -589,12 +597,18 @@ def _setTextModeTheme(baseDir: str, name: str) -> None:
|
||||||
copyfile(textModeLogoFilename,
|
copyfile(textModeLogoFilename,
|
||||||
baseDir + '/accounts/logo.txt')
|
baseDir + '/accounts/logo.txt')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setTextModeTheme unable to copy ' +
|
||||||
|
textModeLogoFilename + ' ' +
|
||||||
|
baseDir + '/accounts/logo.txt')
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
copyfile(baseDir + '/img/logo.txt',
|
copyfile(baseDir + '/img/logo.txt',
|
||||||
baseDir + '/accounts/logo.txt')
|
baseDir + '/accounts/logo.txt')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setTextModeTheme unable to copy ' +
|
||||||
|
baseDir + '/img/logo.txt ' +
|
||||||
|
baseDir + '/accounts/logo.txt')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# set the text mode banner which appears in browsers such as Lynx
|
# set the text mode banner which appears in browsers such as Lynx
|
||||||
|
|
@ -604,12 +618,17 @@ def _setTextModeTheme(baseDir: str, name: str) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(baseDir + '/accounts/banner.txt')
|
os.remove(baseDir + '/accounts/banner.txt')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setTextModeTheme unable to delete ' +
|
||||||
|
baseDir + '/accounts/banner.txt')
|
||||||
pass
|
pass
|
||||||
if os.path.isfile(textModeBannerFilename):
|
if os.path.isfile(textModeBannerFilename):
|
||||||
try:
|
try:
|
||||||
copyfile(textModeBannerFilename,
|
copyfile(textModeBannerFilename,
|
||||||
baseDir + '/accounts/banner.txt')
|
baseDir + '/accounts/banner.txt')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setTextModeTheme unable to copy ' +
|
||||||
|
textModeBannerFilename + ' ' +
|
||||||
|
baseDir + '/accounts/banner.txt')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -641,8 +660,7 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
for acct in dirs:
|
for acct in dirs:
|
||||||
if not isAccountDir(acct):
|
if not isAccountDir(acct):
|
||||||
continue
|
continue
|
||||||
accountDir = \
|
accountDir = os.path.join(baseDir + '/accounts', acct)
|
||||||
os.path.join(baseDir + '/accounts', acct)
|
|
||||||
|
|
||||||
for backgroundType in backgroundNames:
|
for backgroundType in backgroundNames:
|
||||||
for ext in extensions:
|
for ext in extensions:
|
||||||
|
|
@ -662,6 +680,8 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
backgroundType + '-background.' + ext)
|
backgroundType + '-background.' + ext)
|
||||||
continue
|
continue
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
|
backgroundImageFilename)
|
||||||
pass
|
pass
|
||||||
# background image was not found
|
# background image was not found
|
||||||
# so remove any existing file
|
# so remove any existing file
|
||||||
|
|
@ -671,6 +691,9 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
os.remove(baseDir + '/accounts/' +
|
os.remove(baseDir + '/accounts/' +
|
||||||
backgroundType + '-background.' + ext)
|
backgroundType + '-background.' + ext)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setThemeImages unable to delete ' +
|
||||||
|
baseDir + '/accounts/' +
|
||||||
|
backgroundType + '-background.' + ext)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if os.path.isfile(profileImageFilename) and \
|
if os.path.isfile(profileImageFilename) and \
|
||||||
|
|
@ -679,12 +702,16 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
copyfile(profileImageFilename,
|
copyfile(profileImageFilename,
|
||||||
accountDir + '/image.png')
|
accountDir + '/image.png')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
|
profileImageFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
copyfile(bannerFilename,
|
copyfile(bannerFilename,
|
||||||
accountDir + '/banner.png')
|
accountDir + '/banner.png')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
|
bannerFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -692,21 +719,25 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
copyfile(searchBannerFilename,
|
copyfile(searchBannerFilename,
|
||||||
accountDir + '/search_banner.png')
|
accountDir + '/search_banner.png')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
|
searchBannerFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if os.path.isfile(leftColImageFilename):
|
if os.path.isfile(leftColImageFilename):
|
||||||
copyfile(leftColImageFilename,
|
copyfile(leftColImageFilename,
|
||||||
accountDir + '/left_col_image.png')
|
accountDir + '/left_col_image.png')
|
||||||
else:
|
elif os.path.isfile(accountDir +
|
||||||
if os.path.isfile(accountDir +
|
|
||||||
'/left_col_image.png'):
|
'/left_col_image.png'):
|
||||||
try:
|
try:
|
||||||
os.remove(accountDir + '/left_col_image.png')
|
os.remove(accountDir + '/left_col_image.png')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setThemeImages unable to delete ' +
|
||||||
|
accountDir + '/left_col_image.png')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
|
leftColImageFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -719,8 +750,12 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(accountDir + '/right_col_image.png')
|
os.remove(accountDir + '/right_col_image.png')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setThemeImages unable to delete ' +
|
||||||
|
accountDir + '/right_col_image.png')
|
||||||
pass
|
pass
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
|
rightColImageFilename)
|
||||||
pass
|
pass
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
@ -745,6 +780,7 @@ def setNewsAvatar(baseDir: str, name: str,
|
||||||
try:
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: setNewsAvatar unable to delete ' + filename)
|
||||||
pass
|
pass
|
||||||
if os.path.isdir(baseDir + '/cache/avatars'):
|
if os.path.isdir(baseDir + '/cache/avatars'):
|
||||||
copyfile(newFilename, filename)
|
copyfile(newFilename, filename)
|
||||||
|
|
@ -780,6 +816,7 @@ def setTheme(baseDir: str, name: str, domain: str,
|
||||||
globals()['setTheme' + themeName](baseDir,
|
globals()['setTheme' + themeName](baseDir,
|
||||||
allowLocalNetworkAccess)
|
allowLocalNetworkAccess)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: setTheme unable to set theme ' + themeName)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if prevThemeName:
|
if prevThemeName:
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ class threadWithTrace(threading.Thread):
|
||||||
|
|
||||||
|
|
||||||
def removeDormantThreads(baseDir: str, threadsList: [], debug: bool,
|
def removeDormantThreads(baseDir: str, threadsList: [], debug: bool,
|
||||||
timeoutMins: int = 30) -> None:
|
timeoutMins: int) -> None:
|
||||||
"""Removes threads whose execution has completed
|
"""Removes threads whose execution has completed
|
||||||
"""
|
"""
|
||||||
if len(threadsList) == 0:
|
if len(threadsList) == 0:
|
||||||
|
|
@ -150,4 +150,6 @@ def removeDormantThreads(baseDir: str, threadsList: [], debug: bool,
|
||||||
',' + str(noOfActiveThreads) +
|
',' + str(noOfActiveThreads) +
|
||||||
',' + str(len(threadsList)) + '\n')
|
',' + str(len(threadsList)) + '\n')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: removeDormantThreads unable to write ' +
|
||||||
|
sendLogFilename)
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
73
utils.py
73
utils.py
|
|
@ -16,9 +16,9 @@ import json
|
||||||
import idna
|
import idna
|
||||||
import locale
|
import locale
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from followingCalendar import addPersonToCalendar
|
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
from cryptography.hazmat.primitives import hashes
|
from cryptography.hazmat.primitives import hashes
|
||||||
|
from followingCalendar import addPersonToCalendar
|
||||||
|
|
||||||
# posts containing these strings will always get screened out,
|
# posts containing these strings will always get screened out,
|
||||||
# both incoming and outgoing.
|
# both incoming and outgoing.
|
||||||
|
|
@ -209,8 +209,7 @@ def hasUsersPath(pathStr: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def validPostDate(published: str, maxAgeDays: int = 90,
|
def validPostDate(published: str, maxAgeDays: int, debug: bool) -> bool:
|
||||||
debug: bool = False) -> bool:
|
|
||||||
"""Returns true if the published date is recent and is not in the future
|
"""Returns true if the published date is recent and is not in the future
|
||||||
"""
|
"""
|
||||||
baselineTime = datetime.datetime(1970, 1, 1)
|
baselineTime = datetime.datetime(1970, 1, 1)
|
||||||
|
|
@ -222,6 +221,8 @@ def validPostDate(published: str, maxAgeDays: int = 90,
|
||||||
postTimeObject = \
|
postTimeObject = \
|
||||||
datetime.datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
|
datetime.datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
|
print('EX: validPostDate invalid published date ' + str(published))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
daysDiff = postTimeObject - baselineTime
|
daysDiff = postTimeObject - baselineTime
|
||||||
|
|
@ -252,7 +253,7 @@ def getFullDomain(domain: str, port: int) -> str:
|
||||||
|
|
||||||
|
|
||||||
def isDormant(baseDir: str, nickname: str, domain: str, actor: str,
|
def isDormant(baseDir: str, nickname: str, domain: str, actor: str,
|
||||||
dormantMonths: int = 3) -> bool:
|
dormantMonths: int) -> bool:
|
||||||
"""Is the given followed actor dormant, from the standpoint
|
"""Is the given followed actor dormant, from the standpoint
|
||||||
of the given account
|
of the given account
|
||||||
"""
|
"""
|
||||||
|
|
@ -625,6 +626,8 @@ def removeAvatarFromCache(baseDir: str, actorStr: str) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(avatarFilename)
|
os.remove(avatarFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: removeAvatarFromCache ' +
|
||||||
|
'unable to delete cached avatar ' + str(avatarFilename))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -638,7 +641,7 @@ def saveJson(jsonObject: {}, filename: str) -> bool:
|
||||||
fp.write(json.dumps(jsonObject))
|
fp.write(json.dumps(jsonObject))
|
||||||
return True
|
return True
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('WARN: saveJson ' + str(tries))
|
print('EX: saveJson ' + str(tries))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tries += 1
|
tries += 1
|
||||||
return False
|
return False
|
||||||
|
|
@ -656,7 +659,7 @@ def loadJson(filename: str, delaySec: int = 2, maxTries: int = 5) -> {}:
|
||||||
jsonObject = json.loads(data)
|
jsonObject = json.loads(data)
|
||||||
break
|
break
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('WARN: loadJson exception')
|
print('EX: loadJson exception ' + str(filename))
|
||||||
if delaySec > 0:
|
if delaySec > 0:
|
||||||
time.sleep(delaySec)
|
time.sleep(delaySec)
|
||||||
tries += 1
|
tries += 1
|
||||||
|
|
@ -681,7 +684,7 @@ def loadJsonOnionify(filename: str, domain: str, onionDomain: str,
|
||||||
jsonObject = json.loads(data)
|
jsonObject = json.loads(data)
|
||||||
break
|
break
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('WARN: loadJson exception')
|
print('EX: loadJsonOnionify exception ' + str(filename))
|
||||||
if delaySec > 0:
|
if delaySec > 0:
|
||||||
time.sleep(delaySec)
|
time.sleep(delaySec)
|
||||||
tries += 1
|
tries += 1
|
||||||
|
|
@ -1285,8 +1288,8 @@ def clearFromPostCaches(baseDir: str, recentPostsCache: {},
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('WARN: clearFromPostCaches file not removed ' +
|
print('EX: clearFromPostCaches file not removed ' +
|
||||||
postFilename)
|
str(postFilename))
|
||||||
pass
|
pass
|
||||||
# if the post is in the recent posts cache then remove it
|
# if the post is in the recent posts cache then remove it
|
||||||
if recentPostsCache.get('index'):
|
if recentPostsCache.get('index'):
|
||||||
|
|
@ -1384,6 +1387,9 @@ def setReplyIntervalHours(baseDir: str, nickname: str, domain: str,
|
||||||
fp.write(str(replyIntervalHours))
|
fp.write(str(replyIntervalHours))
|
||||||
return True
|
return True
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: setReplyIntervalHours unable to save reply interval ' +
|
||||||
|
str(replyIntervalFilename) + ' ' +
|
||||||
|
str(replyIntervalHours))
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@ -1411,6 +1417,7 @@ def canReplyTo(baseDir: str, nickname: str, domain: str,
|
||||||
try:
|
try:
|
||||||
pubDate = datetime.datetime.strptime(published, '%Y-%m-%dT%H:%M:%SZ')
|
pubDate = datetime.datetime.strptime(published, '%Y-%m-%dT%H:%M:%SZ')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: canReplyTo unrecognized published date ' + str(published))
|
||||||
return False
|
return False
|
||||||
if not currDateStr:
|
if not currDateStr:
|
||||||
currDate = datetime.datetime.utcnow()
|
currDate = datetime.datetime.utcnow()
|
||||||
|
|
@ -1419,6 +1426,8 @@ def canReplyTo(baseDir: str, nickname: str, domain: str,
|
||||||
currDate = datetime.datetime.strptime(currDateStr,
|
currDate = datetime.datetime.strptime(currDateStr,
|
||||||
'%Y-%m-%dT%H:%M:%SZ')
|
'%Y-%m-%dT%H:%M:%SZ')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: canReplyTo unrecognized current date ' +
|
||||||
|
str(currDateStr))
|
||||||
return False
|
return False
|
||||||
hoursSincePublication = int((currDate - pubDate).total_seconds() / 3600)
|
hoursSincePublication = int((currDate - pubDate).total_seconds() / 3600)
|
||||||
if hoursSincePublication < 0 or \
|
if hoursSincePublication < 0 or \
|
||||||
|
|
@ -1442,12 +1451,16 @@ def _removeAttachment(baseDir: str, httpPrefix: str, domain: str,
|
||||||
try:
|
try:
|
||||||
os.remove(mediaFilename)
|
os.remove(mediaFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _removeAttachment unable to delete media file ' +
|
||||||
|
str(mediaFilename))
|
||||||
pass
|
pass
|
||||||
etagFilename = mediaFilename + '.etag'
|
etagFilename = mediaFilename + '.etag'
|
||||||
if os.path.isfile(etagFilename):
|
if os.path.isfile(etagFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(etagFilename)
|
os.remove(etagFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _removeAttachment unable to delete etag file ' +
|
||||||
|
str(etagFilename))
|
||||||
pass
|
pass
|
||||||
postJson['attachment'] = []
|
postJson['attachment'] = []
|
||||||
|
|
||||||
|
|
@ -1516,6 +1529,8 @@ def _deletePostRemoveReplies(baseDir: str, nickname: str, domain: str,
|
||||||
try:
|
try:
|
||||||
os.remove(repliesFilename)
|
os.remove(repliesFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _deletePostRemoveReplies unable to delete replies file ' +
|
||||||
|
str(repliesFilename))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1575,6 +1590,9 @@ def _deleteCachedHtml(baseDir: str, nickname: str, domain: str,
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _deleteCachedHtml ' +
|
||||||
|
'unable to delete cached post file ' +
|
||||||
|
str(cachedPostFilename))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1622,6 +1640,8 @@ def _deleteHashtagsOnPost(baseDir: str, postJsonObject: {}) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(tagIndexFilename)
|
os.remove(tagIndexFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _deleteHashtagsOnPost unable to delete tag index ' +
|
||||||
|
str(tagIndexFilename))
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# write the new hashtag index without the given post in it
|
# write the new hashtag index without the given post in it
|
||||||
|
|
@ -1660,10 +1680,16 @@ def _deleteConversationPost(baseDir: str, nickname: str, domain: str,
|
||||||
try:
|
try:
|
||||||
os.remove(conversationFilename + '.muted')
|
os.remove(conversationFilename + '.muted')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _deleteConversationPost ' +
|
||||||
|
'unable to remove conversation ' +
|
||||||
|
str(conversationFilename) + '.muted')
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
os.remove(conversationFilename)
|
os.remove(conversationFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _deleteConversationPost ' +
|
||||||
|
'unable to remove conversation ' +
|
||||||
|
str(conversationFilename))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1682,6 +1708,9 @@ def deletePost(baseDir: str, httpPrefix: str,
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
|
print('EX: deletePost unable to delete post ' +
|
||||||
|
str(postFilename))
|
||||||
pass
|
pass
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -1710,6 +1739,8 @@ def deletePost(baseDir: str, httpPrefix: str,
|
||||||
try:
|
try:
|
||||||
os.remove(extFilename)
|
os.remove(extFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: deletePost unable to remove ext ' +
|
||||||
|
str(extFilename))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# remove cached html version of the post
|
# remove cached html version of the post
|
||||||
|
|
@ -1739,6 +1770,8 @@ def deletePost(baseDir: str, httpPrefix: str,
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
|
print('EX: deletePost unable to delete post ' + str(postFilename))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2179,6 +2212,9 @@ def undoLikesCollectionEntry(recentPostsCache: {},
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: undoLikesCollectionEntry ' +
|
||||||
|
'unable to delete cached post ' +
|
||||||
|
str(cachedPostFilename))
|
||||||
pass
|
pass
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
|
|
@ -2241,6 +2277,10 @@ def undoAnnounceCollectionEntry(recentPostsCache: {},
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
|
print('EX: undoAnnounceCollectionEntry ' +
|
||||||
|
'unable to delete cached post ' +
|
||||||
|
str(cachedPostFilename))
|
||||||
pass
|
pass
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
|
|
@ -2305,6 +2345,10 @@ def updateAnnounceCollection(recentPostsCache: {},
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
|
print('EX: updateAnnounceCollection ' +
|
||||||
|
'unable to delete cached post ' +
|
||||||
|
str(cachedPostFilename))
|
||||||
pass
|
pass
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
|
|
@ -2388,7 +2432,7 @@ def mediaFileMimeType(filename: str) -> str:
|
||||||
return extensions[fileExt]
|
return extensions[fileExt]
|
||||||
|
|
||||||
|
|
||||||
def isRecentPost(postJsonObject: {}, maxDays: int = 3) -> bool:
|
def isRecentPost(postJsonObject: {}, maxDays: int) -> bool:
|
||||||
""" Is the given post recent?
|
""" Is the given post recent?
|
||||||
"""
|
"""
|
||||||
if not hasObjectDict(postJsonObject):
|
if not hasObjectDict(postJsonObject):
|
||||||
|
|
@ -2407,6 +2451,8 @@ def isRecentPost(postJsonObject: {}, maxDays: int = 3) -> bool:
|
||||||
datetime.datetime.strptime(publishedDateStr,
|
datetime.datetime.strptime(publishedDateStr,
|
||||||
"%Y-%m-%dT%H:%M:%SZ")
|
"%Y-%m-%dT%H:%M:%SZ")
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: isRecentPost unrecognized published date ' +
|
||||||
|
str(publishedDateStr))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
publishedDaysSinceEpoch = \
|
publishedDaysSinceEpoch = \
|
||||||
|
|
@ -2552,7 +2598,7 @@ def loadTranslationsFromFile(baseDir: str, language: str) -> ({}, str):
|
||||||
"""
|
"""
|
||||||
if not os.path.isdir(baseDir + '/translations'):
|
if not os.path.isdir(baseDir + '/translations'):
|
||||||
print('ERROR: translations directory not found')
|
print('ERROR: translations directory not found')
|
||||||
return
|
return None, None
|
||||||
if not language:
|
if not language:
|
||||||
systemLanguage = locale.getdefaultlocale()[0]
|
systemLanguage = locale.getdefaultlocale()[0]
|
||||||
else:
|
else:
|
||||||
|
|
@ -2849,6 +2895,7 @@ def dateStringToSeconds(dateStr: str) -> int:
|
||||||
expiryTime = \
|
expiryTime = \
|
||||||
datetime.datetime.strptime(dateStr, '%Y-%m-%dT%H:%M:%SZ')
|
datetime.datetime.strptime(dateStr, '%Y-%m-%dT%H:%M:%SZ')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: dateStringToSeconds unable to parse date ' + str(dateStr))
|
||||||
return None
|
return None
|
||||||
return int(datetime.datetime.timestamp(expiryTime))
|
return int(datetime.datetime.timestamp(expiryTime))
|
||||||
|
|
||||||
|
|
@ -2983,7 +3030,7 @@ def getSupportedLanguages(baseDir: str) -> []:
|
||||||
"""
|
"""
|
||||||
translationsDir = baseDir + '/translations'
|
translationsDir = baseDir + '/translations'
|
||||||
languagesStr = []
|
languagesStr = []
|
||||||
for subdir, dirs, files in os.walk(translationsDir):
|
for _, _, files in os.walk(translationsDir):
|
||||||
for f in files:
|
for f in files:
|
||||||
if not f.endswith('.json'):
|
if not f.endswith('.json'):
|
||||||
continue
|
continue
|
||||||
|
|
@ -2999,7 +3046,7 @@ def getCategoryTypes(baseDir: str) -> []:
|
||||||
"""
|
"""
|
||||||
ontologyDir = baseDir + '/ontology'
|
ontologyDir = baseDir + '/ontology'
|
||||||
categories = []
|
categories = []
|
||||||
for subdir, dirs, files in os.walk(ontologyDir):
|
for _, _, files in os.walk(ontologyDir):
|
||||||
for f in files:
|
for f in files:
|
||||||
if not f.endswith('.json'):
|
if not f.endswith('.json'):
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ def _htmlCalendarDay(personCache: {}, cssCache: {}, translate: {},
|
||||||
try:
|
try:
|
||||||
os.remove(calendarFile)
|
os.remove(calendarFile)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: _htmlCalendarDay unable to delete ' + calendarFile)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
cssFilename = baseDir + '/epicyon-calendar.css'
|
cssFilename = baseDir + '/epicyon-calendar.css'
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,7 @@ def _htmlNewswire(baseDir: str, newswire: {}, nickname: str, moderator: bool,
|
||||||
publishedDate = \
|
publishedDate = \
|
||||||
datetime.strptime(dateStr, "%Y-%m-%d %H:%M:%S%z")
|
datetime.strptime(dateStr, "%Y-%m-%d %H:%M:%S%z")
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('WARN: bad date format ' + dateStr)
|
print('EX: _htmlNewswire bad date format ' + dateStr)
|
||||||
continue
|
continue
|
||||||
dateShown = publishedDate.strftime("%Y-%m-%d %H:%M")
|
dateShown = publishedDate.strftime("%Y-%m-%d %H:%M")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ def loadPeertubeInstances(baseDir: str, peertubeInstances: []) -> None:
|
||||||
|
|
||||||
def _addEmbeddedVideoFromSites(translate: {}, content: str,
|
def _addEmbeddedVideoFromSites(translate: {}, content: str,
|
||||||
peertubeInstances: [],
|
peertubeInstances: [],
|
||||||
width: int = 400, height: int = 300) -> str:
|
width: int, height: int) -> str:
|
||||||
"""Adds embedded videos
|
"""Adds embedded videos
|
||||||
"""
|
"""
|
||||||
if '>vimeo.com/' in content:
|
if '>vimeo.com/' in content:
|
||||||
|
|
@ -250,6 +250,6 @@ def addEmbeddedElements(translate: {}, content: str,
|
||||||
"""Adds embedded elements for various media types
|
"""Adds embedded elements for various media types
|
||||||
"""
|
"""
|
||||||
content = _addEmbeddedVideoFromSites(translate, content,
|
content = _addEmbeddedVideoFromSites(translate, content,
|
||||||
peertubeInstances)
|
peertubeInstances, 400, 300)
|
||||||
content = _addEmbeddedAudio(translate, content)
|
content = _addEmbeddedAudio(translate, content)
|
||||||
return _addEmbeddedVideo(translate, content)
|
return _addEmbeddedVideo(translate, content)
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ def setMinimal(baseDir: str, domain: str, nickname: str,
|
||||||
try:
|
try:
|
||||||
os.remove(minimalFilename)
|
os.remove(minimalFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: setMinimal unable to delete ' + minimalFilename)
|
||||||
pass
|
pass
|
||||||
elif not minimal and not minimalFileExists:
|
elif not minimal and not minimalFileExists:
|
||||||
with open(minimalFilename, 'w+') as fp:
|
with open(minimalFilename, 'w+') as fp:
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ def htmlAccountInfo(cssCache: {}, translate: {},
|
||||||
followersList = \
|
followersList = \
|
||||||
downloadFollowCollection(signingPrivateKeyPem,
|
downloadFollowCollection(signingPrivateKeyPem,
|
||||||
'followers', session,
|
'followers', session,
|
||||||
httpPrefix, searchActor, 1, 5)
|
httpPrefix, searchActor, 1, 5, debug)
|
||||||
blockedFollowers = []
|
blockedFollowers = []
|
||||||
for followerActor in followersList:
|
for followerActor in followersList:
|
||||||
followerNickname = getNicknameFromActor(followerActor)
|
followerNickname = getNicknameFromActor(followerActor)
|
||||||
|
|
@ -146,7 +146,7 @@ def htmlAccountInfo(cssCache: {}, translate: {},
|
||||||
followingList = \
|
followingList = \
|
||||||
downloadFollowCollection(signingPrivateKeyPem,
|
downloadFollowCollection(signingPrivateKeyPem,
|
||||||
'following', session,
|
'following', session,
|
||||||
httpPrefix, searchActor, 1, 5)
|
httpPrefix, searchActor, 1, 5, debug)
|
||||||
blockedFollowing = []
|
blockedFollowing = []
|
||||||
for followingActor in followingList:
|
for followingActor in followingList:
|
||||||
followingNickname = getNicknameFromActor(followingActor)
|
followingNickname = getNicknameFromActor(followingActor)
|
||||||
|
|
|
||||||
|
|
@ -1403,7 +1403,7 @@ def individualPostAsHtml(signingPrivateKeyPem: str,
|
||||||
postActor, nickname, domainFull, False)
|
postActor, nickname, domainFull, False)
|
||||||
|
|
||||||
# create a file for use by text-to-speech
|
# create a file for use by text-to-speech
|
||||||
if isRecentPost(postJsonObject):
|
if isRecentPost(postJsonObject, 3):
|
||||||
if postJsonObject.get('actor'):
|
if postJsonObject.get('actor'):
|
||||||
if not os.path.isfile(announceFilename + '.tts'):
|
if not os.path.isfile(announceFilename + '.tts'):
|
||||||
updateSpeaker(baseDir, httpPrefix,
|
updateSpeaker(baseDir, httpPrefix,
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ def insertQuestion(baseDir: str, translate: {},
|
||||||
try:
|
try:
|
||||||
votes = int(questionOption['replies']['totalItems'])
|
votes = int(questionOption['replies']['totalItems'])
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: insertQuestion unable to convert to int')
|
||||||
pass
|
pass
|
||||||
if votes > maxVotes:
|
if votes > maxVotes:
|
||||||
maxVotes = int(votes+1)
|
maxVotes = int(votes+1)
|
||||||
|
|
@ -89,6 +90,7 @@ def insertQuestion(baseDir: str, translate: {},
|
||||||
try:
|
try:
|
||||||
votes = int(questionOption['replies']['totalItems'])
|
votes = int(questionOption['replies']['totalItems'])
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: insertQuestion unable to convert to int 2')
|
||||||
pass
|
pass
|
||||||
votesPercent = str(int(votes * 100 / maxVotes))
|
votesPercent = str(int(votes * 100 / maxVotes))
|
||||||
content += \
|
content += \
|
||||||
|
|
|
||||||
|
|
@ -428,7 +428,8 @@ def htmlSearch(cssCache: {}, translate: {},
|
||||||
with open(cachedHashtagSwarmFilename, 'r') as fp:
|
with open(cachedHashtagSwarmFilename, 'r') as fp:
|
||||||
swarmStr = fp.read()
|
swarmStr = fp.read()
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('WARN: Unable to read cached hashtag swarm')
|
print('EX: htmlSearch unable to read cached hashtag swarm ' +
|
||||||
|
cachedHashtagSwarmFilename)
|
||||||
pass
|
pass
|
||||||
if not swarmStr:
|
if not swarmStr:
|
||||||
swarmStr = htmlHashTagSwarm(baseDir, actor, translate)
|
swarmStr = htmlHashTagSwarm(baseDir, actor, translate)
|
||||||
|
|
@ -437,7 +438,8 @@ def htmlSearch(cssCache: {}, translate: {},
|
||||||
with open(cachedHashtagSwarmFilename, 'w+') as fp:
|
with open(cachedHashtagSwarmFilename, 'w+') as fp:
|
||||||
fp.write(swarmStr)
|
fp.write(swarmStr)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('WARN: Unable to save cached hashtag swarm')
|
print('EX: htmlSearch unable to save cached hashtag swarm ' +
|
||||||
|
cachedHashtagSwarmFilename)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
followStr += ' <p class="hashtagswarm">' + swarmStr + '</p>\n'
|
followStr += ' <p class="hashtagswarm">' + swarmStr + '</p>\n'
|
||||||
|
|
|
||||||
|
|
@ -477,6 +477,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
try:
|
try:
|
||||||
os.remove(dmFile)
|
os.remove(dmFile)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: htmlTimeline unable to delete ' + dmFile)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# should the Replies button be highlighted?
|
# should the Replies button be highlighted?
|
||||||
|
|
@ -488,6 +489,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
try:
|
try:
|
||||||
os.remove(replyFile)
|
os.remove(replyFile)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: htmlTimeline unable to delete ' + replyFile)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# should the Shares button be highlighted?
|
# should the Shares button be highlighted?
|
||||||
|
|
@ -499,6 +501,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
try:
|
try:
|
||||||
os.remove(newShareFile)
|
os.remove(newShareFile)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: htmlTimeline unable to delete ' + newShareFile)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# should the Wanted button be highlighted?
|
# should the Wanted button be highlighted?
|
||||||
|
|
@ -510,6 +513,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
try:
|
try:
|
||||||
os.remove(newWantedFile)
|
os.remove(newWantedFile)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: htmlTimeline unable to delete ' + newWantedFile)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# should the Moderation/reports button be highlighted?
|
# should the Moderation/reports button be highlighted?
|
||||||
|
|
@ -521,6 +525,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
try:
|
try:
|
||||||
os.remove(newReportFile)
|
os.remove(newReportFile)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: htmlTimeline unable to delete ' + newReportFile)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
separatorStr = ''
|
separatorStr = ''
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,8 @@ def updateAvatarImageCache(signingPrivateKeyPem: str,
|
||||||
try:
|
try:
|
||||||
os.remove(avatarImageFilename)
|
os.remove(avatarImageFilename)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
print('EX: updateAvatarImageCache unable to delete ' +
|
||||||
|
avatarImageFilename)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
with open(avatarImageFilename, 'wb') as f:
|
with open(avatarImageFilename, 'wb') as f:
|
||||||
|
|
@ -1217,9 +1219,9 @@ def editTextField(label: str, name: str, value: str = "",
|
||||||
value + '"' + placeholderStr + requiredStr + '>\n'
|
value + '"' + placeholderStr + requiredStr + '>\n'
|
||||||
|
|
||||||
|
|
||||||
def editNumberField(label: str, name: str, value: int = 1,
|
def editNumberField(label: str, name: str, value: int,
|
||||||
minValue: int = 1, maxValue: int = 999999,
|
minValue: int, maxValue: int,
|
||||||
placeholder: int = 1) -> str:
|
placeholder: int) -> str:
|
||||||
"""Returns html for editing an integer number field
|
"""Returns html for editing an integer number field
|
||||||
"""
|
"""
|
||||||
if value is None:
|
if value is None:
|
||||||
|
|
@ -1234,9 +1236,8 @@ def editNumberField(label: str, name: str, value: int = 1,
|
||||||
'min="' + str(minValue) + '" max="' + str(maxValue) + '" step="1">\n'
|
'min="' + str(minValue) + '" max="' + str(maxValue) + '" step="1">\n'
|
||||||
|
|
||||||
|
|
||||||
def editCurrencyField(label: str, name: str, value: str = "0.00",
|
def editCurrencyField(label: str, name: str, value: str,
|
||||||
placeholder: str = "0.00",
|
placeholder: str, required: bool) -> str:
|
||||||
required: bool = False) -> str:
|
|
||||||
"""Returns html for editing a currency field
|
"""Returns html for editing a currency field
|
||||||
"""
|
"""
|
||||||
if value is None:
|
if value is None:
|
||||||
|
|
@ -1256,7 +1257,7 @@ def editCurrencyField(label: str, name: str, value: str = "0.00",
|
||||||
requiredStr + '>\n'
|
requiredStr + '>\n'
|
||||||
|
|
||||||
|
|
||||||
def editCheckBox(label: str, name: str, checked: bool = False) -> str:
|
def editCheckBox(label: str, name: str, checked: bool) -> str:
|
||||||
"""Returns html for editing a checkbox field
|
"""Returns html for editing a checkbox field
|
||||||
"""
|
"""
|
||||||
checkedStr = ''
|
checkedStr = ''
|
||||||
|
|
@ -1268,10 +1269,8 @@ def editCheckBox(label: str, name: str, checked: bool = False) -> str:
|
||||||
'name="' + name + '"' + checkedStr + '> ' + label + '<br>\n'
|
'name="' + name + '"' + checkedStr + '> ' + label + '<br>\n'
|
||||||
|
|
||||||
|
|
||||||
def editTextArea(label: str, name: str, value: str = "",
|
def editTextArea(label: str, name: str, value: str,
|
||||||
height: int = 600,
|
height: int, placeholder: str, spellcheck: bool) -> str:
|
||||||
placeholder: str = "",
|
|
||||||
spellcheck: bool = False) -> str:
|
|
||||||
"""Returns html for editing a textarea field
|
"""Returns html for editing a textarea field
|
||||||
"""
|
"""
|
||||||
if value is None:
|
if value is None:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue