GPL license does not require all files to have the copyright notice and header. To save some space, I removed the headers from all files except the executables and the main Python module.
40 lines
805 B
Python
40 lines
805 B
Python
import tuned.logs
|
|
|
|
import copy
|
|
import os
|
|
from subprocess import *
|
|
|
|
log = tuned.logs.get()
|
|
|
|
def write_to_file(f, data):
|
|
log.debug("Writing to file: %s < %s" % (f, data))
|
|
try:
|
|
fd = open(f, "w")
|
|
fd.write(str(data))
|
|
fd.close()
|
|
except (OSError,IOError) as e:
|
|
log.error("Writing to file %s error: %s" % (f, e))
|
|
|
|
def read_file(f):
|
|
old_value = ""
|
|
try:
|
|
f = open(f, "r")
|
|
old_value = f.read()
|
|
f.close()
|
|
except (OSError,IOError) as e:
|
|
log.error("Reading %s error: %s" % (f, e))
|
|
return old_value
|
|
|
|
|
|
def execute(args):
|
|
out = ""
|
|
try:
|
|
proc = Popen(args, stdout=PIPE, stderr=PIPE)
|
|
out, err = proc.communicate()
|
|
|
|
if proc.returncode:
|
|
log.error("Executing %s error: %s" % (args[0], err[:-1]))
|
|
except (OSError,IOError) as e:
|
|
log.error("Executing %s error: %s" % (args[0], e))
|
|
return out
|
|
|