summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSérgio Almeida <mephx.x@gmail.com>2009-07-27 20:30:11 +0100
committerSérgio Almeida <mephx.x@gmail.com>2009-07-27 20:30:11 +0100
commit7344569e0efd98064ce305cd6f0db933327a9400 (patch)
tree427bfd4ee5eae95a4bfc1596b749f25d29f9a5ca
parentFixed syntax typo on umodule.py (diff)
downloaduselect-7344569e0efd98064ce305cd6f0db933327a9400.tar.gz
uselect-7344569e0efd98064ce305cd6f0db933327a9400.tar.bz2
uselect-7344569e0efd98064ce305cd6f0db933327a9400.zip
Open uprofile branch
-rw-r--r--install.sh4
-rw-r--r--uio.py24
-rw-r--r--umodule.py2
-rwxr-xr-x[-rw-r--r--]uprofile.py81
-rwxr-xr-xuselect.py36
5 files changed, 123 insertions, 24 deletions
diff --git a/install.sh b/install.sh
index bb6fb3d..d25b12c 100644
--- a/install.sh
+++ b/install.sh
@@ -10,7 +10,9 @@ if [ "$(id -u)" != "0" ]; then
fi
rm -f /usr/bin/uselect
-rm -f /usr/share/uselect
+rm -f /usr/bin/uprofile
+rm -rf /usr/share/uselect
mkdir /usr/share/uselect
cp -R * /usr/share/uselect/
ln -s /usr/share/uselect/uselect.py /usr/bin/uselect
+ln -s /usr/share/uselect/uprofile.py /usr/bin/uprofile
diff --git a/uio.py b/uio.py
index 6e48a29..013ea3e 100644
--- a/uio.py
+++ b/uio.py
@@ -34,9 +34,10 @@ class FileSystem:
self.environment = self.home + '/.uselect/'
if not os.path.exists(self.environment):
os.mkdir(self.environment)
- self.environment += 'bin/'
- if not os.path.exists(self.environment):
- os.mkdir(self.environment)
+ if not os.path.exists(self.environment + 'bin/'):
+ os.mkdir(self.environment + 'bin/')
+ if not os.path.exists(self.environment + 'env.d/'):
+ os.mkdir(self.environment + 'env.d/')
def get_env(self):
env = []
@@ -100,8 +101,10 @@ class FileSystem:
return
else:
return os.listdir(path)
+
def path_exists(self, path):
return os.path.exists(path)
+
def real_path(self, path):
return os.path.realpath(path)
@@ -232,7 +235,20 @@ class PrintSystem:
for line in action.output:
print(line)
return
-
+
+ def print_uprofile_ui(self, profile = None, profiles = None, args = None):
+ if profile == None:
+ self.print_profiles(profiles)
+
+ def print_profiles(self, profiles):
+ self.print_line(bold + lime + 'Profiles:' + reset)
+ table = []
+ for profile in profiles:
+ table.append([bold + profile.name, profile.description])
+
+ self.print_table(table)
+
+
def print_module(self, module):
self.print_line(bold + lime + 'Module' + space + reset \
+ bold +module.name + lime + ':' + reset)
diff --git a/umodule.py b/umodule.py
index 1677880..f4d318a 100644
--- a/umodule.py
+++ b/umodule.py
@@ -302,7 +302,7 @@ class Var():
class Env(Action):
- def do_action(self, args):a
+ def do_action(self, args):
for var in self.vars:
for value in var.values:
if not value[1]:
diff --git a/uprofile.py b/uprofile.py
index e69de29..ad96eed 100644..100755
--- a/uprofile.py
+++ b/uprofile.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# Universal Select Tool
+# Profiling Tool
+# uprofile.py mephx.x@gmail.com
+
+import os
+import re
+import sys
+import stat
+import string
+import traceback
+
+from umodule import *
+from uio import *
+
+class Profile:
+
+ def __init__(self, name):
+ self.name = name
+ self.description = 'Empty'
+ return
+
+class UniversalProfileTool:
+
+ def __init__(self):
+ self.profiles = []
+ return
+
+ def get_profiles(self):
+ """ Returns the list of available uprofiles """
+ for profile in filesystem.list_dir('.uprofile/'):
+ self.profiles.append(Profile(profile))
+ return
+
+ def parse_argv(self, args):
+ global verbose, version
+ profile = None
+ profiles = None
+ printsystem.use_colors(True)
+ for arg in args:
+ if arg == '-v':
+ verbose = True
+ printsystem.verbose()
+ args = args[1:]
+ elif arg == '-nc':
+ printsystem.use_colors(False)
+ args = args[1:]
+
+ if len(args) < 1:
+ self.get_profiles()
+ profiles = self.profiles
+
+ if len(args) == 2:
+ args = None
+ else:
+ args = args[2:]
+
+ return [profile, profiles, args]
+
+
+def main():
+ uprofile = UniversalProfileTool()
+ try:
+ list = uprofile.parse_argv(sys.argv[1:])
+
+ printsystem.print_uprofile_ui(profile = list[0], \
+ profiles = list[1], args = list[2])
+
+ except UserWarning, warning:
+ printsystem.print_exception(warning, True)
+ except Exception, exception:
+ printsystem.print_exception(exception)
+ if not verbose:
+ traceback.print_exc()
+ printsystem.print_line('')
+ exit(1)
+ exit(0)
+
+if __name__ == '__main__': main()
diff --git a/uselect.py b/uselect.py
index c51be9a..e266b8c 100755
--- a/uselect.py
+++ b/uselect.py
@@ -50,46 +50,46 @@ class UniversalSelectTool:
module = eval(modpath + '.module')
return module
- def parse_argv(self, argv):
- global profile, verbose, version
+ def parse_argv(self, args):
+ global verbose, version
module = None
modules = None
action = None
- args = None
printsystem.use_colors(True)
- for arg in argv:
+ for arg in args:
if arg == '-v':
verbose = True
printsystem.verbose()
- argv = argv[1:]
+ args = args[1:]
elif arg == '-nc':
printsystem.use_colors(False)
- argv = argv[1:]
+ args = args[1:]
elif arg == '-version':
printsystem.print_version(version)
- argv = argv[1:]
- if len(argv) < 1:
+ args = args[1:]
+ if len(args) < 1:
self.get_modules()
modules = self.modules
- elif len(argv) == 1:
- module = self.get_module(argv[0])
- elif len(argv) >= 2:
- module = self.get_module(argv[0])
- action = module.get_action(argv[1])
+ elif len(args) == 1:
+ module = self.get_module(args[0])
+ elif len(args) >= 2:
+ module = self.get_module(args[0])
+ action = module.get_action(args[1])
action.build()
- action.do_action(argv[2:])
- if len(argv) == 2:
- argv = None
+ action.do_action(args[2:])
+ if len(args) == 2:
+ args = None
else:
- argv = argv[2:]
+ args = args[2:]
- return [module, modules, argv, action]
+ return [module, modules, args, action]
def main():
uselect = UniversalSelectTool()
try:
list = uselect.parse_argv(sys.argv[1:])
+
printsystem.print_ui(module = list[0], \
modules = list[1], args = list[2], action = list[3])
except UserWarning, warning: