mirror of
https://github.com/lalbornoz/roar.git
synced 2024-12-23 12:56:37 +00:00
IrcMiRCARTBot.py:_uploadToImgur(): prevent file object leak via `with' barrier.
MiRCARTCanvasExportStore.py:_exportFileToImgur(): prevent file object leak via `with' barrier.
This commit is contained in:
parent
85cbffbadb
commit
7475f7108d
@ -180,7 +180,8 @@ class IrcMiRCARTBot(IrcClient.IrcClient):
|
||||
# }}}
|
||||
# {{{ _uploadToImgur(self, imgFilePath, imgName, imgTitle, apiKey): Upload single file to Imgur
|
||||
def _uploadToImgur(self, imgFilePath, imgName, imgTitle, apiKey):
|
||||
requestImageData = open(imgFilePath, "rb").read()
|
||||
with open(imgFilePath, "rb") as requestImage:
|
||||
requestImageData = requestImage.read()
|
||||
requestData = { \
|
||||
"image": base64.b64encode(requestImageData), \
|
||||
"key": apiKey, \
|
||||
|
@ -42,7 +42,8 @@ class MiRCARTCanvasExportStore():
|
||||
|
||||
# {{{ _exportFileToImgur(self, apiKey, imgName, imgTitle, pathName): upload single PNG file to Imgur
|
||||
def _exportFileToImgur(self, apiKey, imgName, imgTitle, pathName):
|
||||
requestImageData = open(pathName, "rb").read()
|
||||
with open(pathName, "rb") as requestImage:
|
||||
requestImageData = requestImage.read()
|
||||
requestData = { \
|
||||
"image": base64.b64encode(requestImageData), \
|
||||
"key": apiKey, \
|
||||
|
Loading…
Reference in New Issue
Block a user