[Jahshaka-cvs] jah/jahtools/jcapture jcapture_admin.py,1.2,1.3
Status: Beta
Brought to you by:
jahshaka
From: Charles Y. <lil...@us...> - 2007-03-22 09:37:10
|
Update of /cvsroot/jahshaka/jah/jahtools/jcapture In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv8815 Modified Files: jcapture_admin.py Log Message: + Yet another silly (and misnamed) admin addition Index: jcapture_admin.py =================================================================== RCS file: /cvsroot/jahshaka/jah/jahtools/jcapture/jcapture_admin.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- jcapture_admin.py 21 Mar 2007 09:17:47 -0000 1.2 +++ jcapture_admin.py 22 Mar 2007 09:37:06 -0000 1.3 @@ -2,6 +2,7 @@ import bootstrap import Tkinter +import tkFileDialog import urllib2 import sys import os @@ -153,6 +154,80 @@ def play( self ): os.spawnvpe( os.P_NOWAIT, "jbatch_tk", [ "jbatch_tk", "oml:http://" + self.server + ":" + str( self.port ) + self.uri ], os.environ ) +class local_audio( Tkinter.Frame ): + def __init__( self, master ): + Tkinter.Frame.__init__( self, master ) + + self.running = False + self.server = "localhost" + self.port = 51032 + self.dir = os.environ[ "HOME" ] + self.secure = Tkinter.IntVar( ) + self.secure.set( 0 ) + self.title = "Audio Player" + + if self.valid( ): + self.running = fetch_info( self.server + ":" + str( self.port ) ) != { } + frame = Tkinter.Frame( master ) + frame.pack( fill = Tkinter.BOTH ) + Tkinter.Label( frame, text = self.title ).pack( side = Tkinter.TOP, fill = Tkinter.NONE, anchor = Tkinter.NW ) + self.b_browse = Tkinter.Button( frame, text = "Browse", command = self.browse ) + self.b_browse.pack( side = Tkinter.RIGHT, anchor = Tkinter.E ) + self.b_stop = Tkinter.Button( frame, text = "Stop", command = self.stop ) + self.b_stop.pack( side = Tkinter.RIGHT, anchor = Tkinter.E ) + self.b_start = Tkinter.Button( frame, text = "Start", command = self.start ) + self.b_start.pack( side = Tkinter.RIGHT, anchor = Tkinter.E ) + self.b_home = Tkinter.Button( frame, text = "Home", command = self.home ) + self.b_home.pack( side = Tkinter.RIGHT, anchor = Tkinter.E ) + self.b_secure = Tkinter.Checkbutton( frame, text = "Secure", variable = self.secure ) + self.b_secure.pack( side = Tkinter.LEFT ) + self.show_state( ) + + def valid( self ): + return True + + def show_state( self ): + if self.running: + self.b_browse.config( state = Tkinter.NORMAL ) + self.b_home.config( state = Tkinter.DISABLED ) + self.b_stop.config( state = Tkinter.NORMAL ) + self.b_start.config( state = Tkinter.DISABLED ) + self.b_secure.config( state = Tkinter.DISABLED ) + else: + self.b_browse.config( state = Tkinter.DISABLED ) + self.b_home.config( state = Tkinter.NORMAL ) + self.b_stop.config( state = Tkinter.DISABLED ) + self.b_start.config( state = Tkinter.NORMAL ) + self.b_secure.config( state = Tkinter.NORMAL ) + + def start( self ): + command = "jbatch_server --conform filter:conform image=0 audio=1 filter:resampler --store openal:" + os.system( command ) + command = "jcapture --port=" + str( self.port ) + " --title=\"" + self.title + "\" --device= --extension=render --uri=" + if self.secure.get( ) == 1: + command += " --host=" + self.server + command += " --index=/jah/list?dir=" + self.dir + os.system( command ) + self.running = True + self.show_state( ) + + def stop( self ): + try: + self.running = False + self.show_state( ) + os.system( "jbatch_client shutdown" ) + urllib2.urlopen( "http://" + self.server + ":" + str( self.port ) + "/jah/quit" ) + except Exception, e: + pass + + def home( self ): + dir = tkFileDialog.askdirectory( parent = self.master, initialdir = self.dir ) + if dir != "": + self.dir = dir + + def browse( self ): + os.spawnvpe( os.P_NOWAIT, "firefox", [ "firefox", "http://" + self.server + ":" + str( self.port ) ], os.environ ) + """Provide basic access to a remote jcapture server""" class remote( Tkinter.Frame ): def __init__( self, master, server ): @@ -164,8 +239,6 @@ frame.pack( fill = Tkinter.BOTH ) if "title" in self.info.keys( ): text = self.info[ "title" ] - if "capture" in self.info.keys( ) and self.info[ "capture" ] != "": - text += "\n" + "http://" + self.server + self.info[ "capture" ] Tkinter.Label( frame, text = text ).pack( side = Tkinter.TOP, fill = Tkinter.NONE, anchor = Tkinter.NW ) else: Tkinter.Label( frame, text = self.server ).pack( side = Tkinter.TOP ) @@ -223,7 +296,7 @@ self.bprobe.config( state = Tkinter.DISABLED ) if self.server.get( ) == "localhost": - for type in [ local_ivtv, local_dv ]: + for type in [ local_ivtv, local_dv, local_audio ]: node = type( self.nodes ) if node.valid( ): node.pack( side = Tkinter.LEFT ) |