# ["arecord", "-D", "hw", "-f", "cd", "-r", "8000", "-t", "wav", "-V", "stereo", "/dev/null"])
def save_scenario(self, name):
- res = subprocess.call(["alsactl", "store", "-f", name])
- if res != 0:
- raise RuntimeError("Saving audio scenario to '%s' failed" % name)
+ while True:
+ res = subprocess.call(["alsactl", "store", "-f", name])
+ if res == 0: return
+ if res > 0:
+ raise RuntimeError("Saving audio scenario to '%s' failed" % name)
def load_scenario(self, name):
- res = subprocess.call(["alsactl", "restore", "-f", name])
- if res != 0:
- raise RuntimeError("Loading audio scenario '%s' failed with error %d" % (name, res))
+ while True:
+ res = subprocess.call(["alsactl", "restore", "-f", name])
+ if res == 0: return
+ if res > 0:
+ raise RuntimeError("Loading audio scenario '%s' failed with error %d" % (name, res))
def mixer_set(self, name, *args):
args = map(str, args)
- res = subprocess.call(["amixer", "-q", "set", name] + args)
- if res != 0:
- raise RuntimeError("Setting mixer '%s' to %s failed with error %d" % (name, " ".join(args), res))
+ while True:
+ res = subprocess.call(["amixer", "-q", "set", name] + args)
+ if res == 0: return
+ if res > 0:
+ raise RuntimeError("Setting mixer '%s' to %s failed with error %d" % (name, " ".join(args), res))
def mixer_set_many(self, *args):
"""Perform many mixer set operations via amixer --stdin"""
- proc = subprocess.Popen(["amixer", "-q", "--stdin"], stdin=subprocess.PIPE)
cmd_input = []
for k, v in args:
cmd_input.append("sset " + repr(k) + " " + repr(v))
- (out, err) = proc.communicate(input="\n".join(cmd_input))
- res = proc.wait()
- if res != 0:
- raise RuntimeError("Setting mixer failed with error %d" % res)
+ while True:
+ proc = subprocess.Popen(["amixer", "-q", "--stdin"], stdin=subprocess.PIPE)
+ (out, err) = proc.communicate(input="\n".join(cmd_input))
+ res = proc.wait()
+ if res == 0: return
+ if res > 0:
+ raise RuntimeError("Setting mixer failed with error %d" % res)
#class Hub:
self.trackpoint()
def start_track(self, tstamp = None, basename = None):
- if basename is None:
+ if basename is not None:
self.basename = basename
elif tstamp is not None:
# Compute basename for output files
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<trk>
- <trkseg>""" % VERSION
+ <trkseg>""" % zavai.VERSION
self.wpt = open(self.basename + "-wpt.gpx", "wt")
print >>self.wpt, """<?xml version="1.0" encoding="UTF-8"?>
creator="audiomap %s"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.topografix.com/GPX/1/0"
- xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">""" % VERSION
+ xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">""" % zavai.VERSION
self.wpt_seq = 1;
self.notify_activity_monitors()