Opened 4 years ago

Last modified 2 months ago

#2915 new defect

i.segment.hierarchical: print statements should be replaced by messages

Reported by: mlennert Owned by: grass-dev@…
Priority: normal Milestone: 7.8.3
Component: Addons Version: unspecified
Keywords: i.segment.hierarchical messages Cc:
CPU: Unspecified Platform: Unspecified

Description

i.segment.hierarchical contains many print() statements. These should all be replaced by messages that can be "quieted".

I'm not very familiar with the message interface in pygrass: is there a need to create a new Messenger() for each different function & class ?

Change History (7)

comment:1 in reply to:  description Changed 4 years ago by zarch

Replying to mlennert:

i.segment.hierarchical contains many print() statements. These should all be replaced by messages that can be "quieted".

I'm not very familiar with the message interface in pygrass: is there a need to create a new Messenger() for each different function & class ?

You can get a Messenger instance using the get_msgr function.

from grass.pygrass.messages import get_msgr

def func0():
    msgr = get_msgr()
    msgr.message("Said something...")

def func1():
    msgr = get_msgr()
    msgr.message("Said something else...")

class MyClass(object):
    msgr = get_msgr()

    def mth(self):
        self.msgr.message("That's all!")
        
func0()
func1()
MyClass().mth()

or you can create a global variable

from grass.pygrass.messages import get_msgr

msgr = get_msgr()


def func0():
    msgr.message("Said something...")

def func1():
    msgr.message("Said something else...")

class MyClass(object):
    def mth(self):
        msgr.message("That's all!")
        
func0()
func1()
MyClass().mth()

comment:2 Changed 4 years ago by martinl

Milestone: 7.0.47.0.5

comment:3 Changed 3 years ago by neteler

Milestone: 7.0.57.0.6

comment:4 Changed 2 years ago by neteler

Milestone: 7.0.67.0.7

comment:5 Changed 10 months ago by martinl

Still relevant?

comment:6 Changed 10 months ago by martinl

Milestone: 7.0.7

Remove Milestone from Addons bugreports.

comment:7 Changed 2 months ago by neteler

Milestone: 7.8.3
Note: See TracTickets for help on using tickets.