mirror of https://gitlab.com/bashrc2/epicyon
Use with style when writing files
parent
df7d650b5b
commit
25d0cd8c65
21
blocking.py
21
blocking.py
|
@ -39,10 +39,8 @@ def addGlobalBlock(baseDir: str,
|
||||||
if blockHandle in open(blockingFilename).read():
|
if blockHandle in open(blockingFilename).read():
|
||||||
return False
|
return False
|
||||||
# block an account handle or domain
|
# block an account handle or domain
|
||||||
blockFile = open(blockingFilename, "a+")
|
with open(blockingFilename, 'a+') as blockFile:
|
||||||
if blockFile:
|
|
||||||
blockFile.write(blockHandle + '\n')
|
blockFile.write(blockHandle + '\n')
|
||||||
blockFile.close()
|
|
||||||
else:
|
else:
|
||||||
blockHashtag = blockNickname
|
blockHashtag = blockNickname
|
||||||
# is the hashtag already blocked?
|
# is the hashtag already blocked?
|
||||||
|
@ -50,10 +48,8 @@ def addGlobalBlock(baseDir: str,
|
||||||
if blockHashtag + '\n' in open(blockingFilename).read():
|
if blockHashtag + '\n' in open(blockingFilename).read():
|
||||||
return False
|
return False
|
||||||
# block a hashtag
|
# block a hashtag
|
||||||
blockFile = open(blockingFilename, "a+")
|
with open(blockingFilename, 'a+') as blockFile:
|
||||||
if blockFile:
|
|
||||||
blockFile.write(blockHashtag + '\n')
|
blockFile.write(blockHashtag + '\n')
|
||||||
blockFile.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,9 +65,8 @@ def addBlock(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(blockingFilename):
|
if os.path.isfile(blockingFilename):
|
||||||
if blockHandle in open(blockingFilename).read():
|
if blockHandle in open(blockingFilename).read():
|
||||||
return False
|
return False
|
||||||
blockFile = open(blockingFilename, "a+")
|
with open(blockingFilename, 'a+') as blockFile:
|
||||||
blockFile.write(blockHandle + '\n')
|
blockFile.write(blockHandle + '\n')
|
||||||
blockFile.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -493,10 +488,8 @@ def mutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
|
||||||
muteFile = open(postFilename + '.muted', 'w+')
|
with open(postFilename + '.muted', 'w+') as muteFile:
|
||||||
if muteFile:
|
|
||||||
muteFile.write('\n')
|
muteFile.write('\n')
|
||||||
muteFile.close()
|
|
||||||
print('MUTE: ' + postFilename + '.muted file added')
|
print('MUTE: ' + postFilename + '.muted file added')
|
||||||
|
|
||||||
# if the post is in the recent posts cache then mark it as muted
|
# if the post is in the recent posts cache then mark it as muted
|
||||||
|
@ -751,12 +744,10 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None:
|
||||||
break
|
break
|
||||||
|
|
||||||
# write the allow file
|
# write the allow file
|
||||||
allowFile = open(allowFilename, "w+")
|
with open(allowFilename, 'w+') as allowFile:
|
||||||
if allowFile:
|
|
||||||
allowFile.write(domainFull + '\n')
|
allowFile.write(domainFull + '\n')
|
||||||
for d in allowedDomains:
|
for d in allowedDomains:
|
||||||
allowFile.write(d + '\n')
|
allowFile.write(d + '\n')
|
||||||
allowFile.close()
|
|
||||||
print('Broch mode enabled')
|
print('Broch mode enabled')
|
||||||
|
|
||||||
setConfigParam(baseDir, "brochMode", enabled)
|
setConfigParam(baseDir, "brochMode", enabled)
|
||||||
|
|
|
@ -61,10 +61,8 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
|
||||||
indexStr = ''
|
indexStr = ''
|
||||||
with open(bookmarksIndexFilename, 'r') as indexFile:
|
with open(bookmarksIndexFilename, 'r') as indexFile:
|
||||||
indexStr = indexFile.read().replace(bookmarkIndex + '\n', '')
|
indexStr = indexFile.read().replace(bookmarkIndex + '\n', '')
|
||||||
bookmarksIndexFile = open(bookmarksIndexFilename, 'w+')
|
with open(bookmarksIndexFilename, 'w+') as bookmarksIndexFile:
|
||||||
if bookmarksIndexFile:
|
|
||||||
bookmarksIndexFile.write(indexStr)
|
bookmarksIndexFile.write(indexStr)
|
||||||
bookmarksIndexFile.close()
|
|
||||||
|
|
||||||
if not postJsonObject.get('type'):
|
if not postJsonObject.get('type'):
|
||||||
return
|
return
|
||||||
|
@ -219,10 +217,8 @@ def updateBookmarksCollection(recentPostsCache: {},
|
||||||
print('WARN: Failed to write entry to bookmarks index ' +
|
print('WARN: Failed to write entry to bookmarks index ' +
|
||||||
bookmarksIndexFilename + ' ' + str(e))
|
bookmarksIndexFilename + ' ' + str(e))
|
||||||
else:
|
else:
|
||||||
bookmarksIndexFile = open(bookmarksIndexFilename, 'w+')
|
with open(bookmarksIndexFilename, 'w+') as bookmarksIndexFile:
|
||||||
if bookmarksIndexFile:
|
|
||||||
bookmarksIndexFile.write(bookmarkIndex + '\n')
|
bookmarksIndexFile.write(bookmarkIndex + '\n')
|
||||||
bookmarksIndexFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def bookmark(recentPostsCache: {},
|
def bookmark(recentPostsCache: {},
|
||||||
|
|
207
daemon.py
207
daemon.py
|
@ -431,10 +431,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.maxReplies,
|
self.server.maxReplies,
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
# record the vote
|
# record the vote
|
||||||
votesFile = open(votesFilename, 'a+')
|
with open(votesFilename, 'a+') as votesFile:
|
||||||
if votesFile:
|
|
||||||
votesFile.write(messageId + '\n')
|
votesFile.write(messageId + '\n')
|
||||||
votesFile.close()
|
|
||||||
|
|
||||||
# ensure that the cached post is removed if it exists,
|
# ensure that the cached post is removed if it exists,
|
||||||
# so that it then will be recreated
|
# so that it then will be recreated
|
||||||
|
@ -2104,10 +2102,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(accountDir):
|
if os.path.isdir(accountDir):
|
||||||
noNewswireFile = open(newswireBlockedFilename, "w+")
|
nwFilename = newswireBlockedFilename
|
||||||
if noNewswireFile:
|
with open(nwFilename, 'w+') as noNewswireFile:
|
||||||
noNewswireFile.write('\n')
|
noNewswireFile.write('\n')
|
||||||
noNewswireFile.close()
|
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
usersPathStr = \
|
usersPathStr = \
|
||||||
usersPath + '/' + self.server.defaultTimeline + \
|
usersPath + '/' + self.server.defaultTimeline + \
|
||||||
|
@ -2140,10 +2137,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(accountDir):
|
if os.path.isdir(accountDir):
|
||||||
noFeaturesFile = open(featuresBlockedFilename, "w+")
|
featFilename = featuresBlockedFilename
|
||||||
if noFeaturesFile:
|
with open(featFilename, 'w+') as noFeaturesFile:
|
||||||
noFeaturesFile.write('\n')
|
noFeaturesFile.write('\n')
|
||||||
noFeaturesFile.close()
|
|
||||||
refreshNewswire(self.server.baseDir)
|
refreshNewswire(self.server.baseDir)
|
||||||
usersPathStr = \
|
usersPathStr = \
|
||||||
usersPath + '/' + self.server.defaultTimeline + \
|
usersPath + '/' + self.server.defaultTimeline + \
|
||||||
|
@ -2175,10 +2171,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
os.remove(newswireModFilename)
|
os.remove(newswireModFilename)
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(accountDir):
|
if os.path.isdir(accountDir):
|
||||||
modNewswireFile = open(newswireModFilename, "w+")
|
nwFilename = newswireModFilename
|
||||||
if modNewswireFile:
|
with open(nwFilename, 'w+') as modNewswireFile:
|
||||||
modNewswireFile.write('\n')
|
modNewswireFile.write('\n')
|
||||||
modNewswireFile.close()
|
|
||||||
usersPathStr = \
|
usersPathStr = \
|
||||||
usersPath + '/' + self.server.defaultTimeline + \
|
usersPath + '/' + self.server.defaultTimeline + \
|
||||||
'?page=' + str(pageNumber)
|
'?page=' + str(pageNumber)
|
||||||
|
@ -3459,10 +3454,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
if fields.get('editedLinks'):
|
if fields.get('editedLinks'):
|
||||||
linksStr = fields['editedLinks']
|
linksStr = fields['editedLinks']
|
||||||
linksFile = open(linksFilename, "w+")
|
with open(linksFilename, 'w+') as linksFile:
|
||||||
if linksFile:
|
|
||||||
linksFile.write(linksStr)
|
linksFile.write(linksStr)
|
||||||
linksFile.close()
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(linksFilename):
|
if os.path.isfile(linksFilename):
|
||||||
os.remove(linksFilename)
|
os.remove(linksFilename)
|
||||||
|
@ -3474,10 +3467,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
aboutStr = fields['editedAbout']
|
aboutStr = fields['editedAbout']
|
||||||
if not dangerousMarkup(aboutStr,
|
if not dangerousMarkup(aboutStr,
|
||||||
allowLocalNetworkAccess):
|
allowLocalNetworkAccess):
|
||||||
aboutFile = open(aboutFilename, "w+")
|
with open(aboutFilename, 'w+') as aboutFile:
|
||||||
if aboutFile:
|
|
||||||
aboutFile.write(aboutStr)
|
aboutFile.write(aboutStr)
|
||||||
aboutFile.close()
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(aboutFilename):
|
if os.path.isfile(aboutFilename):
|
||||||
os.remove(aboutFilename)
|
os.remove(aboutFilename)
|
||||||
|
@ -3486,10 +3477,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
TOSStr = fields['editedTOS']
|
TOSStr = fields['editedTOS']
|
||||||
if not dangerousMarkup(TOSStr,
|
if not dangerousMarkup(TOSStr,
|
||||||
allowLocalNetworkAccess):
|
allowLocalNetworkAccess):
|
||||||
TOSFile = open(TOSFilename, "w+")
|
with open(TOSFilename, 'w+') as TOSFile:
|
||||||
if TOSFile:
|
|
||||||
TOSFile.write(TOSStr)
|
TOSFile.write(TOSStr)
|
||||||
TOSFile.close()
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(TOSFilename):
|
if os.path.isfile(TOSFilename):
|
||||||
os.remove(TOSFilename)
|
os.remove(TOSFilename)
|
||||||
|
@ -3664,10 +3653,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
extractTextFieldsInPOST(postBytes, boundary, debug)
|
extractTextFieldsInPOST(postBytes, boundary, debug)
|
||||||
if fields.get('editedNewswire'):
|
if fields.get('editedNewswire'):
|
||||||
newswireStr = fields['editedNewswire']
|
newswireStr = fields['editedNewswire']
|
||||||
newswireFile = open(newswireFilename, "w+")
|
with open(newswireFilename, 'w+') as newswireFile:
|
||||||
if newswireFile:
|
|
||||||
newswireFile.write(newswireStr)
|
newswireFile.write(newswireStr)
|
||||||
newswireFile.close()
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(newswireFilename):
|
if os.path.isfile(newswireFilename):
|
||||||
os.remove(newswireFilename)
|
os.remove(newswireFilename)
|
||||||
|
@ -3698,10 +3685,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
newswireTrusted = fields['trustedNewswire']
|
newswireTrusted = fields['trustedNewswire']
|
||||||
if not newswireTrusted.endswith('\n'):
|
if not newswireTrusted.endswith('\n'):
|
||||||
newswireTrusted += '\n'
|
newswireTrusted += '\n'
|
||||||
trustFile = open(newswireTrustedFilename, "w+")
|
with open(newswireTrustedFilename, 'w+') as trustFile:
|
||||||
if trustFile:
|
|
||||||
trustFile.write(newswireTrusted)
|
trustFile.write(newswireTrusted)
|
||||||
trustFile.close()
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(newswireTrustedFilename):
|
if os.path.isfile(newswireTrustedFilename):
|
||||||
os.remove(newswireTrustedFilename)
|
os.remove(newswireTrustedFilename)
|
||||||
|
@ -3787,10 +3772,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
citationsStr += citationDate + '\n'
|
citationsStr += citationDate + '\n'
|
||||||
# save citations dates, so that they can be added when
|
# save citations dates, so that they can be added when
|
||||||
# reloading the newblog screen
|
# reloading the newblog screen
|
||||||
citationsFile = open(citationsFilename, "w+")
|
with open(citationsFilename, 'w+') as citationsFile:
|
||||||
if citationsFile:
|
|
||||||
citationsFile.write(citationsStr)
|
citationsFile.write(citationsStr)
|
||||||
citationsFile.close()
|
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
self._redirect_headers(actorStr + '/newblog',
|
self._redirect_headers(actorStr + '/newblog',
|
||||||
|
@ -4710,17 +4693,16 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
clearModeratorStatus(baseDir)
|
clearModeratorStatus(baseDir)
|
||||||
if ',' in fields['moderators']:
|
if ',' in fields['moderators']:
|
||||||
# if the list was given as comma separated
|
# if the list was given as comma separated
|
||||||
modFile = open(moderatorsFile, "w+")
|
|
||||||
mods = fields['moderators'].split(',')
|
|
||||||
for modNick in mods:
|
|
||||||
modNick = modNick.strip()
|
|
||||||
modDir = baseDir + \
|
|
||||||
'/accounts/' + modNick + \
|
|
||||||
'@' + domain
|
|
||||||
if os.path.isdir(modDir):
|
|
||||||
modFile.write(modNick + '\n')
|
|
||||||
modFile.close()
|
|
||||||
mods = fields['moderators'].split(',')
|
mods = fields['moderators'].split(',')
|
||||||
|
with open(moderatorsFile, 'w+') as modFile:
|
||||||
|
for modNick in mods:
|
||||||
|
modNick = modNick.strip()
|
||||||
|
modDir = baseDir + \
|
||||||
|
'/accounts/' + modNick + \
|
||||||
|
'@' + domain
|
||||||
|
if os.path.isdir(modDir):
|
||||||
|
modFile.write(modNick + '\n')
|
||||||
|
|
||||||
for modNick in mods:
|
for modNick in mods:
|
||||||
modNick = modNick.strip()
|
modNick = modNick.strip()
|
||||||
modDir = baseDir + \
|
modDir = baseDir + \
|
||||||
|
@ -4732,18 +4714,17 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'moderator')
|
'moderator')
|
||||||
else:
|
else:
|
||||||
# nicknames on separate lines
|
# nicknames on separate lines
|
||||||
modFile = open(moderatorsFile, "w+")
|
|
||||||
mods = fields['moderators'].split('\n')
|
|
||||||
for modNick in mods:
|
|
||||||
modNick = modNick.strip()
|
|
||||||
modDir = \
|
|
||||||
baseDir + \
|
|
||||||
'/accounts/' + modNick + \
|
|
||||||
'@' + domain
|
|
||||||
if os.path.isdir(modDir):
|
|
||||||
modFile.write(modNick + '\n')
|
|
||||||
modFile.close()
|
|
||||||
mods = fields['moderators'].split('\n')
|
mods = fields['moderators'].split('\n')
|
||||||
|
with open(moderatorsFile, 'w+') as modFile:
|
||||||
|
for modNick in mods:
|
||||||
|
modNick = modNick.strip()
|
||||||
|
modDir = \
|
||||||
|
baseDir + \
|
||||||
|
'/accounts/' + modNick + \
|
||||||
|
'@' + domain
|
||||||
|
if os.path.isdir(modDir):
|
||||||
|
modFile.write(modNick + '\n')
|
||||||
|
|
||||||
for modNick in mods:
|
for modNick in mods:
|
||||||
modNick = modNick.strip()
|
modNick = modNick.strip()
|
||||||
modDir = \
|
modDir = \
|
||||||
|
@ -4766,17 +4747,16 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
clearEditorStatus(baseDir)
|
clearEditorStatus(baseDir)
|
||||||
if ',' in fields['editors']:
|
if ',' in fields['editors']:
|
||||||
# if the list was given as comma separated
|
# if the list was given as comma separated
|
||||||
edFile = open(editorsFile, "w+")
|
|
||||||
eds = fields['editors'].split(',')
|
|
||||||
for edNick in eds:
|
|
||||||
edNick = edNick.strip()
|
|
||||||
edDir = baseDir + \
|
|
||||||
'/accounts/' + edNick + \
|
|
||||||
'@' + domain
|
|
||||||
if os.path.isdir(edDir):
|
|
||||||
edFile.write(edNick + '\n')
|
|
||||||
edFile.close()
|
|
||||||
eds = fields['editors'].split(',')
|
eds = fields['editors'].split(',')
|
||||||
|
with open(editorsFile, 'w+') as edFile:
|
||||||
|
for edNick in eds:
|
||||||
|
edNick = edNick.strip()
|
||||||
|
edDir = baseDir + \
|
||||||
|
'/accounts/' + edNick + \
|
||||||
|
'@' + domain
|
||||||
|
if os.path.isdir(edDir):
|
||||||
|
edFile.write(edNick + '\n')
|
||||||
|
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = baseDir + \
|
edDir = baseDir + \
|
||||||
|
@ -4788,18 +4768,17 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'editor')
|
'editor')
|
||||||
else:
|
else:
|
||||||
# nicknames on separate lines
|
# nicknames on separate lines
|
||||||
edFile = open(editorsFile, "w+")
|
|
||||||
eds = fields['editors'].split('\n')
|
|
||||||
for edNick in eds:
|
|
||||||
edNick = edNick.strip()
|
|
||||||
edDir = \
|
|
||||||
baseDir + \
|
|
||||||
'/accounts/' + edNick + \
|
|
||||||
'@' + domain
|
|
||||||
if os.path.isdir(edDir):
|
|
||||||
edFile.write(edNick + '\n')
|
|
||||||
edFile.close()
|
|
||||||
eds = fields['editors'].split('\n')
|
eds = fields['editors'].split('\n')
|
||||||
|
with open(editorsFile, 'w+') as edFile:
|
||||||
|
for edNick in eds:
|
||||||
|
edNick = edNick.strip()
|
||||||
|
edDir = \
|
||||||
|
baseDir + \
|
||||||
|
'/accounts/' + edNick + \
|
||||||
|
'@' + domain
|
||||||
|
if os.path.isdir(edDir):
|
||||||
|
edFile.write(edNick + '\n')
|
||||||
|
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = \
|
edDir = \
|
||||||
|
@ -4822,17 +4801,16 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
clearCounselorStatus(baseDir)
|
clearCounselorStatus(baseDir)
|
||||||
if ',' in fields['counselors']:
|
if ',' in fields['counselors']:
|
||||||
# if the list was given as comma separated
|
# if the list was given as comma separated
|
||||||
edFile = open(counselorsFile, "w+")
|
|
||||||
eds = fields['counselors'].split(',')
|
|
||||||
for edNick in eds:
|
|
||||||
edNick = edNick.strip()
|
|
||||||
edDir = baseDir + \
|
|
||||||
'/accounts/' + edNick + \
|
|
||||||
'@' + domain
|
|
||||||
if os.path.isdir(edDir):
|
|
||||||
edFile.write(edNick + '\n')
|
|
||||||
edFile.close()
|
|
||||||
eds = fields['counselors'].split(',')
|
eds = fields['counselors'].split(',')
|
||||||
|
with open(counselorsFile, 'w+') as edFile:
|
||||||
|
for edNick in eds:
|
||||||
|
edNick = edNick.strip()
|
||||||
|
edDir = baseDir + \
|
||||||
|
'/accounts/' + edNick + \
|
||||||
|
'@' + domain
|
||||||
|
if os.path.isdir(edDir):
|
||||||
|
edFile.write(edNick + '\n')
|
||||||
|
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = baseDir + \
|
edDir = baseDir + \
|
||||||
|
@ -4844,18 +4822,17 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'counselor')
|
'counselor')
|
||||||
else:
|
else:
|
||||||
# nicknames on separate lines
|
# nicknames on separate lines
|
||||||
edFile = open(counselorsFile, "w+")
|
|
||||||
eds = fields['counselors'].split('\n')
|
|
||||||
for edNick in eds:
|
|
||||||
edNick = edNick.strip()
|
|
||||||
edDir = \
|
|
||||||
baseDir + \
|
|
||||||
'/accounts/' + edNick + \
|
|
||||||
'@' + domain
|
|
||||||
if os.path.isdir(edDir):
|
|
||||||
edFile.write(edNick + '\n')
|
|
||||||
edFile.close()
|
|
||||||
eds = fields['counselors'].split('\n')
|
eds = fields['counselors'].split('\n')
|
||||||
|
with open(counselorsFile, 'w+') as edFile:
|
||||||
|
for edNick in eds:
|
||||||
|
edNick = edNick.strip()
|
||||||
|
edDir = \
|
||||||
|
baseDir + \
|
||||||
|
'/accounts/' + edNick + \
|
||||||
|
'@' + domain
|
||||||
|
if os.path.isdir(edDir):
|
||||||
|
edFile.write(edNick + '\n')
|
||||||
|
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = \
|
edDir = \
|
||||||
|
@ -4878,17 +4855,16 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
clearArtistStatus(baseDir)
|
clearArtistStatus(baseDir)
|
||||||
if ',' in fields['artists']:
|
if ',' in fields['artists']:
|
||||||
# if the list was given as comma separated
|
# if the list was given as comma separated
|
||||||
edFile = open(artistsFile, "w+")
|
|
||||||
eds = fields['artists'].split(',')
|
|
||||||
for edNick in eds:
|
|
||||||
edNick = edNick.strip()
|
|
||||||
edDir = baseDir + \
|
|
||||||
'/accounts/' + edNick + \
|
|
||||||
'@' + domain
|
|
||||||
if os.path.isdir(edDir):
|
|
||||||
edFile.write(edNick + '\n')
|
|
||||||
edFile.close()
|
|
||||||
eds = fields['artists'].split(',')
|
eds = fields['artists'].split(',')
|
||||||
|
with open(artistsFile, 'w+') as edFile:
|
||||||
|
for edNick in eds:
|
||||||
|
edNick = edNick.strip()
|
||||||
|
edDir = baseDir + \
|
||||||
|
'/accounts/' + edNick + \
|
||||||
|
'@' + domain
|
||||||
|
if os.path.isdir(edDir):
|
||||||
|
edFile.write(edNick + '\n')
|
||||||
|
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = baseDir + \
|
edDir = baseDir + \
|
||||||
|
@ -4900,18 +4876,17 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'artist')
|
'artist')
|
||||||
else:
|
else:
|
||||||
# nicknames on separate lines
|
# nicknames on separate lines
|
||||||
edFile = open(artistsFile, "w+")
|
|
||||||
eds = fields['artists'].split('\n')
|
|
||||||
for edNick in eds:
|
|
||||||
edNick = edNick.strip()
|
|
||||||
edDir = \
|
|
||||||
baseDir + \
|
|
||||||
'/accounts/' + edNick + \
|
|
||||||
'@' + domain
|
|
||||||
if os.path.isdir(edDir):
|
|
||||||
edFile.write(edNick + '\n')
|
|
||||||
edFile.close()
|
|
||||||
eds = fields['artists'].split('\n')
|
eds = fields['artists'].split('\n')
|
||||||
|
with open(artistsFile, 'w+') as edFile:
|
||||||
|
for edNick in eds:
|
||||||
|
edNick = edNick.strip()
|
||||||
|
edDir = \
|
||||||
|
baseDir + \
|
||||||
|
'/accounts/' + edNick + \
|
||||||
|
'@' + domain
|
||||||
|
if os.path.isdir(edDir):
|
||||||
|
edFile.write(edNick + '\n')
|
||||||
|
|
||||||
for edNick in eds:
|
for edNick in eds:
|
||||||
edNick = edNick.strip()
|
edNick = edNick.strip()
|
||||||
edDir = \
|
edDir = \
|
||||||
|
@ -13327,10 +13302,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.baseDir + '/accounts/' + \
|
self.server.baseDir + '/accounts/' + \
|
||||||
nickname + '@' + self.server.domain + '/.lastUsed'
|
nickname + '@' + self.server.domain + '/.lastUsed'
|
||||||
try:
|
try:
|
||||||
lastUsedFile = open(lastUsedFilename, 'w+')
|
with open(lastUsedFilename, 'w+') as lastUsedFile:
|
||||||
if lastUsedFile:
|
|
||||||
lastUsedFile.write(str(int(time.time())))
|
lastUsedFile.write(str(int(time.time())))
|
||||||
lastUsedFile.close()
|
|
||||||
except BaseException:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -175,10 +175,8 @@ def _markPostAsRead(actor: str, postId: str, postCategory: str) -> None:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('WARN: Failed to mark post as read' + str(e))
|
print('WARN: Failed to mark post as read' + str(e))
|
||||||
else:
|
else:
|
||||||
readFile = open(readPostsFilename, 'w+')
|
with open(readPostsFilename, 'w+') as readFile:
|
||||||
if readFile:
|
|
||||||
readFile.write(postId + '\n')
|
readFile.write(postId + '\n')
|
||||||
readFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def _hasReadPost(actor: str, postId: str, postCategory: str) -> bool:
|
def _hasReadPost(actor: str, postId: str, postCategory: str) -> bool:
|
||||||
|
|
10
filters.py
10
filters.py
|
@ -17,9 +17,8 @@ def addFilter(baseDir: str, nickname: str, domain: str, words: str) -> bool:
|
||||||
if os.path.isfile(filtersFilename):
|
if os.path.isfile(filtersFilename):
|
||||||
if words in open(filtersFilename).read():
|
if words in open(filtersFilename).read():
|
||||||
return False
|
return False
|
||||||
filtersFile = open(filtersFilename, "a+")
|
with open(filtersFilename, 'a+') as filtersFile:
|
||||||
filtersFile.write(words + '\n')
|
filtersFile.write(words + '\n')
|
||||||
filtersFile.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,9 +34,8 @@ def addGlobalFilter(baseDir: str, words: str) -> bool:
|
||||||
if os.path.isfile(filtersFilename):
|
if os.path.isfile(filtersFilename):
|
||||||
if words in open(filtersFilename).read():
|
if words in open(filtersFilename).read():
|
||||||
return False
|
return False
|
||||||
filtersFile = open(filtersFilename, "a+")
|
with open(filtersFilename, 'a+') as filtersFile:
|
||||||
filtersFile.write(words + '\n')
|
filtersFile.write(words + '\n')
|
||||||
filtersFile.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
27
follow.py
27
follow.py
|
@ -115,17 +115,17 @@ def _removeFromFollowBase(baseDir: str,
|
||||||
break
|
break
|
||||||
if not actorFound:
|
if not actorFound:
|
||||||
return
|
return
|
||||||
approvefilenew = open(approveFollowsFilename + '.new', 'w+')
|
with open(approveFollowsFilename + '.new', 'w+') as approvefilenew:
|
||||||
with open(approveFollowsFilename, 'r') as approvefile:
|
with open(approveFollowsFilename, 'r') as approvefile:
|
||||||
if not acceptDenyActor:
|
if not acceptDenyActor:
|
||||||
for approveHandle in approvefile:
|
for approveHandle in approvefile:
|
||||||
if not approveHandle.startswith(acceptOrDenyHandle):
|
if not approveHandle.startswith(acceptOrDenyHandle):
|
||||||
approvefilenew.write(approveHandle)
|
approvefilenew.write(approveHandle)
|
||||||
else:
|
else:
|
||||||
for approveHandle in approvefile:
|
for approveHandle in approvefile:
|
||||||
if acceptDenyActor not in approveHandle:
|
if acceptDenyActor not in approveHandle:
|
||||||
approvefilenew.write(approveHandle)
|
approvefilenew.write(approveHandle)
|
||||||
approvefilenew.close()
|
|
||||||
os.rename(approveFollowsFilename + '.new', approveFollowsFilename)
|
os.rename(approveFollowsFilename + '.new', approveFollowsFilename)
|
||||||
|
|
||||||
|
|
||||||
|
@ -765,9 +765,8 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
|
||||||
'Failed to write entry to followers file ' +
|
'Failed to write entry to followers file ' +
|
||||||
str(e))
|
str(e))
|
||||||
else:
|
else:
|
||||||
followersFile = open(followersFilename, "w+")
|
with open(followersFilename, 'w+') as followersFile:
|
||||||
followersFile.write(approveHandle + '\n')
|
followersFile.write(approveHandle + '\n')
|
||||||
followersFile.close()
|
|
||||||
|
|
||||||
print('Beginning follow accept')
|
print('Beginning follow accept')
|
||||||
return followedAccountAccepts(session, baseDir, httpPrefix,
|
return followedAccountAccepts(session, baseDir, httpPrefix,
|
||||||
|
|
51
happening.py
51
happening.py
|
@ -105,9 +105,8 @@ def saveEventPost(baseDir: str, handle: str, postId: str,
|
||||||
tlEventsFilename + ' ' + str(e))
|
tlEventsFilename + ' ' + str(e))
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
tlEventsFile = open(tlEventsFilename, 'w+')
|
with open(tlEventsFilename, 'w+') as tlEventsFile:
|
||||||
tlEventsFile.write(eventId + '\n')
|
tlEventsFile.write(eventId + '\n')
|
||||||
tlEventsFile.close()
|
|
||||||
|
|
||||||
# create a directory for the calendar year
|
# create a directory for the calendar year
|
||||||
if not os.path.isdir(calendarPath + '/' + str(eventYear)):
|
if not os.path.isdir(calendarPath + '/' + str(eventYear)):
|
||||||
|
@ -124,27 +123,20 @@ def saveEventPost(baseDir: str, handle: str, postId: str,
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# append the post Id to the file for the calendar month
|
# append the post Id to the file for the calendar month
|
||||||
calendarFile = open(calendarFilename, 'a+')
|
with open(calendarFilename, 'a+') as calendarFile:
|
||||||
if not calendarFile:
|
calendarFile.write(postId + '\n')
|
||||||
return False
|
|
||||||
calendarFile.write(postId + '\n')
|
|
||||||
calendarFile.close()
|
|
||||||
|
|
||||||
# create a file which will trigger a notification that
|
# create a file which will trigger a notification that
|
||||||
# a new event has been added
|
# a new event has been added
|
||||||
calendarNotificationFilename = \
|
calendarNotificationFilename = \
|
||||||
baseDir + '/accounts/' + handle + '/.newCalendar'
|
baseDir + '/accounts/' + handle + '/.newCalendar'
|
||||||
calendarNotificationFile = \
|
with open(calendarNotificationFilename, 'w+') as calendarNotificationFile:
|
||||||
open(calendarNotificationFilename, 'w+')
|
calendarNotificationFile.write('/calendar?year=' +
|
||||||
if not calendarNotificationFile:
|
str(eventYear) +
|
||||||
return False
|
'?month=' +
|
||||||
calendarNotificationFile.write('/calendar?year=' +
|
str(eventMonthNumber) +
|
||||||
str(eventYear) +
|
'?day=' +
|
||||||
'?month=' +
|
str(eventDayOfMonth))
|
||||||
str(eventMonthNumber) +
|
|
||||||
'?day=' +
|
|
||||||
str(eventDayOfMonth))
|
|
||||||
calendarNotificationFile.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -251,10 +243,9 @@ def getTodaysEvents(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
calendarFile = open(calendarFilename, 'w+')
|
with open(calendarFilename, 'w+') as calendarFile:
|
||||||
for postId in calendarPostIds:
|
for postId in calendarPostIds:
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
calendarFile.close()
|
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
@ -368,10 +359,9 @@ def getThisWeeksEvents(baseDir: str, nickname: str, domain: str) -> {}:
|
||||||
|
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
calendarFile = open(calendarFilename, 'w+')
|
with open(calendarFilename, 'w+') as calendarFile:
|
||||||
for postId in calendarPostIds:
|
for postId in calendarPostIds:
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
calendarFile.close()
|
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
@ -433,10 +423,9 @@ def getCalendarEvents(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
calendarFile = open(calendarFilename, 'w+')
|
with open(calendarFilename, 'w+') as calendarFile:
|
||||||
for postId in calendarPostIds:
|
for postId in calendarPostIds:
|
||||||
calendarFile.write(postId + '\n')
|
calendarFile.write(postId + '\n')
|
||||||
calendarFile.close()
|
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
|
32
inbox.py
32
inbox.py
|
@ -127,10 +127,8 @@ def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None:
|
||||||
daysSinceEpoch = daysDiff.days
|
daysSinceEpoch = daysDiff.days
|
||||||
tagline = str(daysSinceEpoch) + ' ' + nickname + ' ' + postUrl + '\n'
|
tagline = str(daysSinceEpoch) + ' ' + nickname + ' ' + postUrl + '\n'
|
||||||
if not os.path.isfile(tagsFilename):
|
if not os.path.isfile(tagsFilename):
|
||||||
tagsFile = open(tagsFilename, "w+")
|
with open(tagsFilename, 'w+') as tagsFile:
|
||||||
if tagsFile:
|
|
||||||
tagsFile.write(tagline)
|
tagsFile.write(tagline)
|
||||||
tagsFile.close()
|
|
||||||
else:
|
else:
|
||||||
if postUrl not in open(tagsFilename).read():
|
if postUrl not in open(tagsFilename).read():
|
||||||
try:
|
try:
|
||||||
|
@ -1460,10 +1458,8 @@ def _receiveAnnounce(recentPostsCache: {},
|
||||||
postJsonObject, personCache,
|
postJsonObject, personCache,
|
||||||
translate, lookupActor,
|
translate, lookupActor,
|
||||||
themeName)
|
themeName)
|
||||||
ttsFile = open(postFilename + '.tts', "w+")
|
with open(postFilename + '.tts', 'w+') as ttsFile:
|
||||||
if ttsFile:
|
|
||||||
ttsFile.write('\n')
|
ttsFile.write('\n')
|
||||||
ttsFile.close()
|
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Obtaining actor for announce post ' +
|
print('DEBUG: Obtaining actor for announce post ' +
|
||||||
|
@ -1642,15 +1638,11 @@ def populateReplies(baseDir: str, httpPrefix: str, domain: str,
|
||||||
if numLines > maxReplies:
|
if numLines > maxReplies:
|
||||||
return False
|
return False
|
||||||
if messageId not in open(postRepliesFilename).read():
|
if messageId not in open(postRepliesFilename).read():
|
||||||
repliesFile = open(postRepliesFilename, 'a+')
|
with open(postRepliesFilename, 'a+') as repliesFile:
|
||||||
if repliesFile:
|
|
||||||
repliesFile.write(messageId + '\n')
|
repliesFile.write(messageId + '\n')
|
||||||
repliesFile.close()
|
|
||||||
else:
|
else:
|
||||||
repliesFile = open(postRepliesFilename, 'w+')
|
with open(postRepliesFilename, 'w+') as repliesFile:
|
||||||
if repliesFile:
|
|
||||||
repliesFile.write(messageId + '\n')
|
repliesFile.write(messageId + '\n')
|
||||||
repliesFile.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -2107,10 +2099,8 @@ def inboxUpdateIndex(boxname: str, baseDir: str, handle: str,
|
||||||
print('WARN: Failed to write entry to index ' + str(e))
|
print('WARN: Failed to write entry to index ' + str(e))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
indexFile = open(indexFilename, 'w+')
|
with open(indexFilename, 'w+') as indexFile:
|
||||||
if indexFile:
|
|
||||||
indexFile.write(destinationFilename + '\n')
|
indexFile.write(destinationFilename + '\n')
|
||||||
indexFile.close()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('WARN: Failed to write initial entry to index ' + str(e))
|
print('WARN: Failed to write initial entry to index ' + str(e))
|
||||||
|
|
||||||
|
@ -2590,10 +2580,8 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
# This enables you to ignore a threat that's getting boring
|
# This enables you to ignore a threat that's getting boring
|
||||||
if isReplyToMutedPost:
|
if isReplyToMutedPost:
|
||||||
print('MUTE REPLY: ' + destinationFilename)
|
print('MUTE REPLY: ' + destinationFilename)
|
||||||
muteFile = open(destinationFilename + '.muted', 'w+')
|
with open(destinationFilename + '.muted', 'w+') as muteFile:
|
||||||
if muteFile:
|
|
||||||
muteFile.write('\n')
|
muteFile.write('\n')
|
||||||
muteFile.close()
|
|
||||||
|
|
||||||
# update the indexes for different timelines
|
# update the indexes for different timelines
|
||||||
for boxname in updateIndexList:
|
for boxname in updateIndexList:
|
||||||
|
@ -2851,10 +2839,8 @@ def _checkJsonSignature(baseDir: str, queueJson: {}) -> (bool, bool):
|
||||||
alreadyUnknown = True
|
alreadyUnknown = True
|
||||||
|
|
||||||
if not alreadyUnknown:
|
if not alreadyUnknown:
|
||||||
unknownFile = open(unknownContextsFile, "a+")
|
with open(unknownContextsFile, 'a+') as unknownFile:
|
||||||
if unknownFile:
|
|
||||||
unknownFile.write(unknownContext + '\n')
|
unknownFile.write(unknownContext + '\n')
|
||||||
unknownFile.close()
|
|
||||||
else:
|
else:
|
||||||
print('Unrecognized jsonld signature type: ' +
|
print('Unrecognized jsonld signature type: ' +
|
||||||
jwebsigType)
|
jwebsigType)
|
||||||
|
@ -2869,10 +2855,8 @@ def _checkJsonSignature(baseDir: str, queueJson: {}) -> (bool, bool):
|
||||||
alreadyUnknown = True
|
alreadyUnknown = True
|
||||||
|
|
||||||
if not alreadyUnknown:
|
if not alreadyUnknown:
|
||||||
unknownFile = open(unknownSignaturesFile, "a+")
|
with open(unknownSignaturesFile, 'a+') as unknownFile:
|
||||||
if unknownFile:
|
|
||||||
unknownFile.write(jwebsigType + '\n')
|
unknownFile.write(jwebsigType + '\n')
|
||||||
unknownFile.close()
|
|
||||||
return hasJsonSignature, jwebsigType
|
return hasJsonSignature, jwebsigType
|
||||||
|
|
||||||
|
|
||||||
|
|
121
manualapprove.py
121
manualapprove.py
|
@ -41,9 +41,8 @@ def manualDenyFollowRequest(session, baseDir: str,
|
||||||
removeFromFollowRequests(baseDir, nickname, domain, denyHandle, debug)
|
removeFromFollowRequests(baseDir, nickname, domain, denyHandle, debug)
|
||||||
|
|
||||||
# Store rejected follows
|
# Store rejected follows
|
||||||
rejectsFile = open(rejectedFollowsFilename, "a+")
|
with open(rejectedFollowsFilename, 'a+') as rejectsFile:
|
||||||
rejectsFile.write(denyHandle + '\n')
|
rejectsFile.write(denyHandle + '\n')
|
||||||
rejectsFile.close()
|
|
||||||
|
|
||||||
denyNickname = denyHandle.split('@')[0]
|
denyNickname = denyHandle.split('@')[0]
|
||||||
denyDomain = \
|
denyDomain = \
|
||||||
|
@ -70,13 +69,11 @@ def _approveFollowerHandle(accountDir: str, approveHandle: str) -> None:
|
||||||
approvedFilename = accountDir + '/approved.txt'
|
approvedFilename = accountDir + '/approved.txt'
|
||||||
if os.path.isfile(approvedFilename):
|
if os.path.isfile(approvedFilename):
|
||||||
if approveHandle not in open(approvedFilename).read():
|
if approveHandle not in open(approvedFilename).read():
|
||||||
approvedFile = open(approvedFilename, "a+")
|
with open(approvedFilename, 'a+') as approvedFile:
|
||||||
approvedFile.write(approveHandle + '\n')
|
approvedFile.write(approveHandle + '\n')
|
||||||
approvedFile.close()
|
|
||||||
else:
|
else:
|
||||||
approvedFile = open(approvedFilename, "w+")
|
with open(approvedFilename, 'w+') as approvedFile:
|
||||||
approvedFile.write(approveHandle + '\n')
|
approvedFile.write(approveHandle + '\n')
|
||||||
approvedFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def manualApproveFollowRequest(session, baseDir: str,
|
def manualApproveFollowRequest(session, baseDir: str,
|
||||||
|
@ -131,53 +128,60 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
'" ' + approveFollowsFilename)
|
'" ' + approveFollowsFilename)
|
||||||
return
|
return
|
||||||
|
|
||||||
approvefilenew = open(approveFollowsFilename + '.new', 'w+')
|
with open(approveFollowsFilename + '.new', 'w+') as approvefilenew:
|
||||||
updateApprovedFollowers = False
|
updateApprovedFollowers = False
|
||||||
followActivityfilename = None
|
followActivityfilename = None
|
||||||
with open(approveFollowsFilename, 'r') as approvefile:
|
with open(approveFollowsFilename, 'r') as approvefile:
|
||||||
for handleOfFollowRequester in approvefile:
|
for handleOfFollowRequester in approvefile:
|
||||||
# is this the approved follow?
|
# is this the approved follow?
|
||||||
if handleOfFollowRequester.startswith(approveHandleFull):
|
if handleOfFollowRequester.startswith(approveHandleFull):
|
||||||
handleOfFollowRequester = \
|
handleOfFollowRequester = \
|
||||||
handleOfFollowRequester.replace('\n', '').replace('\r', '')
|
handleOfFollowRequester.replace('\n', '')
|
||||||
port2 = port
|
handleOfFollowRequester = \
|
||||||
if ':' in handleOfFollowRequester:
|
handleOfFollowRequester.replace('\r', '')
|
||||||
port2Str = handleOfFollowRequester.split(':')[1]
|
port2 = port
|
||||||
if port2Str.isdigit():
|
if ':' in handleOfFollowRequester:
|
||||||
port2 = int(port2Str)
|
port2Str = handleOfFollowRequester.split(':')[1]
|
||||||
requestsDir = accountDir + '/requests'
|
if port2Str.isdigit():
|
||||||
followActivityfilename = \
|
port2 = int(port2Str)
|
||||||
requestsDir + '/' + handleOfFollowRequester + '.follow'
|
requestsDir = accountDir + '/requests'
|
||||||
if os.path.isfile(followActivityfilename):
|
followActivityfilename = \
|
||||||
followJson = loadJson(followActivityfilename)
|
requestsDir + '/' + handleOfFollowRequester + '.follow'
|
||||||
if followJson:
|
if os.path.isfile(followActivityfilename):
|
||||||
approveNickname = approveHandle.split('@')[0]
|
followJson = loadJson(followActivityfilename)
|
||||||
approveDomain = approveHandle.split('@')[1]
|
if followJson:
|
||||||
approveDomain = \
|
approveNickname = approveHandle.split('@')[0]
|
||||||
approveDomain.replace('\n', '').replace('\r', '')
|
approveDomain = approveHandle.split('@')[1]
|
||||||
approvePort = port2
|
approveDomain = \
|
||||||
if ':' in approveDomain:
|
approveDomain.replace('\n', '')
|
||||||
approvePort = approveDomain.split(':')[1]
|
approveDomain = \
|
||||||
approveDomain = approveDomain.split(':')[0]
|
approveDomain.replace('\r', '')
|
||||||
print('Manual follow accept: Sending Accept for ' +
|
approvePort = port2
|
||||||
handle + ' follow request from ' +
|
if ':' in approveDomain:
|
||||||
approveNickname + '@' + approveDomain)
|
approvePort = approveDomain.split(':')[1]
|
||||||
followedAccountAccepts(session, baseDir, httpPrefix,
|
approveDomain = approveDomain.split(':')[0]
|
||||||
nickname, domain, port,
|
print('Manual follow accept: Sending Accept for ' +
|
||||||
approveNickname, approveDomain,
|
handle + ' follow request from ' +
|
||||||
approvePort,
|
approveNickname + '@' + approveDomain)
|
||||||
followJson['actor'],
|
followedAccountAccepts(session, baseDir,
|
||||||
federationList,
|
httpPrefix,
|
||||||
followJson,
|
nickname, domain, port,
|
||||||
sendThreads, postLog,
|
approveNickname,
|
||||||
cachedWebfingers, personCache,
|
approveDomain,
|
||||||
debug, projectVersion, False)
|
approvePort,
|
||||||
updateApprovedFollowers = True
|
followJson['actor'],
|
||||||
else:
|
federationList,
|
||||||
# this isn't the approved follow so it will remain
|
followJson,
|
||||||
# in the requests file
|
sendThreads, postLog,
|
||||||
approvefilenew.write(handleOfFollowRequester)
|
cachedWebfingers,
|
||||||
approvefilenew.close()
|
personCache,
|
||||||
|
debug,
|
||||||
|
projectVersion, False)
|
||||||
|
updateApprovedFollowers = True
|
||||||
|
else:
|
||||||
|
# this isn't the approved follow so it will remain
|
||||||
|
# in the requests file
|
||||||
|
approvefilenew.write(handleOfFollowRequester)
|
||||||
|
|
||||||
followersFilename = accountDir + '/followers.txt'
|
followersFilename = accountDir + '/followers.txt'
|
||||||
if updateApprovedFollowers:
|
if updateApprovedFollowers:
|
||||||
|
@ -201,9 +205,8 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
else:
|
else:
|
||||||
print('Manual follow accept: first follower accepted for ' +
|
print('Manual follow accept: first follower accepted for ' +
|
||||||
handle + ' is ' + approveHandleFull)
|
handle + ' is ' + approveHandleFull)
|
||||||
followersFile = open(followersFilename, "w+")
|
with open(followersFilename, 'w+') as followersFile:
|
||||||
followersFile.write(approveHandleFull + '\n')
|
followersFile.write(approveHandleFull + '\n')
|
||||||
followersFile.close()
|
|
||||||
|
|
||||||
# only update the follow requests file if the follow is confirmed to be
|
# only update the follow requests file if the follow is confirmed to be
|
||||||
# in followers.txt
|
# in followers.txt
|
||||||
|
|
|
@ -55,19 +55,15 @@ def _updateFeedsOutboxIndex(baseDir: str, domain: str, postId: str) -> None:
|
||||||
print('WARN: Failed to write entry to feeds posts index ' +
|
print('WARN: Failed to write entry to feeds posts index ' +
|
||||||
indexFilename + ' ' + str(e))
|
indexFilename + ' ' + str(e))
|
||||||
else:
|
else:
|
||||||
feedsFile = open(indexFilename, 'w+')
|
with open(indexFilename, 'w+') as feedsFile:
|
||||||
if feedsFile:
|
|
||||||
feedsFile.write(postId + '\n')
|
feedsFile.write(postId + '\n')
|
||||||
feedsFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def _saveArrivedTime(baseDir: str, postFilename: str, arrived: str) -> None:
|
def _saveArrivedTime(baseDir: str, postFilename: str, arrived: str) -> None:
|
||||||
"""Saves the time when an rss post arrived to a file
|
"""Saves the time when an rss post arrived to a file
|
||||||
"""
|
"""
|
||||||
arrivedFile = open(postFilename + '.arrived', 'w+')
|
with open(postFilename + '.arrived', 'w+') as arrivedFile:
|
||||||
if arrivedFile:
|
|
||||||
arrivedFile.write(arrived)
|
arrivedFile.write(arrived)
|
||||||
arrivedFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def _removeControlCharacters(content: str) -> str:
|
def _removeControlCharacters(content: str) -> str:
|
||||||
|
@ -435,15 +431,11 @@ def _createNewsMirror(baseDir: str, domain: str,
|
||||||
|
|
||||||
# append the post Id number to the index file
|
# append the post Id number to the index file
|
||||||
if os.path.isfile(mirrorIndexFilename):
|
if os.path.isfile(mirrorIndexFilename):
|
||||||
indexFile = open(mirrorIndexFilename, "a+")
|
with open(mirrorIndexFilename, 'a+') as indexFile:
|
||||||
if indexFile:
|
|
||||||
indexFile.write(postIdNumber + '\n')
|
indexFile.write(postIdNumber + '\n')
|
||||||
indexFile.close()
|
|
||||||
else:
|
else:
|
||||||
indexFile = open(mirrorIndexFilename, "w+")
|
with open(mirrorIndexFilename, 'w+') as indexFile:
|
||||||
if indexFile:
|
|
||||||
indexFile.write(postIdNumber + '\n')
|
indexFile.write(postIdNumber + '\n')
|
||||||
indexFile.close()
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
35
person.py
35
person.py
|
@ -879,13 +879,13 @@ def reenableAccount(baseDir: str, nickname: str) -> None:
|
||||||
"""
|
"""
|
||||||
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
suspendedFilename = baseDir + '/accounts/suspended.txt'
|
||||||
if os.path.isfile(suspendedFilename):
|
if os.path.isfile(suspendedFilename):
|
||||||
|
lines = []
|
||||||
with open(suspendedFilename, "r") as f:
|
with open(suspendedFilename, "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
suspendedFile = open(suspendedFilename, "w+")
|
with open(suspendedFilename, 'w+') as suspendedFile:
|
||||||
for suspended in lines:
|
for suspended in lines:
|
||||||
if suspended.strip('\n').strip('\r') != nickname:
|
if suspended.strip('\n').strip('\r') != nickname:
|
||||||
suspendedFile.write(suspended)
|
suspendedFile.write(suspended)
|
||||||
suspendedFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
|
@ -923,15 +923,11 @@ def suspendAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
for suspended in lines:
|
for suspended in lines:
|
||||||
if suspended.strip('\n').strip('\r') == nickname:
|
if suspended.strip('\n').strip('\r') == nickname:
|
||||||
return
|
return
|
||||||
suspendedFile = open(suspendedFilename, 'a+')
|
with open(suspendedFilename, 'a+') as suspendedFile:
|
||||||
if suspendedFile:
|
|
||||||
suspendedFile.write(nickname + '\n')
|
suspendedFile.write(nickname + '\n')
|
||||||
suspendedFile.close()
|
|
||||||
else:
|
else:
|
||||||
suspendedFile = open(suspendedFilename, 'w+')
|
with open(suspendedFilename, 'w+') as suspendedFile:
|
||||||
if suspendedFile:
|
|
||||||
suspendedFile.write(nickname + '\n')
|
suspendedFile.write(nickname + '\n')
|
||||||
suspendedFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def canRemovePost(baseDir: str, nickname: str,
|
def canRemovePost(baseDir: str, nickname: str,
|
||||||
|
@ -983,14 +979,13 @@ def _removeTagsForNickname(baseDir: str, nickname: str,
|
||||||
continue
|
continue
|
||||||
if matchStr not in open(tagFilename).read():
|
if matchStr not in open(tagFilename).read():
|
||||||
continue
|
continue
|
||||||
|
lines = []
|
||||||
with open(tagFilename, "r") as f:
|
with open(tagFilename, "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
tagFile = open(tagFilename, "w+")
|
with open(tagFilename, 'w+') as tagFile:
|
||||||
if tagFile:
|
|
||||||
for tagline in lines:
|
for tagline in lines:
|
||||||
if matchStr not in tagline:
|
if matchStr not in tagline:
|
||||||
tagFile.write(tagline)
|
tagFile.write(tagline)
|
||||||
tagFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def removeAccount(baseDir: str, nickname: str,
|
def removeAccount(baseDir: str, nickname: str,
|
||||||
|
@ -1132,10 +1127,8 @@ def isPersonSnoozed(baseDir: str, nickname: str, domain: str,
|
||||||
with open(snoozedFilename, 'r') as snoozedFile:
|
with open(snoozedFilename, 'r') as snoozedFile:
|
||||||
content = snoozedFile.read().replace(replaceStr, '')
|
content = snoozedFile.read().replace(replaceStr, '')
|
||||||
if content:
|
if content:
|
||||||
writeSnoozedFile = open(snoozedFilename, 'w+')
|
with open(snoozedFilename, 'w+') as writeSnoozedFile:
|
||||||
if writeSnoozedFile:
|
|
||||||
writeSnoozedFile.write(content)
|
writeSnoozedFile.write(content)
|
||||||
writeSnoozedFile.close()
|
|
||||||
|
|
||||||
if snoozeActor + ' ' in open(snoozedFilename).read():
|
if snoozeActor + ' ' in open(snoozedFilename).read():
|
||||||
return True
|
return True
|
||||||
|
@ -1154,11 +1147,9 @@ def personSnooze(baseDir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(snoozedFilename):
|
if os.path.isfile(snoozedFilename):
|
||||||
if snoozeActor + ' ' in open(snoozedFilename).read():
|
if snoozeActor + ' ' in open(snoozedFilename).read():
|
||||||
return
|
return
|
||||||
snoozedFile = open(snoozedFilename, "a+")
|
with open(snoozedFilename, 'a+') as snoozedFile:
|
||||||
if snoozedFile:
|
|
||||||
snoozedFile.write(snoozeActor + ' ' +
|
snoozedFile.write(snoozeActor + ' ' +
|
||||||
str(int(time.time())) + '\n')
|
str(int(time.time())) + '\n')
|
||||||
snoozedFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def personUnsnooze(baseDir: str, nickname: str, domain: str,
|
def personUnsnooze(baseDir: str, nickname: str, domain: str,
|
||||||
|
@ -1185,10 +1176,8 @@ def personUnsnooze(baseDir: str, nickname: str, domain: str,
|
||||||
with open(snoozedFilename, 'r') as snoozedFile:
|
with open(snoozedFilename, 'r') as snoozedFile:
|
||||||
content = snoozedFile.read().replace(replaceStr, '')
|
content = snoozedFile.read().replace(replaceStr, '')
|
||||||
if content:
|
if content:
|
||||||
writeSnoozedFile = open(snoozedFilename, 'w+')
|
with open(snoozedFilename, 'w+') as writeSnoozedFile:
|
||||||
if writeSnoozedFile:
|
|
||||||
writeSnoozedFile.write(content)
|
writeSnoozedFile.write(content)
|
||||||
writeSnoozedFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def setPersonNotes(baseDir: str, nickname: str, domain: str,
|
def setPersonNotes(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
24
posts.py
24
posts.py
|
@ -728,10 +728,8 @@ def _updateHashtagsIndex(baseDir: str, tag: {}, newPostId: str) -> None:
|
||||||
|
|
||||||
if not os.path.isfile(tagsFilename):
|
if not os.path.isfile(tagsFilename):
|
||||||
# create a new tags index file
|
# create a new tags index file
|
||||||
tagsFile = open(tagsFilename, "w+")
|
with open(tagsFilename, 'w+') as tagsFile:
|
||||||
if tagsFile:
|
|
||||||
tagsFile.write(tagline)
|
tagsFile.write(tagline)
|
||||||
tagsFile.close()
|
|
||||||
else:
|
else:
|
||||||
# prepend to tags index file
|
# prepend to tags index file
|
||||||
if tagline not in open(tagsFilename).read():
|
if tagline not in open(tagsFilename).read():
|
||||||
|
@ -767,10 +765,8 @@ def _addSchedulePost(baseDir: str, nickname: str, domain: str,
|
||||||
print('WARN: Failed to write entry to scheduled posts index ' +
|
print('WARN: Failed to write entry to scheduled posts index ' +
|
||||||
scheduleIndexFilename + ' ' + str(e))
|
scheduleIndexFilename + ' ' + str(e))
|
||||||
else:
|
else:
|
||||||
scheduleFile = open(scheduleIndexFilename, 'w+')
|
with open(scheduleIndexFilename, 'w+') as scheduleFile:
|
||||||
if scheduleFile:
|
|
||||||
scheduleFile.write(indexStr + '\n')
|
scheduleFile.write(indexStr + '\n')
|
||||||
scheduleFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def _appendEventFields(newPost: {},
|
def _appendEventFields(newPost: {},
|
||||||
|
@ -1194,10 +1190,8 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
newPost['moderationStatus'] = 'pending'
|
newPost['moderationStatus'] = 'pending'
|
||||||
# save to index file
|
# save to index file
|
||||||
moderationIndexFile = baseDir + '/accounts/moderation.txt'
|
moderationIndexFile = baseDir + '/accounts/moderation.txt'
|
||||||
modFile = open(moderationIndexFile, "a+")
|
with open(moderationIndexFile, 'a+') as modFile:
|
||||||
if modFile:
|
|
||||||
modFile.write(newPostId + '\n')
|
modFile.write(newPostId + '\n')
|
||||||
modFile.close()
|
|
||||||
|
|
||||||
# If a patch has been posted - i.e. the output from
|
# If a patch has been posted - i.e. the output from
|
||||||
# git format-patch - then convert the activitypub type
|
# git format-patch - then convert the activitypub type
|
||||||
|
@ -1305,10 +1299,8 @@ def pinPost(baseDir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
||||||
pinnedFilename = accountDir + '/pinToProfile.txt'
|
pinnedFilename = accountDir + '/pinToProfile.txt'
|
||||||
pinFile = open(pinnedFilename, "w+")
|
with open(pinnedFilename, 'w+') as pinFile:
|
||||||
if pinFile:
|
|
||||||
pinFile.write(pinnedContent)
|
pinFile.write(pinnedContent)
|
||||||
pinFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def undoPinnedPost(baseDir: str, nickname: str, domain: str) -> None:
|
def undoPinnedPost(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
|
@ -3452,10 +3444,8 @@ def archivePostsForPerson(httpPrefix: str, nickname: str, domain: str,
|
||||||
break
|
break
|
||||||
# save the new index file
|
# save the new index file
|
||||||
if len(newIndex) > 0:
|
if len(newIndex) > 0:
|
||||||
indexFile = open(indexFilename, 'w+')
|
with open(indexFilename, 'w+') as indexFile:
|
||||||
if indexFile:
|
|
||||||
indexFile.write(newIndex)
|
indexFile.write(newIndex)
|
||||||
indexFile.close()
|
|
||||||
|
|
||||||
postsInBoxDict = {}
|
postsInBoxDict = {}
|
||||||
postsCtr = 0
|
postsCtr = 0
|
||||||
|
@ -3919,10 +3909,8 @@ def _rejectAnnounce(announceFilename: str,
|
||||||
|
|
||||||
# reject the post referenced by the announce activity object
|
# reject the post referenced by the announce activity object
|
||||||
if not os.path.isfile(announceFilename + '.reject'):
|
if not os.path.isfile(announceFilename + '.reject'):
|
||||||
rejectAnnounceFile = open(announceFilename + '.reject', "w+")
|
with open(announceFilename + '.reject', 'w+') as rejectAnnounceFile:
|
||||||
if rejectAnnounceFile:
|
|
||||||
rejectAnnounceFile.write('\n')
|
rejectAnnounceFile.write('\n')
|
||||||
rejectAnnounceFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def downloadAnnounce(session, baseDir: str, httpPrefix: str,
|
def downloadAnnounce(session, baseDir: str, httpPrefix: str,
|
||||||
|
|
|
@ -67,21 +67,17 @@ def questionUpdateVotes(baseDir: str, nickname: str, domain: str,
|
||||||
votersFilename = questionPostFilename.replace('.json', '.voters')
|
votersFilename = questionPostFilename.replace('.json', '.voters')
|
||||||
if not os.path.isfile(votersFilename):
|
if not os.path.isfile(votersFilename):
|
||||||
# create a new voters file
|
# create a new voters file
|
||||||
votersFile = open(votersFilename, 'w+')
|
with open(votersFilename, 'w+') as votersFile:
|
||||||
if votersFile:
|
|
||||||
votersFile.write(replyJson['actor'] +
|
votersFile.write(replyJson['actor'] +
|
||||||
votersFileSeparator +
|
votersFileSeparator +
|
||||||
foundAnswer + '\n')
|
foundAnswer + '\n')
|
||||||
votersFile.close()
|
|
||||||
else:
|
else:
|
||||||
if replyJson['actor'] not in open(votersFilename).read():
|
if replyJson['actor'] not in open(votersFilename).read():
|
||||||
# append to the voters file
|
# append to the voters file
|
||||||
votersFile = open(votersFilename, "a+")
|
with open(votersFilename, 'a+') as votersFile:
|
||||||
if votersFile:
|
|
||||||
votersFile.write(replyJson['actor'] +
|
votersFile.write(replyJson['actor'] +
|
||||||
votersFileSeparator +
|
votersFileSeparator +
|
||||||
foundAnswer + '\n')
|
foundAnswer + '\n')
|
||||||
votersFile.close()
|
|
||||||
else:
|
else:
|
||||||
# change an entry in the voters file
|
# change an entry in the voters file
|
||||||
with open(votersFilename, "r") as votersFile:
|
with open(votersFilename, "r") as votersFile:
|
||||||
|
|
|
@ -129,11 +129,9 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
|
||||||
# write the new schedule index file
|
# write the new schedule index file
|
||||||
scheduleIndexFile = \
|
scheduleIndexFile = \
|
||||||
baseDir + '/accounts/' + handle + '/schedule.index'
|
baseDir + '/accounts/' + handle + '/schedule.index'
|
||||||
scheduleFile = open(scheduleIndexFile, "w+")
|
with open(scheduleIndexFile, 'w+') as scheduleFile:
|
||||||
if scheduleFile:
|
|
||||||
for line in indexLines:
|
for line in indexLines:
|
||||||
scheduleFile.write(line)
|
scheduleFile.write(line)
|
||||||
scheduleFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def runPostSchedule(baseDir: str, httpd, maxScheduledPosts: int):
|
def runPostSchedule(baseDir: str, httpd, maxScheduledPosts: int):
|
||||||
|
|
4
tests.py
4
tests.py
|
@ -3883,10 +3883,8 @@ def _testSpoofGeolocation() -> None:
|
||||||
|
|
||||||
kmlStr += '</Document>\n'
|
kmlStr += '</Document>\n'
|
||||||
kmlStr += '</kml>'
|
kmlStr += '</kml>'
|
||||||
kmlFile = open('unittest_decoy.kml', 'w+')
|
with open('unittest_decoy.kml', 'w+') as kmlFile:
|
||||||
if kmlFile:
|
|
||||||
kmlFile.write(kmlStr)
|
kmlFile.write(kmlStr)
|
||||||
kmlFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def _testSkills() -> None:
|
def _testSkills() -> None:
|
||||||
|
|
9
theme.py
9
theme.py
|
@ -808,9 +808,6 @@ def updateDefaultThemesList(baseDir: str) -> None:
|
||||||
"""
|
"""
|
||||||
themeNames = getThemesList(baseDir)
|
themeNames = getThemesList(baseDir)
|
||||||
defaultThemesFilename = baseDir + '/defaultthemes.txt'
|
defaultThemesFilename = baseDir + '/defaultthemes.txt'
|
||||||
defaultThemesFile = open(defaultThemesFilename, "w+")
|
with open(defaultThemesFilename, 'w+') as defaultThemesFile:
|
||||||
if not defaultThemesFile:
|
for name in themeNames:
|
||||||
return
|
defaultThemesFile.write(name + '\n')
|
||||||
for name in themeNames:
|
|
||||||
defaultThemesFile.write(name + '\n')
|
|
||||||
defaultThemesFile.close()
|
|
||||||
|
|
9
utils.py
9
utils.py
|
@ -43,9 +43,8 @@ def refreshNewswire(baseDir: str):
|
||||||
refreshNewswireFilename = baseDir + '/accounts/.refresh_newswire'
|
refreshNewswireFilename = baseDir + '/accounts/.refresh_newswire'
|
||||||
if os.path.isfile(refreshNewswireFilename):
|
if os.path.isfile(refreshNewswireFilename):
|
||||||
return
|
return
|
||||||
refreshFile = open(refreshNewswireFilename, 'w+')
|
with open(refreshNewswireFilename, 'w+') as refreshFile:
|
||||||
refreshFile.write('\n')
|
refreshFile.write('\n')
|
||||||
refreshFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def getSHA256(msg: str):
|
def getSHA256(msg: str):
|
||||||
|
@ -2198,10 +2197,8 @@ def rejectPostId(baseDir: str, nickname: str, domain: str,
|
||||||
if recentPostsCache['html'].get(postUrl):
|
if recentPostsCache['html'].get(postUrl):
|
||||||
del recentPostsCache['html'][postUrl]
|
del recentPostsCache['html'][postUrl]
|
||||||
|
|
||||||
rejectFile = open(postFilename + '.reject', "w+")
|
with open(postFilename + '.reject', 'w+') as rejectFile:
|
||||||
if rejectFile:
|
|
||||||
rejectFile.write('\n')
|
rejectFile.write('\n')
|
||||||
rejectFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def isDM(postJsonObject: {}) -> bool:
|
def isDM(postJsonObject: {}) -> bool:
|
||||||
|
|
|
@ -1332,10 +1332,8 @@ def individualPostAsHtml(allowDownloads: bool,
|
||||||
postJsonObject, personCache,
|
postJsonObject, personCache,
|
||||||
translate, postJsonObject['actor'],
|
translate, postJsonObject['actor'],
|
||||||
themeName)
|
themeName)
|
||||||
ttsFile = open(announceFilename + '.tts', "w+")
|
with open(announceFilename + '.tts', 'w+') as ttsFile:
|
||||||
if ttsFile:
|
|
||||||
ttsFile.write('\n')
|
ttsFile.write('\n')
|
||||||
ttsFile.close()
|
|
||||||
|
|
||||||
isAnnounced = True
|
isAnnounced = True
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,8 @@ def welcomeScreenIsComplete(baseDir: str,
|
||||||
if not os.path.isdir(accountPath):
|
if not os.path.isdir(accountPath):
|
||||||
return
|
return
|
||||||
completeFilename = accountPath + '/.welcome_complete'
|
completeFilename = accountPath + '/.welcome_complete'
|
||||||
completeFile = open(completeFilename, 'w+')
|
with open(completeFilename, 'w+') as completeFile:
|
||||||
if completeFile:
|
|
||||||
completeFile.write('\n')
|
completeFile.write('\n')
|
||||||
completeFile.close()
|
|
||||||
|
|
||||||
|
|
||||||
def htmlWelcomeScreen(baseDir: str, nickname: str,
|
def htmlWelcomeScreen(baseDir: str, nickname: str,
|
||||||
|
|
Loading…
Reference in New Issue