def player_worker(args): while True: # Fetch the most recent item in the queue. # Blocks the current greenlet until either # it gets a new item or timeout lapses try: # XXX: Raises queue.Empty exception after # timeout (thus the try block) pl_item = q.get(timeout=10) #print "QUEUE ITEM PICKED: %s" % pl_item # XXX: Not your usual subprocess. We're using # the gevent_subprocess module. Blocks only # this greenlet until the process (playlist # item) ends. command = ["vlc", pl_item, "--play-and-exit", "--quiet"] if args.fullscreen: command.append("--fullscreen") subprocess.call(command) except queue.Empty: # Resume loop continue
def hook(self, name, *args): """ Executes a given hook. All additional arguments are passed to the hook as script arguments. :param name: Hook name (like session.pre-up) """ script = self.hooks.get(name, None) if not script: return # Execute the registered hook logger.debug("Executing hook '%s' via script '%s'..." % (name, script)) gevent_subprocess.call([script] + [str(x) for x in args])
def player_worker(): while True: # Fetch the most recent item in the queue. # Blocks the current greenlet until either # it gets a new item or timeout lapses try: # XXX: Raises queue.Empty exception after # timeout (thus the try block) pl_item = q.get(timeout=10) #print "QUEUE ITEM PICKED: %s" % pl_item # XXX: Not your usual subprocess. We're using # the gevent_subprocess module. Blocks only # this greenlet until the process (playlist # item) ends. subprocess.call(["vlc", "--play-and-exit", "--quiet", "--fullscreen", pl_item]) except queue.Empty: # Resume loop continue
def test_call(): print 'call ls -l /' subprocess.call('ls /'.split(' ')) print 'done'