ui and new startup file names

This commit is contained in:
Uriziel 2012-07-10 18:38:53 +02:00
parent 2858785d25
commit 24f097c709
5 changed files with 103 additions and 0 deletions

10
syncplay/ui/__init__.py Normal file
View File

@ -0,0 +1,10 @@
from syncplay.ui.gui import GraphicalUI
from syncplay.ui.consoleUI import ConsoleUI
def getUi(graphical = True):
if(graphical):
return GraphicalUI()
else:
ui = ConsoleUI()
ui.setDaemon(True)
ui.start()
return ui

45
syncplay/ui/consoleUI.py Normal file
View File

@ -0,0 +1,45 @@
'''
Created on 05-07-2012
@author: Uriziel
'''
from __future__ import print_function
import threading
class ConsoleUI(threading.Thread):
def __init__(self):
self.promptMode = threading.Event()
self.PromptResult = ""
self.promptMode.set()
self._syncplayClient = None
threading.Thread.__init__(self, name="ConsoleUI")
def addManager(self, manager):
self._syncplayClient = manager
def run(self):
try:
while True:
data = raw_input()
if not data:
break
data = data.rstrip('\n\r')
if(not self.promptMode.isSet()):
self.PromptResult = data
self.promptMode.set()
elif(self._syncplayClient):
self._syncplayClient.execute_command(data)
except:
raise
def promptFor(self, promptName = ">", message = ""):
print(message)
self.promptMode.clear()
print(promptName+": ", end='')
self.promptMode.wait()
return self.PromptResult
def showMessage(self, message):
print(message)

9
syncplay/ui/gui.py Normal file
View File

@ -0,0 +1,9 @@
'''
Created on 05-07-2012
@author: Uriziel
'''
class GraphicalUI(object):
def __init__(self):
pass

21
syncplay_mpc.py Normal file
View File

@ -0,0 +1,21 @@
#coding:utf8
from syncplay import client
from syncplay.players import mpc
from syncplay import utils
def prepareArguments():
args = utils.MPCConfigurationGetter()
args.prepareClientConfiguration()
return args.getClientConfiguration()
if __name__ == '__main__':
manager = None
try:
args = prepareArguments()
manager = client.Manager(args.host, args.port, args.name, lambda m: mpc.run_mpc(m, args.mpc_path, args.file, args._args))
manager.start()
finally:
if(manager): manager.stop()

18
syncplay_mplayer.py Normal file
View File

@ -0,0 +1,18 @@
#coding:utf8
from syncplay import client
from syncplay.players import mplayer
from syncplay import utils
def prepareArguments():
args = utils.ConfigurationGetter()
args.prepareClientConfiguration()
return args.getClientConfiguration()
if __name__ == '__main__':
args = prepareArguments()
args.args.extend(('-slave', '-msglevel', 'all=1:global=4'))
if(args.file): args.args.extend((args.file,))
manager = client.Manager(args.host, args.port, args.name, lambda m: mplayer.run_mplayer(m, 'mplayer', args.args))
manager.start()