Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Is it possible to use a line break in a list in logger?

If you have a question or need help, this is the place to be.
Post Reply
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Is it possible to use a line break in a list in logger?

Post by Mastiff »

I have a couple of lists (over each room and their temperature) that runs when the temperature mode (day, night, no frost) is changed. The rooms are in a dictionary, so the print command is like this:

Code: Select all

print "\nTemperatur 3 (frostvakt):\n%s,"%(eg.globals.Temp3)
The eg.globals.Temp3 is the dictonary, so runing without the [Room] prints the full list. The \n's are of course line breaks so it's a bit easier to see. But is there a way to have an automatic line break in the list, so parts of it doesn't dissappear under the action tree? I could print one and one room, but that would mean that I'd have to edit the print command every time another room was added to the system, or an extra sensor came in.
jonib
Plugin Developer
Posts: 1328
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Is it possible to use a line break in a list in logger?

Post by jonib »

Try this pprint:

Code: Select all

import pprint
pprint.pprint(eg.globals.Temp3)
jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Is it possible to use a line break in a list in logger?

Post by Pako »

jonib wrote:Try this pprint:

Code: Select all

import pprint
pprint.pprint(eg.globals.Temp3)
Or you can do the following: :D :D

Code: Select all

print str(eg.globals.Temp3)
But I understand, that you want to have each item on a new line.
This can be done like this:

Code: Select all

print "\nTemperatur 3 (frostvakt):\n", "\n".join([str(item) for item in list(eg.globals.Temp3.iteritems())])
Pako
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: Is it possible to use a line break in a list in logger?

Post by Mastiff »

Thanks! But not quite. I don't want to use more lines then necessary, I just want to cut the line before it dissappears under the action tree. Splitting the line in two would do that. But that's perhaps a bit more difficult?
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Is it possible to use a line break in a list in logger?

Post by Pako »

Oh, I did not understand well.
That's a little different situation.
Of course it is also possible.
But you must determine the rules by which the position to insert the end of the line is calculated.
Note: it may be necessary to choose a fixed-width font. Otherwise, it is difficult to specify any rules.
Pako
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: Is it possible to use a line break in a list in logger?

Post by Mastiff »

Eveything's possible, the impossible just takes a bit more time. :) Well, I guess that is going a bit overboard on that, so I'll just keep the one on each line format. Thanks!
Post Reply