close file automaticaly
This commit is contained in:
parent
1202d79a3c
commit
ec6b85a75b
|
@ -154,8 +154,8 @@ class ProfileWindow:
|
|||
scaled_pixbuf.savev(path_to_file, 'png', [], [])
|
||||
must_delete = True
|
||||
|
||||
fd = open(path_to_file, 'rb')
|
||||
data = fd.read()
|
||||
with open(path_to_file, 'rb') as fd:
|
||||
data = fd.read()
|
||||
pixbuf = gtkgui_helpers.get_pixbuf_from_data(data)
|
||||
try:
|
||||
# rescale it
|
||||
|
|
|
@ -905,8 +905,8 @@ class SignalObject(dbus.service.Object):
|
|||
else:
|
||||
invalid_file = True
|
||||
if not invalid_file and filesize < 16384:
|
||||
fd = open(picture, 'rb')
|
||||
data = fd.read()
|
||||
with open(picture, 'rb') as fb:
|
||||
data = fd.read()
|
||||
avatar = base64.b64encode(data).decode('utf-8')
|
||||
avatar_mime_type = mimetypes.guess_type(picture)[0]
|
||||
vcard={}
|
||||
|
|
Loading…
Reference in New Issue