diff options
-rw-r--r-- | install.sh | 4 | ||||
-rw-r--r-- | uio.py | 24 | ||||
-rw-r--r-- | umodule.py | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | uprofile.py | 81 | ||||
-rwxr-xr-x | uselect.py | 36 |
5 files changed, 123 insertions, 24 deletions
@@ -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 @@ -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) @@ -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() @@ -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: |