Added tool to kill GGS subsystems, added ggs_coordinator:get_all_players

This commit is contained in:
Jonatan Pålsson 2011-02-25 20:46:45 +01:00
parent bf972de0b5
commit a20f9351d4
5 changed files with 191 additions and 6 deletions

View file

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<glade-interface>
<!-- interface-requires gtk+ 2.16 -->
<!-- interface-naming-policy project-wide -->
<widget class="GtkWindow" id="window1">
<property name="width_request">561</property>
<property name="height_request">521</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;span size="x-large"&gt;GGS Killtrolpanel&lt;/span&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="pixbuf">kill_process_icon.jpg</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="homogeneous">True</property>
<child>
<widget class="GtkButton" id="playersButton">
<property name="label" translatable="yes">All players</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_playersButton_clicked"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="coordinatorButton">
<property name="label" translatable="yes">Coordinator</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_coordinatorButton_clicked"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="dispatcherButton">
<property name="label" translatable="yes">Dispatcher</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_dispatcherButton_clicked"/>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="coordinatorBackupButton">
<property name="label" translatable="yes">Coordinator backup</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_coordinatorBackupButton_clicked"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="tablesButton">
<property name="label" translatable="yes">All tables</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_tablesButton_clicked"/>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="gamevmButton">
<property name="label" translatable="yes">All GameVMs</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_gamevmButton_clicked"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -0,0 +1,44 @@
#!/usr/bin/env python
import sys, socket, thread, gobject, getpass, time, os
try:
import pygtk
pygtk.require("2.16")
except:
pass
try:
import gtk
import gtk.glade
except:
sys.exit(1)
class GGSKPanel:
def __init__(self):
#Set the Glade file
self.gladefile = "ggskpanel.glade"
self.wTree = gtk.glade.XML(self.gladefile, "window1")
#Create our dictionay and connect it
dic = { "on_window1_destroy_event" : gtk.main_quit
,"on_coordinatorButton_clicked" : lambda x: self.terminateProcess("ggs_coordinator")
,"on_coordinatorBackupButton_clicked" :\
lambda x: self.terminateProcess("ggs_coordinator_backup")
,"on_dispatcherButton_clicked" : lambda x: self.terminateProcess("ggs_dispatcher")
}
self.wTree.signal_autoconnect(dic)
self.wTree.get_widget("window1").show()
def terminateProcess(self, process):
os.system("echo \"exit(whereis(%s), 'Bye bye').\" | erl_call -sname ggs -e" % process)
def setStatus(self, msg):
self.wTree.get_widget("statusbar").push(0, msg)
if __name__ == "__main__":
chat = GGSKPanel()
gobject.threads_init()
gtk.main()

View file

@ -25,11 +25,11 @@ class GGSChat:
thread.start_new_thread(self.listenChat, ())
thread.start_new_thread(self.luserCheck, ())
#Create our dictionay and connect it
dic = {"on_window1_destroy_event" : gtk.main_quit
, "on_sendButton_clicked" : lambda x: self.chat()
, "on_entry_activate" : lambda x : self.chat()
, "on_nickBox_activate" : lambda x : self.changeNick()
, "on_chatBox_focus" : lambda x, y: self.wTree.get_widget("entry").grab_focus()
dic = {"on_window1_destroy_event" : gtk.main_quit
, "on_sendButton_clicked" : lambda x: self.chat()
, "on_entry_activate" : lambda x : self.chat()
, "on_nickBox_activate" : lambda x : self.changeNick()
, "on_chatBox_focus" : lambda x, y: self.wTree.get_widget("entry").grab_focus()
}
self.wTree.signal_autoconnect(dic)

View file

@ -2,7 +2,7 @@
%% API Exports
-export([start_link/0, stop/1, join_table/1, create_table/1, join_lobby/0,
respawn_player/2, respawn_table/1, remove_player/2]).
respawn_player/2, respawn_table/1, remove_player/2, get_all_players/0]).
%% gen_server callback exports
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
@ -53,6 +53,9 @@ remove_player(_From, _Player) ->
%gen_server:cast(ggs_coordinator, {remove_player, Player}).
ggs_logger:not_implemented().
get_all_players() ->
gen_server:call(?SERVER, get_all_players).
%% Just to shorten the name
back_up(State) ->
ggs_coordinator_backup:back_up(State),
@ -99,6 +102,9 @@ handle_call({create_table, {force, TableID}}, From, State) ->
back_up(NewState),
{reply, {ok, TableID}, NewState};
handle_call(get_all_players, _From, State) ->
{reply, State#co_state.players, State};
handle_call(_Message, _From, State) ->
{noreply, State}.