diff options
-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]) |