close file automaticaly

This commit is contained in:
Denis Fomin 2013-01-03 17:09:51 +04:00
parent 1202d79a3c
commit ec6b85a75b
2 changed files with 4 additions and 4 deletions

View File

@ -154,8 +154,8 @@ class ProfileWindow:
scaled_pixbuf.savev(path_to_file, 'png', [], []) scaled_pixbuf.savev(path_to_file, 'png', [], [])
must_delete = True must_delete = True
fd = open(path_to_file, 'rb') with open(path_to_file, 'rb') as fd:
data = fd.read() data = fd.read()
pixbuf = gtkgui_helpers.get_pixbuf_from_data(data) pixbuf = gtkgui_helpers.get_pixbuf_from_data(data)
try: try:
# rescale it # rescale it

View File

@ -905,8 +905,8 @@ class SignalObject(dbus.service.Object):
else: else:
invalid_file = True invalid_file = True
if not invalid_file and filesize < 16384: if not invalid_file and filesize < 16384:
fd = open(picture, 'rb') with open(picture, 'rb') as fb:
data = fd.read() data = fd.read()
avatar = base64.b64encode(data).decode('utf-8') avatar = base64.b64encode(data).decode('utf-8')
avatar_mime_type = mimetypes.guess_type(picture)[0] avatar_mime_type = mimetypes.guess_type(picture)[0]
vcard={} vcard={}