|
|
@@ -165,6 +165,40 @@ def main():
|
|
|
print('database already installed')
|
|
|
sys.exit(1)
|
|
|
|
|
|
+ elif action == 'migrate':
|
|
|
+ conn = sqlite3.connect(dbpath)
|
|
|
+ cursor = conn.cursor()
|
|
|
+ try:
|
|
|
+ cursor.execute(("select value "
|
|
|
+ "from config "
|
|
|
+ "where name = 'version'"))
|
|
|
+ row = cursor.fetchone()
|
|
|
+ min_version = row[0] if row else ''
|
|
|
+
|
|
|
+ except sqlite3.OperationalError as err:
|
|
|
+ strerr = str(err)
|
|
|
+ if "table" in strerr and "config" in strerr:
|
|
|
+ min_version = ''
|
|
|
+ else:
|
|
|
+ print(err)
|
|
|
+
|
|
|
+ from fourier.migrations import versions
|
|
|
+
|
|
|
+ cursor = conn.cursor()
|
|
|
+ for v, qrs in versions:
|
|
|
+ if v > min_version:
|
|
|
+ try:
|
|
|
+ for q in qrs:
|
|
|
+ cursor.execute(q)
|
|
|
+ cursor.execute()
|
|
|
+ except Exception as ex:
|
|
|
+ print('failed: {}'.format(ex))
|
|
|
+ conn.rollback()
|
|
|
+
|
|
|
+ elif action == 'connect':
|
|
|
+ subprocess.call(['sqlite3', dbpath])
|
|
|
+
|
|
|
+
|
|
|
elif args.entity == 'station':
|
|
|
if action == 'list':
|
|
|
stations_path = os.path.join('/var/fourier', device_id)
|
|
|
@@ -210,7 +244,6 @@ def main():
|
|
|
ffmpeg = subprocess.Popen([
|
|
|
'ffmpeg', '-f', 's16le', '-i', 'pipe:0',
|
|
|
'-ac', '1', '-ar', '24000',
|
|
|
- '-ab', '64k',
|
|
|
'-nostdin',
|
|
|
'-f', 'mp3',
|
|
|
filename,
|
|
|
@@ -286,12 +319,17 @@ def main():
|
|
|
|
|
|
totals[index] += len(data)
|
|
|
|
|
|
- if totals[index] % 10 == 0:
|
|
|
+ if totals[index] % 100 == 0:
|
|
|
scr.addstr(index + 1, 5, '{:01x} {:>4} {}\n\n'\
|
|
|
.format(index, stations[index], totals[index])
|
|
|
)
|
|
|
refresh = True
|
|
|
|
|
|
+ else:
|
|
|
+ errout = processes[index].stderr.read(4096)
|
|
|
+ scr.addstr(0, 0, 'ALL FUCKED')
|
|
|
+ refresh = True
|
|
|
+
|
|
|
k = scr.getch()
|
|
|
if k > -1:
|
|
|
key = int(chr(k), 16) if k > 0 else 0
|