add pynma and postgres
--- /dev/null
+++ b/.gitmodules
@@ -1,1 +1,4 @@
+[submodule "pynma"]
+ path = pynma
+ url = git://github.com/uskr/pynma.git
--- a/README.txt
+++ /dev/null
@@ -1,1 +1,1 @@
-ffmpeg from http://ffmpeg.zeranoe.com/builds/
+
--- /dev/null
+++ b/pynma
--- a/scannr.py
+++ b/scannr.py
@@ -1,26 +1,36 @@
-import logging
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s\t%(levelname)s\t%(message)s')
-
import snd
import time
from datetime import date
import threading
from pydispatch import dispatcher
import wave
+import psycopg2
+import sys,os
+
+
+sys.path.insert(0, os.path.join(os.path.dirname(__file__) or '.', 'pynma'))
+import pynma
filename = "demo.wav"
-MIN_LENGTH = 90000
+nma = pynma.PyNMA( "apikey(s)", "developerkey")
+conn = psycopg2.connect("dbname=test user=postgres")
def worker(filename):
+
"""thread worker function
http://www.doughellmann.com/PyMOTW/threading/
+
https://github.com/uskr/pynma
-ffmpeg -i 2012-09-29-1348911268.34-demo.wav -ar 8000 -ab 4.75k test.3gp
-http://stackoverflow.com/questions/2559746/getting-error-while-converting-wav-to-amr-using-ffmpeg
-"""
+
+http://stackoverflow.com/questions/1092531/event-system-in-python """
print 'Worker for '+filename
-
+ """nma.push(application, event, description, (opt) url,)"""
+ """http://initd.org/psycopg/docs/usage.html"""
+ #cur = conn.cursor()
+ #cur.execute("INSERT INTO test (num, data) VALUES (%s, %s)",(100, "abc'def"))
+ #conn.commit()
+ #cur.close()
+
return
def filenameMaker():
@@ -30,18 +40,16 @@
def record_to_async_file():
"Records from the microphone and outputs the resulting data to `path`"
sample_width, data = snd.record()
- print str(len(data))
- if len(data) > MIN_LENGTH:
- data = snd.pack('<' + ('h'*len(data)), *data)
- path = filename
- dispatcher.send( signal='FILE_CREATED', sender=filename, filename=filename)
- wf = wave.open(path, 'wb')
- wf.setnchannels(1)
- wf.setsampwidth(sample_width)
- wf.setframerate(snd.RATE)
- wf.writeframes(data)
- wf.close()
- print("done - result "+str(len(data))+" frames written to "+path)
+ data = snd.pack('<' + ('h'*len(data)), *data)
+ path = filename
+ dispatcher.send( signal='FILE_CREATED', sender=filename, filename=filename)
+ wf = wave.open(path, 'wb')
+ wf.setnchannels(1)
+ wf.setsampwidth(sample_width)
+ wf.setframerate(snd.RATE)
+ wf.writeframes(data)
+ wf.close()
+ print("done - result written to "+path)
dispatcher.connect( filenameMaker, signal='SND_STARTED', sender=dispatcher.Any )
dispatcher.connect( worker, signal='FILE_CREATED', sender=dispatcher.Any )
@@ -49,4 +57,3 @@
while True:
print "ready to record"
record_to_async_file()
-
--- a/trunklog.php
+++ /dev/null
@@ -1,31 +1,1 @@
-<?php
-// http://www.unitrunker.com/logs.html
-/*
-Timestamp as YYYYMMDDHHMMSS
-Site number in unformatted decimal
-Action: Call, Leaves, Joins, Login, Logout, Drop, Add, Busy, Deny, Kill
-Source type I or G
-Source ID in unformatted decimal
-Target type I or G
-Target ID in unformatted decimal
-Channel number in unformatted decimal
-Call Type*/
-$row = 0;
-echo "<table>";
-if (($handle = fopen("C:\Users\Madoka\AppData\Roaming\UniTrunker\S00000001\UniTrunker-20120411.LOG", "r")) !== FALSE) {
- while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
-
- if ($row > 0 && count($data) == 9) {
-
- echo "<tr>";
- for ($c=0; $c < count($data); $c++) {
- echo '<td>'.$data[$c] . "</td>\n";
- }
- echo "</tr>";
- }
- $row++;
- }
- fclose($handle);
-}
-echo "</table>";
-?>
+