summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSérgio Almeida <mephx.x@gmail.com>2009-07-31 18:15:48 +0100
committerSérgio Almeida <mephx.x@gmail.com>2009-07-31 18:28:29 +0100
commitd62f5e09dc2c935e7feefc3cb9b9a1b981929b92 (patch)
tree3810e3890c05f584fd78eb2172be1a512047edea /uprofile.py
parentFixed re-printbug (diff)
downloaduselect-d62f5e09dc2c935e7feefc3cb9b9a1b981929b92.tar.gz
uselect-d62f5e09dc2c935e7feefc3cb9b9a1b981929b92.tar.bz2
uselect-d62f5e09dc2c935e7feefc3cb9b9a1b981929b92.zip
uprofile now verifies '.uprofile/' folder existence
fixed crashes when no profiles are found
Diffstat (limited to 'uprofile.py')
-rwxr-xr-xuprofile.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/uprofile.py b/uprofile.py
index 8a290d5..cc04512 100755
--- a/uprofile.py
+++ b/uprofile.py
@@ -28,6 +28,7 @@ class Profile(Module):
self.output = []
self.modules = []
str = ''
+
for line in filesystem.read_file('.uprofile/' + path):
str += line
@@ -82,11 +83,11 @@ class UniversalProfileTool:
def get_profiles(self):
""" Returns the list of available uprofiles """
- for profile in filesystem.list_dir('.uprofile/'):
- if re.match('.*.json$', profile):
- self.profiles.append(Profile(profile))
- return
-
+ if filesystem.path_exists('.uprofile'):
+ for profile in filesystem.list_dir('.uprofile/'):
+ if re.match('.*.json$', profile):
+ self.profiles.append(Profile(profile))
+
def parse_argv(self, args):
global verbose, version
profile = None
@@ -117,10 +118,15 @@ class UniversalProfileTool:
self.get_profiles()
profiles = self.profiles
elif len(args) < 1:
- profile = self.get_profile('folder')
- action = profile.get_action('activate')
- action.build()
- action.do_action(['activate'], profile.modules)
+ try:
+ profile = self.get_profile('folder')
+ action = profile.get_action('activate')
+ action.build()
+ action.do_action(['activate'], profile.modules)
+ except IOError:
+ self.get_profiles()
+ profiles = self.profiles
+ list = True
elif len(args) == 1:
try:
profile = self.get_profile(args[0])