Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

How to use from console? #13

Closed
achton opened this issue Mar 1, 2011 · 21 comments · Fixed by #24
Closed

How to use from console? #13

achton opened this issue Mar 1, 2011 · 21 comments · Fixed by #24

Comments

@achton
Copy link

achton commented Mar 1, 2011

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
Copy link
Collaborator

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

@l0b0
Copy link
Owner

l0b0 commented Mar 1, 2011

Done in 876e8c3 (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
Copy link
Collaborator

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

@l0b0
Copy link
Owner

l0b0 commented Mar 2, 2011

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

@achton
Copy link
Author

achton commented Mar 3, 2011

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
Copy link
Owner

l0b0 commented Mar 3, 2011

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
Copy link
Author

achton commented Mar 3, 2011

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
Copy link
Collaborator

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

@achton
Copy link
Author

achton commented Mar 18, 2011

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
Copy link
Collaborator

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

@achton
Copy link
Author

achton commented May 3, 2011

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

@l0b0 l0b0 reopened this May 4, 2011
@l0b0
Copy link
Owner

l0b0 commented May 4, 2011

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

@achton
Copy link
Author

achton commented May 4, 2011

Cool, glad we agree :-)

@Fenixin
Copy link
Collaborator

Fenixin commented May 4, 2011

@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
Copy link
Author

achton commented May 4, 2011

@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
Copy link
Collaborator

Fenixin commented May 4, 2011

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
Copy link
Author

achton commented May 4, 2011

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
Copy link
Collaborator

Fenixin commented May 4, 2011

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
Copy link
Author

achton commented May 5, 2011

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
Copy link
Collaborator

Fenixin commented May 5, 2011

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

@Fenixin
Copy link
Collaborator

Fenixin commented Sep 9, 2011

This should be fixed a long time ago!

@Fenixin Fenixin closed this as completed Sep 9, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants