]> ToastFreeware Gitweb - gregoa/zavai.git/commitdiff
Merge branch 'master' of ssh://ciapino/root/zavai
authorEnrico Zini <enrico@enricozini.org>
Thu, 18 Jun 2009 05:13:27 +0000 (13:13 +0800)
committerEnrico Zini <enrico@enricozini.org>
Thu, 18 Jun 2009 05:13:27 +0000 (13:13 +0800)
src/zavai
zavai/__init__.py
zavai/audio.py
zavai/gps.py

index 2be32d4a13b2c16cb141dcd379ec35db1069746c..be527519cafbd3f4dfe5c21e93b3b7bb25a9b410 100755 (executable)
--- a/src/zavai
+++ b/src/zavai
@@ -26,7 +26,7 @@ import dbus
 import dbus.mainloop.glib
 import zavai
 
-VERSION="0.1"
+VERSION=zavai.VERSION
 
 class Parser(optparse.OptionParser):
     def __init__(self, *args, **kwargs):
index 147c5819f555d047ab08a023700ada9498b8cbea..4d48db96e60671899354fa5e1e6b16a74627c685 100644 (file)
@@ -25,6 +25,8 @@ from app import Zavai, Applet
 from gps import GPS, GPX
 from audio import Audio, Recorder
 
+VERSION="0.1"
+
 def warn(*args):
     import sys
     sys.stderr.write(" ".join(map(str, args)) + "\n")
index 15255fcba6ed05f840461a9f75c17a26b2c76739..9d7835e89488405e7dd3acd59bfae9ae90602700 100755 (executable)
@@ -170,31 +170,39 @@ class Audio(zavai.Service):
 #            ["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:
index 8be490ab45abc86a360c70cad6a8f013816fd54f..2b73da7cc917ac10b61f9ac411bd2dc78889c999 100755 (executable)
@@ -236,7 +236,7 @@ class GPX(zavai.Service):
         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
@@ -252,7 +252,7 @@ class GPX(zavai.Service):
     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"?>
@@ -261,7 +261,7 @@ class GPX(zavai.Service):
     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()