l0b0 / mian

Mine analysis - Graph blocks to height in a Minecraft save game
https://github.com/l0b0/mian/wiki
GNU General Public License v3.0
14 stars 4 forks source link

How to use from console? #13

Closed achton closed 13 years ago

achton commented 13 years ago

It seems mian wants to create a screen for me on my console-only rootserver, where I run a MC server from. I'd like it to analyse the world-directory and output a .png. Is that possible?

Cheers, Achton

pepijndevos commented 13 years ago

Not currently, but it would be trivial to implement, I guess.

l0b0 commented 13 years ago

Done in 876e8c315d3e0878bef348ad0da0249afa4077c3 (v0.9.1) - Use -s or --save to output to file. It'll save with the same name as the title would be in the GUI; for example "World3 - mian 0.9.1.png"

pepijndevos commented 13 years ago

May I suggest we adopt the standard Unix convention of using -o < filename >?

l0b0 commented 13 years ago

Excellent idea; the last fix was more of a monkey patch. And it should also support the synonym --output.

achton commented 13 years ago

Totally awesome. Can't get it working, though.

I do: mian -s /home/minecraft/ -b 01,dirt,09,sand /home/minecraft/server/world/

And get: You need to specify exactly one save directory.

Sorry, haven't looked through the code yet, just wanted to exemplify a use case for you guys.

l0b0 commented 13 years ago

You need to specify the top level directory of the save, in other words one of those usually called "WorldN", where N is a number. If your directory structure is different, just remember that mian looks for mcr files in the "region" directory directly below the savegame. In other words, ls /home/minecraft/server/world/region/*.mcr should list some files.

achton commented 13 years ago

Thanks, l0b0. I just realised that I don't need to provide a path for the output file. mian actually tells me what's wrong with my command, I just didn't read it properly. Omitting the path after the -s option fixes this.

Next problem is that I get the same error with or without the -s option:

Traceback (most recent call last):
  File "/usr/local/bin/mian", line 9, in <module>
    load_entry_point('mian==0.9.2', 'console_scripts', 'mian')()
  File "/usr/local/lib/python2.6/dist-packages/mian-0.9.2-py2.6.egg/mian/mian.py", line 404, in main
    mian(world_dir, block_type_hexes, nether, log, interactive)
  File "/usr/local/lib/python2.6/dist-packages/mian-0.9.2-py2.6.egg/mian/mian.py", line 258, in mian
    plot(total_counts, block_type_hexes, title, log, interactive)
  File "/usr/local/lib/python2.6/dist-packages/mian-0.9.2-py2.6.egg/mian/mian.py", line 176, in plot
    fig = plt.figure()
  File "/usr/lib/pymodules/python2.6/matplotlib/pyplot.py", line 254, in figure
    **kwargs)
  File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py", line 90, in new_figure_manager
    window = Tk.Tk()
  File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1646, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

Seems that mian still attempts to create a GUI for me?

pepijndevos commented 13 years ago

I can confirm that matplotlib still flashes a screen when using -s.

achton commented 13 years ago

Just checking in: is this fixed, meant to be fixed or postponed? I'm new to Github, but it seems the issue is closed, and I still can't figure out how to use this feature.

Thanks folks!

pepijndevos commented 13 years ago

It is possible to generate PNG, but somehow, a display is still required.

achton commented 13 years ago

So could you please reopen this feature request? I really think this would be a valid enhancement to mian.

l0b0 commented 13 years ago

I don't really have much time to work on this, but it should definitely be open.

achton commented 13 years ago

Cool, glad we agree :-)

Fenixin commented 13 years ago

@achton, try my branch save-image, as far as I tested it works perfect without a X server running:

https://github.com/Fenixin/mian/tree/save-image

The problem was that you have to choose the backend before run import matplotlib.pyplot. Here is a helpful link!

Should I request a pull? It's a bit dirty at the moment... maybe is better to import pyplot when the options are parsed.

achton commented 13 years ago

@Fenixin: I could not get your build to work. I had trouble with commandline options and NBT.

However, I applied your changes to l0b0's branch manually, and it works perfectly! I get a nice .png to current directory without a hitch.

I don't understand Python, so I can't really tell you what to do about it, but let me know if I can help in any other way.

Cheers, Achton

Fenixin commented 13 years ago

That's strange, that branch is just (or it should be) l0b0's master branch with that change... What was the problem with nbt? What was the error message? Anyway, glad it worked!

achton commented 13 years ago

What I got when cloning your branch, was version 0.8.7. So it wouldn't recognize the --s parameter, and also gave me this error:

Traceback (most recent call last):
  File "/usr/local/bin/mian", line 9, in <module>
    load_entry_point('mian==0.8.7', 'console_scripts', 'mian')()
  File "/usr/local/lib/python2.6/dist-packages/mian-0.8.7-py2.6.egg/mian/mian.py", line 249, in main
    mian(world_dir, bt_hexes, nether)
  File "/usr/local/lib/python2.6/dist-packages/mian-0.8.7-py2.6.egg/mian/mian.py", line 176, in mian
    raw_blocks += nbtfile['Level']['Blocks'].value
  File "/usr/local/lib/python2.6/dist-packages/NBT-1.0-py2.6.egg/nbt/nbt.py", line 227, in __getitem__
    raise KeyError("A tag with this name does not exist")
KeyError: 'A tag with this name does not exist'
Fenixin commented 13 years ago

Ahh... I see the problem now. You are using the master branch of my fork (completely outdated).

The branch is called "save-image", if you cloned my entire repo then you can switch the branch doing:

git checkout save-image

achton commented 13 years ago

Ah cr*p .. I was completely not paying attention there :) Thanks for correcting my Git-fail :)

Anyway .. it definitely works, so how can I help wrap this up as an actual feature so l0b0 can release it?

Fenixin commented 13 years ago

I'll request a pull to add this, that's the only thing we can do (I think).

Fenixin commented 13 years ago

This should be fixed a long time ago!