Skip to content

Commit dced8aa

Browse files
committed
Merge pull request #68 from ensonic/master
Also flush on read() to not return cached data.
2 parents f9a9d2e + 9f5f35b commit dced8aa

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

ev3dev/core.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ def file_handle(self, path, mode, reopen=False):
5858
"""Manages the file handle cache and opening the files in the correct mode"""
5959

6060
if path not in self._cache:
61-
f = open(path, mode)
61+
f = open(path, mode, 0)
6262
self._cache[path] = f
6363
elif reopen:
6464
self._cache[path].close()
65-
f = open(path, mode)
65+
f = open(path, mode, 0)
6666
self._cache[path] = f
6767
else:
6868
f = self._cache[path]
@@ -74,10 +74,10 @@ def read(self, path):
7474

7575
try:
7676
f.seek(0)
77-
value = f.readline()
77+
value = f.read()
7878
except IOError:
7979
f = self.file_handle(path, 'w+', reopen=True)
80-
value = f.readline()
80+
value = f.read()
8181

8282
return value.strip()
8383

@@ -91,8 +91,6 @@ def write(self, path, value):
9191
f = self.file_handle(path, 'w+', reopen=True)
9292
f.write(value)
9393

94-
f.flush()
95-
9694

9795
# -----------------------------------------------------------------------------
9896
# Define the base class from which all other ev3dev classes are defined.

0 commit comments

Comments
 (0)