mirror of https://gitlab.com/bashrc2/epicyon
More specific exceptions
parent
8c4c1782ad
commit
6953b2cd43
64
auth.py
64
auth.py
|
@ -163,21 +163,38 @@ def storeBasicCredentials(baseDir: str, nickname: str, password: str) -> bool:
|
||||||
storeStr = nickname + ':' + _hashPassword(password)
|
storeStr = nickname + ':' + _hashPassword(password)
|
||||||
if os.path.isfile(passwordFile):
|
if os.path.isfile(passwordFile):
|
||||||
if nickname + ':' in open(passwordFile).read():
|
if nickname + ':' in open(passwordFile).read():
|
||||||
with open(passwordFile, 'r') as fin:
|
try:
|
||||||
with open(passwordFile + '.new', 'w+') as fout:
|
with open(passwordFile, 'r') as fin:
|
||||||
for line in fin:
|
with open(passwordFile + '.new', 'w+') as fout:
|
||||||
if not line.startswith(nickname + ':'):
|
for line in fin:
|
||||||
fout.write(line)
|
if not line.startswith(nickname + ':'):
|
||||||
else:
|
fout.write(line)
|
||||||
fout.write(storeStr + '\n')
|
else:
|
||||||
os.rename(passwordFile + '.new', passwordFile)
|
fout.write(storeStr + '\n')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to save password ' + passwordFile)
|
||||||
|
return False
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.rename(passwordFile + '.new', passwordFile)
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to save password 2')
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
# append to password file
|
# append to password file
|
||||||
with open(passwordFile, 'a+') as passfile:
|
try:
|
||||||
passfile.write(storeStr + '\n')
|
with open(passwordFile, 'a+') as passfile:
|
||||||
|
passfile.write(storeStr + '\n')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to append password')
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
with open(passwordFile, 'w+') as passfile:
|
try:
|
||||||
passfile.write(storeStr + '\n')
|
with open(passwordFile, 'w+') as passfile:
|
||||||
|
passfile.write(storeStr + '\n')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to create password file')
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -187,12 +204,21 @@ def removePassword(baseDir: str, nickname: str) -> None:
|
||||||
"""
|
"""
|
||||||
passwordFile = baseDir + '/accounts/passwords'
|
passwordFile = baseDir + '/accounts/passwords'
|
||||||
if os.path.isfile(passwordFile):
|
if os.path.isfile(passwordFile):
|
||||||
with open(passwordFile, 'r') as fin:
|
try:
|
||||||
with open(passwordFile + '.new', 'w+') as fout:
|
with open(passwordFile, 'r') as fin:
|
||||||
for line in fin:
|
with open(passwordFile + '.new', 'w+') as fout:
|
||||||
if not line.startswith(nickname + ':'):
|
for line in fin:
|
||||||
fout.write(line)
|
if not line.startswith(nickname + ':'):
|
||||||
os.rename(passwordFile + '.new', passwordFile)
|
fout.write(line)
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to remove password from file')
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.rename(passwordFile + '.new', passwordFile)
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to remove password from file 2')
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def authorize(baseDir: str, path: str, authHeader: str, debug: bool) -> bool:
|
def authorize(baseDir: str, path: str, authHeader: str, debug: bool) -> bool:
|
||||||
|
@ -254,6 +280,6 @@ def recordLoginFailure(baseDir: str, ipAddress: str,
|
||||||
'Disconnecting invalid user epicyon ' +
|
'Disconnecting invalid user epicyon ' +
|
||||||
ipAddress + ' port 443: ' +
|
ipAddress + ' port 443: ' +
|
||||||
'Too many authentication failures [preauth]\n')
|
'Too many authentication failures [preauth]\n')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: recordLoginFailure failed ' + str(failureLog))
|
print('EX: recordLoginFailure failed ' + str(failureLog))
|
||||||
pass
|
pass
|
||||||
|
|
71
blocking.py
71
blocking.py
|
@ -146,11 +146,17 @@ def removeGlobalBlock(baseDir: str,
|
||||||
if os.path.isfile(unblockingFilename):
|
if os.path.isfile(unblockingFilename):
|
||||||
if unblockHandle in open(unblockingFilename).read():
|
if unblockHandle in open(unblockingFilename).read():
|
||||||
with open(unblockingFilename, 'r') as fp:
|
with open(unblockingFilename, 'r') as fp:
|
||||||
with open(unblockingFilename + '.new', 'w+') as fpnew:
|
try:
|
||||||
for line in fp:
|
with open(unblockingFilename + '.new', 'w+') as fpnew:
|
||||||
handle = line.replace('\n', '').replace('\r', '')
|
for line in fp:
|
||||||
if unblockHandle not in line:
|
handle = \
|
||||||
fpnew.write(handle + '\n')
|
line.replace('\n', '').replace('\r', '')
|
||||||
|
if unblockHandle not in line:
|
||||||
|
fpnew.write(handle + '\n')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: failed to remove global block ' +
|
||||||
|
unblockingFilename)
|
||||||
|
return False
|
||||||
if os.path.isfile(unblockingFilename + '.new'):
|
if os.path.isfile(unblockingFilename + '.new'):
|
||||||
os.rename(unblockingFilename + '.new', unblockingFilename)
|
os.rename(unblockingFilename + '.new', unblockingFilename)
|
||||||
return True
|
return True
|
||||||
|
@ -159,12 +165,17 @@ def removeGlobalBlock(baseDir: str,
|
||||||
if os.path.isfile(unblockingFilename):
|
if os.path.isfile(unblockingFilename):
|
||||||
if unblockHashtag + '\n' in open(unblockingFilename).read():
|
if unblockHashtag + '\n' in open(unblockingFilename).read():
|
||||||
with open(unblockingFilename, 'r') as fp:
|
with open(unblockingFilename, 'r') as fp:
|
||||||
with open(unblockingFilename + '.new', 'w+') as fpnew:
|
try:
|
||||||
for line in fp:
|
with open(unblockingFilename + '.new', 'w+') as fpnew:
|
||||||
blockLine = \
|
for line in fp:
|
||||||
line.replace('\n', '').replace('\r', '')
|
blockLine = \
|
||||||
if unblockHashtag not in line:
|
line.replace('\n', '').replace('\r', '')
|
||||||
fpnew.write(blockLine + '\n')
|
if unblockHashtag not in line:
|
||||||
|
fpnew.write(blockLine + '\n')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: failed to remove global hashtag block ' +
|
||||||
|
unblockingFilename)
|
||||||
|
return False
|
||||||
if os.path.isfile(unblockingFilename + '.new'):
|
if os.path.isfile(unblockingFilename + '.new'):
|
||||||
os.rename(unblockingFilename + '.new', unblockingFilename)
|
os.rename(unblockingFilename + '.new', unblockingFilename)
|
||||||
return True
|
return True
|
||||||
|
@ -181,11 +192,15 @@ def removeBlock(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(unblockingFilename):
|
if os.path.isfile(unblockingFilename):
|
||||||
if unblockHandle in open(unblockingFilename).read():
|
if unblockHandle in open(unblockingFilename).read():
|
||||||
with open(unblockingFilename, 'r') as fp:
|
with open(unblockingFilename, 'r') as fp:
|
||||||
with open(unblockingFilename + '.new', 'w+') as fpnew:
|
try:
|
||||||
for line in fp:
|
with open(unblockingFilename + '.new', 'w+') as fpnew:
|
||||||
handle = line.replace('\n', '').replace('\r', '')
|
for line in fp:
|
||||||
if unblockHandle not in line:
|
handle = line.replace('\n', '').replace('\r', '')
|
||||||
fpnew.write(handle + '\n')
|
if unblockHandle not in line:
|
||||||
|
fpnew.write(handle + '\n')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: failed to remove block ' + unblockingFilename)
|
||||||
|
return False
|
||||||
if os.path.isfile(unblockingFilename + '.new'):
|
if os.path.isfile(unblockingFilename + '.new'):
|
||||||
os.rename(unblockingFilename + '.new', unblockingFilename)
|
os.rename(unblockingFilename + '.new', unblockingFilename)
|
||||||
return True
|
return True
|
||||||
|
@ -553,9 +568,13 @@ def mutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
else:
|
else:
|
||||||
print('MUTE: cached post not found ' + cachedPostFilename)
|
print('MUTE: cached post not found ' + cachedPostFilename)
|
||||||
|
|
||||||
with open(postFilename + '.muted', 'w+') as muteFile:
|
try:
|
||||||
muteFile.write('\n')
|
with open(postFilename + '.muted', 'w+') as muteFile:
|
||||||
print('MUTE: ' + postFilename + '.muted file added')
|
muteFile.write('\n')
|
||||||
|
print('MUTE: ' + postFilename + '.muted file added')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: Failed to save mute file ' + postFilename + '.muted')
|
||||||
|
return
|
||||||
|
|
||||||
# if the post is in the recent posts cache then mark it as muted
|
# if the post is in the recent posts cache then mark it as muted
|
||||||
if recentPostsCache.get('index'):
|
if recentPostsCache.get('index'):
|
||||||
|
@ -882,11 +901,15 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None:
|
||||||
break
|
break
|
||||||
|
|
||||||
# write the allow file
|
# write the allow file
|
||||||
with open(allowFilename, 'w+') as allowFile:
|
try:
|
||||||
allowFile.write(domainFull + '\n')
|
with open(allowFilename, 'w+') as allowFile:
|
||||||
for d in allowedDomains:
|
allowFile.write(domainFull + '\n')
|
||||||
allowFile.write(d + '\n')
|
for d in allowedDomains:
|
||||||
print('Broch mode enabled')
|
allowFile.write(d + '\n')
|
||||||
|
print('Broch mode enabled')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: Broch mode not enabled due to file write')
|
||||||
|
return
|
||||||
|
|
||||||
setConfigParam(baseDir, "brochMode", enabled)
|
setConfigParam(baseDir, "brochMode", enabled)
|
||||||
|
|
||||||
|
|
15
blog.py
15
blog.py
|
@ -91,11 +91,16 @@ def _noOfBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
||||||
if lines and removals:
|
if lines and removals:
|
||||||
print('Rewriting ' + postFilename + ' to remove ' +
|
print('Rewriting ' + postFilename + ' to remove ' +
|
||||||
str(len(removals)) + ' entries')
|
str(len(removals)) + ' entries')
|
||||||
with open(postFilename, 'w+') as f:
|
try:
|
||||||
for replyPostId in lines:
|
with open(postFilename, 'w+') as f:
|
||||||
replyPostId = replyPostId.replace('\n', '').replace('\r', '')
|
for replyPostId in lines:
|
||||||
if replyPostId not in removals:
|
replyPostId = \
|
||||||
f.write(replyPostId + '\n')
|
replyPostId.replace('\n', '').replace('\r', '')
|
||||||
|
if replyPostId not in removals:
|
||||||
|
f.write(replyPostId + '\n')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to remove replies from post ' + postFilename)
|
||||||
|
pass
|
||||||
|
|
||||||
return replies
|
return replies
|
||||||
|
|
||||||
|
|
25
bookmarks.py
25
bookmarks.py
|
@ -51,12 +51,11 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
if debug:
|
if debug:
|
||||||
print('EX: undoBookmarksCollectionEntry ' +
|
print('EX: undoBookmarksCollectionEntry ' +
|
||||||
'unable to delete cached post file ' +
|
'unable to delete cached post file ' +
|
||||||
str(cachedPostFilename))
|
str(cachedPostFilename))
|
||||||
pass
|
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
# remove from the index
|
# remove from the index
|
||||||
|
@ -74,9 +73,13 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
|
||||||
indexStr = ''
|
indexStr = ''
|
||||||
with open(bookmarksIndexFilename, 'r') as indexFile:
|
with open(bookmarksIndexFilename, 'r') as indexFile:
|
||||||
indexStr = indexFile.read().replace(bookmarkIndex + '\n', '')
|
indexStr = indexFile.read().replace(bookmarkIndex + '\n', '')
|
||||||
with open(bookmarksIndexFilename, 'w+') as bookmarksIndexFile:
|
try:
|
||||||
bookmarksIndexFile.write(indexStr)
|
with open(bookmarksIndexFilename, 'w+') as bookmarksIndexFile:
|
||||||
|
bookmarksIndexFile.write(indexStr)
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write bookmarks index ' +
|
||||||
|
bookmarksIndexFilename)
|
||||||
|
pass
|
||||||
if not postJsonObject.get('type'):
|
if not postJsonObject.get('type'):
|
||||||
return
|
return
|
||||||
if postJsonObject['type'] != 'Create':
|
if postJsonObject['type'] != 'Create':
|
||||||
|
@ -163,12 +166,11 @@ def updateBookmarksCollection(recentPostsCache: {},
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
if debug:
|
if debug:
|
||||||
print('EX: updateBookmarksCollection ' +
|
print('EX: updateBookmarksCollection ' +
|
||||||
'unable to delete cached post ' +
|
'unable to delete cached post ' +
|
||||||
str(cachedPostFilename))
|
str(cachedPostFilename))
|
||||||
pass
|
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
if not postJsonObject.get('object'):
|
if not postJsonObject.get('object'):
|
||||||
|
@ -233,8 +235,13 @@ def updateBookmarksCollection(recentPostsCache: {},
|
||||||
print('WARN: Failed to write entry to bookmarks index ' +
|
print('WARN: Failed to write entry to bookmarks index ' +
|
||||||
bookmarksIndexFilename + ' ' + str(e))
|
bookmarksIndexFilename + ' ' + str(e))
|
||||||
else:
|
else:
|
||||||
with open(bookmarksIndexFilename, 'w+') as bookmarksIndexFile:
|
try:
|
||||||
bookmarksIndexFile.write(bookmarkIndex + '\n')
|
with open(bookmarksIndexFilename, 'w+') as bookmarksIndexFile:
|
||||||
|
bookmarksIndexFile.write(bookmarkIndex + '\n')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write bookmarks index ' +
|
||||||
|
bookmarksIndexFilename)
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def bookmark(recentPostsCache: {},
|
def bookmark(recentPostsCache: {},
|
||||||
|
|
3
cache.py
3
cache.py
|
@ -26,9 +26,8 @@ def _removePersonFromCache(baseDir: str, personUrl: str,
|
||||||
if os.path.isfile(cacheFilename):
|
if os.path.isfile(cacheFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cacheFilename)
|
os.remove(cacheFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: unable to delete cached actor ' + str(cacheFilename))
|
print('EX: unable to delete cached actor ' + str(cacheFilename))
|
||||||
pass
|
|
||||||
if personCache.get(personUrl):
|
if personCache.get(personUrl):
|
||||||
del personCache[personUrl]
|
del personCache[personUrl]
|
||||||
|
|
||||||
|
|
|
@ -95,11 +95,10 @@ def updateHashtagCategories(baseDir: str) -> None:
|
||||||
if os.path.isfile(categoryListFilename):
|
if os.path.isfile(categoryListFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(categoryListFilename)
|
os.remove(categoryListFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: updateHashtagCategories ' +
|
print('EX: updateHashtagCategories ' +
|
||||||
'unable to delete cached category list ' +
|
'unable to delete cached category list ' +
|
||||||
categoryListFilename)
|
categoryListFilename)
|
||||||
pass
|
|
||||||
return
|
return
|
||||||
|
|
||||||
categoryList = []
|
categoryList = []
|
||||||
|
@ -112,8 +111,11 @@ def updateHashtagCategories(baseDir: str) -> None:
|
||||||
categoryListStr += categoryStr + '\n'
|
categoryListStr += categoryStr + '\n'
|
||||||
|
|
||||||
# save a list of available categories for quick lookup
|
# save a list of available categories for quick lookup
|
||||||
with open(categoryListFilename, 'w+') as fp:
|
try:
|
||||||
fp.write(categoryListStr)
|
with open(categoryListFilename, 'w+') as fp:
|
||||||
|
fp.write(categoryListStr)
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write category ' + categoryListFilename)
|
||||||
|
|
||||||
|
|
||||||
def _validHashtagCategory(category: str) -> bool:
|
def _validHashtagCategory(category: str) -> bool:
|
||||||
|
@ -159,12 +161,15 @@ def setHashtagCategory(baseDir: str, hashtag: str, category: str,
|
||||||
# don't overwrite any existing categories
|
# don't overwrite any existing categories
|
||||||
if os.path.isfile(categoryFilename):
|
if os.path.isfile(categoryFilename):
|
||||||
return False
|
return False
|
||||||
with open(categoryFilename, 'w+') as fp:
|
try:
|
||||||
fp.write(category)
|
with open(categoryFilename, 'w+') as fp:
|
||||||
if update:
|
fp.write(category)
|
||||||
updateHashtagCategories(baseDir)
|
if update:
|
||||||
return True
|
updateHashtagCategories(baseDir)
|
||||||
|
return True
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write category ' + categoryFilename)
|
||||||
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
16
content.py
16
content.py
|
@ -1015,21 +1015,19 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
if os.path.isfile(possibleOtherFormat):
|
if os.path.isfile(possibleOtherFormat):
|
||||||
try:
|
try:
|
||||||
os.remove(possibleOtherFormat)
|
os.remove(possibleOtherFormat)
|
||||||
except BaseException:
|
except OSError:
|
||||||
if debug:
|
if debug:
|
||||||
print('EX: saveMediaInFormPOST ' +
|
print('EX: saveMediaInFormPOST ' +
|
||||||
'unable to delete other ' +
|
'unable to delete other ' +
|
||||||
str(possibleOtherFormat))
|
str(possibleOtherFormat))
|
||||||
pass
|
|
||||||
if os.path.isfile(filenameBase):
|
if os.path.isfile(filenameBase):
|
||||||
try:
|
try:
|
||||||
os.remove(filenameBase)
|
os.remove(filenameBase)
|
||||||
except BaseException:
|
except OSError:
|
||||||
if debug:
|
if debug:
|
||||||
print('EX: saveMediaInFormPOST ' +
|
print('EX: saveMediaInFormPOST ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
str(filenameBase))
|
str(filenameBase))
|
||||||
pass
|
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: No media found within POST')
|
print('DEBUG: No media found within POST')
|
||||||
|
@ -1097,12 +1095,11 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
if os.path.isfile(possibleOtherFormat):
|
if os.path.isfile(possibleOtherFormat):
|
||||||
try:
|
try:
|
||||||
os.remove(possibleOtherFormat)
|
os.remove(possibleOtherFormat)
|
||||||
except BaseException:
|
except OSError:
|
||||||
if debug:
|
if debug:
|
||||||
print('EX: saveMediaInFormPOST ' +
|
print('EX: saveMediaInFormPOST ' +
|
||||||
'unable to delete other 2 ' +
|
'unable to delete other 2 ' +
|
||||||
str(possibleOtherFormat))
|
str(possibleOtherFormat))
|
||||||
pass
|
|
||||||
|
|
||||||
# don't allow scripts within svg files
|
# don't allow scripts within svg files
|
||||||
if detectedExtension == 'svg':
|
if detectedExtension == 'svg':
|
||||||
|
@ -1111,8 +1108,11 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
if dangerousSVG(svgStr, False):
|
if dangerousSVG(svgStr, False):
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
with open(filename, 'wb') as fp:
|
try:
|
||||||
fp.write(mediaBytes[startPos:])
|
with open(filename, 'wb') as fp:
|
||||||
|
fp.write(mediaBytes[startPos:])
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write media')
|
||||||
|
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
print('WARN: Media file could not be written to file: ' + filename)
|
print('WARN: Media file could not be written to file: ' + filename)
|
||||||
|
|
|
@ -45,7 +45,7 @@ def updateConversation(baseDir: str, nickname: str, domain: str,
|
||||||
with open(conversationFilename, 'w+') as fp:
|
with open(conversationFilename, 'w+') as fp:
|
||||||
fp.write(postId + '\n')
|
fp.write(postId + '\n')
|
||||||
return True
|
return True
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: updateConversation ' +
|
print('EX: updateConversation ' +
|
||||||
'unable to write to ' + conversationFilename)
|
'unable to write to ' + conversationFilename)
|
||||||
pass
|
pass
|
||||||
|
@ -54,7 +54,7 @@ def updateConversation(baseDir: str, nickname: str, domain: str,
|
||||||
with open(conversationFilename, 'a+') as fp:
|
with open(conversationFilename, 'a+') as fp:
|
||||||
fp.write(postId + '\n')
|
fp.write(postId + '\n')
|
||||||
return True
|
return True
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: updateConversation 2 ' +
|
print('EX: updateConversation 2 ' +
|
||||||
'unable to write to ' + conversationFilename)
|
'unable to write to ' + conversationFilename)
|
||||||
pass
|
pass
|
||||||
|
@ -72,8 +72,12 @@ def muteConversation(baseDir: str, nickname: str, domain: str,
|
||||||
return
|
return
|
||||||
if os.path.isfile(conversationFilename + '.muted'):
|
if os.path.isfile(conversationFilename + '.muted'):
|
||||||
return
|
return
|
||||||
with open(conversationFilename + '.muted', 'w+') as fp:
|
try:
|
||||||
fp.write('\n')
|
with open(conversationFilename + '.muted', 'w+') as fp:
|
||||||
|
fp.write('\n')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write mute ' + conversationFilename)
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def unmuteConversation(baseDir: str, nickname: str, domain: str,
|
def unmuteConversation(baseDir: str, nickname: str, domain: str,
|
||||||
|
@ -89,7 +93,6 @@ def unmuteConversation(baseDir: str, nickname: str, domain: str,
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
os.remove(conversationFilename + '.muted')
|
os.remove(conversationFilename + '.muted')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: unmuteConversation unable to delete ' +
|
print('EX: unmuteConversation unable to delete ' +
|
||||||
conversationFilename + '.muted')
|
conversationFilename + '.muted')
|
||||||
pass
|
|
||||||
|
|
196
daemon.py
196
daemon.py
|
@ -532,8 +532,12 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.maxReplies,
|
self.server.maxReplies,
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
# record the vote
|
# record the vote
|
||||||
with open(votesFilename, 'a+') as votesFile:
|
try:
|
||||||
votesFile.write(messageId + '\n')
|
with open(votesFilename, 'a+') as votesFile:
|
||||||
|
votesFile.write(messageId + '\n')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write vote ' +
|
||||||
|
votesFilename)
|
||||||
|
|
||||||
# ensure that the cached post is removed if it exists,
|
# ensure that the cached post is removed if it exists,
|
||||||
# so that it then will be recreated
|
# so that it then will be recreated
|
||||||
|
@ -546,11 +550,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _sendReplyToQuestion ' +
|
print('EX: _sendReplyToQuestion ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
cachedPostFilename)
|
cachedPostFilename)
|
||||||
pass
|
|
||||||
# remove from memory cache
|
# remove from memory cache
|
||||||
removePostFromCache(postJsonObject,
|
removePostFromCache(postJsonObject,
|
||||||
self.server.recentPostsCache)
|
self.server.recentPostsCache)
|
||||||
|
@ -847,7 +850,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
with open(mediaFilename + '.etag', 'w+') as etagFile:
|
with open(mediaFilename + '.etag', 'w+') as etagFile:
|
||||||
etagFile.write(etag)
|
etagFile.write(etag)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _set_headers_etag ' +
|
print('EX: _set_headers_etag ' +
|
||||||
'unable to write ' + mediaFilename + '.etag')
|
'unable to write ' + mediaFilename + '.etag')
|
||||||
pass
|
pass
|
||||||
|
@ -1758,14 +1761,14 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
with open(saltFilename, 'r') as fp:
|
with open(saltFilename, 'r') as fp:
|
||||||
salt = fp.read()
|
salt = fp.read()
|
||||||
except Exception as e:
|
except OSError as e:
|
||||||
print('WARN: Unable to read salt for ' +
|
print('WARN: Unable to read salt for ' +
|
||||||
loginNickname + ' ' + str(e))
|
loginNickname + ' ' + str(e))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(saltFilename, 'w+') as fp:
|
with open(saltFilename, 'w+') as fp:
|
||||||
fp.write(salt)
|
fp.write(salt)
|
||||||
except Exception as e:
|
except OSError as e:
|
||||||
print('WARN: Unable to save salt for ' +
|
print('WARN: Unable to save salt for ' +
|
||||||
loginNickname + ' ' + str(e))
|
loginNickname + ' ' + str(e))
|
||||||
|
|
||||||
|
@ -1779,7 +1782,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
with open(tokenFilename, 'w+') as fp:
|
with open(tokenFilename, 'w+') as fp:
|
||||||
fp.write(token)
|
fp.write(token)
|
||||||
except Exception as e:
|
except OSError as e:
|
||||||
print('WARN: Unable to save token for ' +
|
print('WARN: Unable to save token for ' +
|
||||||
loginNickname + ' ' + str(e))
|
loginNickname + ' ' + str(e))
|
||||||
|
|
||||||
|
@ -2348,17 +2351,19 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(newswireBlockedFilename):
|
if os.path.isfile(newswireBlockedFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(newswireBlockedFilename)
|
os.remove(newswireBlockedFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _personOptions unable to delete ' +
|
print('EX: _personOptions unable to delete ' +
|
||||||
newswireBlockedFilename)
|
newswireBlockedFilename)
|
||||||
pass
|
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(accountDir):
|
if os.path.isdir(accountDir):
|
||||||
nwFilename = newswireBlockedFilename
|
nwFilename = newswireBlockedFilename
|
||||||
with open(nwFilename, 'w+') as noNewswireFile:
|
try:
|
||||||
noNewswireFile.write('\n')
|
with open(nwFilename, 'w+') as noNewswireFile:
|
||||||
refreshNewswire(self.server.baseDir)
|
noNewswireFile.write('\n')
|
||||||
|
refreshNewswire(self.server.baseDir)
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write ' + nwFilename)
|
||||||
usersPathStr = \
|
usersPathStr = \
|
||||||
usersPath + '/' + self.server.defaultTimeline + \
|
usersPath + '/' + self.server.defaultTimeline + \
|
||||||
'?page=' + str(pageNumber)
|
'?page=' + str(pageNumber)
|
||||||
|
@ -2388,17 +2393,19 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(featuresBlockedFilename):
|
if os.path.isfile(featuresBlockedFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(featuresBlockedFilename)
|
os.remove(featuresBlockedFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _personOptions unable to delete ' +
|
print('EX: _personOptions unable to delete ' +
|
||||||
featuresBlockedFilename)
|
featuresBlockedFilename)
|
||||||
pass
|
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(accountDir):
|
if os.path.isdir(accountDir):
|
||||||
featFilename = featuresBlockedFilename
|
featFilename = featuresBlockedFilename
|
||||||
with open(featFilename, 'w+') as noFeaturesFile:
|
try:
|
||||||
noFeaturesFile.write('\n')
|
with open(featFilename, 'w+') as noFeaturesFile:
|
||||||
refreshNewswire(self.server.baseDir)
|
noFeaturesFile.write('\n')
|
||||||
|
refreshNewswire(self.server.baseDir)
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write ' + featFilename)
|
||||||
usersPathStr = \
|
usersPathStr = \
|
||||||
usersPath + '/' + self.server.defaultTimeline + \
|
usersPath + '/' + self.server.defaultTimeline + \
|
||||||
'?page=' + str(pageNumber)
|
'?page=' + str(pageNumber)
|
||||||
|
@ -2428,15 +2435,17 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(newswireModFilename):
|
if os.path.isfile(newswireModFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(newswireModFilename)
|
os.remove(newswireModFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _personOptions unable to delete ' +
|
print('EX: _personOptions unable to delete ' +
|
||||||
newswireModFilename)
|
newswireModFilename)
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(accountDir):
|
if os.path.isdir(accountDir):
|
||||||
nwFilename = newswireModFilename
|
nwFilename = newswireModFilename
|
||||||
with open(nwFilename, 'w+') as modNewswireFile:
|
try:
|
||||||
modNewswireFile.write('\n')
|
with open(nwFilename, 'w+') as modNewswireFile:
|
||||||
|
modNewswireFile.write('\n')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write ' + nwFilename)
|
||||||
usersPathStr = \
|
usersPathStr = \
|
||||||
usersPath + '/' + self.server.defaultTimeline + \
|
usersPath + '/' + self.server.defaultTimeline + \
|
||||||
'?page=' + str(pageNumber)
|
'?page=' + str(pageNumber)
|
||||||
|
@ -3582,8 +3591,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
mediaFilename = \
|
mediaFilename = \
|
||||||
mediaFilenameBase + '.' + \
|
mediaFilenameBase + '.' + \
|
||||||
getImageExtensionFromMimeType(self.headers['Content-type'])
|
getImageExtensionFromMimeType(self.headers['Content-type'])
|
||||||
with open(mediaFilename, 'wb') as avFile:
|
try:
|
||||||
avFile.write(mediaBytes)
|
with open(mediaFilename, 'wb') as avFile:
|
||||||
|
avFile.write(mediaBytes)
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write ' + mediaFilename)
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: image saved to ' + mediaFilename)
|
print('DEBUG: image saved to ' + mediaFilename)
|
||||||
self.send_response(201)
|
self.send_response(201)
|
||||||
|
@ -3901,10 +3913,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(linksFilename):
|
if os.path.isfile(linksFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(linksFilename)
|
os.remove(linksFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _linksUpdate unable to delete ' +
|
print('EX: _linksUpdate unable to delete ' +
|
||||||
linksFilename)
|
linksFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
adminNickname = \
|
adminNickname = \
|
||||||
getConfigParam(baseDir, 'admin')
|
getConfigParam(baseDir, 'admin')
|
||||||
|
@ -3919,10 +3930,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(aboutFilename):
|
if os.path.isfile(aboutFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(aboutFilename)
|
os.remove(aboutFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _linksUpdate unable to delete ' +
|
print('EX: _linksUpdate unable to delete ' +
|
||||||
aboutFilename)
|
aboutFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
if fields.get('editedTOS'):
|
if fields.get('editedTOS'):
|
||||||
TOSStr = fields['editedTOS']
|
TOSStr = fields['editedTOS']
|
||||||
|
@ -3934,10 +3944,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(TOSFilename):
|
if os.path.isfile(TOSFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(TOSFilename)
|
os.remove(TOSFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _linksUpdate unable to delete ' +
|
print('EX: _linksUpdate unable to delete ' +
|
||||||
TOSFilename)
|
TOSFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
self._redirect_headers(actorStr + '/' + defaultTimeline,
|
self._redirect_headers(actorStr + '/' + defaultTimeline,
|
||||||
|
@ -4037,10 +4046,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(categoryFilename):
|
if os.path.isfile(categoryFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(categoryFilename)
|
os.remove(categoryFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _setHashtagCategory unable to delete ' +
|
print('EX: _setHashtagCategory unable to delete ' +
|
||||||
categoryFilename)
|
categoryFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
self._redirect_headers(tagScreenStr,
|
self._redirect_headers(tagScreenStr,
|
||||||
|
@ -4114,63 +4122,71 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
extractTextFieldsInPOST(postBytes, boundary, debug)
|
extractTextFieldsInPOST(postBytes, boundary, debug)
|
||||||
if fields.get('editedNewswire'):
|
if fields.get('editedNewswire'):
|
||||||
newswireStr = fields['editedNewswire']
|
newswireStr = fields['editedNewswire']
|
||||||
with open(newswireFilename, 'w+') as newswireFile:
|
try:
|
||||||
newswireFile.write(newswireStr)
|
with open(newswireFilename, 'w+') as newswireFile:
|
||||||
|
newswireFile.write(newswireStr)
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write ' + newswireFilename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(newswireFilename):
|
if os.path.isfile(newswireFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(newswireFilename)
|
os.remove(newswireFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _newswireUpdate unable to delete ' +
|
print('EX: _newswireUpdate unable to delete ' +
|
||||||
newswireFilename)
|
newswireFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# save filtered words list for the newswire
|
# save filtered words list for the newswire
|
||||||
filterNewswireFilename = \
|
filterNewswireFilename = \
|
||||||
baseDir + '/accounts/' + \
|
baseDir + '/accounts/' + \
|
||||||
'news@' + domain + '/filters.txt'
|
'news@' + domain + '/filters.txt'
|
||||||
if fields.get('filteredWordsNewswire'):
|
if fields.get('filteredWordsNewswire'):
|
||||||
with open(filterNewswireFilename, 'w+') as filterfile:
|
try:
|
||||||
filterfile.write(fields['filteredWordsNewswire'])
|
with open(filterNewswireFilename, 'w+') as filterfile:
|
||||||
|
filterfile.write(fields['filteredWordsNewswire'])
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write ' + filterNewswireFilename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filterNewswireFilename):
|
if os.path.isfile(filterNewswireFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(filterNewswireFilename)
|
os.remove(filterNewswireFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _newswireUpdate unable to delete ' +
|
print('EX: _newswireUpdate unable to delete ' +
|
||||||
filterNewswireFilename)
|
filterNewswireFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# save news tagging rules
|
# save news tagging rules
|
||||||
hashtagRulesFilename = \
|
hashtagRulesFilename = \
|
||||||
baseDir + '/accounts/hashtagrules.txt'
|
baseDir + '/accounts/hashtagrules.txt'
|
||||||
if fields.get('hashtagRulesList'):
|
if fields.get('hashtagRulesList'):
|
||||||
with open(hashtagRulesFilename, 'w+') as rulesfile:
|
try:
|
||||||
rulesfile.write(fields['hashtagRulesList'])
|
with open(hashtagRulesFilename, 'w+') as rulesfile:
|
||||||
|
rulesfile.write(fields['hashtagRulesList'])
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write ' + hashtagRulesFilename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(hashtagRulesFilename):
|
if os.path.isfile(hashtagRulesFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(hashtagRulesFilename)
|
os.remove(hashtagRulesFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _newswireUpdate unable to delete ' +
|
print('EX: _newswireUpdate unable to delete ' +
|
||||||
hashtagRulesFilename)
|
hashtagRulesFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
newswireTrustedFilename = baseDir + '/accounts/newswiretrusted.txt'
|
newswireTrustedFilename = baseDir + '/accounts/newswiretrusted.txt'
|
||||||
if fields.get('trustedNewswire'):
|
if fields.get('trustedNewswire'):
|
||||||
newswireTrusted = fields['trustedNewswire']
|
newswireTrusted = fields['trustedNewswire']
|
||||||
if not newswireTrusted.endswith('\n'):
|
if not newswireTrusted.endswith('\n'):
|
||||||
newswireTrusted += '\n'
|
newswireTrusted += '\n'
|
||||||
with open(newswireTrustedFilename, 'w+') as trustFile:
|
try:
|
||||||
trustFile.write(newswireTrusted)
|
with open(newswireTrustedFilename, 'w+') as trustFile:
|
||||||
|
trustFile.write(newswireTrusted)
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write ' + newswireTrustedFilename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(newswireTrustedFilename):
|
if os.path.isfile(newswireTrustedFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(newswireTrustedFilename)
|
os.remove(newswireTrustedFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _newswireUpdate unable to delete ' +
|
print('EX: _newswireUpdate unable to delete ' +
|
||||||
newswireTrustedFilename)
|
newswireTrustedFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
self._redirect_headers(actorStr + '/' + defaultTimeline,
|
self._redirect_headers(actorStr + '/' + defaultTimeline,
|
||||||
|
@ -4197,10 +4213,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(citationsFilename):
|
if os.path.isfile(citationsFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(citationsFilename)
|
os.remove(citationsFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _citationsUpdate unable to delete ' +
|
print('EX: _citationsUpdate unable to delete ' +
|
||||||
citationsFilename)
|
citationsFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
if newswire and \
|
if newswire and \
|
||||||
' boundary=' in self.headers['Content-type']:
|
' boundary=' in self.headers['Content-type']:
|
||||||
|
@ -4257,8 +4272,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
citationsStr += citationDate + '\n'
|
citationsStr += citationDate + '\n'
|
||||||
# save citations dates, so that they can be added when
|
# save citations dates, so that they can be added when
|
||||||
# reloading the newblog screen
|
# reloading the newblog screen
|
||||||
with open(citationsFilename, 'w+') as citationsFile:
|
try:
|
||||||
citationsFile.write(citationsStr)
|
with open(citationsFilename, 'w+') as citationsFile:
|
||||||
|
citationsFile.write(citationsStr)
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write ' + citationsFilename)
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
self._redirect_headers(actorStr + '/newblog',
|
self._redirect_headers(actorStr + '/newblog',
|
||||||
|
@ -4504,10 +4522,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(filenameBase):
|
if os.path.isfile(filenameBase):
|
||||||
try:
|
try:
|
||||||
os.remove(filenameBase)
|
os.remove(filenameBase)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate unable to delete ' +
|
print('EX: _profileUpdate unable to delete ' +
|
||||||
filenameBase)
|
filenameBase)
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
filenameBase = \
|
filenameBase = \
|
||||||
acctDir(baseDir, nickname, domain) + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
|
@ -4541,10 +4558,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(postImageFilename + '.etag'):
|
if os.path.isfile(postImageFilename + '.etag'):
|
||||||
try:
|
try:
|
||||||
os.remove(postImageFilename + '.etag')
|
os.remove(postImageFilename + '.etag')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate unable to delete ' +
|
print('EX: _profileUpdate unable to delete ' +
|
||||||
postImageFilename + '.etag')
|
postImageFilename + '.etag')
|
||||||
pass
|
|
||||||
|
|
||||||
city = getSpoofedCity(self.server.city,
|
city = getSpoofedCity(self.server.city,
|
||||||
baseDir, nickname, domain)
|
baseDir, nickname, domain)
|
||||||
|
@ -4712,8 +4728,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if fields.get('cityDropdown'):
|
if fields.get('cityDropdown'):
|
||||||
cityFilename = \
|
cityFilename = \
|
||||||
acctDir(baseDir, nickname, domain) + '/city.txt'
|
acctDir(baseDir, nickname, domain) + '/city.txt'
|
||||||
with open(cityFilename, 'w+') as fp:
|
try:
|
||||||
fp.write(fields['cityDropdown'])
|
with open(cityFilename, 'w+') as fp:
|
||||||
|
fp.write(fields['cityDropdown'])
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write ' + cityFilename)
|
||||||
|
|
||||||
# change displayed name
|
# change displayed name
|
||||||
if fields.get('displayNickname'):
|
if fields.get('displayNickname'):
|
||||||
|
@ -5597,11 +5616,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
os.remove(baseDir +
|
os.remove(baseDir +
|
||||||
'/fonts/custom.' + ext)
|
'/fonts/custom.' + ext)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
baseDir + '/fonts/custom.' + ext)
|
baseDir + '/fonts/custom.' + ext)
|
||||||
pass
|
|
||||||
if os.path.isfile(baseDir +
|
if os.path.isfile(baseDir +
|
||||||
'/fonts/custom.' + ext +
|
'/fonts/custom.' + ext +
|
||||||
'.etag'):
|
'.etag'):
|
||||||
|
@ -5609,12 +5627,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
os.remove(baseDir +
|
os.remove(baseDir +
|
||||||
'/fonts/custom.' + ext +
|
'/fonts/custom.' + ext +
|
||||||
'.etag')
|
'.etag')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
baseDir + '/fonts/custom.' +
|
baseDir + '/fonts/custom.' +
|
||||||
ext + '.etag')
|
ext + '.etag')
|
||||||
pass
|
|
||||||
currTheme = getTheme(baseDir)
|
currTheme = getTheme(baseDir)
|
||||||
if currTheme:
|
if currTheme:
|
||||||
self.server.themeName = currTheme
|
self.server.themeName = currTheme
|
||||||
|
@ -5664,11 +5681,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(followDMsFilename):
|
if os.path.isfile(followDMsFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(followDMsFilename)
|
os.remove(followDMsFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
followDMsFilename)
|
followDMsFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# remove Twitter retweets
|
# remove Twitter retweets
|
||||||
removeTwitterFilename = \
|
removeTwitterFilename = \
|
||||||
|
@ -5685,11 +5701,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(removeTwitterFilename):
|
if os.path.isfile(removeTwitterFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(removeTwitterFilename)
|
os.remove(removeTwitterFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
removeTwitterFilename)
|
removeTwitterFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# hide Like button
|
# hide Like button
|
||||||
hideLikeButtonFile = \
|
hideLikeButtonFile = \
|
||||||
|
@ -5708,20 +5723,18 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(notifyLikesFilename):
|
if os.path.isfile(notifyLikesFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(notifyLikesFilename)
|
os.remove(notifyLikesFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
notifyLikesFilename)
|
notifyLikesFilename)
|
||||||
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 OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
hideLikeButtonFile)
|
hideLikeButtonFile)
|
||||||
pass
|
|
||||||
|
|
||||||
# hide Reaction button
|
# hide Reaction button
|
||||||
hideReactionButtonFile = \
|
hideReactionButtonFile = \
|
||||||
|
@ -5740,20 +5753,18 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(notifyReactionsFilename):
|
if os.path.isfile(notifyReactionsFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(notifyReactionsFilename)
|
os.remove(notifyReactionsFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
notifyReactionsFilename)
|
notifyReactionsFilename)
|
||||||
pass
|
|
||||||
if not hideReactionButtonActive:
|
if not hideReactionButtonActive:
|
||||||
if os.path.isfile(hideReactionButtonFile):
|
if os.path.isfile(hideReactionButtonFile):
|
||||||
try:
|
try:
|
||||||
os.remove(hideReactionButtonFile)
|
os.remove(hideReactionButtonFile)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
hideReactionButtonFile)
|
hideReactionButtonFile)
|
||||||
pass
|
|
||||||
|
|
||||||
# notify about new Likes
|
# notify about new Likes
|
||||||
if onFinalWelcomeScreen:
|
if onFinalWelcomeScreen:
|
||||||
|
@ -5773,11 +5784,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(notifyLikesFilename):
|
if os.path.isfile(notifyLikesFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(notifyLikesFilename)
|
os.remove(notifyLikesFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
notifyLikesFilename)
|
notifyLikesFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
notifyReactionsFilename = \
|
notifyReactionsFilename = \
|
||||||
acctDir(baseDir, nickname, domain) + \
|
acctDir(baseDir, nickname, domain) + \
|
||||||
|
@ -5800,11 +5810,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(notifyReactionsFilename):
|
if os.path.isfile(notifyReactionsFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(notifyReactionsFilename)
|
os.remove(notifyReactionsFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
notifyReactionsFilename)
|
notifyReactionsFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# this account is a bot
|
# this account is a bot
|
||||||
if fields.get('isBot'):
|
if fields.get('isBot'):
|
||||||
|
@ -5865,11 +5874,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(filterFilename):
|
if os.path.isfile(filterFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(filterFilename)
|
os.remove(filterFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
filterFilename)
|
filterFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# word replacements
|
# word replacements
|
||||||
switchFilename = \
|
switchFilename = \
|
||||||
|
@ -5882,11 +5890,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(switchFilename):
|
if os.path.isfile(switchFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(switchFilename)
|
os.remove(switchFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
switchFilename)
|
switchFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# autogenerated tags
|
# autogenerated tags
|
||||||
autoTagsFilename = \
|
autoTagsFilename = \
|
||||||
|
@ -5899,11 +5906,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(autoTagsFilename):
|
if os.path.isfile(autoTagsFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(autoTagsFilename)
|
os.remove(autoTagsFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
autoTagsFilename)
|
autoTagsFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# autogenerated content warnings
|
# autogenerated content warnings
|
||||||
autoCWFilename = \
|
autoCWFilename = \
|
||||||
|
@ -5916,11 +5922,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(autoCWFilename):
|
if os.path.isfile(autoCWFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(autoCWFilename)
|
os.remove(autoCWFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
autoCWFilename)
|
autoCWFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# save blocked accounts list
|
# save blocked accounts list
|
||||||
blockedFilename = \
|
blockedFilename = \
|
||||||
|
@ -5937,7 +5942,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
blockedFilename)
|
blockedFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# Save DM allowed instances list.
|
# Save DM allowed instances list.
|
||||||
# The allow list for incoming DMs,
|
# The allow list for incoming DMs,
|
||||||
|
@ -5952,11 +5956,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(dmAllowedInstancesFilename):
|
if os.path.isfile(dmAllowedInstancesFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(dmAllowedInstancesFilename)
|
os.remove(dmAllowedInstancesFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
dmAllowedInstancesFilename)
|
dmAllowedInstancesFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# save allowed instances list
|
# save allowed instances list
|
||||||
# This is the account level allow list
|
# This is the account level allow list
|
||||||
|
@ -5970,11 +5973,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(allowedInstancesFilename):
|
if os.path.isfile(allowedInstancesFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(allowedInstancesFilename)
|
os.remove(allowedInstancesFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
allowedInstancesFilename)
|
allowedInstancesFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
if isModerator(self.server.baseDir, nickname):
|
if isModerator(self.server.baseDir, nickname):
|
||||||
# set selected content warning lists
|
# set selected content warning lists
|
||||||
|
@ -6036,11 +6038,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(peertubeInstancesFile):
|
if os.path.isfile(peertubeInstancesFile):
|
||||||
try:
|
try:
|
||||||
os.remove(peertubeInstancesFile)
|
os.remove(peertubeInstancesFile)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
peertubeInstancesFile)
|
peertubeInstancesFile)
|
||||||
pass
|
|
||||||
self.server.peertubeInstances.clear()
|
self.server.peertubeInstances.clear()
|
||||||
|
|
||||||
# save git project names list
|
# save git project names list
|
||||||
|
@ -6054,11 +6055,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(gitProjectsFilename):
|
if os.path.isfile(gitProjectsFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(gitProjectsFilename)
|
os.remove(gitProjectsFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
gitProjectsFilename)
|
gitProjectsFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# save actor json file within accounts
|
# save actor json file within accounts
|
||||||
if actorChanged:
|
if actorChanged:
|
||||||
|
@ -16296,10 +16296,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
print('Edited blog post, removing cached html')
|
print('Edited blog post, removing cached html')
|
||||||
try:
|
try:
|
||||||
os.remove(cachedFilename)
|
os.remove(cachedFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _receiveNewPostProcess ' +
|
print('EX: _receiveNewPostProcess ' +
|
||||||
'unable to delete ' + cachedFilename)
|
'unable to delete ' + cachedFilename)
|
||||||
pass
|
|
||||||
# remove from memory cache
|
# remove from memory cache
|
||||||
removePostFromCache(postJsonObject,
|
removePostFromCache(postJsonObject,
|
||||||
self.server.recentPostsCache)
|
self.server.recentPostsCache)
|
||||||
|
@ -16732,10 +16731,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
try:
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _receiveNewPostProcess ' +
|
print('EX: _receiveNewPostProcess ' +
|
||||||
'unable to delete ' + filename)
|
'unable to delete ' + filename)
|
||||||
pass
|
|
||||||
self.postToNickname = nickname
|
self.postToNickname = nickname
|
||||||
return 1
|
return 1
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -201,6 +201,5 @@ def removeOldHashtags(baseDir: str, maxMonths: int) -> str:
|
||||||
for removeFilename in removeHashtags:
|
for removeFilename in removeHashtags:
|
||||||
try:
|
try:
|
||||||
os.remove(removeFilename)
|
os.remove(removeFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: removeOldHashtags unable to delete ' + removeFilename)
|
print('EX: removeOldHashtags unable to delete ' + removeFilename)
|
||||||
pass
|
|
||||||
|
|
|
@ -46,9 +46,8 @@ def E2EEremoveDevice(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(deviceFilename):
|
if os.path.isfile(deviceFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(deviceFilename)
|
os.remove(deviceFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: E2EEremoveDevice unable to delete ' + deviceFilename)
|
print('EX: E2EEremoveDevice unable to delete ' + deviceFilename)
|
||||||
pass
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -341,9 +341,8 @@ def clearFollows(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
try:
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: clearFollows unable to delete ' + filename)
|
print('EX: clearFollows unable to delete ' + filename)
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def clearFollowers(baseDir: str, nickname: str, domain: str) -> None:
|
def clearFollowers(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
|
@ -908,10 +907,9 @@ def followedAccountAccepts(session, baseDir: str, httpPrefix: str,
|
||||||
if os.path.isfile(followActivityfilename):
|
if os.path.isfile(followActivityfilename):
|
||||||
try:
|
try:
|
||||||
os.remove(followActivityfilename)
|
os.remove(followActivityfilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: followedAccountAccepts unable to delete ' +
|
print('EX: followedAccountAccepts unable to delete ' +
|
||||||
followActivityfilename)
|
followActivityfilename)
|
||||||
pass
|
|
||||||
|
|
||||||
groupAccount = False
|
groupAccount = False
|
||||||
if followJson:
|
if followJson:
|
||||||
|
@ -983,10 +981,9 @@ def followedAccountRejects(session, baseDir: str, httpPrefix: str,
|
||||||
# remove the follow request json
|
# remove the follow request json
|
||||||
try:
|
try:
|
||||||
os.remove(followActivityfilename)
|
os.remove(followActivityfilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: followedAccountRejects unable to delete ' +
|
print('EX: followedAccountRejects unable to delete ' +
|
||||||
followActivityfilename)
|
followActivityfilename)
|
||||||
pass
|
|
||||||
# send the reject activity
|
# send the reject activity
|
||||||
return sendSignedJson(rejectJson, session, baseDir,
|
return sendSignedJson(rejectJson, session, baseDir,
|
||||||
nicknameToFollow, domainToFollow, port,
|
nicknameToFollow, domainToFollow, port,
|
||||||
|
|
54
inbox.py
54
inbox.py
|
@ -920,7 +920,7 @@ def _receiveUpdateToQuestion(recentPostsCache: {}, messageJson: {},
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _receiveUpdateToQuestion unable to delete ' +
|
print('EX: _receiveUpdateToQuestion unable to delete ' +
|
||||||
cachedPostFilename)
|
cachedPostFilename)
|
||||||
# remove from memory cache
|
# remove from memory cache
|
||||||
|
@ -1944,7 +1944,7 @@ def _receiveAnnounce(recentPostsCache: {},
|
||||||
# if the announce can't be downloaded then remove it
|
# if the announce can't be downloaded then remove it
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _receiveAnnounce unable to delete ' +
|
print('EX: _receiveAnnounce unable to delete ' +
|
||||||
str(postFilename))
|
str(postFilename))
|
||||||
pass
|
pass
|
||||||
|
@ -2059,10 +2059,9 @@ def _receiveUndoAnnounce(recentPostsCache: {},
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _receiveUndoAnnounce unable to delete ' +
|
print('EX: _receiveUndoAnnounce unable to delete ' +
|
||||||
str(postFilename))
|
str(postFilename))
|
||||||
pass
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -2973,7 +2972,7 @@ def _receiveQuestionVote(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: replytoQuestion unable to delete ' +
|
print('EX: replytoQuestion unable to delete ' +
|
||||||
cachedPostFilename)
|
cachedPostFilename)
|
||||||
|
|
||||||
|
@ -3592,9 +3591,8 @@ def clearQueueItems(baseDir: str, queue: []) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(os.path.join(queueDir, qfile))
|
os.remove(os.path.join(queueDir, qfile))
|
||||||
ctr += 1
|
ctr += 1
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: clearQueueItems unable to delete ' + qfile)
|
print('EX: clearQueueItems unable to delete ' + qfile)
|
||||||
pass
|
|
||||||
break
|
break
|
||||||
break
|
break
|
||||||
if ctr > 0:
|
if ctr > 0:
|
||||||
|
@ -3659,10 +3657,9 @@ def _inboxQuotaExceeded(queue: {}, queueFilename: str,
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _inboxQuotaExceeded unable to delete ' +
|
print('EX: _inboxQuotaExceeded unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
return True
|
return True
|
||||||
quotasDaily['domains'][postDomain] += 1
|
quotasDaily['domains'][postDomain] += 1
|
||||||
|
@ -3682,10 +3679,9 @@ def _inboxQuotaExceeded(queue: {}, queueFilename: str,
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _inboxQuotaExceeded unable to delete ' +
|
print('EX: _inboxQuotaExceeded unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
return True
|
return True
|
||||||
quotasPerMin['domains'][postDomain] += 1
|
quotasPerMin['domains'][postDomain] += 1
|
||||||
|
@ -3704,10 +3700,9 @@ def _inboxQuotaExceeded(queue: {}, queueFilename: str,
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _inboxQuotaExceeded unable to delete ' +
|
print('EX: _inboxQuotaExceeded unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
return True
|
return True
|
||||||
quotasDaily['accounts'][postHandle] += 1
|
quotasDaily['accounts'][postHandle] += 1
|
||||||
|
@ -3728,10 +3723,9 @@ def _inboxQuotaExceeded(queue: {}, queueFilename: str,
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _inboxQuotaExceeded unable to delete ' +
|
print('EX: _inboxQuotaExceeded unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
return True
|
return True
|
||||||
quotasPerMin['accounts'][postHandle] += 1
|
quotasPerMin['accounts'][postHandle] += 1
|
||||||
|
@ -3913,10 +3907,9 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: runInboxQueue 1 unable to delete ' +
|
print('EX: runInboxQueue 1 unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# clear the daily quotas for maximum numbers of received posts
|
# clear the daily quotas for maximum numbers of received posts
|
||||||
|
@ -3988,10 +3981,9 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: runInboxQueue 2 unable to delete ' +
|
print('EX: runInboxQueue 2 unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -4041,10 +4033,9 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: runInboxQueue 3 unable to delete ' +
|
print('EX: runInboxQueue 3 unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -4063,10 +4054,9 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: runInboxQueue 4 unable to delete ' +
|
print('EX: runInboxQueue 4 unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -4094,10 +4084,9 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: runInboxQueue 5 unable to delete ' +
|
print('EX: runInboxQueue 5 unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -4117,10 +4106,9 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: runInboxQueue 6 unable to delete ' +
|
print('EX: runInboxQueue 6 unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
print('Queue: Follow activity for ' + keyId +
|
print('Queue: Follow activity for ' + keyId +
|
||||||
|
@ -4140,10 +4128,9 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: runInboxQueue 7 unable to delete ' +
|
print('EX: runInboxQueue 7 unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -4163,10 +4150,9 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: runInboxQueue 8 unable to delete ' +
|
print('EX: runInboxQueue 8 unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -4183,10 +4169,9 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: runInboxQueue 9 unable to delete ' +
|
print('EX: runInboxQueue 9 unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
@ -4265,9 +4250,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: runInboxQueue 10 unable to delete ' +
|
print('EX: runInboxQueue 10 unable to delete ' +
|
||||||
str(queueFilename))
|
str(queueFilename))
|
||||||
pass
|
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
|
|
3
like.py
3
like.py
|
@ -430,10 +430,9 @@ def updateLikesCollection(recentPostsCache: {},
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: updateLikesCollection unable to delete ' +
|
print('EX: updateLikesCollection unable to delete ' +
|
||||||
cachedPostFilename)
|
cachedPostFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
obj = postJsonObject
|
obj = postJsonObject
|
||||||
if hasObjectDict(postJsonObject):
|
if hasObjectDict(postJsonObject):
|
||||||
|
|
|
@ -254,17 +254,15 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
if os.path.isfile(followActivityfilename):
|
if os.path.isfile(followActivityfilename):
|
||||||
try:
|
try:
|
||||||
os.remove(followActivityfilename)
|
os.remove(followActivityfilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: manualApproveFollowRequest unable to delete ' +
|
print('EX: manualApproveFollowRequest unable to delete ' +
|
||||||
followActivityfilename)
|
followActivityfilename)
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
os.remove(approveFollowsFilename + '.new')
|
os.remove(approveFollowsFilename + '.new')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: manualApproveFollowRequest unable to delete ' +
|
print('EX: manualApproveFollowRequest unable to delete ' +
|
||||||
approveFollowsFilename + '.new')
|
approveFollowsFilename + '.new')
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def manualApproveFollowRequestThread(session, baseDir: str,
|
def manualApproveFollowRequestThread(session, baseDir: str,
|
||||||
|
|
6
media.py
6
media.py
|
@ -168,10 +168,9 @@ def convertImageToLowBandwidth(imageFilename: str) -> None:
|
||||||
if os.path.isfile(lowBandwidthFilename):
|
if os.path.isfile(lowBandwidthFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(lowBandwidthFilename)
|
os.remove(lowBandwidthFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: convertImageToLowBandwidth unable to delete ' +
|
print('EX: convertImageToLowBandwidth unable to delete ' +
|
||||||
lowBandwidthFilename)
|
lowBandwidthFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
cmd = \
|
cmd = \
|
||||||
'/usr/bin/convert +noise Multiplicative ' + \
|
'/usr/bin/convert +noise Multiplicative ' + \
|
||||||
|
@ -191,10 +190,9 @@ def convertImageToLowBandwidth(imageFilename: str) -> None:
|
||||||
if os.path.isfile(lowBandwidthFilename):
|
if os.path.isfile(lowBandwidthFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(imageFilename)
|
os.remove(imageFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: convertImageToLowBandwidth unable to delete ' +
|
print('EX: convertImageToLowBandwidth unable to delete ' +
|
||||||
imageFilename)
|
imageFilename)
|
||||||
pass
|
|
||||||
os.rename(lowBandwidthFilename, imageFilename)
|
os.rename(lowBandwidthFilename, imageFilename)
|
||||||
if os.path.isfile(imageFilename):
|
if os.path.isfile(imageFilename):
|
||||||
print('Image converted to low bandwidth ' + imageFilename)
|
print('Image converted to low bandwidth ' + imageFilename)
|
||||||
|
|
|
@ -727,10 +727,9 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
||||||
if os.path.isfile(filename + '.arrived'):
|
if os.path.isfile(filename + '.arrived'):
|
||||||
try:
|
try:
|
||||||
os.remove(filename + '.arrived')
|
os.remove(filename + '.arrived')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _convertRSStoActivityPub ' +
|
print('EX: _convertRSStoActivityPub ' +
|
||||||
'unable to delete ' + filename + '.arrived')
|
'unable to delete ' + filename + '.arrived')
|
||||||
pass
|
|
||||||
|
|
||||||
# setting the url here links to the activitypub object
|
# setting the url here links to the activitypub object
|
||||||
# stored locally
|
# stored locally
|
||||||
|
@ -843,10 +842,9 @@ def runNewswireDaemon(baseDir: str, httpd,
|
||||||
if os.path.isfile(refreshFilename):
|
if os.path.isfile(refreshFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(refreshFilename)
|
os.remove(refreshFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: runNewswireDaemon unable to delete ' +
|
print('EX: runNewswireDaemon unable to delete ' +
|
||||||
str(refreshFilename))
|
str(refreshFilename))
|
||||||
pass
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1040,10 +1040,9 @@ def _addBlogsToNewswire(baseDir: str, domain: str, newswire: {},
|
||||||
if os.path.isfile(newswireModerationFilename):
|
if os.path.isfile(newswireModerationFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(newswireModerationFilename)
|
os.remove(newswireModerationFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _addBlogsToNewswire unable to delete ' +
|
print('EX: _addBlogsToNewswire unable to delete ' +
|
||||||
str(newswireModerationFilename))
|
str(newswireModerationFilename))
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def getDictFromNewswire(session, baseDir: str, domain: str,
|
def getDictFromNewswire(session, baseDir: str, domain: str,
|
||||||
|
|
|
@ -400,10 +400,9 @@ def postMessageToOutbox(session, translate: {},
|
||||||
if os.path.isfile(citationsFilename):
|
if os.path.isfile(citationsFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(citationsFilename)
|
os.remove(citationsFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: postMessageToOutbox unable to delete ' +
|
print('EX: postMessageToOutbox unable to delete ' +
|
||||||
citationsFilename)
|
citationsFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
# The following activity types get added to the index files
|
# The following activity types get added to the index files
|
||||||
indexedActivities = (
|
indexedActivities = (
|
||||||
|
|
21
person.py
21
person.py
|
@ -1045,16 +1045,14 @@ def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
if os.path.isfile(saltFilename):
|
if os.path.isfile(saltFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(saltFilename)
|
os.remove(saltFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: suspendAccount unable to delete ' + saltFilename)
|
print('EX: suspendAccount unable to delete ' + saltFilename)
|
||||||
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 OSError:
|
||||||
print('EX: suspendAccount unable to delete ' + tokenFilename)
|
print('EX: suspendAccount unable to delete ' + tokenFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
||||||
if os.path.isfile(suspendedFilename):
|
if os.path.isfile(suspendedFilename):
|
||||||
|
@ -1163,41 +1161,36 @@ def removeAccount(baseDir: str, nickname: str,
|
||||||
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 OSError:
|
||||||
print('EX: removeAccount unable to delete ' +
|
print('EX: removeAccount unable to delete ' +
|
||||||
baseDir + '/accounts/' + handle + '.json')
|
baseDir + '/accounts/' + handle + '.json')
|
||||||
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 OSError:
|
||||||
print('EX: removeAccount unable to delete ' +
|
print('EX: removeAccount unable to delete ' +
|
||||||
baseDir + '/wfendpoints/' + handle + '.json')
|
baseDir + '/wfendpoints/' + handle + '.json')
|
||||||
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 OSError:
|
||||||
print('EX: removeAccount unable to delete ' +
|
print('EX: removeAccount unable to delete ' +
|
||||||
baseDir + '/keys/private/' + handle + '.key')
|
baseDir + '/keys/private/' + handle + '.key')
|
||||||
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 OSError:
|
||||||
print('EX: removeAccount unable to delete ' +
|
print('EX: removeAccount unable to delete ' +
|
||||||
baseDir + '/keys/public/' + handle + '.pem')
|
baseDir + '/keys/public/' + handle + '.pem')
|
||||||
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)
|
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 OSError:
|
||||||
print('EX: removeAccount unable to delete ' +
|
print('EX: removeAccount unable to delete ' +
|
||||||
baseDir + '/wfdeactivated/' + handle + '.json')
|
baseDir + '/wfdeactivated/' + handle + '.json')
|
||||||
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)
|
ignore_errors=False, onerror=None)
|
||||||
|
|
5
posts.py
5
posts.py
|
@ -1585,7 +1585,7 @@ def undoPinnedPost(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
if os.path.isfile(pinnedFilename):
|
if os.path.isfile(pinnedFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(pinnedFilename)
|
os.remove(pinnedFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: undoPinnedPost unable to delete ' + pinnedFilename)
|
print('EX: undoPinnedPost unable to delete ' + pinnedFilename)
|
||||||
|
|
||||||
|
|
||||||
|
@ -3966,10 +3966,9 @@ def archivePostsForPerson(httpPrefix: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(postCacheFilename):
|
if os.path.isfile(postCacheFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(postCacheFilename)
|
os.remove(postCacheFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: archivePostsForPerson unable to delete ' +
|
print('EX: archivePostsForPerson unable to delete ' +
|
||||||
postCacheFilename)
|
postCacheFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
noOfPosts -= 1
|
noOfPosts -= 1
|
||||||
removeCtr += 1
|
removeCtr += 1
|
||||||
|
|
|
@ -460,10 +460,9 @@ def updateReactionCollection(recentPostsCache: {},
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: updateReactionCollection unable to delete ' +
|
print('EX: updateReactionCollection unable to delete ' +
|
||||||
cachedPostFilename)
|
cachedPostFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
obj = postJsonObject
|
obj = postJsonObject
|
||||||
if hasObjectDict(postJsonObject):
|
if hasObjectDict(postJsonObject):
|
||||||
|
|
12
schedule.py
12
schedule.py
|
@ -48,10 +48,9 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _updatePostSchedule unable to delete ' +
|
print('EX: _updatePostSchedule unable to delete ' +
|
||||||
str(postFilename))
|
str(postFilename))
|
||||||
pass
|
|
||||||
continue
|
continue
|
||||||
# create the new index file
|
# create the new index file
|
||||||
indexLines.append(line)
|
indexLines.append(line)
|
||||||
|
@ -133,10 +132,9 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
|
||||||
indexLines.remove(line)
|
indexLines.remove(line)
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _updatePostSchedule unable to delete ' +
|
print('EX: _updatePostSchedule unable to delete ' +
|
||||||
str(postFilename))
|
str(postFilename))
|
||||||
pass
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# move to the outbox
|
# move to the outbox
|
||||||
|
@ -206,10 +204,9 @@ def removeScheduledPosts(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
if os.path.isfile(scheduleIndexFilename):
|
if os.path.isfile(scheduleIndexFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(scheduleIndexFilename)
|
os.remove(scheduleIndexFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: removeScheduledPosts unable to delete ' +
|
print('EX: removeScheduledPosts unable to delete ' +
|
||||||
scheduleIndexFilename)
|
scheduleIndexFilename)
|
||||||
pass
|
|
||||||
# remove the scheduled posts
|
# remove the scheduled posts
|
||||||
scheduledDir = acctDir(baseDir, nickname, domain) + '/scheduled'
|
scheduledDir = acctDir(baseDir, nickname, domain) + '/scheduled'
|
||||||
if not os.path.isdir(scheduledDir):
|
if not os.path.isdir(scheduledDir):
|
||||||
|
@ -219,7 +216,6 @@ def removeScheduledPosts(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
if os.path.isfile(filePath):
|
if os.path.isfile(filePath):
|
||||||
try:
|
try:
|
||||||
os.remove(filePath)
|
os.remove(filePath)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: removeScheduledPosts unable to delete ' +
|
print('EX: removeScheduledPosts unable to delete ' +
|
||||||
filePath)
|
filePath)
|
||||||
pass
|
|
||||||
|
|
|
@ -439,10 +439,9 @@ def downloadImage(session, baseDir: str, url: str,
|
||||||
if os.path.isfile(imageFilename):
|
if os.path.isfile(imageFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(imageFilename)
|
os.remove(imageFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: downloadImage unable to delete ' +
|
print('EX: downloadImage unable to delete ' +
|
||||||
imageFilename)
|
imageFilename)
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
with open(imageFilename, 'wb') as f:
|
with open(imageFilename, 'wb') as f:
|
||||||
f.write(result.content)
|
f.write(result.content)
|
||||||
|
|
|
@ -148,10 +148,9 @@ def removeSharedItem(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(itemIDfile + '.' + ext):
|
if os.path.isfile(itemIDfile + '.' + ext):
|
||||||
try:
|
try:
|
||||||
os.remove(itemIDfile + '.' + ext)
|
os.remove(itemIDfile + '.' + ext)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: removeSharedItem unable to delete ' +
|
print('EX: removeSharedItem unable to delete ' +
|
||||||
itemIDfile + '.' + ext)
|
itemIDfile + '.' + ext)
|
||||||
pass
|
|
||||||
# remove the item itself
|
# remove the item itself
|
||||||
del sharesJson[itemID]
|
del sharesJson[itemID]
|
||||||
saveJson(sharesJson, sharesFilename)
|
saveJson(sharesJson, sharesFilename)
|
||||||
|
@ -368,10 +367,9 @@ def addShare(baseDir: str,
|
||||||
if moveImage:
|
if moveImage:
|
||||||
try:
|
try:
|
||||||
os.remove(imageFilename)
|
os.remove(imageFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: addShare unable to delete ' +
|
print('EX: addShare unable to delete ' +
|
||||||
str(imageFilename))
|
str(imageFilename))
|
||||||
pass
|
|
||||||
imageUrl = \
|
imageUrl = \
|
||||||
httpPrefix + '://' + domainFull + \
|
httpPrefix + '://' + domainFull + \
|
||||||
'/sharefiles/' + nickname + '/' + itemID + '.' + ext
|
'/sharefiles/' + nickname + '/' + itemID + '.' + ext
|
||||||
|
@ -442,10 +440,9 @@ def _expireSharesForAccount(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(itemIDfile + '.' + ext):
|
if os.path.isfile(itemIDfile + '.' + ext):
|
||||||
try:
|
try:
|
||||||
os.remove(itemIDfile + '.' + ext)
|
os.remove(itemIDfile + '.' + ext)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _expireSharesForAccount unable to delete ' +
|
print('EX: _expireSharesForAccount unable to delete ' +
|
||||||
itemIDfile + '.' + ext)
|
itemIDfile + '.' + ext)
|
||||||
pass
|
|
||||||
saveJson(sharesJson, sharesFilename)
|
saveJson(sharesJson, sharesFilename)
|
||||||
|
|
||||||
|
|
||||||
|
|
6
tests.py
6
tests.py
|
@ -3478,7 +3478,7 @@ def _testJsonString() -> None:
|
||||||
assert messageStr in encodedStr
|
assert messageStr in encodedStr
|
||||||
try:
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -3492,7 +3492,7 @@ def _testSaveLoadJson():
|
||||||
if os.path.isfile(testFilename):
|
if os.path.isfile(testFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(testFilename)
|
os.remove(testFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
assert saveJson(testJson, testFilename)
|
assert saveJson(testJson, testFilename)
|
||||||
assert os.path.isfile(testFilename)
|
assert os.path.isfile(testFilename)
|
||||||
|
@ -3504,7 +3504,7 @@ def _testSaveLoadJson():
|
||||||
assert testLoadJson['param2'] == '"Crème brûlée यह एक परीक्षण ह"'
|
assert testLoadJson['param2'] == '"Crème brûlée यह एक परीक्षण ह"'
|
||||||
try:
|
try:
|
||||||
os.remove(testFilename)
|
os.remove(testFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
34
theme.py
34
theme.py
|
@ -90,9 +90,8 @@ def exportTheme(baseDir: str, theme: str) -> bool:
|
||||||
if os.path.isfile(exportFilename):
|
if os.path.isfile(exportFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(exportFilename)
|
os.remove(exportFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: exportTheme unable to delete ' + str(exportFilename))
|
print('EX: exportTheme unable to delete ' + str(exportFilename))
|
||||||
pass
|
|
||||||
try:
|
try:
|
||||||
make_archive(baseDir + '/exports/' + theme, 'zip', themeDir)
|
make_archive(baseDir + '/exports/' + theme, 'zip', themeDir)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
@ -264,10 +263,9 @@ def _removeTheme(baseDir: str):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
os.remove(baseDir + '/' + filename)
|
os.remove(baseDir + '/' + filename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _removeTheme unable to delete ' +
|
print('EX: _removeTheme unable to delete ' +
|
||||||
baseDir + '/' + filename)
|
baseDir + '/' + filename)
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def setCSSparam(css: str, param: str, value: str) -> str:
|
def setCSSparam(css: str, param: str, value: str) -> str:
|
||||||
|
@ -451,10 +449,9 @@ def disableGrayscale(baseDir: str) -> None:
|
||||||
if os.path.isfile(grayscaleFilename):
|
if os.path.isfile(grayscaleFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(grayscaleFilename)
|
os.remove(grayscaleFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: disableGrayscale unable to delete ' +
|
print('EX: disableGrayscale unable to delete ' +
|
||||||
grayscaleFilename)
|
grayscaleFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def _setCustomFont(baseDir: str):
|
def _setCustomFont(baseDir: str):
|
||||||
|
@ -617,19 +614,17 @@ def _setTextModeTheme(baseDir: str, name: str) -> None:
|
||||||
if os.path.isfile(baseDir + '/accounts/banner.txt'):
|
if os.path.isfile(baseDir + '/accounts/banner.txt'):
|
||||||
try:
|
try:
|
||||||
os.remove(baseDir + '/accounts/banner.txt')
|
os.remove(baseDir + '/accounts/banner.txt')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _setTextModeTheme unable to delete ' +
|
print('EX: _setTextModeTheme unable to delete ' +
|
||||||
baseDir + '/accounts/banner.txt')
|
baseDir + '/accounts/banner.txt')
|
||||||
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 OSError:
|
||||||
print('EX: _setTextModeTheme unable to copy ' +
|
print('EX: _setTextModeTheme unable to copy ' +
|
||||||
textModeBannerFilename + ' ' +
|
textModeBannerFilename + ' ' +
|
||||||
baseDir + '/accounts/banner.txt')
|
baseDir + '/accounts/banner.txt')
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def _setThemeImages(baseDir: str, name: str) -> None:
|
def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
|
@ -679,10 +674,9 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
baseDir + '/accounts/' +
|
baseDir + '/accounts/' +
|
||||||
backgroundType + '-background.' + ext)
|
backgroundType + '-background.' + ext)
|
||||||
continue
|
continue
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _setThemeImages unable to copy ' +
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
backgroundImageFilename)
|
backgroundImageFilename)
|
||||||
pass
|
|
||||||
# background image was not found
|
# background image was not found
|
||||||
# so remove any existing file
|
# so remove any existing file
|
||||||
if os.path.isfile(baseDir + '/accounts/' +
|
if os.path.isfile(baseDir + '/accounts/' +
|
||||||
|
@ -690,21 +684,19 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(baseDir + '/accounts/' +
|
os.remove(baseDir + '/accounts/' +
|
||||||
backgroundType + '-background.' + ext)
|
backgroundType + '-background.' + ext)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _setThemeImages unable to delete ' +
|
print('EX: _setThemeImages unable to delete ' +
|
||||||
baseDir + '/accounts/' +
|
baseDir + '/accounts/' +
|
||||||
backgroundType + '-background.' + ext)
|
backgroundType + '-background.' + ext)
|
||||||
pass
|
|
||||||
|
|
||||||
if os.path.isfile(profileImageFilename) and \
|
if os.path.isfile(profileImageFilename) and \
|
||||||
os.path.isfile(bannerFilename):
|
os.path.isfile(bannerFilename):
|
||||||
try:
|
try:
|
||||||
copyfile(profileImageFilename,
|
copyfile(profileImageFilename,
|
||||||
accountDir + '/image.png')
|
accountDir + '/image.png')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _setThemeImages unable to copy ' +
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
profileImageFilename)
|
profileImageFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
copyfile(bannerFilename,
|
copyfile(bannerFilename,
|
||||||
|
@ -718,10 +710,9 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
if os.path.isfile(searchBannerFilename):
|
if os.path.isfile(searchBannerFilename):
|
||||||
copyfile(searchBannerFilename,
|
copyfile(searchBannerFilename,
|
||||||
accountDir + '/search_banner.png')
|
accountDir + '/search_banner.png')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _setThemeImages unable to copy ' +
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
searchBannerFilename)
|
searchBannerFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if os.path.isfile(leftColImageFilename):
|
if os.path.isfile(leftColImageFilename):
|
||||||
|
@ -731,10 +722,9 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
'/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 OSError:
|
||||||
print('EX: _setThemeImages unable to delete ' +
|
print('EX: _setThemeImages unable to delete ' +
|
||||||
accountDir + '/left_col_image.png')
|
accountDir + '/left_col_image.png')
|
||||||
pass
|
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('EX: _setThemeImages unable to copy ' +
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
leftColImageFilename)
|
leftColImageFilename)
|
||||||
|
@ -749,14 +739,12 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
'/right_col_image.png'):
|
'/right_col_image.png'):
|
||||||
try:
|
try:
|
||||||
os.remove(accountDir + '/right_col_image.png')
|
os.remove(accountDir + '/right_col_image.png')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _setThemeImages unable to delete ' +
|
print('EX: _setThemeImages unable to delete ' +
|
||||||
accountDir + '/right_col_image.png')
|
accountDir + '/right_col_image.png')
|
||||||
pass
|
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('EX: _setThemeImages unable to copy ' +
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
rightColImageFilename)
|
rightColImageFilename)
|
||||||
pass
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|
48
utils.py
48
utils.py
|
@ -625,10 +625,9 @@ def removeAvatarFromCache(baseDir: str, actorStr: str) -> None:
|
||||||
if os.path.isfile(avatarFilename):
|
if os.path.isfile(avatarFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(avatarFilename)
|
os.remove(avatarFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: removeAvatarFromCache ' +
|
print('EX: removeAvatarFromCache ' +
|
||||||
'unable to delete cached avatar ' + str(avatarFilename))
|
'unable to delete cached avatar ' + str(avatarFilename))
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def saveJson(jsonObject: {}, filename: str) -> bool:
|
def saveJson(jsonObject: {}, filename: str) -> bool:
|
||||||
|
@ -1287,10 +1286,9 @@ def clearFromPostCaches(baseDir: str, recentPostsCache: {},
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: clearFromPostCaches file not removed ' +
|
print('EX: clearFromPostCaches file not removed ' +
|
||||||
str(postFilename))
|
str(postFilename))
|
||||||
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'):
|
||||||
if postId in recentPostsCache['index']:
|
if postId in recentPostsCache['index']:
|
||||||
|
@ -1450,18 +1448,16 @@ def _removeAttachment(baseDir: str, httpPrefix: str, domain: str,
|
||||||
if os.path.isfile(mediaFilename):
|
if os.path.isfile(mediaFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(mediaFilename)
|
os.remove(mediaFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _removeAttachment unable to delete media file ' +
|
print('EX: _removeAttachment unable to delete media file ' +
|
||||||
str(mediaFilename))
|
str(mediaFilename))
|
||||||
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 OSError:
|
||||||
print('EX: _removeAttachment unable to delete etag file ' +
|
print('EX: _removeAttachment unable to delete etag file ' +
|
||||||
str(etagFilename))
|
str(etagFilename))
|
||||||
pass
|
|
||||||
postJson['attachment'] = []
|
postJson['attachment'] = []
|
||||||
|
|
||||||
|
|
||||||
|
@ -1528,10 +1524,9 @@ def _deletePostRemoveReplies(baseDir: str, nickname: str, domain: str,
|
||||||
# remove the replies file
|
# remove the replies file
|
||||||
try:
|
try:
|
||||||
os.remove(repliesFilename)
|
os.remove(repliesFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _deletePostRemoveReplies unable to delete replies file ' +
|
print('EX: _deletePostRemoveReplies unable to delete replies file ' +
|
||||||
str(repliesFilename))
|
str(repliesFilename))
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def _isBookmarked(baseDir: str, nickname: str, domain: str,
|
def _isBookmarked(baseDir: str, nickname: str, domain: str,
|
||||||
|
@ -1589,11 +1584,10 @@ def _deleteCachedHtml(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _deleteCachedHtml ' +
|
print('EX: _deleteCachedHtml ' +
|
||||||
'unable to delete cached post file ' +
|
'unable to delete cached post file ' +
|
||||||
str(cachedPostFilename))
|
str(cachedPostFilename))
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def _deleteHashtagsOnPost(baseDir: str, postJsonObject: {}) -> None:
|
def _deleteHashtagsOnPost(baseDir: str, postJsonObject: {}) -> None:
|
||||||
|
@ -1641,10 +1635,9 @@ def _deleteHashtagsOnPost(baseDir: str, postJsonObject: {}) -> None:
|
||||||
# if there are no lines then remove the hashtag file
|
# if there are no lines then remove the hashtag file
|
||||||
try:
|
try:
|
||||||
os.remove(tagIndexFilename)
|
os.remove(tagIndexFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _deleteHashtagsOnPost unable to delete tag index ' +
|
print('EX: _deleteHashtagsOnPost unable to delete tag index ' +
|
||||||
str(tagIndexFilename))
|
str(tagIndexFilename))
|
||||||
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
|
||||||
with open(tagIndexFilename, 'w+') as f:
|
with open(tagIndexFilename, 'w+') as f:
|
||||||
|
@ -1681,18 +1674,16 @@ def _deleteConversationPost(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(conversationFilename + '.muted'):
|
if os.path.isfile(conversationFilename + '.muted'):
|
||||||
try:
|
try:
|
||||||
os.remove(conversationFilename + '.muted')
|
os.remove(conversationFilename + '.muted')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _deleteConversationPost ' +
|
print('EX: _deleteConversationPost ' +
|
||||||
'unable to remove conversation ' +
|
'unable to remove conversation ' +
|
||||||
str(conversationFilename) + '.muted')
|
str(conversationFilename) + '.muted')
|
||||||
pass
|
|
||||||
try:
|
try:
|
||||||
os.remove(conversationFilename)
|
os.remove(conversationFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _deleteConversationPost ' +
|
print('EX: _deleteConversationPost ' +
|
||||||
'unable to remove conversation ' +
|
'unable to remove conversation ' +
|
||||||
str(conversationFilename))
|
str(conversationFilename))
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def deletePost(baseDir: str, httpPrefix: str,
|
def deletePost(baseDir: str, httpPrefix: str,
|
||||||
|
@ -1709,11 +1700,10 @@ def deletePost(baseDir: str, httpPrefix: str,
|
||||||
# finally, remove the post itself
|
# finally, remove the post itself
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
if debug:
|
if debug:
|
||||||
print('EX: deletePost unable to delete post ' +
|
print('EX: deletePost unable to delete post ' +
|
||||||
str(postFilename))
|
str(postFilename))
|
||||||
pass
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# don't allow deletion of bookmarked posts
|
# don't allow deletion of bookmarked posts
|
||||||
|
@ -1740,10 +1730,9 @@ def deletePost(baseDir: str, httpPrefix: str,
|
||||||
if os.path.isfile(extFilename):
|
if os.path.isfile(extFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(extFilename)
|
os.remove(extFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: deletePost unable to remove ext ' +
|
print('EX: deletePost unable to remove ext ' +
|
||||||
str(extFilename))
|
str(extFilename))
|
||||||
pass
|
|
||||||
|
|
||||||
# remove cached html version of the post
|
# remove cached html version of the post
|
||||||
_deleteCachedHtml(baseDir, nickname, domain, postJsonObject)
|
_deleteCachedHtml(baseDir, nickname, domain, postJsonObject)
|
||||||
|
@ -1771,10 +1760,9 @@ def deletePost(baseDir: str, httpPrefix: str,
|
||||||
# finally, remove the post itself
|
# finally, remove the post itself
|
||||||
try:
|
try:
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
if debug:
|
if debug:
|
||||||
print('EX: deletePost unable to delete post ' + str(postFilename))
|
print('EX: deletePost unable to delete post ' + str(postFilename))
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def isValidLanguage(text: str) -> bool:
|
def isValidLanguage(text: str) -> bool:
|
||||||
|
@ -2213,11 +2201,10 @@ def undoLikesCollectionEntry(recentPostsCache: {},
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: undoLikesCollectionEntry ' +
|
print('EX: undoLikesCollectionEntry ' +
|
||||||
'unable to delete cached post ' +
|
'unable to delete cached post ' +
|
||||||
str(cachedPostFilename))
|
str(cachedPostFilename))
|
||||||
pass
|
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
if not postJsonObject.get('type'):
|
if not postJsonObject.get('type'):
|
||||||
|
@ -2278,11 +2265,10 @@ def undoReactionCollectionEntry(recentPostsCache: {},
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: undoReactionCollectionEntry ' +
|
print('EX: undoReactionCollectionEntry ' +
|
||||||
'unable to delete cached post ' +
|
'unable to delete cached post ' +
|
||||||
str(cachedPostFilename))
|
str(cachedPostFilename))
|
||||||
pass
|
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
if not postJsonObject.get('type'):
|
if not postJsonObject.get('type'):
|
||||||
|
@ -2344,12 +2330,11 @@ def undoAnnounceCollectionEntry(recentPostsCache: {},
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
if debug:
|
if debug:
|
||||||
print('EX: undoAnnounceCollectionEntry ' +
|
print('EX: undoAnnounceCollectionEntry ' +
|
||||||
'unable to delete cached post ' +
|
'unable to delete cached post ' +
|
||||||
str(cachedPostFilename))
|
str(cachedPostFilename))
|
||||||
pass
|
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
if not postJsonObject.get('type'):
|
if not postJsonObject.get('type'):
|
||||||
|
@ -2412,12 +2397,11 @@ def updateAnnounceCollection(recentPostsCache: {},
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
if debug:
|
if debug:
|
||||||
print('EX: updateAnnounceCollection ' +
|
print('EX: updateAnnounceCollection ' +
|
||||||
'unable to delete cached post ' +
|
'unable to delete cached post ' +
|
||||||
str(cachedPostFilename))
|
str(cachedPostFilename))
|
||||||
pass
|
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
if not hasObjectDict(postJsonObject):
|
if not hasObjectDict(postJsonObject):
|
||||||
|
|
|
@ -108,9 +108,8 @@ def _htmlCalendarDay(personCache: {}, cssCache: {}, translate: {},
|
||||||
if os.path.isfile(calendarFile):
|
if os.path.isfile(calendarFile):
|
||||||
try:
|
try:
|
||||||
os.remove(calendarFile)
|
os.remove(calendarFile)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _htmlCalendarDay unable to delete ' + calendarFile)
|
print('EX: _htmlCalendarDay unable to delete ' + calendarFile)
|
||||||
pass
|
|
||||||
|
|
||||||
cssFilename = baseDir + '/epicyon-calendar.css'
|
cssFilename = baseDir + '/epicyon-calendar.css'
|
||||||
if os.path.isfile(baseDir + '/calendar.css'):
|
if os.path.isfile(baseDir + '/calendar.css'):
|
||||||
|
|
|
@ -36,9 +36,11 @@ def setMinimal(baseDir: str, domain: str, nickname: str,
|
||||||
if minimal and minimalFileExists:
|
if minimal and minimalFileExists:
|
||||||
try:
|
try:
|
||||||
os.remove(minimalFilename)
|
os.remove(minimalFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: setMinimal unable to delete ' + minimalFilename)
|
print('EX: setMinimal unable to delete ' + minimalFilename)
|
||||||
pass
|
|
||||||
elif not minimal and not minimalFileExists:
|
elif not minimal and not minimalFileExists:
|
||||||
with open(minimalFilename, 'w+') as fp:
|
try:
|
||||||
fp.write('\n')
|
with open(minimalFilename, 'w+') as fp:
|
||||||
|
fp.write('\n')
|
||||||
|
except OSError:
|
||||||
|
print('WARN: unable to write minimal ' + minimalFilename)
|
||||||
|
|
|
@ -476,9 +476,8 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
if boxName == 'dm':
|
if boxName == 'dm':
|
||||||
try:
|
try:
|
||||||
os.remove(dmFile)
|
os.remove(dmFile)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: htmlTimeline unable to delete ' + dmFile)
|
print('EX: htmlTimeline unable to delete ' + dmFile)
|
||||||
pass
|
|
||||||
|
|
||||||
# should the Replies button be highlighted?
|
# should the Replies button be highlighted?
|
||||||
newReply = False
|
newReply = False
|
||||||
|
@ -488,9 +487,8 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
if boxName == 'tlreplies':
|
if boxName == 'tlreplies':
|
||||||
try:
|
try:
|
||||||
os.remove(replyFile)
|
os.remove(replyFile)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: htmlTimeline unable to delete ' + replyFile)
|
print('EX: htmlTimeline unable to delete ' + replyFile)
|
||||||
pass
|
|
||||||
|
|
||||||
# should the Shares button be highlighted?
|
# should the Shares button be highlighted?
|
||||||
newShare = False
|
newShare = False
|
||||||
|
@ -500,9 +498,8 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
if boxName == 'tlshares':
|
if boxName == 'tlshares':
|
||||||
try:
|
try:
|
||||||
os.remove(newShareFile)
|
os.remove(newShareFile)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: htmlTimeline unable to delete ' + newShareFile)
|
print('EX: htmlTimeline unable to delete ' + newShareFile)
|
||||||
pass
|
|
||||||
|
|
||||||
# should the Wanted button be highlighted?
|
# should the Wanted button be highlighted?
|
||||||
newWanted = False
|
newWanted = False
|
||||||
|
@ -512,9 +509,8 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
if boxName == 'tlwanted':
|
if boxName == 'tlwanted':
|
||||||
try:
|
try:
|
||||||
os.remove(newWantedFile)
|
os.remove(newWantedFile)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: htmlTimeline unable to delete ' + newWantedFile)
|
print('EX: htmlTimeline unable to delete ' + newWantedFile)
|
||||||
pass
|
|
||||||
|
|
||||||
# should the Moderation/reports button be highlighted?
|
# should the Moderation/reports button be highlighted?
|
||||||
newReport = False
|
newReport = False
|
||||||
|
@ -524,9 +520,8 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
if boxName == 'moderation':
|
if boxName == 'moderation':
|
||||||
try:
|
try:
|
||||||
os.remove(newReportFile)
|
os.remove(newReportFile)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: htmlTimeline unable to delete ' + newReportFile)
|
print('EX: htmlTimeline unable to delete ' + newReportFile)
|
||||||
pass
|
|
||||||
|
|
||||||
separatorStr = ''
|
separatorStr = ''
|
||||||
if boxName != 'tlmedia':
|
if boxName != 'tlmedia':
|
||||||
|
|
|
@ -283,10 +283,9 @@ def updateAvatarImageCache(signingPrivateKeyPem: str,
|
||||||
if os.path.isfile(avatarImageFilename):
|
if os.path.isfile(avatarImageFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(avatarImageFilename)
|
os.remove(avatarImageFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: updateAvatarImageCache unable to delete ' +
|
print('EX: updateAvatarImageCache unable to delete ' +
|
||||||
avatarImageFilename)
|
avatarImageFilename)
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
with open(avatarImageFilename, 'wb') as f:
|
with open(avatarImageFilename, 'wb') as f:
|
||||||
f.write(result.content)
|
f.write(result.content)
|
||||||
|
|
Loading…
Reference in New Issue