mirror of https://gitlab.com/bashrc2/epicyon
Use with when opening files
parent
e8d45565b4
commit
112f4be382
|
@ -995,11 +995,8 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
|||
if os.path.isfile(possibleOtherFormat):
|
||||
os.remove(possibleOtherFormat)
|
||||
|
||||
fd = open(filename, 'wb')
|
||||
if not fd:
|
||||
return None, None
|
||||
fd.write(mediaBytes[startPos:])
|
||||
fd.close()
|
||||
with open(filename, 'wb') as fp:
|
||||
fp.write(mediaBytes[startPos:])
|
||||
|
||||
if not os.path.isfile(filename):
|
||||
print('WARN: Media file could not be written to file: ' + filename)
|
||||
|
|
4
posts.py
4
posts.py
|
@ -1348,11 +1348,9 @@ def getPinnedPostAsJson(baseDir: str, httpPrefix: str,
|
|||
pinnedPostJson = {}
|
||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||
if os.path.isfile(pinnedFilename):
|
||||
pinFile = open(pinnedFilename, "r")
|
||||
pinnedContent = None
|
||||
if pinFile:
|
||||
with open(pinnedFilename, "r") as pinFile:
|
||||
pinnedContent = pinFile.read()
|
||||
pinFile.close()
|
||||
if pinnedContent:
|
||||
pinnedPostJson = {
|
||||
'atomUri': actor + '/pinned',
|
||||
|
|
Loading…
Reference in New Issue