tarina

git clone https://git.tarina.org/tarina
Log | Files | Refs | README | LICENSE

commit 096ea39d0593da8e9382073d344ed18620094e12
parent b6f75bb6055bbb2860be28d3dad1fb7642305993
Author: rob <rob@tarina.org>
Date:   Mon, 20 Mar 2023 09:31:52 +0000

browser controll

Diffstat:
Msrv/tarinaserver.py | 36+++++++++---------------------------
Msrv/templates/index.html | 4++--
Mtarina.py | 34+++++++++++++++++++++-------------
3 files changed, 32 insertions(+), 42 deletions(-)

diff --git a/srv/tarinaserver.py b/srv/tarinaserver.py @@ -45,7 +45,8 @@ urls = ( app = web.application(urls, globals()) render = web.template.render('templates/', base="base") web.config.debug=False -store = web.session.DiskStore(basedir + '/sessions') +os.system('rm '+basedir+'/sessions/*') +store = web.session.DiskStore(basedir + '/sessions/') session = web.session.Session(app,store,initializer={'login': 0, 'user': '', 'backurl': '', 'bildsida': 0, 'cameras': [], 'reload': 0, 'randhash':''}) port=55555 @@ -146,28 +147,7 @@ def counttakes(filmname, filmfolder, scene, shot): class index: def GET(self): - interface=open('/dev/shm/interface','r') - menu=interface.readlines() - try: - selected=int(menu[0]) - except: - selected=0 - try: - name=menu[3].split(':')[1] - except: - name='' - try: - scene=menu[4].split(':')[1].split('/')[0] - except: - scene=1 - try: - shot=menu[5].split(':')[1].split('/')[0] - except: - shot=1 - try: - take=menu[6].split(':')[1].split('/')[0] - except: - take=1 + session.reload=1 films = getfilms(filmfolder) renderedfilms = [] unrenderedfilms = [] @@ -210,7 +190,7 @@ class index: session.reload = 1 raise web.seeother('/') if session.reload == 1: - time.sleep(0.5) + time.sleep(1) interface=open('/dev/shm/interface','r') menu=interface.readlines() try: @@ -219,6 +199,7 @@ class index: selected=0 try: name=menu[3].split(':')[1] + name=name.rstrip('\n') except: name='' try: @@ -234,9 +215,10 @@ class index: except: take=1 session.reload = 0 - - thumb="static/Videos/" + name + "/scene" + str(scene).zfill(3) + "/shot" + str(shot).zfill(3) + "/take" + str(take).zfill(3) + ".jpeg" - if os.path.exists(thumb) == False: + thumb="/static/Videos/"+name+"/scene"+str(scene).zfill(3)+"/shot"+str(shot).zfill(3)+"/take"+str(take).zfill(3)+".jpeg" + print(thumb) + if os.path.isfile(basedir+thumb) == False: + print(basedir+thumb) thumb='' return render.index(renderedfilms, unrenderedfilms, session.cameras, menu, selected,name,scene,shot,take,str,session.randhash,thumb) diff --git a/srv/templates/index.html b/srv/templates/index.html @@ -25,9 +25,9 @@ $for m in menu[3:]: $ y+=1 </div> $if thumb != '': - $ picture="static/Videos/" + name + "/scene" + str(scene).zfill(3) + "/shot" + str(shot).zfill(3) + "/picture" + str(take).zfill(3) + ".jpeg" -$else: $ picture="static/Videos/" + name + "/scene" + str(scene).zfill(3) + "/shot" + str(shot).zfill(3) + "/take" + str(take).zfill(3) + ".jpeg" +$else: + $ picture="static/Videos/" + name + "/scene" + str(scene).zfill(3) + "/shot" + str(shot).zfill(3) + "/picture" + str(take).zfill(3) + ".jpeg" <img width="99%" src="$picture?$randhash"/><br> <br> <h1>FILMS</h1> diff --git a/tarina.py b/tarina.py @@ -1095,8 +1095,10 @@ def main(): allfiles = os.listdir(filmfolder + filmname+'/.videos/') for origin in origin_videos: if origin not in allfiles: - os.remove(origin) - time.sleep(2) + try: + os.remove(origin) + except: + print('not exist') organize(filmfolder,'onthefloor') scenes, shots, takes = browse(filmname,filmfolder,scene,shot,take) scene = scenes @@ -1263,12 +1265,12 @@ def sendtoserver(host, port, data): def listenforclients(host, port, q): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - #s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - #s.settimeout(0) + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + s.bind((host,port)) + #s.settimeout(1) try: - s.bind((host,port)) print("listening on port "+str(port)) - s.listen(5) + s.listen(100) c, addr = s.accept() while True: data = c.recv(1024).decode() @@ -2017,9 +2019,14 @@ def organize(filmfolder, filmname): #print(s) unorganized_nr = int(s[4:7]) takename = filmfolder + filmname + '/' + i + '/' + p + '/take' + str(unorganized_nr).zfill(3) - origin=os.path.realpath(takename+'.mp4') - if origin != os.path.abspath(takename+'.mp4'): - origin_files.append(origin) + if '.mp4' in s: + origin=os.path.realpath(takename+'.mp4') + if origin != os.path.abspath(takename+'.mp4'): + origin_files.append(origin) + elif '.h264' in s: + origin=os.path.realpath(takename+'.h264') + if origin != os.path.abspath(takename+'.h264'): + origin_files.append(origin) if organized_nr == unorganized_nr: #print('correct') pass @@ -3489,10 +3496,12 @@ def flushbutton(): break def getbutton(lastbutton, buttonpressed, buttontime, holdbutton): - global i2cbuttons, serverstate, nextstatus, process, que, tarinactrl_ip, recording, onlysound + global i2cbuttons, serverstate, nextstatus, process, que, tarinactrl_ip, recording, onlysound, filmname, filmfolder, scene, shot, take, selected #Check controller pressed = '' + nextstatus = '' if process.is_alive() == False and serverstate == 'on': + buttonpressed = True nextstatus = que.get() if "*" in nextstatus: tarinactrl_ip = nextstatus.split('*')[1] @@ -3544,8 +3553,7 @@ def getbutton(lastbutton, buttonpressed, buttontime, holdbutton): take=1 elif nextstatus=="RETAKE": pressed="retake" - print(nextstatus) - nextstatus='' + #print(nextstatus) with term.cbreak(): val = term.inkey(timeout=0) if val.is_sequence: @@ -3613,7 +3621,7 @@ def getbutton(lastbutton, buttonpressed, buttontime, holdbutton): buttontime = time.time() holdbutton = pressed buttonpressed = True - if readbus == 255 and event == '': + if readbus == 255 and event == '' and nextstatus == '' : buttonpressed = False if float(time.time() - buttontime) > 0.2 and buttonpressed == True: if holdbutton == 'up' or holdbutton == 'down' or holdbutton == 'right' or holdbutton == 'left' or holdbutton == 'shutdown' or holdbutton == 'remove':