As you know, we are upgrading to Piqueserver. All current scripts must be made compatible with Python 3 and Piqueserver's script API. Piqueserver's script API is similar to PySnip's, but there are still some changes that need to be taken care of. Here are some tips and recommendations to ease the porting process up:
- Use the
2to3 python module to convert scripts from python 2 to python 3. I recommend you first run 2to3 script_name.py and review what changes will be made. Once you are sure you want to convert the script, run 2to3 -w script_name.py, this will modify the script file. 2to3 also creates a backup of the converted script when using the -w option, named script_name.py.bak, in case things go wrong or you need the older file back. There's a special situation to keep in mind, for some reason, in scripts which import the commands module, 2to3 replaces this module with the subprocess module, so make sure to change it back after running 2to3 in case your script is affected. Refer to the 2to3 documentation for more info.
- Read the Piqueserver Porting scripts documentation.
- Read Piqueserver's source code, including the scripts which are included with piqueserver. There's nothing better than learning what changed straight from the source, right?
- Please, if you find any trouble with Piqueserver's API, discuss it here. That way we get to know about things that changed with the API. For example, it's worth knowing Piqueserver no longer has the
pyspades.types module (actually it does, but the old type classes are gone). This means no more MultikeyDict and etc. This change also affects the server's players variable. In PySnip, the players member of the ServerProtocol class used to be a MultikeyDict. In Piqueserver, it is now a normal python dict, with the player_id as key and the player object as value. Another important thing is that commands now word differently, instead of using the @admin decorator and the name and add functions, now you just use the @command decorator, with the command name, arguments and extra keyword arguments (like admin_only). You need to import command from the piqueserver.commands module. Share your findings in this issue comments.
Progress:
This list may not be exhaustive and will probably be expanded in the near future. Marked items are ported scripts so far.
Also, testing the already ported scripts and searching for bugs would be helpful, if you can. If you are going to work on porting a script, say so in the comments.
As you know, we are upgrading to Piqueserver. All current scripts must be made compatible with Python 3 and Piqueserver's script API. Piqueserver's script API is similar to PySnip's, but there are still some changes that need to be taken care of. Here are some tips and recommendations to ease the porting process up:
2to3python module to convert scripts from python 2 to python 3. I recommend you first run2to3 script_name.pyand review what changes will be made. Once you are sure you want to convert the script, run2to3 -w script_name.py, this will modify the script file.2to3also creates a backup of the converted script when using the-woption, namedscript_name.py.bak, in case things go wrong or you need the older file back. There's a special situation to keep in mind, for some reason, in scripts which import thecommandsmodule,2to3replaces this module with thesubprocessmodule, so make sure to change it back after running2to3in case your script is affected. Refer to the2to3documentation for more info.pyspades.typesmodule (actually it does, but the old type classes are gone). This means no moreMultikeyDictand etc. This change also affects the server'splayersvariable. In PySnip, theplayersmember of theServerProtocolclass used to be aMultikeyDict. In Piqueserver, it is now a normal pythondict, with theplayer_idas key and theplayerobject as value. Another important thing is that commands now word differently, instead of using the@admindecorator and thenameandaddfunctions, now you just use the@commanddecorator, with the command name, arguments and extra keyword arguments (likeadmin_only). You need to importcommandfrom thepiqueserver.commandsmodule. Share your findings in this issue comments.Progress:
This list may not be exhaustive and will probably be expanded in the near future. Marked items are ported scripts so far.
Also, testing the already ported scripts and searching for bugs would be helpful, if you can. If you are going to work on porting a script, say so in the comments.