Discussion:
[PATCH 1/1] tuna config: Fix pygtk import
Arnaldo Carvalho de Melo
2015-04-29 14:30:29 UTC
Permalink
We should 'import gtk', not 'import pygtk', fixes bugs when the error
paths try to use gtk.messageDialog():

[***@ssdandy tuna]# tuna
Traceback (most recent call last):
File "/home/acme/git/tuna/tuna-cmd.py", line 654, in <module>
main()
File "/home/acme/git/tuna/tuna-cmd.py", line 648, in main
app = tuna_gui.main_gui(kthreads, uthreads, cpus_filtered)
File "/home/acme/git/tuna/tuna/tuna_gui.py", line 64, in __init__
self.profileview.init_default_file()
File "/home/acme/git/tuna/tuna/gui/profileview.py", line 141, in
init_default_file
not self.config.load(self.config.config['lastfile']):
File "/home/acme/git/tuna/tuna/config.py", line 48, in load
if(self.tuned2Tuna(profileName) < 0):
File "/home/acme/git/tuna/tuna/config.py", line 66, in tuned2Tuna
dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR,\
NameError: global name 'gtk' is not defined
[***@ssdandy tuna]#

Signed-off-by: Arnaldo Carvalho de Melo <***@redhat.com>
---
tuna/config.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tuna/config.py b/tuna/config.py
index 77cc4d800c03..7e19a28f967f 100644
--- a/tuna/config.py
+++ b/tuna/config.py
@@ -1,5 +1,5 @@
import io, os, re, fnmatch
-import sys, pygtk
+import sys, gtk
import codecs, ConfigParser
from time import localtime, strftime
from subprocess import Popen, PIPE, STDOUT, call
--
1.8.3.1
John Kacur
2015-04-29 14:46:36 UTC
Permalink
Assuming that this is untested though?

----- Original Message -----
Post by Arnaldo Carvalho de Melo
We should 'import gtk', not 'import pygtk', fixes bugs when the error
File "/home/acme/git/tuna/tuna-cmd.py", line 654, in <module>
main()
File "/home/acme/git/tuna/tuna-cmd.py", line 648, in main
app = tuna_gui.main_gui(kthreads, uthreads, cpus_filtered)
File "/home/acme/git/tuna/tuna/tuna_gui.py", line 64, in __init__
self.profileview.init_default_file()
File "/home/acme/git/tuna/tuna/gui/profileview.py", line 141, in
init_default_file
File "/home/acme/git/tuna/tuna/config.py", line 48, in load
File "/home/acme/git/tuna/tuna/config.py", line 66, in tuned2Tuna
dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR,\
NameError: global name 'gtk' is not defined
---
tuna/config.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tuna/config.py b/tuna/config.py
index 77cc4d800c03..7e19a28f967f 100644
--- a/tuna/config.py
+++ b/tuna/config.py
@@ -1,5 +1,5 @@
import io, os, re, fnmatch
-import sys, pygtk
+import sys, gtk
import codecs, ConfigParser
from time import localtime, strftime
from subprocess import Popen, PIPE, STDOUT, call
--
1.8.3.1
Arnaldo Carvalho de Melo
2015-04-29 15:14:16 UTC
Permalink
Post by John Kacur
Assuming that this is untested though?
Tested, on a RHEL7 system, and that leads to another problem, where the
fact that there is nothing in /etc/tuna/ generates a messageDialog()
saying that the config file is "corrupted", which is not the case, it
should just start with default values, etc.

But that is for another patch. Trying to figure out how to do that, as
this was done by somobody else, using some ConfigParser() python classes
I am not familiar with.

To repro the problem, just run tuna, as root, on a system with nothing
on /etc/tuna/, it should produce the Dialog, and will freeze the screen,
with nothing on the tuna panes, till the user presses Ok.

- Arnaldo
Post by John Kacur
----- Original Message -----
Post by Arnaldo Carvalho de Melo
We should 'import gtk', not 'import pygtk', fixes bugs when the error
File "/home/acme/git/tuna/tuna-cmd.py", line 654, in <module>
main()
File "/home/acme/git/tuna/tuna-cmd.py", line 648, in main
app = tuna_gui.main_gui(kthreads, uthreads, cpus_filtered)
File "/home/acme/git/tuna/tuna/tuna_gui.py", line 64, in __init__
self.profileview.init_default_file()
File "/home/acme/git/tuna/tuna/gui/profileview.py", line 141, in
init_default_file
File "/home/acme/git/tuna/tuna/config.py", line 48, in load
File "/home/acme/git/tuna/tuna/config.py", line 66, in tuned2Tuna
dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR,\
NameError: global name 'gtk' is not defined
---
tuna/config.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tuna/config.py b/tuna/config.py
index 77cc4d800c03..7e19a28f967f 100644
--- a/tuna/config.py
+++ b/tuna/config.py
@@ -1,5 +1,5 @@
import io, os, re, fnmatch
-import sys, pygtk
+import sys, gtk
import codecs, ConfigParser
from time import localtime, strftime
from subprocess import Popen, PIPE, STDOUT, call
--
1.8.3.1
Guy Streeter
2015-04-29 15:20:26 UTC
Permalink
Post by Arnaldo Carvalho de Melo
Post by John Kacur
Assuming that this is untested though?
Tested, on a RHEL7 system, and that leads to another problem, where the
fact that there is nothing in /etc/tuna/ generates a messageDialog()
saying that the config file is "corrupted", which is not the case, it
should just start with default values, etc.
But that is for another patch. Trying to figure out how to do that, as
this was done by somobody else, using some ConfigParser() python classes
I am not familiar with.
To repro the problem, just run tuna, as root, on a system with nothing on
/etc/tuna/, it should produce the Dialog, and will freeze the screen,
with nothing on the tuna panes, till the user presses Ok.
- Arnaldo
I don't know why that configuration stuff was tacked onto tuna. It's the
reason tuna has to run as root now. I think it would be better if we just
had a button that launched a separate configuration app.

- --Guy
Arnaldo Carvalho de Melo
2015-04-29 16:16:03 UTC
Permalink
Post by Guy Streeter
Post by Arnaldo Carvalho de Melo
Post by John Kacur
Assuming that this is untested though?
Tested, on a RHEL7 system, and that leads to another problem, where the
fact that there is nothing in /etc/tuna/ generates a messageDialog()
saying that the config file is "corrupted", which is not the case, it
should just start with default values, etc.
But that is for another patch. Trying to figure out how to do that, as
this was done by somobody else, using some ConfigParser() python classes
I am not familiar with.
To repro the problem, just run tuna, as root, on a system with nothing on
/etc/tuna/, it should produce the Dialog, and will freeze the screen,
with nothing on the tuna panes, till the user presses Ok.
I don't know why that configuration stuff was tacked onto tuna. It's the
reason tuna has to run as root now. I think it would be better if we just
had a button that launched a separate configuration app.
Was part of a integration with tuned, approved/requested by management
at Red Hat.

And yes, it is sad that the GUI now goes thru that sequence that ends up
asking for 'root' priviledges to be granted.

On the command line, tho, it works as before, subject to the permissions
enforced by the kernel to /proc, ethtool, schedutils, etc.

[***@ssdandy ~]$ tuna -t docker -CP
thread ctxt_switches
pid SCHED_ rtpri affinity voluntary nonvoluntary cmd
1101 OTHER 0 0xff 634 140 docker
1538 OTHER 0 0xff 30 0 docker
1125 OTHER 0 0xff 7215 4 docker
1126 OTHER 0 0xff 3 3 docker
2152 OTHER 0 0xff 7241 1 docker
1258 OTHER 0 0xff 4 0 docker
1105 OTHER 0 0xff 30227 2 docker
1170 OTHER 0 0xff 14205 7 docker
[***@ssdandy ~]$

I think this should be changed so that it works as before, i.e. as
non-root user one can use the GUI, and whatever operations that requires
root priviledges should be presented only if those priviledges are
available.

- Arnaldo

Loading...