mirror of https://gitlab.com/bashrc2/epicyon
Exception prefix
parent
a2b4efcaaf
commit
10f24bcc2d
12
auth.py
12
auth.py
|
@ -172,14 +172,14 @@ def storeBasicCredentials(baseDir: str, nickname: str, password: str) -> bool:
|
||||||
else:
|
else:
|
||||||
fout.write(storeStr + '\n')
|
fout.write(storeStr + '\n')
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: unable to save password ' + passwordFile +
|
print('EX: unable to save password ' + passwordFile +
|
||||||
' ' + str(e))
|
' ' + str(e))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.rename(passwordFile + '.new', passwordFile)
|
os.rename(passwordFile + '.new', passwordFile)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to save password 2')
|
print('EX: unable to save password 2')
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
# append to password file
|
# append to password file
|
||||||
|
@ -187,14 +187,14 @@ def storeBasicCredentials(baseDir: str, nickname: str, password: str) -> bool:
|
||||||
with open(passwordFile, 'a+') as passfile:
|
with open(passwordFile, 'a+') as passfile:
|
||||||
passfile.write(storeStr + '\n')
|
passfile.write(storeStr + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to append password')
|
print('EX: unable to append password')
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(passwordFile, 'w+') as passfile:
|
with open(passwordFile, 'w+') as passfile:
|
||||||
passfile.write(storeStr + '\n')
|
passfile.write(storeStr + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to create password file')
|
print('EX: unable to create password file')
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -212,13 +212,13 @@ def removePassword(baseDir: str, nickname: str) -> None:
|
||||||
if not line.startswith(nickname + ':'):
|
if not line.startswith(nickname + ':'):
|
||||||
fout.write(line)
|
fout.write(line)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: unable to remove password from file ' + str(e))
|
print('EX: unable to remove password from file ' + str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.rename(passwordFile + '.new', passwordFile)
|
os.rename(passwordFile + '.new', passwordFile)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to remove password from file 2')
|
print('EX: unable to remove password from file 2')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
29
blocking.py
29
blocking.py
|
@ -53,7 +53,7 @@ def addGlobalBlock(baseDir: str,
|
||||||
with open(blockingFilename, 'a+') as blockFile:
|
with open(blockingFilename, 'a+') as blockFile:
|
||||||
blockFile.write(blockHandle + '\n')
|
blockFile.write(blockHandle + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to save blocked handle ' + blockHandle)
|
print('EX: unable to save blocked handle ' + blockHandle)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
blockHashtag = blockNickname
|
blockHashtag = blockNickname
|
||||||
|
@ -66,7 +66,7 @@ def addGlobalBlock(baseDir: str,
|
||||||
with open(blockingFilename, 'a+') as blockFile:
|
with open(blockingFilename, 'a+') as blockFile:
|
||||||
blockFile.write(blockHashtag + '\n')
|
blockFile.write(blockHashtag + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to save blocked hashtag ' + blockHashtag)
|
print('EX: unable to save blocked hashtag ' + blockHashtag)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -96,14 +96,14 @@ def addBlock(baseDir: str, nickname: str, domain: str,
|
||||||
followingStr = followingFile.read()
|
followingStr = followingFile.read()
|
||||||
followingStr = followingStr.replace(blockHandle + '\n', '')
|
followingStr = followingStr.replace(blockHandle + '\n', '')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: Unable to read following ' + followingFilename)
|
print('EX: Unable to read following ' + followingFilename)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(followingFilename, 'w+') as followingFile:
|
with open(followingFilename, 'w+') as followingFile:
|
||||||
followingFile.write(followingStr)
|
followingFile.write(followingStr)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: Unable to write following ' + followingStr)
|
print('EX: Unable to write following ' + followingStr)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# if they are a follower then remove them
|
# if they are a follower then remove them
|
||||||
|
@ -116,21 +116,21 @@ def addBlock(baseDir: str, nickname: str, domain: str,
|
||||||
followersStr = followersFile.read()
|
followersStr = followersFile.read()
|
||||||
followersStr = followersStr.replace(blockHandle + '\n', '')
|
followersStr = followersStr.replace(blockHandle + '\n', '')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: Unable to read followers ' + followersFilename)
|
print('EX: Unable to read followers ' + followersFilename)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(followersFilename, 'w+') as followersFile:
|
with open(followersFilename, 'w+') as followersFile:
|
||||||
followersFile.write(followersStr)
|
followersFile.write(followersStr)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: Unable to write followers ' + followersStr)
|
print('EX: Unable to write followers ' + followersStr)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(blockingFilename, 'a+') as blockFile:
|
with open(blockingFilename, 'a+') as blockFile:
|
||||||
blockFile.write(blockHandle + '\n')
|
blockFile.write(blockHandle + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to append block handle ' + blockHandle)
|
print('EX: unable to append block handle ' + blockHandle)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ def removeGlobalBlock(baseDir: str,
|
||||||
if unblockHandle not in line:
|
if unblockHandle not in line:
|
||||||
fpnew.write(handle + '\n')
|
fpnew.write(handle + '\n')
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: failed to remove global block ' +
|
print('EX: failed to remove global block ' +
|
||||||
unblockingFilename + ' ' + str(e))
|
unblockingFilename + ' ' + str(e))
|
||||||
return False
|
return False
|
||||||
if os.path.isfile(unblockingFilename + '.new'):
|
if os.path.isfile(unblockingFilename + '.new'):
|
||||||
|
@ -173,7 +173,7 @@ def removeGlobalBlock(baseDir: str,
|
||||||
if unblockHashtag not in line:
|
if unblockHashtag not in line:
|
||||||
fpnew.write(blockLine + '\n')
|
fpnew.write(blockLine + '\n')
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: failed to remove global hashtag block ' +
|
print('EX: failed to remove global hashtag block ' +
|
||||||
unblockingFilename + ' ' + str(e))
|
unblockingFilename + ' ' + str(e))
|
||||||
return False
|
return False
|
||||||
if os.path.isfile(unblockingFilename + '.new'):
|
if os.path.isfile(unblockingFilename + '.new'):
|
||||||
|
@ -199,7 +199,7 @@ def removeBlock(baseDir: str, nickname: str, domain: str,
|
||||||
if unblockHandle not in line:
|
if unblockHandle not in line:
|
||||||
fpnew.write(handle + '\n')
|
fpnew.write(handle + '\n')
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: failed to remove block ' +
|
print('EX: failed to remove block ' +
|
||||||
unblockingFilename + ' ' + str(e))
|
unblockingFilename + ' ' + str(e))
|
||||||
return False
|
return False
|
||||||
if os.path.isfile(unblockingFilename + '.new'):
|
if os.path.isfile(unblockingFilename + '.new'):
|
||||||
|
@ -574,7 +574,7 @@ def mutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
muteFile.write('\n')
|
muteFile.write('\n')
|
||||||
print('MUTE: ' + postFilename + '.muted file added')
|
print('MUTE: ' + postFilename + '.muted file added')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: Failed to save mute file ' + postFilename + '.muted')
|
print('EX: Failed to save mute file ' + postFilename + '.muted')
|
||||||
return
|
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
|
||||||
|
@ -641,7 +641,6 @@ def unmutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
if debug:
|
if debug:
|
||||||
print('EX: unmutePost mute filename not deleted ' +
|
print('EX: unmutePost mute filename not deleted ' +
|
||||||
str(muteFilename))
|
str(muteFilename))
|
||||||
pass
|
|
||||||
print('UNMUTE: ' + muteFilename + ' file removed')
|
print('UNMUTE: ' + muteFilename + ' file removed')
|
||||||
|
|
||||||
postJsonObj = postJsonObject
|
postJsonObj = postJsonObject
|
||||||
|
@ -692,7 +691,6 @@ def unmutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
if debug:
|
if debug:
|
||||||
print('EX: unmutePost cached post not deleted ' +
|
print('EX: unmutePost cached post not deleted ' +
|
||||||
str(cachedPostFilename))
|
str(cachedPostFilename))
|
||||||
pass
|
|
||||||
|
|
||||||
# if the post is in the recent posts cache then mark it as unmuted
|
# if the post is in the recent posts cache then mark it as unmuted
|
||||||
if recentPostsCache.get('index'):
|
if recentPostsCache.get('index'):
|
||||||
|
@ -726,7 +724,6 @@ def unmutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
print('EX: ' +
|
print('EX: ' +
|
||||||
'unmutePost cached ref post not removed ' +
|
'unmutePost cached ref post not removed ' +
|
||||||
str(cachedPostFilename))
|
str(cachedPostFilename))
|
||||||
pass
|
|
||||||
|
|
||||||
if recentPostsCache.get('json'):
|
if recentPostsCache.get('json'):
|
||||||
if recentPostsCache['json'].get(alsoUpdatePostId):
|
if recentPostsCache['json'].get(alsoUpdatePostId):
|
||||||
|
@ -871,7 +868,6 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None:
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: setBrochMode allow file not deleted ' +
|
print('EX: setBrochMode allow file not deleted ' +
|
||||||
str(allowFilename))
|
str(allowFilename))
|
||||||
pass
|
|
||||||
print('Broch mode turned off')
|
print('Broch mode turned off')
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(allowFilename):
|
if os.path.isfile(allowFilename):
|
||||||
|
@ -909,7 +905,7 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None:
|
||||||
allowFile.write(d + '\n')
|
allowFile.write(d + '\n')
|
||||||
print('Broch mode enabled')
|
print('Broch mode enabled')
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: Broch mode not enabled due to file write ' + str(e))
|
print('EX: Broch mode not enabled due to file write ' + str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
setConfigParam(baseDir, "brochMode", enabled)
|
setConfigParam(baseDir, "brochMode", enabled)
|
||||||
|
@ -942,7 +938,6 @@ def brochModeLapses(baseDir: str, lapseDays: int) -> bool:
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: brochModeLapses allow file not deleted ' +
|
print('EX: brochModeLapses allow file not deleted ' +
|
||||||
str(allowFilename))
|
str(allowFilename))
|
||||||
pass
|
|
||||||
if removed:
|
if removed:
|
||||||
setConfigParam(baseDir, "brochMode", False)
|
setConfigParam(baseDir, "brochMode", False)
|
||||||
print('Broch mode has elapsed')
|
print('Broch mode has elapsed')
|
||||||
|
|
2
blog.py
2
blog.py
|
@ -99,7 +99,7 @@ def _noOfBlogReplies(baseDir: str, httpPrefix: str, translate: {},
|
||||||
if replyPostId not in removals:
|
if replyPostId not in removals:
|
||||||
f.write(replyPostId + '\n')
|
f.write(replyPostId + '\n')
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: unable to remove replies from post ' +
|
print('EX: unable to remove replies from post ' +
|
||||||
postFilename + ' ' + str(e))
|
postFilename + ' ' + str(e))
|
||||||
|
|
||||||
return replies
|
return replies
|
||||||
|
|
|
@ -77,9 +77,8 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
|
||||||
with open(bookmarksIndexFilename, 'w+') as bookmarksIndexFile:
|
with open(bookmarksIndexFilename, 'w+') as bookmarksIndexFile:
|
||||||
bookmarksIndexFile.write(indexStr)
|
bookmarksIndexFile.write(indexStr)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write bookmarks index ' +
|
print('EX: unable to write bookmarks index ' +
|
||||||
bookmarksIndexFilename)
|
bookmarksIndexFilename)
|
||||||
pass
|
|
||||||
if not postJsonObject.get('type'):
|
if not postJsonObject.get('type'):
|
||||||
return
|
return
|
||||||
if postJsonObject['type'] != 'Create':
|
if postJsonObject['type'] != 'Create':
|
||||||
|
@ -239,9 +238,8 @@ def updateBookmarksCollection(recentPostsCache: {},
|
||||||
with open(bookmarksIndexFilename, 'w+') as bookmarksIndexFile:
|
with open(bookmarksIndexFilename, 'w+') as bookmarksIndexFile:
|
||||||
bookmarksIndexFile.write(bookmarkIndex + '\n')
|
bookmarksIndexFile.write(bookmarkIndex + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write bookmarks index ' +
|
print('EX: unable to write bookmarks index ' +
|
||||||
bookmarksIndexFilename)
|
bookmarksIndexFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def bookmark(recentPostsCache: {},
|
def bookmark(recentPostsCache: {},
|
||||||
|
|
|
@ -115,7 +115,7 @@ def updateHashtagCategories(baseDir: str) -> None:
|
||||||
with open(categoryListFilename, 'w+') as fp:
|
with open(categoryListFilename, 'w+') as fp:
|
||||||
fp.write(categoryListStr)
|
fp.write(categoryListStr)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write category ' + categoryListFilename)
|
print('EX: unable to write category ' + categoryListFilename)
|
||||||
|
|
||||||
|
|
||||||
def _validHashtagCategory(category: str) -> bool:
|
def _validHashtagCategory(category: str) -> bool:
|
||||||
|
@ -168,9 +168,8 @@ def setHashtagCategory(baseDir: str, hashtag: str, category: str,
|
||||||
updateHashtagCategories(baseDir)
|
updateHashtagCategories(baseDir)
|
||||||
return True
|
return True
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: unable to write category ' + categoryFilename +
|
print('EX: unable to write category ' + categoryFilename +
|
||||||
' ' + str(e))
|
' ' + str(e))
|
||||||
pass
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1112,7 +1112,7 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
with open(filename, 'wb') as fp:
|
with open(filename, 'wb') as fp:
|
||||||
fp.write(mediaBytes[startPos:])
|
fp.write(mediaBytes[startPos:])
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write media')
|
print('EX: 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)
|
||||||
|
|
|
@ -48,7 +48,6 @@ def updateConversation(baseDir: str, nickname: str, domain: str,
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: updateConversation ' +
|
print('EX: updateConversation ' +
|
||||||
'unable to write to ' + conversationFilename)
|
'unable to write to ' + conversationFilename)
|
||||||
pass
|
|
||||||
elif postId + '\n' not in open(conversationFilename).read():
|
elif postId + '\n' not in open(conversationFilename).read():
|
||||||
try:
|
try:
|
||||||
with open(conversationFilename, 'a+') as fp:
|
with open(conversationFilename, 'a+') as fp:
|
||||||
|
@ -57,7 +56,6 @@ def updateConversation(baseDir: str, nickname: str, domain: str,
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: updateConversation 2 ' +
|
print('EX: updateConversation 2 ' +
|
||||||
'unable to write to ' + conversationFilename)
|
'unable to write to ' + conversationFilename)
|
||||||
pass
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,8 +74,7 @@ def muteConversation(baseDir: str, nickname: str, domain: str,
|
||||||
with open(conversationFilename + '.muted', 'w+') as fp:
|
with open(conversationFilename + '.muted', 'w+') as fp:
|
||||||
fp.write('\n')
|
fp.write('\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write mute ' + conversationFilename)
|
print('EX: unable to write mute ' + conversationFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def unmuteConversation(baseDir: str, nickname: str, domain: str,
|
def unmuteConversation(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
46
daemon.py
46
daemon.py
|
@ -536,7 +536,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(votesFilename, 'a+') as votesFile:
|
with open(votesFilename, 'a+') as votesFile:
|
||||||
votesFile.write(messageId + '\n')
|
votesFile.write(messageId + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write vote ' +
|
print('EX: unable to write vote ' +
|
||||||
votesFilename)
|
votesFilename)
|
||||||
|
|
||||||
# ensure that the cached post is removed if it exists,
|
# ensure that the cached post is removed if it exists,
|
||||||
|
@ -841,10 +841,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
with open(mediaFilename + '.etag', 'r') as etagFile:
|
with open(mediaFilename + '.etag', 'r') as etagFile:
|
||||||
etag = etagFile.read()
|
etag = etagFile.read()
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _set_headers_etag ' +
|
print('EX: _set_headers_etag ' +
|
||||||
'unable to read ' + mediaFilename + '.etag')
|
'unable to read ' + mediaFilename + '.etag')
|
||||||
pass
|
|
||||||
if not etag:
|
if not etag:
|
||||||
etag = md5(data).hexdigest() # nosec
|
etag = md5(data).hexdigest() # nosec
|
||||||
try:
|
try:
|
||||||
|
@ -853,7 +852,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: _set_headers_etag ' +
|
print('EX: _set_headers_etag ' +
|
||||||
'unable to write ' + mediaFilename + '.etag')
|
'unable to write ' + mediaFilename + '.etag')
|
||||||
pass
|
|
||||||
# if etag:
|
# if etag:
|
||||||
# self.send_header('ETag', '"' + etag + '"')
|
# self.send_header('ETag', '"' + etag + '"')
|
||||||
if lastModified:
|
if lastModified:
|
||||||
|
@ -877,10 +875,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
with open(mediaFilename, 'r') as etagFile:
|
with open(mediaFilename, 'r') as etagFile:
|
||||||
currEtag = etagFile.read()
|
currEtag = etagFile.read()
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _etag_exists unable to read ' +
|
print('EX: _etag_exists unable to read ' +
|
||||||
str(mediaFilename))
|
str(mediaFilename))
|
||||||
pass
|
|
||||||
if currEtag and oldEtag == currEtag:
|
if currEtag and oldEtag == currEtag:
|
||||||
# The file has not changed
|
# The file has not changed
|
||||||
return True
|
return True
|
||||||
|
@ -1762,14 +1759,14 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(saltFilename, 'r') as fp:
|
with open(saltFilename, 'r') as fp:
|
||||||
salt = fp.read()
|
salt = fp.read()
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: Unable to read salt for ' +
|
print('EX: 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 OSError as e:
|
except OSError as e:
|
||||||
print('WARN: Unable to save salt for ' +
|
print('EX: Unable to save salt for ' +
|
||||||
loginNickname + ' ' + str(e))
|
loginNickname + ' ' + str(e))
|
||||||
|
|
||||||
tokenText = loginNickname + loginPassword + salt
|
tokenText = loginNickname + loginPassword + salt
|
||||||
|
@ -1783,7 +1780,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(tokenFilename, 'w+') as fp:
|
with open(tokenFilename, 'w+') as fp:
|
||||||
fp.write(token)
|
fp.write(token)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: Unable to save token for ' +
|
print('EX: Unable to save token for ' +
|
||||||
loginNickname + ' ' + str(e))
|
loginNickname + ' ' + str(e))
|
||||||
|
|
||||||
personUpgradeActor(baseDir, None, loginHandle,
|
personUpgradeActor(baseDir, None, loginHandle,
|
||||||
|
@ -2363,7 +2360,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
noNewswireFile.write('\n')
|
noNewswireFile.write('\n')
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: unable to write ' + nwFilename +
|
print('EX: unable to write ' + nwFilename +
|
||||||
' ' + str(e))
|
' ' + str(e))
|
||||||
usersPathStr = \
|
usersPathStr = \
|
||||||
usersPath + '/' + self.server.defaultTimeline + \
|
usersPath + '/' + self.server.defaultTimeline + \
|
||||||
|
@ -2406,7 +2403,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
noFeaturesFile.write('\n')
|
noFeaturesFile.write('\n')
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: unable to write ' + featFilename +
|
print('EX: unable to write ' + featFilename +
|
||||||
' ' + str(e))
|
' ' + str(e))
|
||||||
usersPathStr = \
|
usersPathStr = \
|
||||||
usersPath + '/' + self.server.defaultTimeline + \
|
usersPath + '/' + self.server.defaultTimeline + \
|
||||||
|
@ -2447,7 +2444,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(nwFilename, 'w+') as modNewswireFile:
|
with open(nwFilename, 'w+') as modNewswireFile:
|
||||||
modNewswireFile.write('\n')
|
modNewswireFile.write('\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + nwFilename)
|
print('EX: unable to write ' + nwFilename)
|
||||||
usersPathStr = \
|
usersPathStr = \
|
||||||
usersPath + '/' + self.server.defaultTimeline + \
|
usersPath + '/' + self.server.defaultTimeline + \
|
||||||
'?page=' + str(pageNumber)
|
'?page=' + str(pageNumber)
|
||||||
|
@ -3597,7 +3594,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(mediaFilename, 'wb') as avFile:
|
with open(mediaFilename, 'wb') as avFile:
|
||||||
avFile.write(mediaBytes)
|
avFile.write(mediaBytes)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + mediaFilename)
|
print('EX: 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)
|
||||||
|
@ -4128,7 +4125,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(newswireFilename, 'w+') as newswireFile:
|
with open(newswireFilename, 'w+') as newswireFile:
|
||||||
newswireFile.write(newswireStr)
|
newswireFile.write(newswireStr)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + newswireFilename)
|
print('EX: unable to write ' + newswireFilename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(newswireFilename):
|
if os.path.isfile(newswireFilename):
|
||||||
try:
|
try:
|
||||||
|
@ -4146,7 +4143,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(filterNewswireFilename, 'w+') as filterfile:
|
with open(filterNewswireFilename, 'w+') as filterfile:
|
||||||
filterfile.write(fields['filteredWordsNewswire'])
|
filterfile.write(fields['filteredWordsNewswire'])
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + filterNewswireFilename)
|
print('EX: unable to write ' + filterNewswireFilename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filterNewswireFilename):
|
if os.path.isfile(filterNewswireFilename):
|
||||||
try:
|
try:
|
||||||
|
@ -4163,7 +4160,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(hashtagRulesFilename, 'w+') as rulesfile:
|
with open(hashtagRulesFilename, 'w+') as rulesfile:
|
||||||
rulesfile.write(fields['hashtagRulesList'])
|
rulesfile.write(fields['hashtagRulesList'])
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + hashtagRulesFilename)
|
print('EX: unable to write ' + hashtagRulesFilename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(hashtagRulesFilename):
|
if os.path.isfile(hashtagRulesFilename):
|
||||||
try:
|
try:
|
||||||
|
@ -4181,7 +4178,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(newswireTrustedFilename, 'w+') as trustFile:
|
with open(newswireTrustedFilename, 'w+') as trustFile:
|
||||||
trustFile.write(newswireTrusted)
|
trustFile.write(newswireTrusted)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + newswireTrustedFilename)
|
print('EX: unable to write ' + newswireTrustedFilename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(newswireTrustedFilename):
|
if os.path.isfile(newswireTrustedFilename):
|
||||||
try:
|
try:
|
||||||
|
@ -4278,7 +4275,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(citationsFilename, 'w+') as citationsFile:
|
with open(citationsFilename, 'w+') as citationsFile:
|
||||||
citationsFile.write(citationsStr)
|
citationsFile.write(citationsStr)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + citationsFilename)
|
print('EX: 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',
|
||||||
|
@ -4734,7 +4731,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
with open(cityFilename, 'w+') as fp:
|
with open(cityFilename, 'w+') as fp:
|
||||||
fp.write(fields['cityDropdown'])
|
fp.write(fields['cityDropdown'])
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + cityFilename)
|
print('EX: unable to write ' + cityFilename)
|
||||||
|
|
||||||
# change displayed name
|
# change displayed name
|
||||||
if fields.get('displayNickname'):
|
if fields.get('displayNickname'):
|
||||||
|
@ -5940,7 +5937,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if os.path.isfile(blockedFilename):
|
if os.path.isfile(blockedFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(blockedFilename)
|
os.remove(blockedFilename)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _profileUpdate ' +
|
print('EX: _profileUpdate ' +
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
blockedFilename)
|
blockedFilename)
|
||||||
|
@ -15948,10 +15945,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
with open(mediaTagFilename, 'r') as etagFile:
|
with open(mediaTagFilename, 'r') as etagFile:
|
||||||
etag = etagFile.read()
|
etag = etagFile.read()
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: do_HEAD unable to read ' +
|
print('EX: do_HEAD unable to read ' +
|
||||||
mediaTagFilename)
|
mediaTagFilename)
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
with open(mediaFilename, 'rb') as avFile:
|
with open(mediaFilename, 'rb') as avFile:
|
||||||
mediaBinary = avFile.read()
|
mediaBinary = avFile.read()
|
||||||
|
@ -15959,10 +15955,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
with open(mediaTagFilename, 'w+') as etagFile:
|
with open(mediaTagFilename, 'w+') as etagFile:
|
||||||
etagFile.write(etag)
|
etagFile.write(etag)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: do_HEAD unable to write ' +
|
print('EX: do_HEAD unable to write ' +
|
||||||
mediaTagFilename)
|
mediaTagFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
mediaFileType = mediaFileMimeType(checkPath)
|
mediaFileType = mediaFileMimeType(checkPath)
|
||||||
self._set_headers_head(mediaFileType, fileLength,
|
self._set_headers_head(mediaFileType, fileLength,
|
||||||
|
@ -16129,10 +16124,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
with open(lastUsedFilename, 'w+') as lastUsedFile:
|
with open(lastUsedFilename, 'w+') as lastUsedFile:
|
||||||
lastUsedFile.write(str(int(time.time())))
|
lastUsedFile.write(str(int(time.time())))
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _receiveNewPostProcess unable to write ' +
|
print('EX: _receiveNewPostProcess unable to write ' +
|
||||||
lastUsedFilename)
|
lastUsedFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
mentionsStr = ''
|
mentionsStr = ''
|
||||||
if fields.get('mentions'):
|
if fields.get('mentions'):
|
||||||
|
|
|
@ -895,9 +895,8 @@ if args.socnet:
|
||||||
with open('socnet.dot', 'w+') as fp:
|
with open('socnet.dot', 'w+') as fp:
|
||||||
fp.write(dotGraph)
|
fp.write(dotGraph)
|
||||||
print('Saved to socnet.dot')
|
print('Saved to socnet.dot')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: commandline unable to write socnet.dot')
|
print('EX: commandline unable to write socnet.dot')
|
||||||
pass
|
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if args.postsraw:
|
if args.postsraw:
|
||||||
|
|
10
follow.py
10
follow.py
|
@ -304,7 +304,7 @@ def unfollowAccount(baseDir: str, nickname: str, domain: str,
|
||||||
checkHandle != '!' + handleToUnfollowLower:
|
checkHandle != '!' + handleToUnfollowLower:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: unable to write ' + filename + ' ' + str(e))
|
print('EX: unable to write ' + filename + ' ' + str(e))
|
||||||
|
|
||||||
# write to an unfollowed file so that if a follow accept
|
# write to an unfollowed file so that if a follow accept
|
||||||
# later arrives then it can be ignored
|
# later arrives then it can be ignored
|
||||||
|
@ -319,7 +319,7 @@ def unfollowAccount(baseDir: str, nickname: str, domain: str,
|
||||||
with open(unfollowedFilename, 'w+') as f:
|
with open(unfollowedFilename, 'w+') as f:
|
||||||
f.write(handleToUnfollow + '\n')
|
f.write(handleToUnfollow + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + unfollowedFilename)
|
print('EX: unable to write ' + unfollowedFilename)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -660,7 +660,7 @@ def _storeFollowRequest(baseDir: str,
|
||||||
with open(approveFollowsFilename, 'w+') as fp:
|
with open(approveFollowsFilename, 'w+') as fp:
|
||||||
fp.write(approveHandleStored + '\n')
|
fp.write(approveHandleStored + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + approveFollowsFilename)
|
print('EX: unable to write ' + approveFollowsFilename)
|
||||||
|
|
||||||
# store the follow request in its own directory
|
# store the follow request in its own directory
|
||||||
# We don't rely upon the inbox because items in there could expire
|
# We don't rely upon the inbox because items in there could expire
|
||||||
|
@ -864,7 +864,7 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
|
||||||
with open(followersFilename, 'w+') as followersFile:
|
with open(followersFilename, 'w+') as followersFile:
|
||||||
followersFile.write(approveHandle + '\n')
|
followersFile.write(approveHandle + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + followersFilename)
|
print('EX: unable to write ' + followersFilename)
|
||||||
|
|
||||||
print('Beginning follow accept')
|
print('Beginning follow accept')
|
||||||
return followedAccountAccepts(session, baseDir, httpPrefix,
|
return followedAccountAccepts(session, baseDir, httpPrefix,
|
||||||
|
@ -1062,7 +1062,7 @@ def sendFollowRequest(session, baseDir: str,
|
||||||
with open(unfollowedFilename, 'w+') as fp:
|
with open(unfollowedFilename, 'w+') as fp:
|
||||||
fp.write(unfollowedFile)
|
fp.write(unfollowedFile)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + unfollowedFilename)
|
print('EX: unable to write ' + unfollowedFilename)
|
||||||
|
|
||||||
newFollowJson = {
|
newFollowJson = {
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
|
|
|
@ -50,7 +50,7 @@ def receivingCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
with open(calendarFilename, 'w+') as fp:
|
with open(calendarFilename, 'w+') as fp:
|
||||||
fp.write(followingHandles)
|
fp.write(followingHandles)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + calendarFilename)
|
print('EX: unable to write ' + calendarFilename)
|
||||||
return handle + '\n' in open(calendarFilename).read()
|
return handle + '\n' in open(calendarFilename).read()
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ def _receiveCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
with open(calendarFilename, 'w+') as fp:
|
with open(calendarFilename, 'w+') as fp:
|
||||||
fp.write(followingHandles + handle + '\n')
|
fp.write(followingHandles + handle + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + calendarFilename)
|
print('EX: unable to write ' + calendarFilename)
|
||||||
|
|
||||||
# already in the calendar file?
|
# already in the calendar file?
|
||||||
if handle + '\n' in followingHandles:
|
if handle + '\n' in followingHandles:
|
||||||
|
@ -110,7 +110,7 @@ def _receiveCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
with open(calendarFilename, 'w+') as fp:
|
with open(calendarFilename, 'w+') as fp:
|
||||||
fp.write(followingHandles)
|
fp.write(followingHandles)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + calendarFilename)
|
print('EX: unable to write ' + calendarFilename)
|
||||||
else:
|
else:
|
||||||
print(handle + ' not in followingCalendar.txt')
|
print(handle + ' not in followingCalendar.txt')
|
||||||
# not already in the calendar file
|
# not already in the calendar file
|
||||||
|
@ -121,7 +121,7 @@ def _receiveCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
with open(calendarFilename, 'w+') as fp:
|
with open(calendarFilename, 'w+') as fp:
|
||||||
fp.write(followingHandles)
|
fp.write(followingHandles)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + calendarFilename)
|
print('EX: unable to write ' + calendarFilename)
|
||||||
|
|
||||||
|
|
||||||
def addPersonToCalendar(baseDir: str, nickname: str, domain: str,
|
def addPersonToCalendar(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
2
git.py
2
git.py
|
@ -217,5 +217,5 @@ def receiveGitPatch(baseDir: str, nickname: str, domain: str,
|
||||||
patchFile.write(patchStr)
|
patchFile.write(patchStr)
|
||||||
return True
|
return True
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN unable to write patch ' + patchFilename + ' ' + str(e))
|
print('EX: unable to write patch ' + patchFilename + ' ' + str(e))
|
||||||
return False
|
return False
|
||||||
|
|
16
happening.py
16
happening.py
|
@ -105,7 +105,7 @@ def saveEventPost(baseDir: str, handle: str, postId: str,
|
||||||
tlEventsFile.seek(0, 0)
|
tlEventsFile.seek(0, 0)
|
||||||
tlEventsFile.write(eventId + '\n' + content)
|
tlEventsFile.write(eventId + '\n' + content)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: Failed to write entry to events file ' +
|
print('EX: Failed to write entry to events file ' +
|
||||||
tlEventsFilename + ' ' + str(e))
|
tlEventsFilename + ' ' + str(e))
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
@ -113,7 +113,7 @@ def saveEventPost(baseDir: str, handle: str, postId: str,
|
||||||
with open(tlEventsFilename, 'w+') as tlEventsFile:
|
with open(tlEventsFilename, 'w+') as tlEventsFile:
|
||||||
tlEventsFile.write(eventId + '\n')
|
tlEventsFile.write(eventId + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + tlEventsFilename)
|
print('EX: unable to write ' + tlEventsFilename)
|
||||||
|
|
||||||
# create a directory for the calendar year
|
# create a directory for the calendar year
|
||||||
if not os.path.isdir(calendarPath + '/' + str(eventYear)):
|
if not os.path.isdir(calendarPath + '/' + str(eventYear)):
|
||||||
|
@ -134,7 +134,7 @@ def saveEventPost(baseDir: str, handle: str, postId: str,
|
||||||
with open(calendarFilename, 'a+') as calendarFile:
|
with open(calendarFilename, 'a+') as calendarFile:
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to append ' + calendarFilename)
|
print('EX: unable to append ' + calendarFilename)
|
||||||
|
|
||||||
# create a file which will trigger a notification that
|
# create a file which will trigger a notification that
|
||||||
# a new event has been added
|
# a new event has been added
|
||||||
|
@ -146,7 +146,7 @@ def saveEventPost(baseDir: str, handle: str, postId: str,
|
||||||
with open(calNotifyFilename, 'w+') as calendarNotificationFile:
|
with open(calNotifyFilename, 'w+') as calendarNotificationFile:
|
||||||
calendarNotificationFile.write(notifyStr)
|
calendarNotificationFile.write(notifyStr)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + calNotifyFilename)
|
print('EX: unable to write ' + calNotifyFilename)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ def getTodaysEvents(baseDir: str, nickname: str, domain: str,
|
||||||
for postId in calendarPostIds:
|
for postId in calendarPostIds:
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + calendarFilename)
|
print('EX: unable to write ' + calendarFilename)
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ def getThisWeeksEvents(baseDir: str, nickname: str, domain: str) -> {}:
|
||||||
for postId in calendarPostIds:
|
for postId in calendarPostIds:
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + calendarFilename)
|
print('EX: unable to write ' + calendarFilename)
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ def getCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
for postId in calendarPostIds:
|
for postId in calendarPostIds:
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + calendarFilename)
|
print('EX: unable to write ' + calendarFilename)
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
@ -472,4 +472,4 @@ def removeCalendarEvent(baseDir: str, nickname: str, domain: str,
|
||||||
if messageId not in line:
|
if messageId not in line:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + calendarFilename)
|
print('EX: unable to write ' + calendarFilename)
|
||||||
|
|
31
inbox.py
31
inbox.py
|
@ -240,7 +240,7 @@ def storeHashTags(baseDir: str, nickname: str, domain: str,
|
||||||
with open(tagsFilename, 'w+') as tagsFile:
|
with open(tagsFilename, 'w+') as tagsFile:
|
||||||
tagsFile.write(tagline)
|
tagsFile.write(tagline)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + tagsFilename)
|
print('EX: unable to write ' + tagsFilename)
|
||||||
else:
|
else:
|
||||||
if postUrl not in open(tagsFilename).read():
|
if postUrl not in open(tagsFilename).read():
|
||||||
try:
|
try:
|
||||||
|
@ -250,7 +250,7 @@ def storeHashTags(baseDir: str, nickname: str, domain: str,
|
||||||
tagsFile.seek(0, 0)
|
tagsFile.seek(0, 0)
|
||||||
tagsFile.write(tagline + content)
|
tagsFile.write(tagline + content)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: Failed to write entry to tags file ' +
|
print('EX: Failed to write entry to tags file ' +
|
||||||
tagsFilename + ' ' + str(e))
|
tagsFilename + ' ' + str(e))
|
||||||
removeOldHashtags(baseDir, 3)
|
removeOldHashtags(baseDir, 3)
|
||||||
|
|
||||||
|
@ -1948,7 +1948,6 @@ def _receiveAnnounce(recentPostsCache: {},
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: _receiveAnnounce unable to delete ' +
|
print('EX: _receiveAnnounce unable to delete ' +
|
||||||
str(postFilename))
|
str(postFilename))
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Announce post downloaded for ' +
|
print('DEBUG: Announce post downloaded for ' +
|
||||||
|
@ -1985,7 +1984,7 @@ def _receiveAnnounce(recentPostsCache: {},
|
||||||
with open(postFilename + '.tts', 'w+') as ttsFile:
|
with open(postFilename + '.tts', 'w+') as ttsFile:
|
||||||
ttsFile.write('\n')
|
ttsFile.write('\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write recent post ' +
|
print('EX: unable to write recent post ' +
|
||||||
postFilename)
|
postFilename)
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -2154,13 +2153,13 @@ def populateReplies(baseDir: str, httpPrefix: str, domain: str,
|
||||||
with open(postRepliesFilename, 'a+') as repliesFile:
|
with open(postRepliesFilename, 'a+') as repliesFile:
|
||||||
repliesFile.write(messageId + '\n')
|
repliesFile.write(messageId + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to append ' + postRepliesFilename)
|
print('EX: unable to append ' + postRepliesFilename)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(postRepliesFilename, 'w+') as repliesFile:
|
with open(postRepliesFilename, 'w+') as repliesFile:
|
||||||
repliesFile.write(messageId + '\n')
|
repliesFile.write(messageId + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + postRepliesFilename)
|
print('EX: unable to write ' + postRepliesFilename)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -2337,7 +2336,7 @@ def _dmNotify(baseDir: str, handle: str, url: str) -> None:
|
||||||
with open(dmFile, 'w+') as fp:
|
with open(dmFile, 'w+') as fp:
|
||||||
fp.write(url)
|
fp.write(url)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + dmFile)
|
print('EX: unable to write ' + dmFile)
|
||||||
|
|
||||||
|
|
||||||
def _alreadyLiked(baseDir: str, nickname: str, domain: str,
|
def _alreadyLiked(baseDir: str, nickname: str, domain: str,
|
||||||
|
@ -2547,7 +2546,7 @@ def _notifyPostArrival(baseDir: str, handle: str, url: str) -> None:
|
||||||
with open(notifyFile, 'w+') as fp:
|
with open(notifyFile, 'w+') as fp:
|
||||||
fp.write(url)
|
fp.write(url)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + notifyFile)
|
print('EX: unable to write ' + notifyFile)
|
||||||
|
|
||||||
|
|
||||||
def _replyNotify(baseDir: str, handle: str, url: str) -> None:
|
def _replyNotify(baseDir: str, handle: str, url: str) -> None:
|
||||||
|
@ -2562,7 +2561,7 @@ def _replyNotify(baseDir: str, handle: str, url: str) -> None:
|
||||||
with open(replyFile, 'w+') as fp:
|
with open(replyFile, 'w+') as fp:
|
||||||
fp.write(url)
|
fp.write(url)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + replyFile)
|
print('EX: unable to write ' + replyFile)
|
||||||
|
|
||||||
|
|
||||||
def _gitPatchNotify(baseDir: str, handle: str,
|
def _gitPatchNotify(baseDir: str, handle: str,
|
||||||
|
@ -2580,7 +2579,7 @@ def _gitPatchNotify(baseDir: str, handle: str,
|
||||||
with open(patchFile, 'w+') as fp:
|
with open(patchFile, 'w+') as fp:
|
||||||
fp.write('git ' + handle + ' ' + subject)
|
fp.write('git ' + handle + ' ' + subject)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + patchFile)
|
print('EX: unable to write ' + patchFile)
|
||||||
|
|
||||||
|
|
||||||
def _groupHandle(baseDir: str, handle: str) -> bool:
|
def _groupHandle(baseDir: str, handle: str) -> bool:
|
||||||
|
@ -2731,14 +2730,14 @@ def inboxUpdateIndex(boxname: str, baseDir: str, handle: str,
|
||||||
written = True
|
written = True
|
||||||
return True
|
return True
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: Failed to write entry to index ' + str(e))
|
print('EX: Failed to write entry to index ' + str(e))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(indexFilename, 'w+') as indexFile:
|
with open(indexFilename, 'w+') as indexFile:
|
||||||
indexFile.write(destinationFilename + '\n')
|
indexFile.write(destinationFilename + '\n')
|
||||||
written = True
|
written = True
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: Failed to write initial entry to index ' + str(e))
|
print('EX: Failed to write initial entry to index ' + str(e))
|
||||||
|
|
||||||
return written
|
return written
|
||||||
|
|
||||||
|
@ -2774,7 +2773,7 @@ def _updateLastSeen(baseDir: str, handle: str, actor: str) -> None:
|
||||||
with open(lastSeenFilename, 'w+') as lastSeenFile:
|
with open(lastSeenFilename, 'w+') as lastSeenFile:
|
||||||
lastSeenFile.write(str(daysSinceEpoch))
|
lastSeenFile.write(str(daysSinceEpoch))
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + lastSeenFilename)
|
print('EX: unable to write ' + lastSeenFilename)
|
||||||
|
|
||||||
|
|
||||||
def _bounceDM(senderPostId: str, session, httpPrefix: str,
|
def _bounceDM(senderPostId: str, session, httpPrefix: str,
|
||||||
|
@ -3514,7 +3513,7 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
with open(destinationFilenameMuted, 'w+') as muteFile:
|
with open(destinationFilenameMuted, 'w+') as muteFile:
|
||||||
muteFile.write('\n')
|
muteFile.write('\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + destinationFilenameMuted)
|
print('EX: unable to write ' + destinationFilenameMuted)
|
||||||
|
|
||||||
# update the indexes for different timelines
|
# update the indexes for different timelines
|
||||||
for boxname in updateIndexList:
|
for boxname in updateIndexList:
|
||||||
|
@ -3805,7 +3804,7 @@ def _checkJsonSignature(baseDir: str, queueJson: {}) -> (bool, bool):
|
||||||
with open(unknownContextsFile, 'a+') as unknownFile:
|
with open(unknownContextsFile, 'a+') as unknownFile:
|
||||||
unknownFile.write(unknownContext + '\n')
|
unknownFile.write(unknownContext + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to append ' + unknownContextsFile)
|
print('EX: unable to append ' + unknownContextsFile)
|
||||||
else:
|
else:
|
||||||
print('Unrecognized jsonld signature type: ' + jwebsigType)
|
print('Unrecognized jsonld signature type: ' + jwebsigType)
|
||||||
|
|
||||||
|
@ -3823,7 +3822,7 @@ def _checkJsonSignature(baseDir: str, queueJson: {}) -> (bool, bool):
|
||||||
with open(unknownSignaturesFile, 'a+') as unknownFile:
|
with open(unknownSignaturesFile, 'a+') as unknownFile:
|
||||||
unknownFile.write(jwebsigType + '\n')
|
unknownFile.write(jwebsigType + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to append ' + unknownSignaturesFile)
|
print('EX: unable to append ' + unknownSignaturesFile)
|
||||||
return hasJsonSignature, jwebsigType
|
return hasJsonSignature, jwebsigType
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ def manualDenyFollowRequest(session, baseDir: str,
|
||||||
with open(rejectedFollowsFilename, 'a+') as rejectsFile:
|
with open(rejectedFollowsFilename, 'a+') as rejectsFile:
|
||||||
rejectsFile.write(denyHandle + '\n')
|
rejectsFile.write(denyHandle + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to append ' + rejectedFollowsFilename)
|
print('EX: unable to append ' + rejectedFollowsFilename)
|
||||||
|
|
||||||
denyNickname = denyHandle.split('@')[0]
|
denyNickname = denyHandle.split('@')[0]
|
||||||
denyDomain = \
|
denyDomain = \
|
||||||
|
@ -111,13 +111,13 @@ def _approveFollowerHandle(accountDir: str, approveHandle: str) -> None:
|
||||||
with open(approvedFilename, 'a+') as approvedFile:
|
with open(approvedFilename, 'a+') as approvedFile:
|
||||||
approvedFile.write(approveHandle + '\n')
|
approvedFile.write(approveHandle + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to append ' + approvedFilename)
|
print('EX: unable to append ' + approvedFilename)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(approvedFilename, 'w+') as approvedFile:
|
with open(approvedFilename, 'w+') as approvedFile:
|
||||||
approvedFile.write(approveHandle + '\n')
|
approvedFile.write(approveHandle + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + approvedFilename)
|
print('EX: unable to write ' + approvedFilename)
|
||||||
|
|
||||||
|
|
||||||
def manualApproveFollowRequest(session, baseDir: str,
|
def manualApproveFollowRequest(session, baseDir: str,
|
||||||
|
@ -252,7 +252,7 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
with open(followersFilename, 'w+') as followersFile:
|
with open(followersFilename, 'w+') as followersFile:
|
||||||
followersFile.write(approveHandleFull + '\n')
|
followersFile.write(approveHandleFull + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + followersFilename)
|
print('EX: unable to write ' + followersFilename)
|
||||||
|
|
||||||
# only update the follow requests file if the follow is confirmed to be
|
# only update the follow requests file if the follow is confirmed to be
|
||||||
# in followers.txt
|
# in followers.txt
|
||||||
|
|
3
media.py
3
media.py
|
@ -277,9 +277,8 @@ def _updateEtag(mediaFilename: str) -> None:
|
||||||
try:
|
try:
|
||||||
with open(mediaFilename, 'rb') as mediaFile:
|
with open(mediaFilename, 'rb') as mediaFile:
|
||||||
data = mediaFile.read()
|
data = mediaFile.read()
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _updateEtag unable to read ' + str(mediaFilename))
|
print('EX: _updateEtag unable to read ' + str(mediaFilename))
|
||||||
pass
|
|
||||||
|
|
||||||
if not data:
|
if not data:
|
||||||
return
|
return
|
||||||
|
|
|
@ -61,7 +61,7 @@ def _updateFeedsOutboxIndex(baseDir: str, domain: str, postId: str) -> None:
|
||||||
with open(indexFilename, 'w+') as feedsFile:
|
with open(indexFilename, 'w+') as feedsFile:
|
||||||
feedsFile.write(postId + '\n')
|
feedsFile.write(postId + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + indexFilename)
|
print('EX: unable to write ' + indexFilename)
|
||||||
|
|
||||||
|
|
||||||
def _saveArrivedTime(baseDir: str, postFilename: str, arrived: str) -> None:
|
def _saveArrivedTime(baseDir: str, postFilename: str, arrived: str) -> None:
|
||||||
|
@ -71,7 +71,7 @@ def _saveArrivedTime(baseDir: str, postFilename: str, arrived: str) -> None:
|
||||||
with open(postFilename + '.arrived', 'w+') as arrivedFile:
|
with open(postFilename + '.arrived', 'w+') as arrivedFile:
|
||||||
arrivedFile.write(arrived)
|
arrivedFile.write(arrived)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + postFilename + '.arrived')
|
print('EX: unable to write ' + postFilename + '.arrived')
|
||||||
|
|
||||||
|
|
||||||
def _removeControlCharacters(content: str) -> str:
|
def _removeControlCharacters(content: str) -> str:
|
||||||
|
@ -493,7 +493,7 @@ def _createNewsMirror(baseDir: str, domain: str,
|
||||||
with open(mirrorIndexFilename, 'w+') as indexFile:
|
with open(mirrorIndexFilename, 'w+') as indexFile:
|
||||||
indexFile.write(indexContent)
|
indexFile.write(indexContent)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + mirrorIndexFilename)
|
print('EX: unable to write ' + mirrorIndexFilename)
|
||||||
|
|
||||||
mirrorArticleDir = mirrorDir + '/' + postIdNumber
|
mirrorArticleDir = mirrorDir + '/' + postIdNumber
|
||||||
if os.path.isdir(mirrorArticleDir):
|
if os.path.isdir(mirrorArticleDir):
|
||||||
|
@ -522,13 +522,13 @@ def _createNewsMirror(baseDir: str, domain: str,
|
||||||
with open(mirrorIndexFilename, 'a+') as indexFile:
|
with open(mirrorIndexFilename, 'a+') as indexFile:
|
||||||
indexFile.write(postIdNumber + '\n')
|
indexFile.write(postIdNumber + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to append ' + mirrorIndexFilename)
|
print('EX: unable to append ' + mirrorIndexFilename)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(mirrorIndexFilename, 'w+') as indexFile:
|
with open(mirrorIndexFilename, 'w+') as indexFile:
|
||||||
indexFile.write(postIdNumber + '\n')
|
indexFile.write(postIdNumber + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + mirrorIndexFilename)
|
print('EX: unable to write ' + mirrorIndexFilename)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
26
person.py
26
person.py
|
@ -511,7 +511,7 @@ def _createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
with open(filename, 'w+') as text_file:
|
with open(filename, 'w+') as text_file:
|
||||||
print(privateKeyPem, file=text_file)
|
print(privateKeyPem, file=text_file)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to save ' + filename)
|
print('EX: unable to save ' + filename)
|
||||||
|
|
||||||
# save the public key
|
# save the public key
|
||||||
publicKeysSubdir = '/keys/public'
|
publicKeysSubdir = '/keys/public'
|
||||||
|
@ -522,7 +522,7 @@ def _createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
with open(filename, 'w+') as text_file:
|
with open(filename, 'w+') as text_file:
|
||||||
print(publicKeyPem, file=text_file)
|
print(publicKeyPem, file=text_file)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to save 2 ' + filename)
|
print('EX: unable to save 2 ' + filename)
|
||||||
|
|
||||||
if password:
|
if password:
|
||||||
password = removeLineEndings(password)
|
password = removeLineEndings(password)
|
||||||
|
@ -635,7 +635,7 @@ def createPerson(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
with open(followDMsFilename, 'w+') as fFile:
|
with open(followDMsFilename, 'w+') as fFile:
|
||||||
fFile.write('\n')
|
fFile.write('\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + followDMsFilename)
|
print('EX: unable to write ' + followDMsFilename)
|
||||||
|
|
||||||
# notify when posts are liked
|
# notify when posts are liked
|
||||||
if nickname != 'news':
|
if nickname != 'news':
|
||||||
|
@ -645,7 +645,7 @@ def createPerson(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
with open(notifyLikesFilename, 'w+') as nFile:
|
with open(notifyLikesFilename, 'w+') as nFile:
|
||||||
nFile.write('\n')
|
nFile.write('\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + notifyLikesFilename)
|
print('EX: unable to write ' + notifyLikesFilename)
|
||||||
|
|
||||||
# notify when posts have emoji reactions
|
# notify when posts have emoji reactions
|
||||||
if nickname != 'news':
|
if nickname != 'news':
|
||||||
|
@ -655,7 +655,7 @@ def createPerson(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
with open(notifyReactionsFilename, 'w+') as nFile:
|
with open(notifyReactionsFilename, 'w+') as nFile:
|
||||||
nFile.write('\n')
|
nFile.write('\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + notifyReactionsFilename)
|
print('EX: unable to write ' + notifyReactionsFilename)
|
||||||
|
|
||||||
theme = getConfigParam(baseDir, 'theme')
|
theme = getConfigParam(baseDir, 'theme')
|
||||||
if not theme:
|
if not theme:
|
||||||
|
@ -1037,7 +1037,7 @@ def reenableAccount(baseDir: str, nickname: str) -> None:
|
||||||
if suspended.strip('\n').strip('\r') != nickname:
|
if suspended.strip('\n').strip('\r') != nickname:
|
||||||
suspendedFile.write(suspended)
|
suspendedFile.write(suspended)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print('WARN: unable to save ' + suspendedFilename +
|
print('EX: unable to save ' + suspendedFilename +
|
||||||
' ' + str(e))
|
' ' + str(e))
|
||||||
|
|
||||||
|
|
||||||
|
@ -1084,13 +1084,13 @@ def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
with open(suspendedFilename, 'a+') as suspendedFile:
|
with open(suspendedFilename, 'a+') as suspendedFile:
|
||||||
suspendedFile.write(nickname + '\n')
|
suspendedFile.write(nickname + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to append ' + suspendedFilename)
|
print('EX: unable to append ' + suspendedFilename)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(suspendedFilename, 'w+') as suspendedFile:
|
with open(suspendedFilename, 'w+') as suspendedFile:
|
||||||
suspendedFile.write(nickname + '\n')
|
suspendedFile.write(nickname + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + suspendedFilename)
|
print('EX: unable to write ' + suspendedFilename)
|
||||||
|
|
||||||
|
|
||||||
def canRemovePost(baseDir: str, nickname: str,
|
def canRemovePost(baseDir: str, nickname: str,
|
||||||
|
@ -1153,7 +1153,7 @@ def _removeTagsForNickname(baseDir: str, nickname: str,
|
||||||
if matchStr not in tagline:
|
if matchStr not in tagline:
|
||||||
tagFile.write(tagline)
|
tagFile.write(tagline)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + tagFilename)
|
print('EX: unable to write ' + tagFilename)
|
||||||
|
|
||||||
|
|
||||||
def removeAccount(baseDir: str, nickname: str,
|
def removeAccount(baseDir: str, nickname: str,
|
||||||
|
@ -1322,7 +1322,7 @@ def isPersonSnoozed(baseDir: str, nickname: str, domain: str,
|
||||||
with open(snoozedFilename, 'w+') as writeSnoozedFile:
|
with open(snoozedFilename, 'w+') as writeSnoozedFile:
|
||||||
writeSnoozedFile.write(content)
|
writeSnoozedFile.write(content)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + snoozedFilename)
|
print('EX: unable to write ' + snoozedFilename)
|
||||||
|
|
||||||
if snoozeActor + ' ' in open(snoozedFilename).read():
|
if snoozeActor + ' ' in open(snoozedFilename).read():
|
||||||
return True
|
return True
|
||||||
|
@ -1346,7 +1346,7 @@ def personSnooze(baseDir: str, nickname: str, domain: str,
|
||||||
snoozedFile.write(snoozeActor + ' ' +
|
snoozedFile.write(snoozeActor + ' ' +
|
||||||
str(int(time.time())) + '\n')
|
str(int(time.time())) + '\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to append ' + snoozedFilename)
|
print('EX: unable to append ' + snoozedFilename)
|
||||||
|
|
||||||
|
|
||||||
def personUnsnooze(baseDir: str, nickname: str, domain: str,
|
def personUnsnooze(baseDir: str, nickname: str, domain: str,
|
||||||
|
@ -1377,7 +1377,7 @@ def personUnsnooze(baseDir: str, nickname: str, domain: str,
|
||||||
with open(snoozedFilename, 'w+') as writeSnoozedFile:
|
with open(snoozedFilename, 'w+') as writeSnoozedFile:
|
||||||
writeSnoozedFile.write(content)
|
writeSnoozedFile.write(content)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + snoozedFilename)
|
print('EX: unable to write ' + snoozedFilename)
|
||||||
|
|
||||||
|
|
||||||
def setPersonNotes(baseDir: str, nickname: str, domain: str,
|
def setPersonNotes(baseDir: str, nickname: str, domain: str,
|
||||||
|
@ -1396,7 +1396,7 @@ def setPersonNotes(baseDir: str, nickname: str, domain: str,
|
||||||
with open(notesFilename, 'w+') as notesFile:
|
with open(notesFilename, 'w+') as notesFile:
|
||||||
notesFile.write(notes)
|
notesFile.write(notes)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + notesFilename)
|
print('EX: unable to write ' + notesFilename)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ def setPetName(baseDir: str, nickname: str, domain: str,
|
||||||
with open(petnamesFilename, 'w+') as petnamesFile:
|
with open(petnamesFilename, 'w+') as petnamesFile:
|
||||||
petnamesFile.write(newPetnamesStr)
|
petnamesFile.write(newPetnamesStr)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to save ' + petnamesFilename)
|
print('EX: unable to save ' + petnamesFilename)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
# entry does not exist in the petnames file
|
# entry does not exist in the petnames file
|
||||||
|
@ -53,7 +53,7 @@ def setPetName(baseDir: str, nickname: str, domain: str,
|
||||||
with open(petnamesFilename, 'a+') as petnamesFile:
|
with open(petnamesFilename, 'a+') as petnamesFile:
|
||||||
petnamesFile.write(entry)
|
petnamesFile.write(entry)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to append ' + petnamesFilename)
|
print('EX: unable to append ' + petnamesFilename)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ def setPetName(baseDir: str, nickname: str, domain: str,
|
||||||
with open(petnamesFilename, 'w+') as petnamesFile:
|
with open(petnamesFilename, 'w+') as petnamesFile:
|
||||||
petnamesFile.write(entry)
|
petnamesFile.write(entry)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + petnamesFilename)
|
print('EX: unable to write ' + petnamesFilename)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
7
posts.py
7
posts.py
|
@ -1577,7 +1577,7 @@ def pinPost(baseDir: str, nickname: str, domain: str,
|
||||||
with open(pinnedFilename, 'w+') as pinFile:
|
with open(pinnedFilename, 'w+') as pinFile:
|
||||||
pinFile.write(pinnedContent)
|
pinFile.write(pinnedContent)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write ' + pinnedFilename)
|
print('EX: unable to write ' + pinnedFilename)
|
||||||
|
|
||||||
|
|
||||||
def undoPinnedPost(baseDir: str, nickname: str, domain: str) -> None:
|
def undoPinnedPost(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
|
@ -2125,9 +2125,8 @@ def createReportPost(baseDir: str,
|
||||||
try:
|
try:
|
||||||
with open(newReportFile, 'w+') as fp:
|
with open(newReportFile, 'w+') as fp:
|
||||||
fp.write(toUrl + '/moderation')
|
fp.write(toUrl + '/moderation')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: createReportPost unable to write ' + newReportFile)
|
print('EX: createReportPost unable to write ' + newReportFile)
|
||||||
pass
|
|
||||||
|
|
||||||
return postJsonObject
|
return postJsonObject
|
||||||
|
|
||||||
|
@ -5137,7 +5136,7 @@ def editedPostFilename(baseDir: str, nickname: str, domain: str,
|
||||||
try:
|
try:
|
||||||
with open(actorFilename, 'r') as fp:
|
with open(actorFilename, 'r') as fp:
|
||||||
lastpostId = fp.read()
|
lastpostId = fp.read()
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: editedPostFilename unable to read ' + actorFilename)
|
print('EX: editedPostFilename unable to read ' + actorFilename)
|
||||||
return ''
|
return ''
|
||||||
if not lastpostId:
|
if not lastpostId:
|
||||||
|
|
|
@ -293,10 +293,9 @@ def _indicateNewShareAvailable(baseDir: str, httpPrefix: str,
|
||||||
fp.write(localActor + '/tlshares')
|
fp.write(localActor + '/tlshares')
|
||||||
else:
|
else:
|
||||||
fp.write(localActor + '/tlwanted')
|
fp.write(localActor + '/tlwanted')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _indicateNewShareAvailable unable to write ' +
|
print('EX: _indicateNewShareAvailable unable to write ' +
|
||||||
str(newShareFile))
|
str(newShareFile))
|
||||||
pass
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|
17
theme.py
17
theme.py
|
@ -593,20 +593,18 @@ def _setTextModeTheme(baseDir: str, name: str) -> None:
|
||||||
try:
|
try:
|
||||||
copyfile(textModeLogoFilename,
|
copyfile(textModeLogoFilename,
|
||||||
baseDir + '/accounts/logo.txt')
|
baseDir + '/accounts/logo.txt')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _setTextModeTheme unable to copy ' +
|
print('EX: _setTextModeTheme unable to copy ' +
|
||||||
textModeLogoFilename + ' ' +
|
textModeLogoFilename + ' ' +
|
||||||
baseDir + '/accounts/logo.txt')
|
baseDir + '/accounts/logo.txt')
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
copyfile(baseDir + '/img/logo.txt',
|
copyfile(baseDir + '/img/logo.txt',
|
||||||
baseDir + '/accounts/logo.txt')
|
baseDir + '/accounts/logo.txt')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _setTextModeTheme unable to copy ' +
|
print('EX: _setTextModeTheme unable to copy ' +
|
||||||
baseDir + '/img/logo.txt ' +
|
baseDir + '/img/logo.txt ' +
|
||||||
baseDir + '/accounts/logo.txt')
|
baseDir + '/accounts/logo.txt')
|
||||||
pass
|
|
||||||
|
|
||||||
# set the text mode banner which appears in browsers such as Lynx
|
# set the text mode banner which appears in browsers such as Lynx
|
||||||
textModeBannerFilename = \
|
textModeBannerFilename = \
|
||||||
|
@ -701,10 +699,9 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
try:
|
try:
|
||||||
copyfile(bannerFilename,
|
copyfile(bannerFilename,
|
||||||
accountDir + '/banner.png')
|
accountDir + '/banner.png')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _setThemeImages unable to copy ' +
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
bannerFilename)
|
bannerFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if os.path.isfile(searchBannerFilename):
|
if os.path.isfile(searchBannerFilename):
|
||||||
|
@ -725,10 +722,9 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: _setThemeImages unable to delete ' +
|
print('EX: _setThemeImages unable to delete ' +
|
||||||
accountDir + '/left_col_image.png')
|
accountDir + '/left_col_image.png')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _setThemeImages unable to copy ' +
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
leftColImageFilename)
|
leftColImageFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if os.path.isfile(rightColImageFilename):
|
if os.path.isfile(rightColImageFilename):
|
||||||
|
@ -742,7 +738,7 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: _setThemeImages unable to delete ' +
|
print('EX: _setThemeImages unable to delete ' +
|
||||||
accountDir + '/right_col_image.png')
|
accountDir + '/right_col_image.png')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: _setThemeImages unable to copy ' +
|
print('EX: _setThemeImages unable to copy ' +
|
||||||
rightColImageFilename)
|
rightColImageFilename)
|
||||||
break
|
break
|
||||||
|
@ -767,9 +763,8 @@ def setNewsAvatar(baseDir: str, name: 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: setNewsAvatar unable to delete ' + filename)
|
print('EX: setNewsAvatar unable to delete ' + filename)
|
||||||
pass
|
|
||||||
if os.path.isdir(baseDir + '/cache/avatars'):
|
if os.path.isdir(baseDir + '/cache/avatars'):
|
||||||
copyfile(newFilename, filename)
|
copyfile(newFilename, filename)
|
||||||
accountDir = acctDir(baseDir, nickname, domain)
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
|
|
|
@ -149,7 +149,6 @@ def removeDormantThreads(baseDir: str, threadsList: [], debug: bool,
|
||||||
logFile.write(currTime.strftime("%Y-%m-%dT%H:%M:%SZ") +
|
logFile.write(currTime.strftime("%Y-%m-%dT%H:%M:%SZ") +
|
||||||
',' + str(noOfActiveThreads) +
|
',' + str(noOfActiveThreads) +
|
||||||
',' + str(len(threadsList)) + '\n')
|
',' + str(len(threadsList)) + '\n')
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: removeDormantThreads unable to write ' +
|
print('EX: removeDormantThreads unable to write ' +
|
||||||
sendLogFilename)
|
sendLogFilename)
|
||||||
pass
|
|
||||||
|
|
2
utils.py
2
utils.py
|
@ -639,7 +639,7 @@ def saveJson(jsonObject: {}, filename: str) -> bool:
|
||||||
with open(filename, 'w+') as fp:
|
with open(filename, 'w+') as fp:
|
||||||
fp.write(json.dumps(jsonObject))
|
fp.write(json.dumps(jsonObject))
|
||||||
return True
|
return True
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: saveJson ' + str(tries))
|
print('EX: saveJson ' + str(tries))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tries += 1
|
tries += 1
|
||||||
|
|
|
@ -43,4 +43,4 @@ def setMinimal(baseDir: str, domain: str, nickname: str,
|
||||||
with open(minimalFilename, 'w+') as fp:
|
with open(minimalFilename, 'w+') as fp:
|
||||||
fp.write('\n')
|
fp.write('\n')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('WARN: unable to write minimal ' + minimalFilename)
|
print('EX: unable to write minimal ' + minimalFilename)
|
||||||
|
|
|
@ -433,20 +433,18 @@ def htmlSearch(cssCache: {}, translate: {},
|
||||||
try:
|
try:
|
||||||
with open(cachedHashtagSwarmFilename, 'r') as fp:
|
with open(cachedHashtagSwarmFilename, 'r') as fp:
|
||||||
swarmStr = fp.read()
|
swarmStr = fp.read()
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: htmlSearch unable to read cached hashtag swarm ' +
|
print('EX: htmlSearch unable to read cached hashtag swarm ' +
|
||||||
cachedHashtagSwarmFilename)
|
cachedHashtagSwarmFilename)
|
||||||
pass
|
|
||||||
if not swarmStr:
|
if not swarmStr:
|
||||||
swarmStr = htmlHashTagSwarm(baseDir, actor, translate)
|
swarmStr = htmlHashTagSwarm(baseDir, actor, translate)
|
||||||
if swarmStr:
|
if swarmStr:
|
||||||
try:
|
try:
|
||||||
with open(cachedHashtagSwarmFilename, 'w+') as fp:
|
with open(cachedHashtagSwarmFilename, 'w+') as fp:
|
||||||
fp.write(swarmStr)
|
fp.write(swarmStr)
|
||||||
except BaseException:
|
except OSError:
|
||||||
print('EX: htmlSearch unable to save cached hashtag swarm ' +
|
print('EX: htmlSearch unable to save cached hashtag swarm ' +
|
||||||
cachedHashtagSwarmFilename)
|
cachedHashtagSwarmFilename)
|
||||||
pass
|
|
||||||
|
|
||||||
followStr += ' <p class="hashtagswarm">' + swarmStr + '</p>\n'
|
followStr += ' <p class="hashtagswarm">' + swarmStr + '</p>\n'
|
||||||
followStr += ' </center>\n'
|
followStr += ' </center>\n'
|
||||||
|
|
Loading…
Reference in New Issue