Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions ev3dev/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ def file_handle(self, path, mode, reopen=False):
"""Manages the file handle cache and opening the files in the correct mode"""

if path not in self._cache:
f = open(path, mode)
f = open(path, mode, 0)
self._cache[path] = f
elif reopen:
self._cache[path].close()
f = open(path, mode)
f = open(path, mode, 0)
self._cache[path] = f
else:
f = self._cache[path]
Expand All @@ -74,10 +74,10 @@ def read(self, path):

try:
f.seek(0)
value = f.readline()
value = f.read()
except IOError:
f = self.file_handle(path, 'w+', reopen=True)
value = f.readline()
value = f.read()

return value.strip()

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

f.flush()


# -----------------------------------------------------------------------------
# Define the base class from which all other ev3dev classes are defined.
Expand Down