-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·76 lines (60 loc) · 2.3 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python2
import sys
import os
import datetime
sys.path.append('./kivymd')
from kivymd.theming import ThemeManager
from kivymd.selectioncontrols import MDCheckbox
from kivymd.navigationdrawer import MDNavigationDrawer, NavigationDrawerHeaderBase
from kivymd.material_resources import DEVICE_TYPE
from kivymd.list import ILeftBody, ILeftBodyTouch, IRightBodyTouch, BaseListItem
from kivymd.label import MDLabel
from kivymd.dialog import MDDialog
from kivymd.date_picker import MDDatePicker
from kivymd.button import MDIconButton
from kivy.lang import Builder
from kivy.app import App
import subprocess, shlex
import sqlite3
# from kivy.metrics import dp
# from kivy.properties import ObjectProperty
# from kivy.uix.image import Image
# from kivymd.bottomsheet import MDListBottomSheet, MDGridBottomSheet
# from kivymd.snackbar import Snackbar
# from plyer.facades import Orientation
# from kivymd.time_picker import MDTimePicker
from upload import TransferData
class SimpleApp(App):
theme_cls = ThemeManager()
theme_cls.theme_style = 'Dark'
theme_cls.primary_palette = 'Indigo'
def build(self, ):
main_widget = Builder.load_file('./mdkvfile.kv')
self.conn = sqlite3.connect('database.db')
self.dpbox = TransferData()
try:
self.conn.execute(''' CREATE TABLE vox
(username text, timestamp text unique, data text);
''')
except:
pass
return main_widget
def insertFile(self, fileData, username):
query = '''INSERT INTO vox
(username, timestamp, data) VALUES (?,?,?)'''
cur =self.conn.cursor()
cur.execute(query, (str(username), str(datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S')), fileData))
self.conn.commit()
def send(self, fileName):
# print(os.path.basename(fileName))
return self.dpbox.upload_file(fileName, '/test_dropbox/' + os.path.basename(fileName))
# def generateLink(self, fileName):
# self.dpbox.
def record(self, username):
p = subprocess.Popen(shlex.split('python2 soundRecord.py %s' % username))
p.wait()
with open('output.wav') as f:
a = f.read()
self.insertFile(a, username)
if __name__ == '__main__':
SimpleApp().run()