9f67a15b77
Resolves: rhbz#830415
88 lines
2.7 KiB
Diff
88 lines
2.7 KiB
Diff
diff -up tuned-2.0.1/experiments/powertop2tuned.py.orig tuned-2.0.1/experiments/powertop2tuned.py
|
|
--- tuned-2.0.1/experiments/powertop2tuned.py.orig 2012-04-03 19:25:37.000000000 +0200
|
|
+++ tuned-2.0.1/experiments/powertop2tuned.py 2012-06-12 17:19:30.548102052 +0200
|
|
@@ -44,12 +44,14 @@ stop() {
|
|
process $@
|
|
"""
|
|
|
|
-TUNED_CONF_PROLOG = "# Automatically generated by powertop2tuned tool"
|
|
+TUNED_CONF_PROLOG = "# Automatically generated by powertop2tuned tool\n\n"
|
|
TUNED_CONF_INCLUDE = """[main]
|
|
%s
|
|
+
|
|
"""
|
|
TUNED_CONF_EPILOG="""[powertop_script]
|
|
type=script
|
|
+replace=1
|
|
script=script.sh
|
|
"""
|
|
|
|
@@ -74,6 +76,8 @@ class PowertopHTMLParser(HTMLParser):
|
|
|
|
def handle_starttag(self, tag, attrs):
|
|
self.lastStartTag = tag
|
|
+ if self.lastStartTag == "div" and dict(attrs)["id"] == "tuning":
|
|
+ self.inProperTable = True
|
|
if self.inProperTable and tag == "td":
|
|
self.tdCounter += 1
|
|
|
|
@@ -92,8 +96,6 @@ class PowertopHTMLParser(HTMLParser):
|
|
|
|
def handle_data(self, data):
|
|
prefix = self.prefix
|
|
- if self.lastStartTag == "h2" and data == "Software settings in need of tuning":
|
|
- self.inProperTable = True
|
|
if self.inProperTable and self.tdCounter == 1:
|
|
self.lastDesc = data
|
|
if self.lastDesc.lower().find("autosuspend") != -1 and (self.lastDesc.lower().find("keyboard") != -1 or self.lastDesc.lower().find("mouse") != -1):
|
|
@@ -103,10 +105,10 @@ class PowertopHTMLParser(HTMLParser):
|
|
self.tdCounter = 0
|
|
if not self.inScript:
|
|
self.data += "\t# " + self.lastDesc + "\n"
|
|
- self.data += "\t" + prefix + data
|
|
+ self.data += "\t" + prefix + data.strip()
|
|
self.inScript = True
|
|
else:
|
|
- self.data += data
|
|
+ self.data += data.strip()
|
|
|
|
class PowertopProfile:
|
|
BAD_PRIVS = 100
|
|
@@ -132,16 +134,18 @@ class PowertopProfile:
|
|
return True
|
|
|
|
def generateHTML(self):
|
|
- f = tempfile.NamedTemporaryFile()
|
|
- name = unicode(f.name)
|
|
- f.close()
|
|
-
|
|
- ret = os.system('powertop --html="%s"' % (name))
|
|
- if ret != 0:
|
|
- os.unlink(name)
|
|
- return ret
|
|
+ proc = Popen(["powertop", "--html=/tmp/powertop"], stdout=PIPE)
|
|
+ output = proc.communicate()[0]
|
|
+ if proc.returncode != 0:
|
|
+ return ret
|
|
|
|
- return name;
|
|
+ prefix = "PowerTOP outputing using base filename "
|
|
+ if output.find(prefix) == -1:
|
|
+ return -1
|
|
+
|
|
+ name = output[output.find(prefix)+len(prefix):-1]
|
|
+ #print "Parsed filename=", [name]
|
|
+ return name
|
|
|
|
def parseHTML(self, enable_tunings):
|
|
f = open(self.name)
|
|
@@ -163,7 +167,7 @@ class PowertopProfile:
|
|
print "Generating Tuned config file", os.path.join(self.output, "tuned.conf")
|
|
f = open(os.path.join(self.output, "tuned.conf"), "w")
|
|
f.write(TUNED_CONF_PROLOG)
|
|
- if (new_profile):
|
|
+ if (not new_profile):
|
|
f.write(TUNED_CONF_INCLUDE % ("include=" + profile))
|
|
f.write(TUNED_CONF_EPILOG)
|
|
f.close()
|