Skip to content

Commit

Permalink
dbustop: Change colors for only message type
Browse files Browse the repository at this point in the history
Signed-off-by: Peace Lee <iipeace5@gmail.com>
  • Loading branch information
iipeace committed Sep 29, 2021
1 parent ddad134 commit 76563b9
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions guider/guider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__credits__ = "Peace Lee"
__license__ = "GPLv2"
__version__ = "3.9.8"
__revision__ = "210928"
__revision__ = "210929"
__maintainer__ = "Peace Lee"
__email__ = "iipeace5@gmail.com"
__repository__ = "https://github.com/iipeace/guider"
Expand All @@ -16,15 +16,9 @@



# import sys package #
try:
import sys
except ImportError:
print("[ERROR] failed to import sys package")
sys.exit(0)

# import essential packages #
try:
import sys

This comment has been minimized.

This comment has been minimized.

Copy link
@iipeace

iipeace Sep 29, 2021

Author Owner

It's just my mistake ;)
I'll move it to upper side.

import os
import re
import gc
Expand All @@ -37,8 +31,7 @@
#from ctypes import *
except ImportError:
err = sys.exc_info()[1]
print("[ERROR] failed to import essential package: %s" % err.args[0])
sys.exit(0)
sys.exit("[ERROR] failed to import essential package: %s" % err.args[0])

# convert an unsupported type #
try:
Expand Down Expand Up @@ -4145,11 +4138,7 @@ def printSyscalls(systable):
bufstring += '\n'
bufstring = "%s'%s', " % (bufstring, syscall)

print(bufstring)

print('total: %s' % len(systable))

sys.exit(0)
sys.exit('%s\ntotal: %s' % (bufstring, len(systable)))

This comment has been minimized.

Copy link
@elfring

elfring Sep 29, 2021

Is the format string “%i more appropriate for a length specification?

This comment has been minimized.

Copy link
@iipeace

iipeace Sep 29, 2021

Author Owner

What do you think about pros for the format string "%i"?
I think "%s' is general and it can handle all types.




Expand Down Expand Up @@ -49754,11 +49743,9 @@ def _updateTaskInfo(dbusData, sentData, recvData):
per = long(0)

# get time info #
if pid in sentData and \
name in sentData[pid]:
if pid in sentData and name in sentData[pid]:
data = sentData[pid][name]
elif pid in recvData and \
name in recvData[pid]:
elif pid in recvData and name in recvData[pid]:
data = recvData[pid][name]
else:
continue
Expand All @@ -49779,20 +49766,26 @@ def _updateTaskInfo(dbusData, sentData, recvData):
# check error #
if data['err'] > 0:
errstr = ', Err: %s' % data['err']
color = 'RED'
else:
errstr = ''
color = 'CYAN'

# set color #
try:
mtype, stats = name.lstrip('[').split(']', 1)
mtype = DbusMgr.msgColorList[mtype.strip()]
name = '[%s]%s' % (mtype, stats)
except SystemExit:
sys.exit(0)
except:
pass

if data['max'] > 0:
name = \
'%s {Min: %.3f, Avr: %.3f, Max: %.3f%s} %s' % \
(name, data['min'], avr, data['max'],
name = ('%s {Min: %.3f, Avr: %.3f, Max: %.3f%s}'
'%s') % (name, data['min'], avr, data['max'],
errstr, wstat)

count = convertNum(value['cnt'])
size = convertSize(data['size'])
name = convertColor(name, color)

dbusList.append(
"{0:>4}({1:>6}/{2:>3}%) {3:1}".format(
Expand Down Expand Up @@ -61719,7 +61712,7 @@ def runEventLoop(self):
continue

# print status #
SysMgr.printErr(
SysMgr.printWarn(
'terminated %s(%s)' % (self.comm, self.pid))

# wait event #
Expand Down

4 comments on commit 76563b9

@elfring
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you mix changes for different issues in such a commit?

@iipeace
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I though they were not major issues because of laziness ;)
I'll try to split commits by issues.

@elfring
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you think about to extend the collaboration with topic development branches (and corresponding merge commits) accordingly? 🤔

@iipeace
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds great!
Then I should consider CONTRITBUTING.md.

Please sign in to comment.