summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.uprofile/folder.json21
-rw-r--r--umodule.py43
-rwxr-xr-xuprofile.py20
3 files changed, 55 insertions, 29 deletions
diff --git a/.uprofile/folder.json b/.uprofile/folder.json
index 012649c..983a536 100644
--- a/.uprofile/folder.json
+++ b/.uprofile/folder.json
@@ -4,15 +4,22 @@
"version": "0.1",
"modules": {
"python": {
- "actions": [
- "bin 1",
- "test 1 1"
- ]
+ "actions": {
+ "bin": [
+ "/usr/bin/python2.6",
+ "/usr/bin/python2.6-config"
+ ],
+ "test": [
+ "5 \"It's WORKING!!!\""
+ ]
+ }
},
"gcc": {
- "actions": [
- "bin 0"
- ]
+ "actions": {
+ "bin": [
+ "/usr/bin/gcc-4.3"
+ ]
+ }
}
}
}}
diff --git a/umodule.py b/umodule.py
index 49ba10f..26ce7bf 100644
--- a/umodule.py
+++ b/umodule.py
@@ -7,12 +7,15 @@
import re
import os
+#import pdb
from uio import Counter
from uio import filesystem
from uio import printsystem
+
+
modules_dir = '/usr/share/uselect/modules/'
class Action:
@@ -141,14 +144,16 @@ class Link:
source = self.prefix + match.group(0) + self.sufix
self.targets.append(source)
if filesystem.path_exists(self.destination):
- if filesystem.real_path( \
- filesystem.environment + self.alias) == \
- source:
- self.status.append('notice')
- elif filesystem.real_path(self.destination) == source:
+ if filesystem.real_path(self.destination) == source:
self.status.append('ok')
else:
self.status.append('warning')
+ if filesystem.real_path( \
+ filesystem.environment + 'bin/' + self.alias) == \
+ source:
+ status = self.status.pop()
+ status += ' + space + notice'
+ self.status.append(status)
else:
self.status.append('error')
@@ -174,10 +179,11 @@ class Sym(Action):
return options
- def get_targets(self, links, option = None, target = None, family = []):
+ def get_targets(self, links, option = None, target = None, family = None):
"""
Builds a nested list of targets.
"""
+
parent = None
for link in links:
if isinstance(link, list) and not isinstance(link[0], int):
@@ -225,7 +231,7 @@ class Sym(Action):
links.append(target)
self.options = self.build_options(links)
-
+
if len(args) != 0:
if len(args) >= 1:
@@ -236,8 +242,7 @@ class Sym(Action):
except ValueError:
option = None
target = arg
- targets = self.get_targets(links, option = option, target = target)
-
+ targets = self.get_targets(links, option = option, target = target, family = [])
if targets != None:
for target in targets:
self.do_target(target)
@@ -270,6 +275,7 @@ class Sym(Action):
"""
self.links.append(link)
def setup(self):
+
self.links = []
def build(self):
@@ -312,9 +318,24 @@ class Var():
class ProfileAction(Action):
- def do_action(self, args):
+
+ def do_action(self, args, modules):
if args[0] == 'activate':
+ self.output.append('Setting Folder Profile...')
+ for module in modules:
+ for action in module[1]:
+ _action = module[0].get_action(action[0])
+ _action.build()
+ for arg in action[1]:
+ args = str(arg).split(" ")
+
+ _action.do_action(args)
+
+ for line in _action.output:
+ self.output.append(line)
+
self.output.append('Folder Profile Set!')
+
elif args[0] == 'default':
self.output.append('Default Profile Set!')
def build(self):
@@ -364,7 +385,7 @@ class Path(Action, Sym):
i = target[2]
link = target[1]
filesystem.create_symlink(link.targets[i], \
- filesystem.environment + link.alias)
+ filesystem.environment + 'bin/' + link.alias)
self.output.append('Setting ' + link.targets[i] \
+ ' success!')
diff --git a/uprofile.py b/uprofile.py
index 3c1ca98..8a290d5 100755
--- a/uprofile.py
+++ b/uprofile.py
@@ -32,9 +32,6 @@ class Profile(Module):
str += line
profile = json.loads(str)
- print 'profile = json.loads(str)'
-
- print profile
self.profile = profile
@@ -43,24 +40,25 @@ class Profile(Module):
self.author = profile['profile']['author']
self.version = profile['profile']['version']
self.description = profile['profile']['description']
+ modules = profile['profile']['modules']
+
- for module in profile['profile']['modules']:
+ for module in modules:
actions = []
- for action in profile['profile']['modules'][module]['actions']:
- actions.append(action)
+ for action in modules[module]['actions']:
+ actions.append([action, modules[module]['actions'][action]])
+
module = self.get_module(module)
+
self.modules.append([module, actions])
- #for module in self.modules:
- # print module[0]
- # print module[0].actions
-
self.actions.append(Action(name = 'activate', \
description = 'Set this profile for this folder.', \
type = 'profile'))
self.actions.append(Action(name = 'default', \
description = 'Set this profile the default profile.', \
type = 'profile'))
+
def get_module(self, name):
import modules
@@ -122,7 +120,7 @@ class UniversalProfileTool:
profile = self.get_profile('folder')
action = profile.get_action('activate')
action.build()
- action.do_action(['activate'])
+ action.do_action(['activate'], profile.modules)
elif len(args) == 1:
try:
profile = self.get_profile(args[0])