Web · Wiki · Activities · Blog · Lists · Chat · Meeting · Bugs · Git · Translate · Archive · People · Donate

Commit 9d40da3034e3c4b11a18369e23e7d40f80b1712c

git voodoo
utils.py
(61 / 27)
  
15sg31DHV+k5BUR1dr/MHzZbtvvWygbryso9uv+VGTFxksnbPRd2lF
2i1fessNulxYf4z+fuZtzLa+JW2JuZTzp1wCPf+b5vP1euNaMTPQn2oeYhhga/3reqKqmOs4u
3SXWnQ7R+mZ6B9m+rxv5VB//vfl/cAA2MtH69RPt3H9g/+HnYygKk8R9K9HDjym+2KvMKNWf9
42uEgJ331yry8R/cbuiPC3HV/7ef/07+PG7YKXEN7D7bG2wkDPtSmpsYSDiAC1tXVHo+UqxOH
5i7ZcvTTtrLGx/k8+PDKwQeVk+3MRncbfx85Q64rsHES5P/usaqBlk2hL8z7Dx3OO65CWE7qk
6os3gmK6+5t+8F4reZ9TF+Xt726mAELl53py0OE1NdWYzwffF4g+Lnd8STEOCXDSxE3PudNn+
7mmW2c7JXqVCCrPHENleS2GRLDlsnKOy1i9dcymYZSC+1dCz5SFtAbZbWICullMhySQVyXs2S
83Aak75qpE3noGUFuu4dAAeJCHvrFkL7YXNKub0aWT1Qkm2S1YEMG6hW81nEcmxEl/Gd//auS
95X/2cb79fri+ULuDWg1sp3PMjCVdXQSKSQlerHWtWVOSk3zZeE9RtBod5aU/vyUt1s3NRgnf
10A3/+3OnK7dghedUzZ2RGbYLfL10D7HAl17KXNOzV786pF+SzzQwn/tzmNBE6KjbOBqq/lgT9
113msjryD3pykLzFpmdWpTzUe16JkH9XoDom2Yc/xXf+FzwzIzmOjmx9WJyrR2yqi1yJkEHae/
129wuP+fesufAEZ8um/TqvqzeYHozJETprQGGAn433JWcGd8qcY3rDLSf0aAAe6NHroy1u3Gvw
13OGmK0Bfvx9/zJRCxFao26p8uWWqxNL3CNjYwxsaMa82WGaNo/j3v+e/8HS1tjfGR6QL7yrWm
147QUtpo3+kTyTzYeyVlx6OP3R2XtFzysbw0Px+v2zjwnXvXOYZaBtjuSQTY4Esc6eQPgZ4yj/
15GumRnAZ+yVjBjGtAwGJLL+e7VnyoL3p0XVs4fFXbhqFVXdLgkSsAyvQEJzNgzDO3aNIflkle
16eMSSG1CUXNaxJpuVdckSiKOn1cwJdkWeBaW+uRORfiXDxYPzc8UiW99A4lB0asvnMdl3PovN
17vvo6oeDNk7icR5EOTn/db/G4sCCaJDWJsXPnWVhItRSXBn20cv2WL7btvXRrw46D1dl5zvL/
18BRqxf/a9fTf+5mQFW507VdlePCVc9Hue53/0uHhCjio/XqaTw2XJ/5b38vSxU73wsOzlqc8z
196A0fOVG1W0xPObhz1JrWO7d+0jONuvOqkdz8so5c7i6lO+8nUAt2ee129bJRQ7Dy3wmyYGxx
20C+W7idLkL9imS99hmf00jXvsnLH4s/Pj2FtnSr4R5U0cSW9gz0OA5rdck//6n8EFF5rMt47J
215bv/PZugsqr8+//ORTt2wfFYlYDCwLU2lXH352m7egs0rEVm8oASjceiAxc1101PyOIY/UMd
22CK6NiWz9br0HU5earopIsxU6uFuq/VRbT8C3mHT6WOV6EMeKAckfTEzw+03cXCUQ2jlYceV8
23RHYq5kbGMCLi/2wNiPfSBFqXYUm2gpw6QU7FSv5STFSQqz72ZWNtLr19c27Nqc6K9Vs3FtTk
245QTyykoinKZXx3rg8ft62KvOyAgLyHJ24ZZEBdqV5ofa40Pp4mKjWJgfbI1txswMPwsrK1Op
25PbsKF+6+7D0y57ieGJIP6Hpok7kn9cjMwzqDc5YFVzQ3JgZ5egiVx9YmgyoY6U7IywnhHdlf
26vAppXhA47VpX5OTU1iR4mUA347c8lLi5tcxKiegDPcGXPbPEOy66DSctUqSw8LDNlSKw6dI2
272eMp62wJsbO/elWbodX64yqm1GlVDiB6tgT
1#Copyright (c) 2011 Walter Bender
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# You should have received a copy of the GNU General Public License
9# along with this library; if not, write to the Free Software
10# Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
11
12import subprocess
13from StringIO import StringIO
14try:
15 OLD_SUGAR_SYSTEM = False
16 import json
17 json.dumps
18 from json import load as jload
19 from json import dump as jdump
20except (ImportError, AttributeError):
21 try:
22 import simplejson as json
23 from simplejson import load as jload
24 from simplejson import dump as jdump
25 except:
26 OLD_SUGAR_SYSTEM = True
27
28
29def json_load(text):
30 """ Load JSON data using what ever resources are available. """
31 if OLD_SUGAR_SYSTEM is True:
32 listdata = json.read(text)
33 else:
34 # strip out leading and trailing whitespace, nulls, and newlines
35 io = StringIO(text)
36 try:
37 listdata = jload(io)
38 except ValueError:
39 # assume that text is ascii list
40 listdata = text.split()
41 for i, value in enumerate(listdata):
42 listdata[i] = int(value)
43 return listdata
44
45
46def json_dump(data):
47 """ Save data using available JSON tools. """
48 if OLD_SUGAR_SYSTEM is True:
49 return json.write(data)
50 else:
51 _io = StringIO()
52 jdump(data, _io)
53 return _io.getvalue()
54
55
56def play_audio_from_file(file_path):
57 """ Audio media """
58 command_line = ['gst-launch', 'filesrc', 'location=' + file_path,
59 '! oggdemux', '! vorbisdec', '! audioconvert',
60 '! alsasink']
61 subprocess.call(command_line)