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