[PY] Phoenix MUS Interface
Hi! I have written a full Python interface to the Phoenix MUS server, and am releasing it here now.
What's this good for?
If you're writing an application/script/anything in Python, you will be able to use this module to interact with your Phoenix server. All the MUS commands currently in the emulator have been implemented.
How do I use it?
You must create a Phoenix class and pass two arguments -- the server host, and port. It will not connect immediately, however it will once you issue a command. You can edit the timeout limit by modifying the Phoenix.timeout variable to an integer of your choice.
Any docs?
All functions have a docstring, so you can take a peek at the source if you want. Soon, I will be posting proper documentation up at this module's PyPI page.
Can you give me an example of how to use this?
Code:
import phoenix
emu = phoenix.Phoenix('localhost', 1233)
emu.hotel_alert('hello everyone')
emu.unload_room(55)
emu.update_catalogue()
emu.sock.close()
Of course, that's not how you should be using it. Embed it in your applications!
Where do I download it?
You can find the full Python package at the module's PyPI page: https://pypi.python.org/pypi/phoenix
You can also install the package with pip or easy_install:
Code:
pip install phoenix
easy_install phoenix
Please report any bugs you find, and give me any suggestions you'd like implemented. There's not much to do in regards with adding more commands, since they are all in the emulator. I will, of course, add support for any that appear in future Phoenix releases.
Enjoy!
Re: [PY] Phoenix MUS Interface
Re: [PY] Phoenix MUS Interface
Quote:
Originally Posted by
Thekguy
Anny screenshots?
I'm not completely sure on how I'm supposed to provide screenshots of a Python library. If you just want proof it works, here:
http://puu.sh/2quYk
Re: [PY] Phoenix MUS Interface
Quote:
Originally Posted by
Funixeh
I'm not completely sure on how I'm supposed to provide screenshots of a Python library. If you just want proof it works, here:
http://puu.sh/2quYk
Cool! nice release
Re: [PY] Phoenix MUS Interface
Quote:
Originally Posted by
Funixeh
I'm not completely sure on how I'm supposed to provide screenshots of a Python library. If you just want proof it works, here:
http://puu.sh/2quYk
Nice release. But I think your date's wrong? :wink:
Re: [PY] Phoenix MUS Interface
Quote:
Originally Posted by
Riley H
Nice release. But I think your date's wrong? :wink:
The date is from Python 2.7.3, not from his PC.
Re: [PY] Phoenix MUS Interface
Quote:
Originally Posted by
Tha
The date is from Python 2.7.3, not from his PC.
Ah, I'm not familiar with Python, so I wouldn't know. But thanks for clearing it up.
Re: [PY] Phoenix MUS Interface
Quote:
Originally Posted by
Riley H
Nice release. But I think your date's wrong? :wink:
Nope, it's the date the Python installation was built on.
I'm going to do documentation properly in a while (and maybe use something like Sphinx), as well as possibly adding a few extra retro-helpful functions as well.
If you have any suggestions, just post them. :):
Re: [PY] Phoenix MUS Interface
Good System. Unfortnely I don't like Python so much, but will be useful for a lot of other persons, with Mac's, etc. :)
Re: [PY] Phoenix MUS Interface
Quote:
Originally Posted by
Droppy
Good System. Unfortnely I don't like Python so much, but will be useful for a lot of other persons, with Mac's, etc. :)
I don't see the relation between Python and Macs. Thanks anyway!
Re: [PY] Phoenix MUS Interface
Quote:
Originally Posted by
Funixeh
I don't see the relation between Python and Macs. Thanks anyway!
I think he's referring to the fact python comes pre-installed to the OS on a Mac.
Not entirely useful, but a nice proof of concept. Could possibly be tied in to a unix-based python web server if you were using something like FAPWS3 (my favourite python web server) with your CMS.
Python is a lovely language. well done :)
Re: [PY] Phoenix MUS Interface
Quote:
Originally Posted by
Funixeh
I don't see the relation between Python and Macs. Thanks anyway!
As opposed to a Windows executable (C#, etc.)
Re: [PY] Phoenix MUS Interface
Quote:
Originally Posted by
Andrew
I think he's referring to the fact python comes pre-installed to the OS on a Mac.
Not entirely useful, but a nice proof of concept. Could possibly be tied in to a unix-based python web server if you were using something like FAPWS3 (my favourite python web server) with your CMS.
Python is a lovely language. well done :)
Thanks! It's true that this probably won't get used a lot in a CMS, unless you were to have a Python API server to interact with Phoenix, and just use that in your PHP CMS. Although it would probably be easier to do the Phoenix MUS in PHP.
Quote:
Originally Posted by
n0minal
As opposed to a Windows executable (C#, etc.)
I'm not a big fan of writing .NET; it all seems unnecessarily complicated. Python can still be run on Windows anyway, and is usually much more readable.
Re: [PY] Phoenix MUS Interface
Updated the module to 0.9.1. Changelog:
- Fixed setup.py to use correct data directory.
- Added function web_build(hotel='com', short=False). Returns the latest web_build used by the Hotel given, and if short is True, then only the four-digit build number is returned.
- Added function hotel_build(hotel='com'). Returns the latest hotel build that's displayed in the Hotel's meta tags.
- Added function phoenix_version(otaku_u, otaku_p). Requires 2 params; Otaku.cm username and password. Used to connect to the licence server to find and return the latest Phoenix build, as an integer.
These do kinda sound a little pointless to me too, but I haven't had much time to come up with better ideas. Perhaps I should create more functions that just use the database (eg. ban()), or maybe even do a web-based Housekeeping in Python. I'll see.
Still working on docs.
Oh, and because I know people are going to start bitching and claiming phoenix_version() is a keylogger or something dumb (and don't even check the source), here's the function so you can shut up before posting:
Code:
def phoenix_version(otaku_u, otaku_p):
"""Returns the latest available version of Phoenix."""
opener = urllib2.build_opener()
opener.addheaders.append(('AuthName', otaku_u))
opener.addheaders.append(('AuthPass', otaku_p))
opener.addheaders.append(('AuthBuild', '14986'))
opener.addheaders.append(('AuthServer', 'Phoenix'))
res = opener.open('http://otaku.cm/phx/licence.php?')
return int(res.headers['CurBuild'])
Re: [PY] Phoenix MUS Interface
I can see this turning into a hotel management tool that is done via command line.
No need for Housekeeping - give your mods manage.py and an access token, and they login with their hotel user/pass. idk jus tan idea.