From f9acf92a0f14ff12a7cfdc44e50263d2081499a3 Mon Sep 17 00:00:00 2001 From: Sérgio Almeida Date: Fri, 31 Jul 2009 18:15:48 +0100 Subject: uprofile now verifies of '.uselect/' folder existance fixed crashes when no profiles are found --- uio.py | 2 ++ uprofile.py | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/uio.py b/uio.py index f00b2ca..c54754f 100644 --- a/uio.py +++ b/uio.py @@ -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]) -- cgit v1.2.3-65-gdbad