Exemplo n.º 1
0
from optparse import OptionParser

if __name__ == '__main__':
        parser = OptionParser()
        parser.add_option("-a", "--all",
                          dest="all",
                          help="Print all matches",
                          default=False,
                          action="store_true"
                          )
        parser.add_option("-n", "--no-apropos",
                          dest="no_apropos",
                          help="Remove the automatic .* put before and after the request",
                          default=False,
                          action="store_true"
                          )
        parser.add_option("-e", "--env-variable",
                          dest="env_variable",
                          help="Use this environment variable instead of PATH",
                          default="PATH"
                          )
        (options, args) = parser.parse_args()
        ALL=options.all
        NO_APROPOS=options.no_apropos
        # set the args for apropos matching
        if not NO_APROPOS:
            args = [".*"+arg+".*" for arg in args]
        files = get_files(args, ALL, options.env_variable)
        for fil in files:
                print fil
Exemplo n.º 2
0
# get available governors
p=subprocess.Popen(["cpufreq-info", "-g"], stdout=subprocess.PIPE)
p.wait()
governors=p.stdout.read().split(" ")
# get available policy
p=subprocess.Popen(["cpufreq-info", "-p"], stdout=subprocess.PIPE)
p.wait()
policy=p.stdout.read()

droid = android.Android()
chooser=andlib.Chooser(droid)
governor=chooser.choose(
        "Select governor\n%s" % policy,
        (
            governors
            )
        )
if not governor:
    sys.exit(1)
askpass=fairy.get_files(("andaskpass.py",), False).pop()
os.environ["SUDO_ASKPASS"]=askpass
p=subprocess.Popen(["sudo", "-A", "cpufreq-set", "-g", governor],
        stderr=subprocess.PIPE,
        env=os.environ)
p.wait()
if p.returncode == 0:
    droid.makeToast("Governor set to %s" % governor)
else:
    andlib.display(droid, "Failed",p.stderr.read())