1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
--- sugar-datastore-0.8.0~git.13d354b.orig/src/olpc/datastore/backingstore.py
+++ sugar-datastore-0.8.0~git.13d354b/src/olpc/datastore/backingstore.py
@@ -258,9 +258,10 @@
if os.path.exists(fn):
fp = open(fn, 'r')
try:
- desc = pickle.load(fp)
- except:
- desc = {}
+ try:
+ desc = pickle.load(fp)
+ except:
+ desc = {}
finally:
fp.close()
--- sugar-datastore-0.8.0~git.13d354b.orig/src/olpc/datastore/converter.py
+++ sugar-datastore-0.8.0~git.13d354b/src/olpc/datastore/converter.py
@@ -74,17 +74,18 @@
cmd = self.raw % data
try:
- cmd = cmd.split()
- # the stderr capture here will hide glib error messages
- # from converters which shouldn't be generating output anyway
- retcode = subprocess.call(cmd, stderr=subprocess.PIPE)
- if retcode: return None
- return codecs.open(target, 'r', 'utf-8')
- except UnicodeDecodeError:
- # The data was an unknown type but couldn't be understood
- # as text so we don't attempt to index it. This most
- # likely means its just an unknown binary format.
- return None
+ try:
+ cmd = cmd.split()
+ # the stderr capture here will hide glib error messages
+ # from converters which shouldn't be generating output anyway
+ retcode = subprocess.call(cmd, stderr=subprocess.PIPE)
+ if retcode: return None
+ return codecs.open(target, 'r', 'utf-8')
+ except UnicodeDecodeError:
+ # The data was an unknown type but couldn't be understood
+ # as text so we don't attempt to index it. This most
+ # likely means its just an unknown binary format.
+ return None
finally:
# we unlink the file as its already been opened for
# reading
--- sugar-datastore-0.8.0~git.13d354b.orig/src/olpc/datastore/datastore.py
+++ sugar-datastore-0.8.0~git.13d354b/src/olpc/datastore/datastore.py
@@ -412,11 +412,12 @@
backingstore = content.backingstore
backingstore.current_user_id = dbus.Bus().get_unix_user(sender)
try:
- # Retrieving the file path for the file will cause the file to be
- # copied or linked to a directory accessible by the caller.
- file_path = content.filename
- except AttributeError:
- file_path = ''
+ try:
+ # Retrieving the file path for the file will cause the file to be
+ # copied or linked to a directory accessible by the caller.
+ file_path = content.filename
+ except AttributeError:
+ file_path = ''
finally:
backingstore.current_user_id = None
return file_path
|