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):
|
if os.path.isfile(possibleOtherFormat):
|
||||||
os.remove(possibleOtherFormat)
|
os.remove(possibleOtherFormat)
|
||||||
|
|
||||||
fd = open(filename, 'wb')
|
with open(filename, 'wb') as fp:
|
||||||
if not fd:
|
fp.write(mediaBytes[startPos:])
|
||||||
return None, None
|
|
||||||
fd.write(mediaBytes[startPos:])
|
|
||||||
fd.close()
|
|
||||||
|
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
print('WARN: Media file could not be written to file: ' + filename)
|
print('WARN: Media file could not be written to file: ' + filename)
|
||||||
|
|
4
posts.py
4
posts.py
|
@ -1348,11 +1348,9 @@ def getPinnedPostAsJson(baseDir: str, httpPrefix: str,
|
||||||
pinnedPostJson = {}
|
pinnedPostJson = {}
|
||||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||||
if os.path.isfile(pinnedFilename):
|
if os.path.isfile(pinnedFilename):
|
||||||
pinFile = open(pinnedFilename, "r")
|
|
||||||
pinnedContent = None
|
pinnedContent = None
|
||||||
if pinFile:
|
with open(pinnedFilename, "r") as pinFile:
|
||||||
pinnedContent = pinFile.read()
|
pinnedContent = pinFile.read()
|
||||||
pinFile.close()
|
|
||||||
if pinnedContent:
|
if pinnedContent:
|
||||||
pinnedPostJson = {
|
pinnedPostJson = {
|
||||||
'atomUri': actor + '/pinned',
|
'atomUri': actor + '/pinned',
|
||||||
|
|
Loading…
Reference in New Issue