mirror of https://gitlab.com/bashrc2/epicyon
Debug messages for exceptions
parent
99ae054cf2
commit
d6150d7fb0
|
@ -202,4 +202,5 @@ def removeOldHashtags(baseDir: str, maxMonths: int) -> str:
|
|||
try:
|
||||
os.remove(removeFilename)
|
||||
except BaseException:
|
||||
print('EX: removeOldHashtags unable to delete ' + removeFilename)
|
||||
pass
|
||||
|
|
|
@ -47,6 +47,7 @@ def E2EEremoveDevice(baseDir: str, nickname: str, domain: str,
|
|||
try:
|
||||
os.remove(deviceFilename)
|
||||
except BaseException:
|
||||
print('EX: E2EEremoveDevice unable to delete ' + deviceFilename)
|
||||
pass
|
||||
return True
|
||||
return False
|
||||
|
|
15
epicyon.py
15
epicyon.py
|
@ -883,6 +883,7 @@ if args.socnet:
|
|||
fp.write(dotGraph)
|
||||
print('Saved to socnet.dot')
|
||||
except BaseException:
|
||||
print('EX: commandline unable to write socnet.dot')
|
||||
pass
|
||||
sys.exit()
|
||||
|
||||
|
@ -2673,17 +2674,19 @@ if args.testdata:
|
|||
print('Generating some test data for user: ' + nickname)
|
||||
|
||||
if os.path.isdir(baseDir + '/tags'):
|
||||
shutil.rmtree(baseDir + '/tags')
|
||||
shutil.rmtree(baseDir + '/tags', ignore_errors=False, onerror=None)
|
||||
if os.path.isdir(baseDir + '/accounts'):
|
||||
shutil.rmtree(baseDir + '/accounts')
|
||||
shutil.rmtree(baseDir + '/accounts', ignore_errors=False, onerror=None)
|
||||
if os.path.isdir(baseDir + '/keys'):
|
||||
shutil.rmtree(baseDir + '/keys')
|
||||
shutil.rmtree(baseDir + '/keys', ignore_errors=False, onerror=None)
|
||||
if os.path.isdir(baseDir + '/media'):
|
||||
shutil.rmtree(baseDir + '/media')
|
||||
shutil.rmtree(baseDir + '/media', ignore_errors=False, onerror=None)
|
||||
if os.path.isdir(baseDir + '/sharefiles'):
|
||||
shutil.rmtree(baseDir + '/sharefiles')
|
||||
shutil.rmtree(baseDir + '/sharefiles',
|
||||
ignore_errors=False, onerror=None)
|
||||
if os.path.isdir(baseDir + '/wfendpoints'):
|
||||
shutil.rmtree(baseDir + '/wfendpoints')
|
||||
shutil.rmtree(baseDir + '/wfendpoints',
|
||||
ignore_errors=False, onerror=None)
|
||||
|
||||
setConfigParam(baseDir, 'registrationsRemaining',
|
||||
str(maxRegistrations))
|
||||
|
|
|
@ -319,6 +319,7 @@ def clearFollows(baseDir: str, nickname: str, domain: str,
|
|||
try:
|
||||
os.remove(filename)
|
||||
except BaseException:
|
||||
print('EX: clearFollows unable to delete ' + filename)
|
||||
pass
|
||||
|
||||
|
||||
|
@ -390,6 +391,8 @@ def getFollowingFeed(baseDir: str, domain: str, port: int, path: str,
|
|||
try:
|
||||
pageNumber = int(pageNumber)
|
||||
except BaseException:
|
||||
print('EX: getFollowingFeed unable to convert to int ' +
|
||||
str(pageNumber))
|
||||
pass
|
||||
path = path.split('?page=')[0]
|
||||
headerOnly = False
|
||||
|
@ -883,6 +886,8 @@ def followedAccountAccepts(session, baseDir: str, httpPrefix: str,
|
|||
try:
|
||||
os.remove(followActivityfilename)
|
||||
except BaseException:
|
||||
print('EX: followedAccountAccepts unable to delete ' +
|
||||
followActivityfilename)
|
||||
pass
|
||||
|
||||
groupAccount = False
|
||||
|
@ -956,6 +961,8 @@ def followedAccountRejects(session, baseDir: str, httpPrefix: str,
|
|||
try:
|
||||
os.remove(followActivityfilename)
|
||||
except BaseException:
|
||||
print('EX: followedAccountRejects unable to delete ' +
|
||||
followActivityfilename)
|
||||
pass
|
||||
# send the reject activity
|
||||
return sendSignedJson(rejectJson, session, baseDir,
|
||||
|
|
|
@ -42,7 +42,7 @@ def _removeEventFromTimeline(eventId: str, tlEventsFilename: str) -> None:
|
|||
with open(tlEventsFilename, 'w+') as fp2:
|
||||
fp2.write(eventsTimeline)
|
||||
except BaseException:
|
||||
print('ERROR: unable to save events timeline')
|
||||
print('EX: ERROR: unable to save events timeline')
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -467,5 +467,5 @@ def verifyPostHeaders(httpPrefix: str, publicKeyPem: str, headers: dict,
|
|||
return True
|
||||
except BaseException:
|
||||
if debug:
|
||||
print('DEBUG: verifyPostHeaders pkcs1_15 verify failure')
|
||||
print('EX: verifyPostHeaders pkcs1_15 verify failure')
|
||||
return False
|
||||
|
|
45
inbox.py
45
inbox.py
|
@ -136,7 +136,7 @@ def _storeLastPostId(baseDir: str, nickname: str, domain: str,
|
|||
with open(actorFilename, 'w+') as fp:
|
||||
fp.write(postId)
|
||||
except BaseException:
|
||||
print('Unable to write last post id to ' + actorFilename)
|
||||
print('EX: Unable to write last post id to ' + actorFilename)
|
||||
pass
|
||||
|
||||
|
||||
|
@ -155,7 +155,7 @@ def _updateCachedHashtagSwarm(baseDir: str, nickname: str, domain: str,
|
|||
modifiedDate = \
|
||||
datetime.datetime.strptime(lastModified, "%Y-%m-%dT%H:%M:%SZ")
|
||||
except BaseException:
|
||||
print('WARN: unable to parse last modified cache date ' +
|
||||
print('EX: unable to parse last modified cache date ' +
|
||||
str(lastModified))
|
||||
pass
|
||||
if modifiedDate:
|
||||
|
@ -180,7 +180,7 @@ def _updateCachedHashtagSwarm(baseDir: str, nickname: str, domain: str,
|
|||
fp.write(newSwarmStr)
|
||||
return True
|
||||
except BaseException:
|
||||
print('WARN: unable to write cached hashtag swarm ' +
|
||||
print('EX: unable to write cached hashtag swarm ' +
|
||||
cachedHashtagSwarmFilename)
|
||||
pass
|
||||
return False
|
||||
|
@ -911,6 +911,8 @@ def _receiveUpdateToQuestion(recentPostsCache: {}, messageJson: {},
|
|||
try:
|
||||
os.remove(cachedPostFilename)
|
||||
except BaseException:
|
||||
print('EX: _receiveUpdateToQuestion unable to delete ' +
|
||||
cachedPostFilename)
|
||||
pass
|
||||
# remove from memory cache
|
||||
removePostFromCache(messageJson, recentPostsCache)
|
||||
|
@ -1659,6 +1661,8 @@ def _receiveAnnounce(recentPostsCache: {},
|
|||
try:
|
||||
os.remove(postFilename)
|
||||
except BaseException:
|
||||
print('EX: _receiveAnnounce unable to delete ' +
|
||||
str(postFilename))
|
||||
pass
|
||||
else:
|
||||
if debug:
|
||||
|
@ -1772,6 +1776,8 @@ def _receiveUndoAnnounce(recentPostsCache: {},
|
|||
try:
|
||||
os.remove(postFilename)
|
||||
except BaseException:
|
||||
print('EX: _receiveUndoAnnounce unable to delete ' +
|
||||
str(postFilename))
|
||||
pass
|
||||
return True
|
||||
|
||||
|
@ -2113,14 +2119,14 @@ def _likeNotify(baseDir: str, domain: str, onionDomain: str,
|
|||
with open(prevLikeFile, 'w+') as fp:
|
||||
fp.write(likeStr)
|
||||
except BaseException:
|
||||
print('ERROR: unable to save previous like notification ' +
|
||||
print('EX: ERROR: unable to save previous like notification ' +
|
||||
prevLikeFile)
|
||||
pass
|
||||
try:
|
||||
with open(likeFile, 'w+') as fp:
|
||||
fp.write(likeStr)
|
||||
except BaseException:
|
||||
print('ERROR: unable to write like notification file ' +
|
||||
print('EX: ERROR: unable to write like notification file ' +
|
||||
likeFile)
|
||||
pass
|
||||
|
||||
|
@ -3036,6 +3042,7 @@ def clearQueueItems(baseDir: str, queue: []) -> None:
|
|||
os.remove(os.path.join(queueDir, qfile))
|
||||
ctr += 1
|
||||
except BaseException:
|
||||
print('EX: clearQueueItems unable to delete ' + qfile)
|
||||
pass
|
||||
break
|
||||
break
|
||||
|
@ -3102,6 +3109,8 @@ def _inboxQuotaExceeded(queue: {}, queueFilename: str,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: _inboxQuotaExceeded unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
queue.pop(0)
|
||||
return True
|
||||
|
@ -3123,6 +3132,8 @@ def _inboxQuotaExceeded(queue: {}, queueFilename: str,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: _inboxQuotaExceeded unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
queue.pop(0)
|
||||
return True
|
||||
|
@ -3143,6 +3154,8 @@ def _inboxQuotaExceeded(queue: {}, queueFilename: str,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: _inboxQuotaExceeded unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
queue.pop(0)
|
||||
return True
|
||||
|
@ -3165,6 +3178,8 @@ def _inboxQuotaExceeded(queue: {}, queueFilename: str,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: _inboxQuotaExceeded unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
queue.pop(0)
|
||||
return True
|
||||
|
@ -3348,6 +3363,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: runInboxQueue 1 unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
continue
|
||||
|
||||
|
@ -3421,6 +3438,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: runInboxQueue 2 unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
if len(queue) > 0:
|
||||
queue.pop(0)
|
||||
|
@ -3472,6 +3491,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: runInboxQueue 3 unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
if len(queue) > 0:
|
||||
queue.pop(0)
|
||||
|
@ -3492,6 +3513,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: runInboxQueue 4 unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
if len(queue) > 0:
|
||||
queue.pop(0)
|
||||
|
@ -3521,6 +3544,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: runInboxQueue 5 unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
if len(queue) > 0:
|
||||
queue.pop(0)
|
||||
|
@ -3542,6 +3567,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: runInboxQueue 6 unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
if len(queue) > 0:
|
||||
queue.pop(0)
|
||||
|
@ -3563,6 +3590,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: runInboxQueue 7 unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
if len(queue) > 0:
|
||||
queue.pop(0)
|
||||
|
@ -3584,6 +3613,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: runInboxQueue 8 unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
if len(queue) > 0:
|
||||
queue.pop(0)
|
||||
|
@ -3602,6 +3633,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: runInboxQueue 9 unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
if len(queue) > 0:
|
||||
queue.pop(0)
|
||||
|
@ -3680,6 +3713,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
try:
|
||||
os.remove(queueFilename)
|
||||
except BaseException:
|
||||
print('EX: runInboxQueue 10 unable to delete ' +
|
||||
str(queueFilename))
|
||||
pass
|
||||
if len(queue) > 0:
|
||||
queue.pop(0)
|
||||
|
|
|
@ -259,7 +259,7 @@ def libretranslate(url: str, text: str,
|
|||
try:
|
||||
response = request.urlopen(req)
|
||||
except BaseException:
|
||||
print('Unable to translate: ' + text)
|
||||
print('EX: Unable to translate: ' + text)
|
||||
return originalText
|
||||
|
||||
response_str = response.read().decode()
|
||||
|
|
2
like.py
2
like.py
|
@ -431,6 +431,8 @@ def updateLikesCollection(recentPostsCache: {},
|
|||
try:
|
||||
os.remove(cachedPostFilename)
|
||||
except BaseException:
|
||||
print('EX: updateLikesCollection unable to delete ' +
|
||||
cachedPostFilename)
|
||||
pass
|
||||
|
||||
obj = postJsonObject
|
||||
|
|
|
@ -87,6 +87,7 @@ def verifyJsonSignature(doc: {}, publicKeyPem: str) -> bool:
|
|||
hazutils.Prehashed(hashes.SHA256()))
|
||||
return True
|
||||
except BaseException:
|
||||
print('EX: verifyJsonSignature unable to verify')
|
||||
return False
|
||||
|
||||
|
||||
|
|
|
@ -255,11 +255,15 @@ def manualApproveFollowRequest(session, baseDir: str,
|
|||
try:
|
||||
os.remove(followActivityfilename)
|
||||
except BaseException:
|
||||
print('EX: manualApproveFollowRequest unable to delete ' +
|
||||
followActivityfilename)
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
os.remove(approveFollowsFilename + '.new')
|
||||
except BaseException:
|
||||
print('EX: manualApproveFollowRequest unable to delete ' +
|
||||
approveFollowsFilename + '.new')
|
||||
pass
|
||||
|
||||
|
||||
|
|
12
media.py
12
media.py
|
@ -126,6 +126,7 @@ def _spoofMetaData(baseDir: str, nickname: str, domain: str,
|
|||
with open(decoySeedFilename, 'w+') as fp:
|
||||
fp.write(str(decoySeed))
|
||||
except BaseException:
|
||||
print('EX: unable to write ' + decoySeedFilename)
|
||||
pass
|
||||
|
||||
if os.path.isfile('/usr/bin/exiftool'):
|
||||
|
@ -166,6 +167,8 @@ def convertImageToLowBandwidth(imageFilename: str) -> None:
|
|||
try:
|
||||
os.remove(lowBandwidthFilename)
|
||||
except BaseException:
|
||||
print('EX: convertImageToLowBandwidth unable to delete ' +
|
||||
lowBandwidthFilename)
|
||||
pass
|
||||
|
||||
cmd = \
|
||||
|
@ -187,6 +190,8 @@ def convertImageToLowBandwidth(imageFilename: str) -> None:
|
|||
try:
|
||||
os.remove(imageFilename)
|
||||
except BaseException:
|
||||
print('EX: convertImageToLowBandwidth unable to delete ' +
|
||||
imageFilename)
|
||||
pass
|
||||
os.rename(lowBandwidthFilename, imageFilename)
|
||||
if os.path.isfile(imageFilename):
|
||||
|
@ -273,6 +278,7 @@ def _updateEtag(mediaFilename: str) -> None:
|
|||
with open(mediaFilename, 'rb') as mediaFile:
|
||||
data = mediaFile.read()
|
||||
except BaseException:
|
||||
print('EX: _updateEtag unable to read ' + str(mediaFilename))
|
||||
pass
|
||||
|
||||
if not data:
|
||||
|
@ -284,6 +290,8 @@ def _updateEtag(mediaFilename: str) -> None:
|
|||
with open(mediaFilename + '.etag', 'w+') as etagFile:
|
||||
etagFile.write(etag)
|
||||
except BaseException:
|
||||
print('EX: _updateEtag unable to write ' +
|
||||
str(mediaFilename) + '.etag')
|
||||
pass
|
||||
|
||||
|
||||
|
@ -382,7 +390,8 @@ def archiveMedia(baseDir: str, archiveDirectory: str,
|
|||
archiveDirectory + '/media')
|
||||
else:
|
||||
# archive to /dev/null
|
||||
rmtree(os.path.join(baseDir + '/media', weekDir))
|
||||
rmtree(os.path.join(baseDir + '/media', weekDir),
|
||||
ignore_errors=False, onerror=None)
|
||||
break
|
||||
|
||||
|
||||
|
@ -407,6 +416,7 @@ def getImageDimensions(imageFilename: str) -> (int, int):
|
|||
result = subprocess.run(['identify', '-format', '"%wx%h"',
|
||||
imageFilename], stdout=subprocess.PIPE)
|
||||
except BaseException:
|
||||
print('EX: getImageDimensions unable to run identify command')
|
||||
return None, None
|
||||
if not result:
|
||||
return None, None
|
||||
|
|
|
@ -471,7 +471,7 @@ def _createNewsMirror(baseDir: str, domain: str,
|
|||
postId = postId.strip()
|
||||
mirrorArticleDir = mirrorDir + '/' + postId
|
||||
if os.path.isdir(mirrorArticleDir):
|
||||
rmtree(mirrorArticleDir)
|
||||
rmtree(mirrorArticleDir, ignore_errors=False, onerror=None)
|
||||
removals.append(postId)
|
||||
noOfDirs -= 1
|
||||
|
||||
|
@ -555,12 +555,12 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
|||
dateStrWithOffset = \
|
||||
datetime.datetime.strptime(dateStr, "%Y-%m-%d %H:%M:%S%z")
|
||||
except BaseException:
|
||||
print('Newswire strptime failed ' + str(dateStr))
|
||||
print('EX: Newswire strptime failed ' + str(dateStr))
|
||||
continue
|
||||
try:
|
||||
dateStr = dateStrWithOffset.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
except BaseException:
|
||||
print('Newswire dateStrWithOffset failed ' +
|
||||
print('EX: Newswire dateStrWithOffset failed ' +
|
||||
str(dateStrWithOffset))
|
||||
continue
|
||||
|
||||
|
@ -726,6 +726,8 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
|||
try:
|
||||
os.remove(filename + '.arrived')
|
||||
except BaseException:
|
||||
print('EX: _convertRSStoActivityPub ' +
|
||||
'unable to delete ' + filename + '.arrived')
|
||||
pass
|
||||
|
||||
# setting the url here links to the activitypub object
|
||||
|
@ -839,6 +841,8 @@ def runNewswireDaemon(baseDir: str, httpd,
|
|||
try:
|
||||
os.remove(refreshFilename)
|
||||
except BaseException:
|
||||
print('EX: runNewswireDaemon unable to delete ' +
|
||||
str(refreshFilename))
|
||||
pass
|
||||
break
|
||||
|
||||
|
|
|
@ -227,6 +227,7 @@ def parseFeedDate(pubDate: str) -> str:
|
|||
publishedDate = \
|
||||
datetime.strptime(pubDate, dateFormat)
|
||||
except BaseException:
|
||||
print('EX: parseFeedDate unable to parse date ' + str(pubDate))
|
||||
continue
|
||||
|
||||
if publishedDate:
|
||||
|
@ -563,6 +564,7 @@ def _jsonFeedV1ToDict(baseDir: str, domain: str, xmlStr: str,
|
|||
try:
|
||||
feedJson = json.loads(xmlStr)
|
||||
except BaseException:
|
||||
print('EX: _jsonFeedV1ToDict unable to load json ' + str(xmlStr))
|
||||
return {}
|
||||
maxBytes = maxFeedItemSizeKb * 1024
|
||||
if not feedJson.get('version'):
|
||||
|
@ -1040,6 +1042,8 @@ def _addBlogsToNewswire(baseDir: str, domain: str, newswire: {},
|
|||
try:
|
||||
os.remove(newswireModerationFilename)
|
||||
except BaseException:
|
||||
print('EX: _addBlogsToNewswire unable to delete ' +
|
||||
str(newswireModerationFilename))
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -397,6 +397,8 @@ def postMessageToOutbox(session, translate: {},
|
|||
try:
|
||||
os.remove(citationsFilename)
|
||||
except BaseException:
|
||||
print('EX: postMessageToOutbox unable to delete ' +
|
||||
citationsFilename)
|
||||
pass
|
||||
|
||||
# The following activity types get added to the index files
|
||||
|
|
28
person.py
28
person.py
|
@ -895,6 +895,8 @@ def personBoxJson(recentPostsCache: {},
|
|||
try:
|
||||
pageNumber = int(pageNumber)
|
||||
except BaseException:
|
||||
print('EX: personBoxJson unable to convert to int ' +
|
||||
str(pageNumber))
|
||||
pass
|
||||
path = path.split('?page=')[0]
|
||||
headerOnly = False
|
||||
|
@ -1035,12 +1037,14 @@ def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
|||
try:
|
||||
os.remove(saltFilename)
|
||||
except BaseException:
|
||||
print('EX: suspendAccount unable to delete ' + saltFilename)
|
||||
pass
|
||||
tokenFilename = acctDir(baseDir, nickname, domain) + '/.token'
|
||||
if os.path.isfile(tokenFilename):
|
||||
try:
|
||||
os.remove(tokenFilename)
|
||||
except BaseException:
|
||||
print('EX: suspendAccount unable to delete ' + tokenFilename)
|
||||
pass
|
||||
|
||||
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
||||
|
@ -1101,6 +1105,8 @@ def _removeTagsForNickname(baseDir: str, nickname: str,
|
|||
try:
|
||||
tagFilename = os.path.join(directory, filename)
|
||||
except BaseException:
|
||||
print('EX: _removeTagsForNickname unable to join ' +
|
||||
str(directory) + ' ' + str(filename))
|
||||
continue
|
||||
if not os.path.isfile(tagFilename):
|
||||
continue
|
||||
|
@ -1140,38 +1146,52 @@ def removeAccount(baseDir: str, nickname: str,
|
|||
removePassword(baseDir, nickname)
|
||||
_removeTagsForNickname(baseDir, nickname, domain, port)
|
||||
if os.path.isdir(baseDir + '/deactivated/' + handle):
|
||||
shutil.rmtree(baseDir + '/deactivated/' + handle)
|
||||
shutil.rmtree(baseDir + '/deactivated/' + handle,
|
||||
ignore_errors=False, onerror=None)
|
||||
if os.path.isdir(baseDir + '/accounts/' + handle):
|
||||
shutil.rmtree(baseDir + '/accounts/' + handle)
|
||||
shutil.rmtree(baseDir + '/accounts/' + handle,
|
||||
ignore_errors=False, onerror=None)
|
||||
if os.path.isfile(baseDir + '/accounts/' + handle + '.json'):
|
||||
try:
|
||||
os.remove(baseDir + '/accounts/' + handle + '.json')
|
||||
except BaseException:
|
||||
print('EX: removeAccount unable to delete ' +
|
||||
baseDir + '/accounts/' + handle + '.json')
|
||||
pass
|
||||
if os.path.isfile(baseDir + '/wfendpoints/' + handle + '.json'):
|
||||
try:
|
||||
os.remove(baseDir + '/wfendpoints/' + handle + '.json')
|
||||
except BaseException:
|
||||
print('EX: removeAccount unable to delete ' +
|
||||
baseDir + '/wfendpoints/' + handle + '.json')
|
||||
pass
|
||||
if os.path.isfile(baseDir + '/keys/private/' + handle + '.key'):
|
||||
try:
|
||||
os.remove(baseDir + '/keys/private/' + handle + '.key')
|
||||
except BaseException:
|
||||
print('EX: removeAccount unable to delete ' +
|
||||
baseDir + '/keys/private/' + handle + '.key')
|
||||
pass
|
||||
if os.path.isfile(baseDir + '/keys/public/' + handle + '.pem'):
|
||||
try:
|
||||
os.remove(baseDir + '/keys/public/' + handle + '.pem')
|
||||
except BaseException:
|
||||
print('EX: removeAccount unable to delete ' +
|
||||
baseDir + '/keys/public/' + handle + '.pem')
|
||||
pass
|
||||
if os.path.isdir(baseDir + '/sharefiles/' + nickname):
|
||||
shutil.rmtree(baseDir + '/sharefiles/' + nickname)
|
||||
shutil.rmtree(baseDir + '/sharefiles/' + nickname,
|
||||
ignore_errors=False, onerror=None)
|
||||
if os.path.isfile(baseDir + '/wfdeactivated/' + handle + '.json'):
|
||||
try:
|
||||
os.remove(baseDir + '/wfdeactivated/' + handle + '.json')
|
||||
except BaseException:
|
||||
print('EX: removeAccount unable to delete ' +
|
||||
baseDir + '/wfdeactivated/' + handle + '.json')
|
||||
pass
|
||||
if os.path.isdir(baseDir + '/sharefilesdeactivated/' + nickname):
|
||||
shutil.rmtree(baseDir + '/sharefilesdeactivated/' + nickname)
|
||||
shutil.rmtree(baseDir + '/sharefilesdeactivated/' + nickname,
|
||||
ignore_errors=False, onerror=None)
|
||||
|
||||
refreshNewswire(baseDir)
|
||||
|
||||
|
|
14
posts.py
14
posts.py
|
@ -893,7 +893,7 @@ def deleteAllPosts(baseDir: str,
|
|||
if os.path.isfile(filePath):
|
||||
os.unlink(filePath)
|
||||
elif os.path.isdir(filePath):
|
||||
shutil.rmtree(filePath)
|
||||
shutil.rmtree(filePath, ignore_errors=False, onerror=None)
|
||||
except Exception as e:
|
||||
print('ERROR: deleteAllPosts ' + str(e))
|
||||
|
||||
|
@ -1569,6 +1569,7 @@ def undoPinnedPost(baseDir: str, nickname: str, domain: str) -> None:
|
|||
try:
|
||||
os.remove(pinnedFilename)
|
||||
except BaseException:
|
||||
print('EX: undoPinnedPost unable to delete ' + pinnedFilename)
|
||||
pass
|
||||
|
||||
|
||||
|
@ -2094,6 +2095,7 @@ def createReportPost(baseDir: str,
|
|||
with open(newReportFile, 'w+') as fp:
|
||||
fp.write(toUrl + '/moderation')
|
||||
except BaseException:
|
||||
print('EX: createReportPost unable to write ' + newReportFile)
|
||||
pass
|
||||
|
||||
return postJsonObject
|
||||
|
@ -3584,6 +3586,8 @@ def _createBoxIndexed(recentPostsCache: {},
|
|||
try:
|
||||
pageStr = '?page=' + str(pageNumber)
|
||||
except BaseException:
|
||||
print('EX: _createBoxIndexed ' +
|
||||
'unable to convert page number to string')
|
||||
pass
|
||||
boxUrl = localActorUrl(httpPrefix, nickname, domain) + '/' + boxname
|
||||
boxHeader = {
|
||||
|
@ -3743,6 +3747,7 @@ def _createBoxIndexed(recentPostsCache: {},
|
|||
try:
|
||||
p = json.loads(postStr)
|
||||
except BaseException:
|
||||
print('EX: _createBoxIndexed unable to load json ' + postStr)
|
||||
continue
|
||||
|
||||
# Does this post have replies?
|
||||
|
@ -3925,6 +3930,8 @@ def archivePostsForPerson(httpPrefix: str, nickname: str, domain: str,
|
|||
try:
|
||||
os.remove(postCacheFilename)
|
||||
except BaseException:
|
||||
print('EX: archivePostsForPerson unable to delete ' +
|
||||
postCacheFilename)
|
||||
pass
|
||||
|
||||
noOfPosts -= 1
|
||||
|
@ -5037,11 +5044,15 @@ def secondsBetweenPublished(published1: str, published2: str) -> int:
|
|||
published1Time = \
|
||||
datetime.datetime.strptime(published1, '%Y-%m-%dT%H:%M:%SZ')
|
||||
except BaseException:
|
||||
print('EX: secondsBetweenPublished unable to parse date 1 ' +
|
||||
str(published1))
|
||||
return -1
|
||||
try:
|
||||
published2Time = \
|
||||
datetime.datetime.strptime(published2, '%Y-%m-%dT%H:%M:%SZ')
|
||||
except BaseException:
|
||||
print('EX: secondsBetweenPublished unable to parse date 2 ' +
|
||||
str(published2))
|
||||
return -1
|
||||
return (published2Time - published1Time).seconds
|
||||
|
||||
|
@ -5079,6 +5090,7 @@ def editedPostFilename(baseDir: str, nickname: str, domain: str,
|
|||
with open(actorFilename, 'r') as fp:
|
||||
lastpostId = fp.read()
|
||||
except BaseException:
|
||||
print('EX: editedPostFilename unable to read ' + actorFilename)
|
||||
return ''
|
||||
if not lastpostId:
|
||||
return ''
|
||||
|
|
21
schedule.py
21
schedule.py
|
@ -49,6 +49,8 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
|
|||
try:
|
||||
os.remove(postFilename)
|
||||
except BaseException:
|
||||
print('EX: _updatePostSchedule unable to delete ' +
|
||||
str(postFilename))
|
||||
pass
|
||||
continue
|
||||
# create the new index file
|
||||
|
@ -131,6 +133,8 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
|
|||
try:
|
||||
os.remove(postFilename)
|
||||
except BaseException:
|
||||
print('EX: _updatePostSchedule unable to delete ' +
|
||||
str(postFilename))
|
||||
pass
|
||||
continue
|
||||
|
||||
|
@ -202,6 +206,8 @@ def removeScheduledPosts(baseDir: str, nickname: str, domain: str) -> None:
|
|||
try:
|
||||
os.remove(scheduleIndexFilename)
|
||||
except BaseException:
|
||||
print('EX: removeScheduledPosts unable to delete ' +
|
||||
scheduleIndexFilename)
|
||||
pass
|
||||
# remove the scheduled posts
|
||||
scheduledDir = acctDir(baseDir, nickname, domain) + '/scheduled'
|
||||
|
@ -209,11 +215,10 @@ def removeScheduledPosts(baseDir: str, nickname: str, domain: str) -> None:
|
|||
return
|
||||
for scheduledPostFilename in os.listdir(scheduledDir):
|
||||
filePath = os.path.join(scheduledDir, scheduledPostFilename)
|
||||
try:
|
||||
if os.path.isfile(filePath):
|
||||
try:
|
||||
os.remove(filePath)
|
||||
except BaseException:
|
||||
pass
|
||||
except BaseException:
|
||||
pass
|
||||
if os.path.isfile(filePath):
|
||||
try:
|
||||
os.remove(filePath)
|
||||
except BaseException:
|
||||
print('EX: removeScheduledPosts unable to delete ' +
|
||||
filePath)
|
||||
pass
|
||||
|
|
|
@ -81,6 +81,7 @@ def urlExists(session, url: str, timeoutSec: int = 3,
|
|||
print('urlExists for ' + url + ' returned ' +
|
||||
str(result.status_code))
|
||||
except BaseException:
|
||||
print('EX: urlExists GET failed ' + str(url))
|
||||
pass
|
||||
return False
|
||||
|
||||
|
|
10
shares.py
10
shares.py
|
@ -149,6 +149,8 @@ def removeSharedItem(baseDir: str, nickname: str, domain: str,
|
|||
try:
|
||||
os.remove(itemIDfile + '.' + ext)
|
||||
except BaseException:
|
||||
print('EX: removeSharedItem unable to delete ' +
|
||||
itemIDfile + '.' + ext)
|
||||
pass
|
||||
# remove the item itself
|
||||
del sharesJson[itemID]
|
||||
|
@ -293,6 +295,8 @@ def _indicateNewShareAvailable(baseDir: str, httpPrefix: str,
|
|||
else:
|
||||
fp.write(localActor + '/tlwanted')
|
||||
except BaseException:
|
||||
print('EX: _indicateNewShareAvailable unable to write ' +
|
||||
str(newShareFile))
|
||||
pass
|
||||
break
|
||||
|
||||
|
@ -364,6 +368,8 @@ def addShare(baseDir: str,
|
|||
try:
|
||||
os.remove(imageFilename)
|
||||
except BaseException:
|
||||
print('EX: addShare unable to delete ' +
|
||||
str(imageFilename))
|
||||
pass
|
||||
imageUrl = \
|
||||
httpPrefix + '://' + domainFull + \
|
||||
|
@ -436,6 +442,8 @@ def _expireSharesForAccount(baseDir: str, nickname: str, domain: str,
|
|||
try:
|
||||
os.remove(itemIDfile + '.' + ext)
|
||||
except BaseException:
|
||||
print('EX: _expireSharesForAccount unable to delete ' +
|
||||
itemIDfile + '.' + ext)
|
||||
pass
|
||||
saveJson(sharesJson, sharesFilename)
|
||||
|
||||
|
@ -460,6 +468,8 @@ def getSharesFeedForPerson(baseDir: str,
|
|||
try:
|
||||
pageNumber = int(pageNumber)
|
||||
except BaseException:
|
||||
print('EX: getSharesFeedForPerson unable to convert to int ' +
|
||||
str(pageNumber))
|
||||
pass
|
||||
path = path.split('?page=')[0]
|
||||
headerOnly = False
|
||||
|
|
|
@ -118,5 +118,6 @@ def siteIsActive(url: str, timeout: int = 10) -> bool:
|
|||
return True
|
||||
|
||||
except BaseException:
|
||||
print('EX: siteIsActive ' + str(loc))
|
||||
pass
|
||||
return False
|
||||
|
|
78
tests.py
78
tests.py
|
@ -245,7 +245,7 @@ def _testHttpSignedGET(baseDir: str):
|
|||
|
||||
path = baseDir + '/.testHttpsigGET'
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||
os.mkdir(path)
|
||||
os.chdir(path)
|
||||
|
||||
|
@ -290,7 +290,7 @@ def _testHttpSignedGET(baseDir: str):
|
|||
boxpath, GETmethod, None,
|
||||
messageBodyJsonStr, debug, noRecencyCheck)
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||
|
||||
|
||||
def _testSignAndVerify() -> None:
|
||||
|
@ -561,7 +561,7 @@ def _testHttpsigBase(withDigest: bool, baseDir: str):
|
|||
|
||||
path = baseDir + '/.testHttpsigBase'
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||
os.mkdir(path)
|
||||
os.chdir(path)
|
||||
|
||||
|
@ -662,7 +662,7 @@ def _testHttpsigBase(withDigest: bool, baseDir: str):
|
|||
messageBodyJsonStr, False) is False
|
||||
|
||||
os.chdir(baseDir)
|
||||
shutil.rmtree(path)
|
||||
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||
|
||||
|
||||
def _testHttpsig(baseDir: str):
|
||||
|
@ -709,7 +709,7 @@ def createServerAlice(path: str, domain: str, port: int,
|
|||
sendThreads: []):
|
||||
print('Creating test server: Alice on port ' + str(port))
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||
os.mkdir(path)
|
||||
os.chdir(path)
|
||||
sharedItemsFederatedDomains = []
|
||||
|
@ -850,7 +850,7 @@ def createServerBob(path: str, domain: str, port: int,
|
|||
sendThreads: []):
|
||||
print('Creating test server: Bob on port ' + str(port))
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||
os.mkdir(path)
|
||||
os.chdir(path)
|
||||
sharedItemsFederatedDomains = []
|
||||
|
@ -988,7 +988,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
|
|||
sendThreads: []):
|
||||
print('Creating test server: Eve on port ' + str(port))
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||
os.mkdir(path)
|
||||
os.chdir(path)
|
||||
sharedItemsFederatedDomains = []
|
||||
|
@ -1055,7 +1055,7 @@ def createServerGroup(path: str, domain: str, port: int,
|
|||
sendThreads: []):
|
||||
print('Creating test server: Group on port ' + str(port))
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||
os.mkdir(path)
|
||||
os.chdir(path)
|
||||
sharedItemsFederatedDomains = []
|
||||
|
@ -1134,7 +1134,7 @@ def testPostMessageBetweenServers(baseDir: str) -> None:
|
|||
proxyType = None
|
||||
|
||||
if os.path.isdir(baseDir + '/.tests'):
|
||||
shutil.rmtree(baseDir + '/.tests')
|
||||
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||
os.mkdir(baseDir + '/.tests')
|
||||
|
||||
# create the servers
|
||||
|
@ -1417,8 +1417,8 @@ def testPostMessageBetweenServers(baseDir: str) -> None:
|
|||
assert thrBob.is_alive() is False
|
||||
|
||||
os.chdir(baseDir)
|
||||
shutil.rmtree(aliceDir)
|
||||
shutil.rmtree(bobDir)
|
||||
shutil.rmtree(aliceDir, ignore_errors=False, onerror=None)
|
||||
shutil.rmtree(bobDir, ignore_errors=False, onerror=None)
|
||||
|
||||
|
||||
def testFollowBetweenServers(baseDir: str) -> None:
|
||||
|
@ -1435,7 +1435,7 @@ def testFollowBetweenServers(baseDir: str) -> None:
|
|||
federationList = []
|
||||
|
||||
if os.path.isdir(baseDir + '/.tests'):
|
||||
shutil.rmtree(baseDir + '/.tests')
|
||||
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||
os.mkdir(baseDir + '/.tests')
|
||||
|
||||
# create the servers
|
||||
|
@ -1605,7 +1605,7 @@ def testFollowBetweenServers(baseDir: str) -> None:
|
|||
if os.path.isfile(os.path.join(queuePath, name))]) == 0
|
||||
|
||||
os.chdir(baseDir)
|
||||
shutil.rmtree(baseDir + '/.tests')
|
||||
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||
|
||||
|
||||
def testSharedItemsFederation(baseDir: str) -> None:
|
||||
|
@ -1622,7 +1622,7 @@ def testSharedItemsFederation(baseDir: str) -> None:
|
|||
federationList = []
|
||||
|
||||
if os.path.isdir(baseDir + '/.tests'):
|
||||
shutil.rmtree(baseDir + '/.tests')
|
||||
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||
os.mkdir(baseDir + '/.tests')
|
||||
|
||||
# create the servers
|
||||
|
@ -1767,7 +1767,7 @@ def testSharedItemsFederation(baseDir: str) -> None:
|
|||
print('\n\n*********************************************************')
|
||||
print('Bob publishes some shared items')
|
||||
if os.path.isdir(bobDir + '/ontology'):
|
||||
shutil.rmtree(bobDir + '/ontology')
|
||||
shutil.rmtree(bobDir + '/ontology', ignore_errors=False, onerror=None)
|
||||
os.mkdir(bobDir + '/ontology')
|
||||
copyfile(baseDir + '/img/logo.png', bobDir + '/logo.png')
|
||||
copyfile(baseDir + '/ontology/foodTypes.json',
|
||||
|
@ -2004,7 +2004,7 @@ def testSharedItemsFederation(baseDir: str) -> None:
|
|||
assert thrBob.is_alive() is False
|
||||
|
||||
os.chdir(baseDir)
|
||||
shutil.rmtree(baseDir + '/.tests')
|
||||
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||
print('Testing federation of shared items between ' +
|
||||
'Alice and Bob is complete')
|
||||
|
||||
|
@ -2026,7 +2026,7 @@ def testGroupFollow(baseDir: str) -> None:
|
|||
federationList = []
|
||||
|
||||
if os.path.isdir(baseDir + '/.tests'):
|
||||
shutil.rmtree(baseDir + '/.tests')
|
||||
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||
os.mkdir(baseDir + '/.tests')
|
||||
|
||||
# create the servers
|
||||
|
@ -2412,7 +2412,7 @@ def testGroupFollow(baseDir: str) -> None:
|
|||
if os.path.isfile(os.path.join(queuePath, name))]) == 0
|
||||
|
||||
os.chdir(baseDir)
|
||||
shutil.rmtree(baseDir + '/.tests')
|
||||
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||
print('Testing following of a group is complete')
|
||||
|
||||
|
||||
|
@ -2427,7 +2427,7 @@ def _testFollowersOfPerson(baseDir: str) -> None:
|
|||
federationList = []
|
||||
baseDir = currDir + '/.tests_followersofperson'
|
||||
if os.path.isdir(baseDir):
|
||||
shutil.rmtree(baseDir)
|
||||
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||
os.mkdir(baseDir)
|
||||
os.chdir(baseDir)
|
||||
createPerson(baseDir, nickname, domain, port,
|
||||
|
@ -2462,7 +2462,7 @@ def _testFollowersOfPerson(baseDir: str) -> None:
|
|||
assert 'drokk@' + domain in followList
|
||||
assert 'sausagedog@' + domain in followList
|
||||
os.chdir(currDir)
|
||||
shutil.rmtree(baseDir)
|
||||
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||
|
||||
|
||||
def _testNoOfFollowersOnDomain(baseDir: str) -> None:
|
||||
|
@ -2477,7 +2477,7 @@ def _testNoOfFollowersOnDomain(baseDir: str) -> None:
|
|||
federationList = []
|
||||
baseDir = currDir + '/.tests_nooffollowersOndomain'
|
||||
if os.path.isdir(baseDir):
|
||||
shutil.rmtree(baseDir)
|
||||
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||
os.mkdir(baseDir)
|
||||
os.chdir(baseDir)
|
||||
createPerson(baseDir, nickname, domain, port, httpPrefix, True,
|
||||
|
@ -2524,7 +2524,7 @@ def _testNoOfFollowersOnDomain(baseDir: str) -> None:
|
|||
assert followersOnOtherDomain == 2
|
||||
|
||||
os.chdir(currDir)
|
||||
shutil.rmtree(baseDir)
|
||||
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||
|
||||
|
||||
def _testGroupFollowers(baseDir: str) -> None:
|
||||
|
@ -2539,7 +2539,7 @@ def _testGroupFollowers(baseDir: str) -> None:
|
|||
federationList = []
|
||||
baseDir = currDir + '/.tests_testgroupfollowers'
|
||||
if os.path.isdir(baseDir):
|
||||
shutil.rmtree(baseDir)
|
||||
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||
os.mkdir(baseDir)
|
||||
os.chdir(baseDir)
|
||||
createPerson(baseDir, nickname, domain, port, httpPrefix, True,
|
||||
|
@ -2569,7 +2569,7 @@ def _testGroupFollowers(baseDir: str) -> None:
|
|||
assert len(grouped['clutterly.domain']) == 1
|
||||
|
||||
os.chdir(currDir)
|
||||
shutil.rmtree(baseDir)
|
||||
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||
|
||||
|
||||
def _testFollows(baseDir: str) -> None:
|
||||
|
@ -2583,7 +2583,7 @@ def _testFollows(baseDir: str) -> None:
|
|||
federationList = ['wild.com', 'mesh.com']
|
||||
baseDir = currDir + '/.tests_testfollows'
|
||||
if os.path.isdir(baseDir):
|
||||
shutil.rmtree(baseDir)
|
||||
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||
os.mkdir(baseDir)
|
||||
os.chdir(baseDir)
|
||||
createPerson(baseDir, nickname, domain, port, httpPrefix, True,
|
||||
|
@ -2647,7 +2647,7 @@ def _testFollows(baseDir: str) -> None:
|
|||
assert(False)
|
||||
|
||||
os.chdir(currDir)
|
||||
shutil.rmtree(baseDir)
|
||||
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||
|
||||
|
||||
def _testCreatePerson(baseDir: str):
|
||||
|
@ -2662,7 +2662,7 @@ def _testCreatePerson(baseDir: str):
|
|||
clientToServer = False
|
||||
baseDir = currDir + '/.tests_createperson'
|
||||
if os.path.isdir(baseDir):
|
||||
shutil.rmtree(baseDir)
|
||||
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||
os.mkdir(baseDir)
|
||||
os.chdir(baseDir)
|
||||
|
||||
|
@ -2703,7 +2703,7 @@ def _testCreatePerson(baseDir: str):
|
|||
lowBandwidth)
|
||||
|
||||
os.chdir(currDir)
|
||||
shutil.rmtree(baseDir)
|
||||
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||
|
||||
|
||||
def showTestBoxes(name: str, inboxPath: str, outboxPath: str) -> None:
|
||||
|
@ -2726,7 +2726,7 @@ def _testAuthentication(baseDir: str) -> None:
|
|||
|
||||
baseDir = currDir + '/.tests_authentication'
|
||||
if os.path.isdir(baseDir):
|
||||
shutil.rmtree(baseDir)
|
||||
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||
os.mkdir(baseDir)
|
||||
os.chdir(baseDir)
|
||||
|
||||
|
@ -2755,7 +2755,7 @@ def _testAuthentication(baseDir: str) -> None:
|
|||
authHeader, False)
|
||||
|
||||
os.chdir(currDir)
|
||||
shutil.rmtree(baseDir)
|
||||
shutil.rmtree(baseDir, ignore_errors=False, onerror=None)
|
||||
|
||||
|
||||
def testClientToServer(baseDir: str):
|
||||
|
@ -2773,7 +2773,7 @@ def testClientToServer(baseDir: str):
|
|||
lowBandwidth = False
|
||||
|
||||
if os.path.isdir(baseDir + '/.tests'):
|
||||
shutil.rmtree(baseDir + '/.tests')
|
||||
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||
os.mkdir(baseDir + '/.tests')
|
||||
|
||||
# create the servers
|
||||
|
@ -3163,8 +3163,8 @@ def testClientToServer(baseDir: str):
|
|||
assert thrBob.is_alive() is False
|
||||
|
||||
os.chdir(baseDir)
|
||||
# shutil.rmtree(aliceDir)
|
||||
# shutil.rmtree(bobDir)
|
||||
# shutil.rmtree(aliceDir, ignore_errors=False, onerror=None)
|
||||
# shutil.rmtree(bobDir, ignore_errors=False, onerror=None)
|
||||
|
||||
|
||||
def _testActorParsing():
|
||||
|
@ -3356,12 +3356,12 @@ def _testAddEmoji(baseDir: str):
|
|||
os.mkdir(path)
|
||||
path = baseDir + '/.tests/emoji'
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||
os.mkdir(path)
|
||||
baseDir = path
|
||||
path = baseDir + '/emoji'
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
shutil.rmtree(path, ignore_errors=False, onerror=None)
|
||||
os.mkdir(path)
|
||||
copytree(baseDirOriginal + '/emoji', baseDir + '/emoji')
|
||||
os.chdir(baseDir)
|
||||
|
@ -3384,7 +3384,8 @@ def _testAddEmoji(baseDir: str):
|
|||
assert contentModified == '<p>Emoji 🍋 🍓 🍌</p>'
|
||||
|
||||
os.chdir(baseDirOriginal)
|
||||
shutil.rmtree(baseDirOriginal + '/.tests')
|
||||
shutil.rmtree(baseDirOriginal + '/.tests',
|
||||
ignore_errors=False, onerror=None)
|
||||
|
||||
|
||||
def _testGetStatusNumber():
|
||||
|
@ -4987,7 +4988,8 @@ def testUpdateActor(baseDir: str):
|
|||
federationList = []
|
||||
|
||||
if os.path.isdir(baseDir + '/.tests'):
|
||||
shutil.rmtree(baseDir + '/.tests')
|
||||
shutil.rmtree(baseDir + '/.tests',
|
||||
ignore_errors=False, onerror=None)
|
||||
os.mkdir(baseDir + '/.tests')
|
||||
|
||||
# create the server
|
||||
|
@ -5089,7 +5091,7 @@ def testUpdateActor(baseDir: str):
|
|||
|
||||
os.chdir(baseDir)
|
||||
if os.path.isdir(baseDir + '/.tests'):
|
||||
shutil.rmtree(baseDir + '/.tests')
|
||||
shutil.rmtree(baseDir + '/.tests', ignore_errors=False, onerror=None)
|
||||
|
||||
|
||||
def _testRemovePostInteractions() -> None:
|
||||
|
|
73
theme.py
73
theme.py
|
@ -30,7 +30,7 @@ def importTheme(baseDir: str, filename: str) -> bool:
|
|||
return False
|
||||
tempThemeDir = baseDir + '/imports/files'
|
||||
if os.path.isdir(tempThemeDir):
|
||||
rmtree(tempThemeDir)
|
||||
rmtree(tempThemeDir, ignore_errors=False, onerror=None)
|
||||
os.mkdir(tempThemeDir)
|
||||
unpack_archive(filename, tempThemeDir, 'zip')
|
||||
essentialThemeFiles = ('name.txt', 'theme.json')
|
||||
|
@ -71,9 +71,9 @@ def importTheme(baseDir: str, filename: str) -> bool:
|
|||
os.mkdir(themeDir)
|
||||
copytree(tempThemeDir, themeDir)
|
||||
if os.path.isdir(tempThemeDir):
|
||||
rmtree(tempThemeDir)
|
||||
rmtree(tempThemeDir, ignore_errors=False, onerror=None)
|
||||
if scanThemesForScripts(themeDir):
|
||||
rmtree(themeDir)
|
||||
rmtree(themeDir, ignore_errors=False, onerror=None)
|
||||
return False
|
||||
return os.path.isfile(themeDir + '/theme.json')
|
||||
|
||||
|
@ -91,10 +91,13 @@ def exportTheme(baseDir: str, theme: str) -> bool:
|
|||
try:
|
||||
os.remove(exportFilename)
|
||||
except BaseException:
|
||||
print('EX: exportTheme unable to delete ' + str(exportFilename))
|
||||
pass
|
||||
try:
|
||||
make_archive(baseDir + '/exports/' + theme, 'zip', themeDir)
|
||||
except BaseException:
|
||||
print('EX: exportTheme unable to archive ' +
|
||||
baseDir + '/exports/' + str(theme))
|
||||
pass
|
||||
return os.path.isfile(exportFilename)
|
||||
|
||||
|
@ -257,11 +260,14 @@ def _removeTheme(baseDir: str):
|
|||
"""
|
||||
themeFiles = _getThemeFiles()
|
||||
for filename in themeFiles:
|
||||
if os.path.isfile(baseDir + '/' + filename):
|
||||
try:
|
||||
os.remove(baseDir + '/' + filename)
|
||||
except BaseException:
|
||||
pass
|
||||
if not os.path.isfile(baseDir + '/' + filename):
|
||||
continue
|
||||
try:
|
||||
os.remove(baseDir + '/' + filename)
|
||||
except BaseException:
|
||||
print('EX: _removeTheme unable to delete ' +
|
||||
baseDir + '/' + filename)
|
||||
pass
|
||||
|
||||
|
||||
def setCSSparam(css: str, param: str, value: str) -> str:
|
||||
|
@ -446,6 +452,8 @@ def disableGrayscale(baseDir: str) -> None:
|
|||
try:
|
||||
os.remove(grayscaleFilename)
|
||||
except BaseException:
|
||||
print('EX: disableGrayscale unable to delete ' +
|
||||
grayscaleFilename)
|
||||
pass
|
||||
|
||||
|
||||
|
@ -589,12 +597,18 @@ def _setTextModeTheme(baseDir: str, name: str) -> None:
|
|||
copyfile(textModeLogoFilename,
|
||||
baseDir + '/accounts/logo.txt')
|
||||
except BaseException:
|
||||
print('EX: _setTextModeTheme unable to copy ' +
|
||||
textModeLogoFilename + ' ' +
|
||||
baseDir + '/accounts/logo.txt')
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
copyfile(baseDir + '/img/logo.txt',
|
||||
baseDir + '/accounts/logo.txt')
|
||||
except BaseException:
|
||||
print('EX: _setTextModeTheme unable to copy ' +
|
||||
baseDir + '/img/logo.txt ' +
|
||||
baseDir + '/accounts/logo.txt')
|
||||
pass
|
||||
|
||||
# set the text mode banner which appears in browsers such as Lynx
|
||||
|
@ -604,12 +618,17 @@ def _setTextModeTheme(baseDir: str, name: str) -> None:
|
|||
try:
|
||||
os.remove(baseDir + '/accounts/banner.txt')
|
||||
except BaseException:
|
||||
print('EX: _setTextModeTheme unable to delete ' +
|
||||
baseDir + '/accounts/banner.txt')
|
||||
pass
|
||||
if os.path.isfile(textModeBannerFilename):
|
||||
try:
|
||||
copyfile(textModeBannerFilename,
|
||||
baseDir + '/accounts/banner.txt')
|
||||
except BaseException:
|
||||
print('EX: _setTextModeTheme unable to copy ' +
|
||||
textModeBannerFilename + ' ' +
|
||||
baseDir + '/accounts/banner.txt')
|
||||
pass
|
||||
|
||||
|
||||
|
@ -641,8 +660,7 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
|||
for acct in dirs:
|
||||
if not isAccountDir(acct):
|
||||
continue
|
||||
accountDir = \
|
||||
os.path.join(baseDir + '/accounts', acct)
|
||||
accountDir = os.path.join(baseDir + '/accounts', acct)
|
||||
|
||||
for backgroundType in backgroundNames:
|
||||
for ext in extensions:
|
||||
|
@ -662,6 +680,8 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
|||
backgroundType + '-background.' + ext)
|
||||
continue
|
||||
except BaseException:
|
||||
print('EX: _setThemeImages unable to copy ' +
|
||||
backgroundImageFilename)
|
||||
pass
|
||||
# background image was not found
|
||||
# so remove any existing file
|
||||
|
@ -671,6 +691,9 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
|||
os.remove(baseDir + '/accounts/' +
|
||||
backgroundType + '-background.' + ext)
|
||||
except BaseException:
|
||||
print('EX: _setThemeImages unable to delete ' +
|
||||
baseDir + '/accounts/' +
|
||||
backgroundType + '-background.' + ext)
|
||||
pass
|
||||
|
||||
if os.path.isfile(profileImageFilename) and \
|
||||
|
@ -679,12 +702,16 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
|||
copyfile(profileImageFilename,
|
||||
accountDir + '/image.png')
|
||||
except BaseException:
|
||||
print('EX: _setThemeImages unable to copy ' +
|
||||
profileImageFilename)
|
||||
pass
|
||||
|
||||
try:
|
||||
copyfile(bannerFilename,
|
||||
accountDir + '/banner.png')
|
||||
except BaseException:
|
||||
print('EX: _setThemeImages unable to copy ' +
|
||||
bannerFilename)
|
||||
pass
|
||||
|
||||
try:
|
||||
|
@ -692,21 +719,25 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
|||
copyfile(searchBannerFilename,
|
||||
accountDir + '/search_banner.png')
|
||||
except BaseException:
|
||||
print('EX: _setThemeImages unable to copy ' +
|
||||
searchBannerFilename)
|
||||
pass
|
||||
|
||||
try:
|
||||
if os.path.isfile(leftColImageFilename):
|
||||
copyfile(leftColImageFilename,
|
||||
accountDir + '/left_col_image.png')
|
||||
else:
|
||||
if os.path.isfile(accountDir +
|
||||
'/left_col_image.png'):
|
||||
try:
|
||||
os.remove(accountDir + '/left_col_image.png')
|
||||
except BaseException:
|
||||
pass
|
||||
|
||||
elif os.path.isfile(accountDir +
|
||||
'/left_col_image.png'):
|
||||
try:
|
||||
os.remove(accountDir + '/left_col_image.png')
|
||||
except BaseException:
|
||||
print('EX: _setThemeImages unable to delete ' +
|
||||
accountDir + '/left_col_image.png')
|
||||
pass
|
||||
except BaseException:
|
||||
print('EX: _setThemeImages unable to copy ' +
|
||||
leftColImageFilename)
|
||||
pass
|
||||
|
||||
try:
|
||||
|
@ -719,8 +750,12 @@ def _setThemeImages(baseDir: str, name: str) -> None:
|
|||
try:
|
||||
os.remove(accountDir + '/right_col_image.png')
|
||||
except BaseException:
|
||||
print('EX: _setThemeImages unable to delete ' +
|
||||
accountDir + '/right_col_image.png')
|
||||
pass
|
||||
except BaseException:
|
||||
print('EX: _setThemeImages unable to copy ' +
|
||||
rightColImageFilename)
|
||||
pass
|
||||
break
|
||||
|
||||
|
@ -745,6 +780,7 @@ def setNewsAvatar(baseDir: str, name: str,
|
|||
try:
|
||||
os.remove(filename)
|
||||
except BaseException:
|
||||
print('EX: setNewsAvatar unable to delete ' + filename)
|
||||
pass
|
||||
if os.path.isdir(baseDir + '/cache/avatars'):
|
||||
copyfile(newFilename, filename)
|
||||
|
@ -780,6 +816,7 @@ def setTheme(baseDir: str, name: str, domain: str,
|
|||
globals()['setTheme' + themeName](baseDir,
|
||||
allowLocalNetworkAccess)
|
||||
except BaseException:
|
||||
print('EX: setTheme unable to set theme ' + themeName)
|
||||
pass
|
||||
|
||||
if prevThemeName:
|
||||
|
|
|
@ -150,4 +150,6 @@ def removeDormantThreads(baseDir: str, threadsList: [], debug: bool,
|
|||
',' + str(noOfActiveThreads) +
|
||||
',' + str(len(threadsList)) + '\n')
|
||||
except BaseException:
|
||||
print('EX: removeDormantThreads unable to write ' +
|
||||
sendLogFilename)
|
||||
pass
|
||||
|
|
63
utils.py
63
utils.py
|
@ -223,7 +223,7 @@ def validPostDate(published: str, maxAgeDays: int = 90,
|
|||
datetime.datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
|
||||
except BaseException:
|
||||
if debug:
|
||||
print('WARN: Invalid published date ' + str(published))
|
||||
print('EX: validPostDate invalid published date ' + str(published))
|
||||
return False
|
||||
|
||||
daysDiff = postTimeObject - baselineTime
|
||||
|
@ -627,8 +627,8 @@ def removeAvatarFromCache(baseDir: str, actorStr: str) -> None:
|
|||
try:
|
||||
os.remove(avatarFilename)
|
||||
except BaseException:
|
||||
print('WARN: Unable to delete cached avatar ' +
|
||||
str(avatarFilename))
|
||||
print('EX: removeAvatarFromCache ' +
|
||||
'unable to delete cached avatar ' + str(avatarFilename))
|
||||
pass
|
||||
|
||||
|
||||
|
@ -642,7 +642,7 @@ def saveJson(jsonObject: {}, filename: str) -> bool:
|
|||
fp.write(json.dumps(jsonObject))
|
||||
return True
|
||||
except BaseException:
|
||||
print('WARN: saveJson ' + str(tries))
|
||||
print('EX: saveJson ' + str(tries))
|
||||
time.sleep(1)
|
||||
tries += 1
|
||||
return False
|
||||
|
@ -660,7 +660,7 @@ def loadJson(filename: str, delaySec: int = 2, maxTries: int = 5) -> {}:
|
|||
jsonObject = json.loads(data)
|
||||
break
|
||||
except BaseException:
|
||||
print('WARN: loadJson exception ' + str(filename))
|
||||
print('EX: loadJson exception ' + str(filename))
|
||||
if delaySec > 0:
|
||||
time.sleep(delaySec)
|
||||
tries += 1
|
||||
|
@ -685,7 +685,7 @@ def loadJsonOnionify(filename: str, domain: str, onionDomain: str,
|
|||
jsonObject = json.loads(data)
|
||||
break
|
||||
except BaseException:
|
||||
print('WARN: loadJson exception ' + str(filename))
|
||||
print('EX: loadJsonOnionify exception ' + str(filename))
|
||||
if delaySec > 0:
|
||||
time.sleep(delaySec)
|
||||
tries += 1
|
||||
|
@ -1289,7 +1289,7 @@ def clearFromPostCaches(baseDir: str, recentPostsCache: {},
|
|||
try:
|
||||
os.remove(postFilename)
|
||||
except BaseException:
|
||||
print('WARN: clearFromPostCaches file not removed ' +
|
||||
print('EX: clearFromPostCaches file not removed ' +
|
||||
str(postFilename))
|
||||
pass
|
||||
# if the post is in the recent posts cache then remove it
|
||||
|
@ -1388,7 +1388,7 @@ def setReplyIntervalHours(baseDir: str, nickname: str, domain: str,
|
|||
fp.write(str(replyIntervalHours))
|
||||
return True
|
||||
except BaseException:
|
||||
print('WARN: unable to save reply interval ' +
|
||||
print('EX: setReplyIntervalHours unable to save reply interval ' +
|
||||
str(replyIntervalFilename) + ' ' +
|
||||
str(replyIntervalHours))
|
||||
pass
|
||||
|
@ -1418,7 +1418,7 @@ def canReplyTo(baseDir: str, nickname: str, domain: str,
|
|||
try:
|
||||
pubDate = datetime.datetime.strptime(published, '%Y-%m-%dT%H:%M:%SZ')
|
||||
except BaseException:
|
||||
print('WARN: Unrecognized published date ' + str(published))
|
||||
print('EX: canReplyTo unrecognized published date ' + str(published))
|
||||
return False
|
||||
if not currDateStr:
|
||||
currDate = datetime.datetime.utcnow()
|
||||
|
@ -1427,7 +1427,8 @@ def canReplyTo(baseDir: str, nickname: str, domain: str,
|
|||
currDate = datetime.datetime.strptime(currDateStr,
|
||||
'%Y-%m-%dT%H:%M:%SZ')
|
||||
except BaseException:
|
||||
print('WARN: Unrecognized current date ' + str(currDateStr))
|
||||
print('EX: canReplyTo unrecognized current date ' +
|
||||
str(currDateStr))
|
||||
return False
|
||||
hoursSincePublication = int((currDate - pubDate).total_seconds() / 3600)
|
||||
if hoursSincePublication < 0 or \
|
||||
|
@ -1451,14 +1452,16 @@ def _removeAttachment(baseDir: str, httpPrefix: str, domain: str,
|
|||
try:
|
||||
os.remove(mediaFilename)
|
||||
except BaseException:
|
||||
print('WARN: unable to delete media file ' + str(mediaFilename))
|
||||
print('EX: _removeAttachment unable to delete media file ' +
|
||||
str(mediaFilename))
|
||||
pass
|
||||
etagFilename = mediaFilename + '.etag'
|
||||
if os.path.isfile(etagFilename):
|
||||
try:
|
||||
os.remove(etagFilename)
|
||||
except BaseException:
|
||||
print('WARN: unable to delete etag file ' + str(etagFilename))
|
||||
print('EX: _removeAttachment unable to delete etag file ' +
|
||||
str(etagFilename))
|
||||
pass
|
||||
postJson['attachment'] = []
|
||||
|
||||
|
@ -1527,7 +1530,8 @@ def _deletePostRemoveReplies(baseDir: str, nickname: str, domain: str,
|
|||
try:
|
||||
os.remove(repliesFilename)
|
||||
except BaseException:
|
||||
print('WARN: unable to delete replies file ' + str(repliesFilename))
|
||||
print('EX: _deletePostRemoveReplies unable to delete replies file ' +
|
||||
str(repliesFilename))
|
||||
pass
|
||||
|
||||
|
||||
|
@ -1587,7 +1591,8 @@ def _deleteCachedHtml(baseDir: str, nickname: str, domain: str,
|
|||
try:
|
||||
os.remove(cachedPostFilename)
|
||||
except BaseException:
|
||||
print('WARN: unable to delete cached post file ' +
|
||||
print('EX: _deleteCachedHtml ' +
|
||||
'unable to delete cached post file ' +
|
||||
str(cachedPostFilename))
|
||||
pass
|
||||
|
||||
|
@ -1636,7 +1641,7 @@ def _deleteHashtagsOnPost(baseDir: str, postJsonObject: {}) -> None:
|
|||
try:
|
||||
os.remove(tagIndexFilename)
|
||||
except BaseException:
|
||||
print('WARN: Unable to delete tag index ' +
|
||||
print('EX: _deleteHashtagsOnPost unable to delete tag index ' +
|
||||
str(tagIndexFilename))
|
||||
pass
|
||||
else:
|
||||
|
@ -1676,13 +1681,15 @@ def _deleteConversationPost(baseDir: str, nickname: str, domain: str,
|
|||
try:
|
||||
os.remove(conversationFilename + '.muted')
|
||||
except BaseException:
|
||||
print('WARN: Unable to remove conversation ' +
|
||||
print('EX: _deleteConversationPost ' +
|
||||
'unable to remove conversation ' +
|
||||
str(conversationFilename) + '.muted')
|
||||
pass
|
||||
try:
|
||||
os.remove(conversationFilename)
|
||||
except BaseException:
|
||||
print('WARN: Unable to remove conversation ' +
|
||||
print('EX: _deleteConversationPost ' +
|
||||
'unable to remove conversation ' +
|
||||
str(conversationFilename))
|
||||
pass
|
||||
|
||||
|
@ -1703,7 +1710,8 @@ def deletePost(baseDir: str, httpPrefix: str,
|
|||
os.remove(postFilename)
|
||||
except BaseException:
|
||||
if debug:
|
||||
print('WARN: Unable to delete post ' + str(postFilename))
|
||||
print('EX: deletePost unable to delete post ' +
|
||||
str(postFilename))
|
||||
pass
|
||||
return
|
||||
|
||||
|
@ -1732,7 +1740,8 @@ def deletePost(baseDir: str, httpPrefix: str,
|
|||
try:
|
||||
os.remove(extFilename)
|
||||
except BaseException:
|
||||
print('WARN: unable to remove ext ' + str(extFilename))
|
||||
print('EX: deletePost unable to remove ext ' +
|
||||
str(extFilename))
|
||||
pass
|
||||
|
||||
# remove cached html version of the post
|
||||
|
@ -1763,7 +1772,7 @@ def deletePost(baseDir: str, httpPrefix: str,
|
|||
os.remove(postFilename)
|
||||
except BaseException:
|
||||
if debug:
|
||||
print('WARN: Unable to delete post ' + str(postFilename))
|
||||
print('EX: deletePost unable to delete post ' + str(postFilename))
|
||||
pass
|
||||
|
||||
|
||||
|
@ -2204,7 +2213,8 @@ def undoLikesCollectionEntry(recentPostsCache: {},
|
|||
try:
|
||||
os.remove(cachedPostFilename)
|
||||
except BaseException:
|
||||
print('WARN: Unable to delete cached post ' +
|
||||
print('EX: undoLikesCollectionEntry ' +
|
||||
'unable to delete cached post ' +
|
||||
str(cachedPostFilename))
|
||||
pass
|
||||
removePostFromCache(postJsonObject, recentPostsCache)
|
||||
|
@ -2269,7 +2279,8 @@ def undoAnnounceCollectionEntry(recentPostsCache: {},
|
|||
os.remove(cachedPostFilename)
|
||||
except BaseException:
|
||||
if debug:
|
||||
print('WARN: Unable to delete cached post ' +
|
||||
print('EX: undoAnnounceCollectionEntry ' +
|
||||
'unable to delete cached post ' +
|
||||
str(cachedPostFilename))
|
||||
pass
|
||||
removePostFromCache(postJsonObject, recentPostsCache)
|
||||
|
@ -2336,7 +2347,8 @@ def updateAnnounceCollection(recentPostsCache: {},
|
|||
os.remove(cachedPostFilename)
|
||||
except BaseException:
|
||||
if debug:
|
||||
print('WARN: Unable to delete cached post ' +
|
||||
print('EX: updateAnnounceCollection ' +
|
||||
'unable to delete cached post ' +
|
||||
str(cachedPostFilename))
|
||||
pass
|
||||
removePostFromCache(postJsonObject, recentPostsCache)
|
||||
|
@ -2440,7 +2452,8 @@ def isRecentPost(postJsonObject: {}, maxDays: int = 3) -> bool:
|
|||
datetime.datetime.strptime(publishedDateStr,
|
||||
"%Y-%m-%dT%H:%M:%SZ")
|
||||
except BaseException:
|
||||
print('WARN: Unrecognized published date ' + str(publishedDateStr))
|
||||
print('EX: isRecentPost unrecognized published date ' +
|
||||
str(publishedDateStr))
|
||||
return False
|
||||
|
||||
publishedDaysSinceEpoch = \
|
||||
|
@ -2883,7 +2896,7 @@ def dateStringToSeconds(dateStr: str) -> int:
|
|||
expiryTime = \
|
||||
datetime.datetime.strptime(dateStr, '%Y-%m-%dT%H:%M:%SZ')
|
||||
except BaseException:
|
||||
print('WARN: Unable to parse date ' + str(dateStr))
|
||||
print('EX: dateStringToSeconds unable to parse date ' + str(dateStr))
|
||||
return None
|
||||
return int(datetime.datetime.timestamp(expiryTime))
|
||||
|
||||
|
|
|
@ -113,6 +113,7 @@ def _htmlCalendarDay(personCache: {}, cssCache: {}, translate: {},
|
|||
try:
|
||||
os.remove(calendarFile)
|
||||
except BaseException:
|
||||
print('EX: _htmlCalendarDay unable to delete ' + calendarFile)
|
||||
pass
|
||||
|
||||
cssFilename = baseDir + '/epicyon-calendar.css'
|
||||
|
|
|
@ -244,7 +244,7 @@ def _htmlNewswire(baseDir: str, newswire: {}, nickname: str, moderator: bool,
|
|||
publishedDate = \
|
||||
datetime.strptime(dateStr, "%Y-%m-%d %H:%M:%S%z")
|
||||
except BaseException:
|
||||
print('WARN: bad date format ' + dateStr)
|
||||
print('EX: _htmlNewswire bad date format ' + dateStr)
|
||||
continue
|
||||
dateShown = publishedDate.strftime("%Y-%m-%d %H:%M")
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ def setMinimal(baseDir: str, domain: str, nickname: str,
|
|||
try:
|
||||
os.remove(minimalFilename)
|
||||
except BaseException:
|
||||
print('EX: setMinimal unable to delete ' + minimalFilename)
|
||||
pass
|
||||
elif not minimal and not minimalFileExists:
|
||||
with open(minimalFilename, 'w+') as fp:
|
||||
|
|
|
@ -74,6 +74,7 @@ def insertQuestion(baseDir: str, translate: {},
|
|||
try:
|
||||
votes = int(questionOption['replies']['totalItems'])
|
||||
except BaseException:
|
||||
print('EX: insertQuestion unable to convert to int')
|
||||
pass
|
||||
if votes > maxVotes:
|
||||
maxVotes = int(votes+1)
|
||||
|
@ -89,6 +90,7 @@ def insertQuestion(baseDir: str, translate: {},
|
|||
try:
|
||||
votes = int(questionOption['replies']['totalItems'])
|
||||
except BaseException:
|
||||
print('EX: insertQuestion unable to convert to int 2')
|
||||
pass
|
||||
votesPercent = str(int(votes * 100 / maxVotes))
|
||||
content += \
|
||||
|
|
|
@ -428,7 +428,8 @@ def htmlSearch(cssCache: {}, translate: {},
|
|||
with open(cachedHashtagSwarmFilename, 'r') as fp:
|
||||
swarmStr = fp.read()
|
||||
except BaseException:
|
||||
print('WARN: Unable to read cached hashtag swarm')
|
||||
print('EX: htmlSearch unable to read cached hashtag swarm ' +
|
||||
cachedHashtagSwarmFilename)
|
||||
pass
|
||||
if not swarmStr:
|
||||
swarmStr = htmlHashTagSwarm(baseDir, actor, translate)
|
||||
|
@ -437,7 +438,8 @@ def htmlSearch(cssCache: {}, translate: {},
|
|||
with open(cachedHashtagSwarmFilename, 'w+') as fp:
|
||||
fp.write(swarmStr)
|
||||
except BaseException:
|
||||
print('WARN: Unable to save cached hashtag swarm')
|
||||
print('EX: htmlSearch unable to save cached hashtag swarm ' +
|
||||
cachedHashtagSwarmFilename)
|
||||
pass
|
||||
|
||||
followStr += ' <p class="hashtagswarm">' + swarmStr + '</p>\n'
|
||||
|
|
|
@ -477,6 +477,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
|||
try:
|
||||
os.remove(dmFile)
|
||||
except BaseException:
|
||||
print('EX: htmlTimeline unable to delete ' + dmFile)
|
||||
pass
|
||||
|
||||
# should the Replies button be highlighted?
|
||||
|
@ -488,6 +489,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
|||
try:
|
||||
os.remove(replyFile)
|
||||
except BaseException:
|
||||
print('EX: htmlTimeline unable to delete ' + replyFile)
|
||||
pass
|
||||
|
||||
# should the Shares button be highlighted?
|
||||
|
@ -499,6 +501,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
|||
try:
|
||||
os.remove(newShareFile)
|
||||
except BaseException:
|
||||
print('EX: htmlTimeline unable to delete ' + newShareFile)
|
||||
pass
|
||||
|
||||
# should the Wanted button be highlighted?
|
||||
|
@ -510,6 +513,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
|||
try:
|
||||
os.remove(newWantedFile)
|
||||
except BaseException:
|
||||
print('EX: htmlTimeline unable to delete ' + newWantedFile)
|
||||
pass
|
||||
|
||||
# should the Moderation/reports button be highlighted?
|
||||
|
@ -521,6 +525,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
|||
try:
|
||||
os.remove(newReportFile)
|
||||
except BaseException:
|
||||
print('EX: htmlTimeline unable to delete ' + newReportFile)
|
||||
pass
|
||||
|
||||
separatorStr = ''
|
||||
|
|
|
@ -283,6 +283,8 @@ def updateAvatarImageCache(signingPrivateKeyPem: str,
|
|||
try:
|
||||
os.remove(avatarImageFilename)
|
||||
except BaseException:
|
||||
print('EX: updateAvatarImageCache unable to delete ' +
|
||||
avatarImageFilename)
|
||||
pass
|
||||
else:
|
||||
with open(avatarImageFilename, 'wb') as f:
|
||||
|
|
Loading…
Reference in New Issue