Difference between revisions of "WiiPy"

From WiiBrew
Jump to navigation Jump to search
Line 37: Line 37:
 
* If the script crashes, you will not get a delay before an immediate return to the loader.  This is because traceback (which would be required to print the stack trace without exiting python) wants to import os for some reason.  This is fixable.
 
* If the script crashes, you will not get a delay before an immediate return to the loader.  This is because traceback (which would be required to print the stack trace without exiting python) wants to import os for some reason.  This is fixable.
  
* If the ogc is not initialized it show the same error message as last time. Probably you should just have it auto initialized as soon as ogc is imported.
+
* For some reason importing os results in a "ImportError: Excluded frozen object named errorno"
 +
 
 
== Source ==
 
== Source ==
  

Revision as of 14:24, 29 June 2008

Template:Infobox homebrewapp

Pronounced "weepy".

PyOGC is an OGC wrapper for Python written in Pyrex (a hybrid Python-C language designed for extension development). The author, tehpola, made a working demo, but the demo itself was made in Pyrex, not real Python. I (comex) hacked Python a little so the interpreter as well would run, and you can run .py files.

Aside from Python being an awesome language, I think Python on Wii might eventually make it much easier for GUI applications to be developed on the Wii, or really anything.

Right now, however, it does not have any GUI, and PyOGC itself is incomplete-- this is really just a demo. The finished version might have have a file selector and maybe a GUI and all that fancy stuff.

Usage

To use, download wiipy.elf, run it by the method of your choice, and put a file called "run.py" on your SD card root containing whatever Python code you want to run.

Besides the modules in PyOGC (the documentation for this is nonexistent, but you can look in the source) you have some basic modules (math, sys), and the standard open() function will open files on the SD card. However, notably, time is presently not available, nor is os and maybe other things.

Alpha 2: Network is available, do this:

import net, _socket as socket
net.init()

Then use the socket functions, but there are some bugs:

  • socket.accept won't actually tell you the IP address which connected
  • You must receive and send data in small chunks. 1024 works, 8192 doesn't (you get a socket error). This is a limitation of the net functions, but future version will deal with this more smartly (chunk data up for you).

Sample

Here is a link of a .py port of the original sample file: [1]

Bugs

  • For some reason, this app seems to fail in weird and wacky ways when launched over the network from HBC. I've only gotten it to work when launched from the SD card. I haven't tested with any additional loaders or the Twilight Hack. YMMV.
  • If the script crashes, you will not get a delay before an immediate return to the loader. This is because traceback (which would be required to print the stack trace without exiting python) wants to import os for some reason. This is fixable.
  • For some reason importing os results in a "ImportError: Excluded frozen object named errorno"

Source

The "source" will eventually be a set of directions for how to patch the Python source distribution to build on the Wii, which will be released when this app is improved. Right now, my directions are extremely ugly: for example, they include copying a failed build command, adding the .a files from libogc to the command line, and running that manually. (Don't ask me why adding the same files in the middle of the command line doesn't work.)

However, if you really want what I have so far, just ask.