Dirk Meyer wrote:
Mathias Weber wrote:
I took a look at the code and you added a comment about yielding in
the scummvm part. You are right it would be better if i don't have to
wait for the scummvm but how to yield here? since i need to give back
a list, or i don't get the list of games? Or did I understand
something wrong?
roms does not return a list, it creates a menu and that can wait. The
return itself is not used. I can do that if you want.
ok i just start a new Process and create the menu when it finishes.
I tried to look how to disable a joystick plugin if it was running but i
couldn't get how i could achieve this. First I would need to check if a
joystick plugin is active if yes i have to stop it and restart it when
the emulator is finished.
What I have seen so far is that I can activate and deactivate a plugin
with plugin.activate and plugin.deactivate. But how do I check if a
plugin is running? Do i just use getbyname? Would you use
plugin.activate/deactivate or add a method to the joystick to let the
plugin release the interface?
thanks
Mathias
Index: freevo_trunk/ui/src/games/plugins/scummvm.py
===================================================================
--- freevo_trunk/ui/src/games/plugins/scummvm.py (revision 9420)
+++ freevo_trunk/ui/src/games/plugins/scummvm.py (working copy)
@@ -36,7 +36,6 @@
# python imports
import logging
-from subprocess import Popen, PIPE
# kaa imports
import kaa.utils
@@ -97,25 +96,54 @@
"""
romlist = []
finished = False
+ parent = None
+ items = None
+ list_started = False
+ def completed(self, exit_code):
+ """
+ The ScummVM returned all configured games, append them to the menu.
+ Add an entry for the ScummVM it self to configure new games or the
+ ScummVM it self.
+ """
+ if self.items == None:
+ self.items = []
+ self.items.append(ScummvmItem(self.parent, 'ScummVM', ''))
+ self.parent.pushmenu(Menu(config.name, self.items, type='games'))
+ self.parent = None
+
+
+ def get_stdout(self, data):
+ """
+ Receive updates from the stdout of the ScummVM. Wait with parsing
+ until a line that starts with '---'
+ """
+ if self.items == None:
+ if data.startswith('---'):
+ self.items = []
+ return
+ # since list was started there are now the configured games coming
+ name = data[:data.find(' ')]
+ description = data[data.find(' '):].strip()
+ self.items.append(ScummvmItem(self.parent, description, name))
+
+
def roms(self, parent):
"""
Show all games.
"""
+ # allready waiting for updated menu?
+ if self.parent != None:
+ return
+ self.parent = parent
+ self.items = None
items = []
- # get list of scummvm
- pipe = Popen([config.bin, '-t'], stdout=PIPE).stdout
- # FIXME: this blocks the notifier loop. Maybe better use
- # kaa.notifier.Process and yield_execution.
- for item in pipe.readlines()[2:]:
- name = item[:item.find(' ')]
- description = item[item.find(' '):].strip()
- items.append(ScummvmItem(parent, description, name))
- # append the scummvm it self, to configure new games
- items.append(ScummvmItem(parent, 'ScummVM', ''))
- parent.pushmenu(Menu(config.name, items, type='games'))
+ # get list of scummvm start a new process
+ self.child = kaa.notifier.Process(config.bin)
+ self.child.start('-t').connect(self.completed)
+ self.child.signals['stdout'].connect(self.get_stdout)
+
-
def items(self, parent):
"""
Return the main menu item.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel