Skip to content

Commit

Permalink
gpio: flush output and strip input
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Mar 17, 2015
1 parent 552b66d commit 105cae5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions gpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import pdb

import logging
logging.basicConfig(level=logging.ERROR)
# logging.basicConfig(level=logging.ERROR)
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)


Expand Down Expand Up @@ -39,12 +40,13 @@ def except_hook(exctype, value, tb):
def _write(f, v):
log.debug("writing: {}: {}".format(f, v))
f.write(str(v))
f.flush()


def _read(f):
log.debug("Reading: {}".format(f))
f.seek(0)
return f.read()
return f.read().strip()


def _verify(function):
Expand All @@ -62,7 +64,7 @@ def wrapped(pin, *args, **kwargs):
_open[pin] = {
'value': open(pjoin(ppath, 'value'), FMODE),
'direction': open(pjoin(ppath, 'direction'), FMODE),
'drive': open(pjoin(ppath, 'drive'), FMODE),
# 'drive': open(pjoin(ppath, 'drive'), FMODE),
}
return function(pin, *args, **kwargs)
return wrapped
Expand Down

0 comments on commit 105cae5

Please sign in to comment.