Author Topic: Small script to see who is online on laanx  (Read 6949 times)

Aiwendil

  • Guest
Small script to see who is online on laanx
« on: October 19, 2009, 09:31:32 am »
Maybe someone is interested in this. It's just a short python script I wrote to check who is online on laanx.

Download

Screenshot:


How to install:
Just download the zip file and unpack it. To run the script you will need python around version 2.6, Python 3 won't work. If it's more commonly used I maybe convert the script. On linux I guess almost everyone will have python installed. You can check the version with "python --version" in a shell. After this all that is needed is a "chmod +x PS-PlayerS.py" on the file and then running it with "./PS-PlayerS.py". On windows most people will need to install python first. You can download python 2.6.3 here: http://www.python.org/download/ . After installing python all that should be needed to start the script is double-clicking it in a windows explorer. Sorry about Mac users...it was never tested on a mac and I have no idea if it works there. If someone is brave enough to try it out please let me know.

The script writes a log file and uses a simple configuration file. Both can be found at "~/.PStools/" in linux, at "C:\Documents and Settings\<username>\.PStools\" in windows XP and at "C:\Users\<username>\.PStools\" in vista.

The configuration file:
---
[config]
dialogwindowx = 990
height = 30
width = 20
frequency = 10.0
mainwindowx = 1109
mainwindowy = 0
dialogwindowy = 73
statuspage = http://laanx.fragnetics.com/index.php?page=char_stats
logfile = ~/.PStools/onlineplayer.log

[friends]
gms = Alerele Anqua Dahtess Dajoji Denorri Dohmo Eliseth Ingles Kander Katu Larizo Marathal Mektar Rhumdor Roberra Smekel Talad Taulus Tazen Venalan Vonor Xopal Zeetra Zordian
friends = Anaros Anumesa Caraick Dannae Detiey Domec Elvi Estava Hangatyr Hevore Ixala Jaguer Jaycol Kaisa Kitaja Lace Lhaa Lolitra Lucyenne Maudis Mordaan Morila Nixe Rigwyn Shew Stelanso Tinwei Vayl Zahii Zakrei
enemies = Paraya Aiwendil
---

[config] section
dialogwindowx: x coordinate where dialog windows appear in screen.
dialogwindowy: y coordinate where dialog windows appear in screen.
mainwindowx: x coordinate where the application window appear in screen.
mainwindowy: y coordinate where the application window appear in screen.
height: the number of lines in the text window showing the players online. By changing this you can change the size of the application.
width: how many characters fit in each line of the text window showing the players online. By changing this you can change the size of the application.
statuspage: the webadress of the status page of the server. Better not touch this.
logfile: Name and position of the logfile.
frequency: How long (in seconds) should the script wait before it checks the status page again.

[friends section]
gms: A list, separated by spaces, of GMs. Those names will show up blue in the application window
friends: A list, separated by spaces, of friends. Those names will show up green in the application window
enemies: A list, separated by spaces, of enemies. Those names will show up red in the application window

About the list:
A player will only show up in one of the lists. If a player is a friend and enemy he/she will only show up as friend. The priority is: Friends - Enemies - GMs - remaining players
The default GM list has the name from the PlaneShift Game Masters thread in the PS forum (from 18th of October 2009). The list must be maintained by the user if a new GM joins the team.

Known bugs in version 0.02
- The text window with the player names messes up sometimes. It's usually correct again after the next update of the player list. I guess some multi-threading problem.
- The server status is not really tested...laanx crashes not often enough. And I have no idea what happens if the server is in the "locked" status for example, I guess the script shows it as "ok" then.

Oh...and up to now this script hasn't formated any hard-disks...but you never know. I can't think of much that can go wrong, but that doesn't mean anything...you don't blame me if something goes terribly wrong. Oh, and I know the sourcecode is pretty ugly...you don't have to look at it if you are disturbed by this.

Changelog: 0.02
- Added a status label for laanx
- Added a status label for the status webpage
- Added Enemies and GMs lists
- Added Config menu
- Added Saving of current window position
- Added possiblitiy to specify where Dialogs appear on screen
- Added Menu items for the GMs and Enemies lists
- Empty names can no longer be added to the lists
- The same name can't be added again to a list

Raekh

  • Guest
Re: Small script to see who is online on laanx
« Reply #1 on: October 19, 2009, 11:20:34 am »
Hey, nice and handy tool there!

2 ideas, without having the slightest clue about effort=P :

1) How about making use of qt or gtk, for a nicer appearance?

2) What I always wanted to have for the ingame buddylist is an option to add custom info to anyone buddied. So how about this? The window could be split horizontally, to display custom info for friends/enemies? But since names in the general list currently are "merely list items", I suppose it would be much more easy to implement by those add/remove-friend or enemy windows? Ideally you would click a friend or enemy in the list, and have the info displayed at the bottom. Hm... maybe this would also require the window to be resizable.. =x

Nonetheless, good work! \\o//

Quote
enemies = Paraya Aiwendil
You enemy'd yourself? =o
xD

Aiwendil

  • Guest
Re: Small script to see who is online on laanx
« Reply #2 on: October 19, 2009, 12:03:40 pm »
Caarrie tested the script on a mac, and it seems to work. Thanks a lot for this. It's now included in http://www.planeshift.caarrie.org/PS_Buddy_list_mac.zip. To run it on a Mac X11 must be installed. The archive contains two applications:
  • PythonCheck - checks if the user has python installed
  • PS_Buddy_list - launches the script in a terminal with X11 (without X11 python will freeze)
The archive must be unzipped in the /Applications/PlaneShift folder in order to run at all.
Config and log files are in "~/.PStools" which is /Users/<username>/.PStools on a mac.

Caarrie also hosts the script at http://www.planeshift.caarrie.org/PS-PlayerS.py-0.02.zip now. Thanks for this. For future versions of the script (If I feel bored again and do something on it ;)) only the "PS-PlayerS.py" file must be replaced on a mac. The PythonCheck and PS_Buddy_list applications should continue to run as long as the script isn't renamed. Thanks lot for this again Caarrie.

(Tested on latest 10.5.8 with python 2.5.1)

Glad you like it so far Raekh.

1) How about making use of qt or gtk, for a nicer appearance?
Oh, I would love to use Qt. Tk/Tkinter is something completely new for me, never used it before. It is...a bit limited. Ok, not really limited but doesn't offer everything I'm used to from Qt. But the problem with Qt is that you will need the libraries and the python bindings installed. Tkinter comes with python, so the python interpreter is all windows users have to install. I guess I can ask linux users to go to the package manager and install Qt and PyQt, but I have no clue how much work that would be on windows. (and the same for gtk and PyGtk)

2) What I always wanted to have for the ingame buddylist is an option to add custom info to anyone buddied. So how about this? The window could be split horizontally, to display custom info for friends/enemies?
Yes, one of the planned features I want to add. No idea yet how I do it, but last name, race, gender, guild and comments for names a planned...if I find the patience to do it. ;)

Quote
enemies = Paraya Aiwendil
You enemy'd yourself? =o
xD

Hehe, needed some neutral names for the screenshot...I already removed all not publicly known alts from the friends list ;). Oh, and that reminds me, Xillix is missing in the default GM list...I have no idea how her GM char is called.


Raekh

  • Guest
Re: Small script to see who is online on laanx
« Reply #3 on: October 19, 2009, 01:11:42 pm »
Quote
I guess I can ask linux users to go to the package manager and install Qt and PyQt
Hm.. maybe there could be some check for qt and gtk, and in case of one of each this could be set in a conf file. The script would always start with checking for a definition in the conf first. If it is empty, it could check for qt/gtk on the system, if it is one of each it could make use of the according one. In addition there could be a third value, like "none", which would cause the script to start using tkinter (for Win and Mac)?
But then again, not really sure if checking such would entirely work without being root? Perhaps having a look at some of those plasmoids, that extract qt versions, could provide with some clue?


Quote
But the problem with Qt is that you will need the libraries and the python bindings installed
On the other hand, or for a start:
Forgetting about that loop to check for installed stuff, perhaps users could set such a variable themselves, in case they run KDE or Gnome, and have the required packages installed, for they could enjoy more eyecandy?

Anyway, most important question would be whether all this could be united simply and efficiently in one small script=P
Okay, that much about my current wild guessing.. ;)

Quote
Yes, one of the planned features I want to add.
Awesome o/

Rigwyn

  • Guest
Re: Small script to see who is online on laanx
« Reply #4 on: October 19, 2009, 01:26:36 pm »

It would be neat if it had a feature for adding user defined fields of several types .. like  int, text, boolean
 

Aiwendil

  • Guest
Re: Small script to see who is online on laanx
« Reply #5 on: October 19, 2009, 01:34:12 pm »
Aiwendil is lazy and keeps the Qt/Gtk ui in mind as a long term goal

It would be neat if it had a feature for adding user defined fields of several types .. like  int, text, boolean

It's a script, I provide the sourcode...one could say it's already possible to add these things ;). Ok, I got what you mean, I will look into it if it can be done easily.

LigH

  • Forum Legend
  • *
  • Posts: 7096
    • View Profile
Re: Small script to see who is online on laanx
« Reply #6 on: October 20, 2009, 02:03:09 am »
 :-\ Another one of such scripts...

I believe Peeg already made one in PHP, which scans the Laanx HTML status page.

Once I took this script and changed it so that it scans the XML server report instead.

Then there was this major hardware failure, and Laanx had to be moved.

Since then, the XML report file is not up-to-date anymore.

Many people already asked acraig to make it available again.

So my "PlaneShift Online Buddy List" always shows the server as "offline" now, for months at least - probably already a year.


 :'( acraig - do something!

Gag Harmond
Knight and Ambassador
The Royal House of Purrty

weltall

  • Associate Developer
  • Veteran
  • *
  • Posts: 1671
    • View Profile
    • http://weltall.heliohost.org
Re: Small script to see who is online on laanx
« Reply #7 on: October 20, 2009, 11:05:12 pm »
- The text window with the player names messes up sometimes. It's usually correct again after the next update of the player list. I guess some multi-threading problem.

this seems to fix the problem

Code: [Select]
--- /tmp/PS-PlayerS.py 2009-10-19 16:23:24.000000000 +0200
+++ ./PS-PlayerS.py 2009-10-21 05:55:59.000000000 +0200
@@ -637,17 +637,17 @@
             self.text.delete("1.0", Tkinter.END)
             # only write the sections that contain any names
             if len(friendslist) > 0:
-                self.text.insert(Tkinter.CURRENT, 'Friends:\n', "FriendsTopic")
-                self.text.insert(Tkinter.CURRENT, friendstext, "Friends")
+                self.text.insert(Tkinter.END, 'Friends:\n', "FriendsTopic")
+                self.text.insert(Tkinter.END, friendstext, "Friends")
             if len(enemieslist) > 0:
-                self.text.insert(Tkinter.CURRENT, 'Enemies:\n', "EnemiesTopic")
-                self.text.insert(Tkinter.CURRENT, enemiestext, "Enemies")
+                self.text.insert(Tkinter.END, 'Enemies:\n', "EnemiesTopic")
+                self.text.insert(Tkinter.END, enemiestext, "Enemies")
             if len(GMslist) > 0:
-                self.text.insert(Tkinter.CURRENT, 'GMs:\n', "GMsTopic")
-                self.text.insert(Tkinter.CURRENT, GMstext, "GMs")
+                self.text.insert(Tkinter.END, 'GMs:\n', "GMsTopic")
+                self.text.insert(Tkinter.END, GMstext, "GMs")
             if len(playerlist) > 0:
-                self.text.insert(Tkinter.CURRENT, 'Players:\n', "PlayersTopic")
-                self.text.insert(Tkinter.CURRENT, playertext, "Players")
+                self.text.insert(Tkinter.END, 'Players:\n', "PlayersTopic")
+                self.text.insert(Tkinter.END, playertext, "Players")
             self.text.config(state=Tkinter.DISABLED)
             # and restore the position of the scrollbar again
             self.text.yview(Tkinter.MOVETO, pos[0])

Akkaido Kivikar

  • Hydlaa Notable
  • *
  • Posts: 726
    • View Profile
Re: Small script to see who is online on laanx
« Reply #8 on: October 21, 2009, 01:44:49 am »
I like the enemies idea... that should be implemented in the buddy list in game, as there are several troublemakers I have on there so I know when to be on the lookout for OOC dramas in their usual haunts.

Looks nice as an application.

Nakem

  • Traveller
  • *
  • Posts: 42
    • View Profile
Re: Small script to see who is online on laanx
« Reply #9 on: November 08, 2009, 04:25:41 pm »
=== Update! See below. ===

If you don't mind, I did a Qt version of this. The interface is the same and it even uses the same configuration but there are binaries, too. So you don't have to install Python or Qt just download the archive and execute the binary. But there are only binaries for Linux and Windows. If anyone wants to compile the binary for Mac, just post here.

A screenshot for Linux:
And a screenshot for Windows:

There are three versions:
The complete archive with everything included. (23MB)(.tar.gz)  (.zip)
The windows binary and the Instructions. (9MB)(.tar.gz)  (.zip)
The linux binary and the Instructions. (14MB)(.tar.gz)  (.zip)

I hope you can use this anywhere... :)
« Last Edit: February 18, 2010, 03:17:37 pm by Nakem »

Aiwendil

  • Guest
Re: Small script to see who is online on laanx
« Reply #10 on: November 23, 2009, 10:43:24 am »
Okay, finished the new version of the script. This time I included a basic info dialog for players. The infos are saved in a xml file in the configuration directory.

Download



ChangeLog: 0.03
  • Added weltall's display patch
  • changed the logfile to include tags for friends, enemies and GMs for easier track down
  • Added a font selection dialog for the player window
  • Added a font selection dialog for the GUI
  • First letter of a name to add is always made uppercase while all other letters are made lowercase now and leading and trailing whitspaces are stripped
  • Added a PopUp Menu to add/remove player from the friends, enemies and GMs lists
  • Removed the "Add Friend" and "Remove Friend" buttons from the main windows (Functions still available through the menu)
  • Added a player info dialog (infos saved in a xml file in the config directory)
  • Added menu item and dialog to edit existing infos of characters
  • Added menu item and dialog to create infos for characters
  • Added a simple html documentation

Known Bugs in 0.03
  • The server status is not really tested...laanx crashes not often enough. And I have no idea what happens if the server is in the "locked" status for example, I guess the script shows it as "ok" then.
  • The script stops working for unknown reasons on windows without an error message. Hard for me to track down because I usually don't run windows. I guess it's something with the timeout when looking up the status page.
  • Font messes up sometimes, no idea why

Sorry, the script is again untested on a Mac. To try it out follow the instructions here and also download the new archive. Then replace the "PS-playerS.py" file in the "PS_Buddy_list_mac.zip" archive with the new version. If I haven't messed up too bad it should still work.

And a big thanks to weltall. The patch works pretty fine. Not really sure why the current cursor position is not always the end of the text box but the way weltall suggests to do is more clean anyway.

Getting rid of the console in windows
And last but not least a short guide for our beloved windows users how to get rid of the console window of python for the script. It's adjusted to windows users needs, namely uses the mouse as much as possible and needs the keyboard only at one point. I hope it's understandable.
  • Open a windows explorer and navigate to the folder the script is saved in.
  • Right-click the script and hold the right button while dragging it in the same folder.
  • Select the "Create Shortcuts here" option to create a shortcut to the script.
  • Open another windows explorer and find the directory Python is installed in (For me "C:\Python26").
  • Go back to the created shortcut and right-click it.
  • Select "Properties" to get the property dialog for the shortcut.
  • Go to the "Target" entry box in the properties of the shortcut. Now add the folder python is installed in and a pythonw.exe in front of the script name. (For me "C:\Python26\pythonw.exe"). Then press "ok".
  • Double click the shortcut if you want to run the script without a console window. A double click on the script will still start the script with the console window.

LigH

  • Forum Legend
  • *
  • Posts: 7096
    • View Profile
Re: Small script to see who is online on laanx
« Reply #11 on: November 23, 2009, 11:22:31 am »
Should also work by right-clicking a *.py file, clicking the "Open with..." entry, adding "pythonw.exe" to the list of applications and selecting it, and checking the box "Always run with...".

Gag Harmond
Knight and Ambassador
The Royal House of Purrty

Aiwendil

  • Guest
Re: Small script to see who is online on laanx
« Reply #12 on: November 23, 2009, 12:47:32 pm »
Sure, with the problem that all python scripts are run without a console then...Not sure if that is wanted for all. There are a lot script that doesn't have any GUI at all.

weltall

  • Associate Developer
  • Veteran
  • *
  • Posts: 1671
    • View Profile
    • http://weltall.heliohost.org
Re: Small script to see who is online on laanx
« Reply #13 on: November 23, 2009, 02:21:35 pm »
what about a guild entry too? :)

Aiwendil

  • Guest
Re: Small script to see who is online on laanx
« Reply #14 on: November 23, 2009, 02:40:36 pm »
what about a guild entry too? :)

There is one ;)