diff options
author | Sérgio Almeida <mephx.x@gmail.com> | 2009-07-31 18:15:48 +0100 |
---|---|---|
committer | Sérgio Almeida <mephx.x@gmail.com> | 2009-07-31 18:28:29 +0100 |
commit | d62f5e09dc2c935e7feefc3cb9b9a1b981929b92 (patch) | |
tree | 3810e3890c05f584fd78eb2172be1a512047edea | |
parent | Fixed re-printbug (diff) | |
download | uselect-d62f5e09dc2c935e7feefc3cb9b9a1b981929b92.tar.gz uselect-d62f5e09dc2c935e7feefc3cb9b9a1b981929b92.tar.bz2 uselect-d62f5e09dc2c935e7feefc3cb9b9a1b981929b92.zip |
uprofile now verifies '.uprofile/' folder existence
fixed crashes when no profiles are found
-rw-r--r-- | uio.py | 2 | ||||
-rwxr-xr-x | uprofile.py | 24 |
2 files changed, 17 insertions, 9 deletions
@@ -337,6 +337,8 @@ class ProfilePrintSystem(PrintSystem): def print_profiles(self, profiles): self.print_line(highlight + space + 'Profiles:' + reset) table = [] + if len(profiles) == 0: + table.append([bold + 'No Profiles Found!' , '']) for profile in profiles: table.append([bold + profile.name, bullet + space + profile.description]) self.print_table(table) 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]) |