1
0
Fork 0

Initial commit of commandline tool.

This commit is contained in:
Marcela Mašláňová 2009-07-09 13:23:10 +02:00
parent b0faedccaa
commit b7a092f3e7
7 changed files with 152 additions and 0 deletions

8
README.command Normal file
View file

@ -0,0 +1,8 @@
tuned_adm.py
------------
tuned_adm.py is commandline tool for setting modes
which needs ktune and kobo packages. kobo is in repo,
ktune must be rebuilt from srpm.
Commandline is calling ktune with 'tuned_adm.py server'
and setting it back by call 'tuned_adm.py default'.

0
commands/__init__.py Normal file
View file

View file

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
from kobo.cli import Command
import os
class Default(Command):
"""set default mode"""
enabled = True
def options(self):
self.parser.usage = "%%prog %s" % self.normalized_name
self.parser.add_option(
"--show-disabled",
default=False,
action="store_true",
help="show disabled workers"
)
def run(self, *args, **kwargs):
os.system('service ktune stop')
os.system('service tuned stop')

View file

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from kobo.cli import Command
import os
class Laptop(Command):
"""set laptop mode"""
enabled = True
def options(self):
self.parser.usage = "%%prog %s" % self.normalized_name
self.parser.add_option(
"--show-disabled",
default=False,
action="store_true",
help="show disabled workers"
)
def run(self, *args, **kwargs):
# this should be part of ktune
# if on wifi then switch off network card?
pass

View file

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from kobo.cli import Command
import os
class Server(Command):
"""set server mode"""
enabled = True
def options(self):
self.parser.usage = "%%prog %s" % self.normalized_name
self.parser.add_option(
"--show-disabled",
default=False,
action="store_true",
help="show disabled workers"
)
def run(self, *args, **kwargs):
# call ktune - need check of status
os.system('service ktune start')
# usb suspend?

45
man/tuned_adm.1 Normal file
View file

@ -0,0 +1,45 @@
.\"/*
.\" * All rights reserved
.\" * Copyright (C) 2009 Red Hat, Inc.
.\" * Authors: Marcela Mašláňová
.\" *
.\" * This program is free software; you can redistribute it and/or
.\" * modify it under the terms of the GNU General Public License
.\" * as published by the Free Software Foundation; either version 2
.\" * of the License, or (at your option) any later version.
.\" *
.\" * This program is distributed in the hope that it will be useful,
.\" * but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" * GNU General Public License for more details.
.\" *
.\" * You should have received a copy of the GNU General Public License
.\" * along with this program; if not, write to the Free Software
.\" * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
.\" */
.\"
.TH TUNED_ADM "1" "9 Jul 2009" "Linux Programmer's Manual"
.SH NAME
tuned_adm \- commandline tool for setting the power-save options
.SH SYNOPSIS
.B tuned_adm
.B
.BR help ", " laptop ", " server
.br
.SH DESCRIPTION
This command line utility allows user to set profile for server or laptop.
.SH "OPTIONS"
.TP
.B help
Print out the list of commands.
.TP
.B laptop
.TP
.B server
.TP
These settings are calling ktune which set up different values for better resource consumption.
.SH "SEE ALSO"
.SH AUTHOR
.nf
Marcela Mašláňová <mmaslano@redhat.com>

22
tuned_adm.py Executable file
View file

@ -0,0 +1,22 @@
#!/usr/bin/python
import os
import sys
import locale
from kobo.cli import *
from kobo.tback import *
set_except_hook()
import commands
CommandContainer.register_module(commands)
def main(argv):
parser = CommandOptionParser(command_container=CommandContainer(), default_command="help")
parser.run()
if __name__ == "__main__":
main(sys.argv[1:])