Revision bc89ff1a

b/snf-webproject/synnefo/webproject/manage.py
74 74
    """
75 75

  
76 76
    results = []
77
    if path is None: path = sys.path
77
    if path is None:
78
        path = sys.path
78 79
    for p in path:
79 80
        importer = sys.path_importer_cache.get(p, None)
80 81
        if importer is None:
......
89 90
        except ImportError:
90 91
            if sys.modules.get(name, None):
91 92
                modpath = sys.modules[name].__path__
92
                if isinstance(modpath, basestring) and not ('', modpath) in results:
93
                    results.append(('', sys.modules[name].__path__))
93
                if (isinstance(modpath, basestring)
94
                    and not ('', modpath) in results):
95
                        results.append(('', sys.modules[name].__path__))
94 96
                else:
95 97
                    for mp in modpath:
96 98
                        if not ('', mp) in results:
......
102 104

  
103 105
    return results
104 106

  
107

  
105 108
def find_management_module(app_name):
106 109
    """
107 110
    Determines the path to the management module for the given app_name,
......
124 127
    try:
125 128
        modules = find_modules(part, paths)
126 129
        paths = [m[1] for m in modules]
127
    except ImportError,e:
130
    except ImportError:
128 131
        if os.path.basename(os.getcwd()) != part:
129
            raise e
132
            raise
130 133

  
131 134
    while parts:
132 135
        part = parts.pop()
......
186 189
                _commands.update(dict([(name, app_name)
187 190
                                       for name in find_commands(path)]))
188 191
            except ImportError:
189
                pass # No management module - ignore this app
192
                pass  # No management module - ignore this app
190 193

  
191 194
        if project_directory:
192 195
            # Remove the "startproject" command from self.commands, because
......
201 204

  
202 205
    return _commands
203 206

  
207

  
204 208
class SynnefoManagementUtility(ManagementUtility):
205 209
    """
206 210
    Override django ManagementUtility to allow us provide a custom
......
235 239
            options, args = parser.parse_args(self.argv)
236 240
            handle_default_options(options)
237 241
        except:
238
            pass # Ignore any option errors at this point.
242
            pass  # Ignore any option errors at this point.
239 243

  
240 244
        # user provides custom settings dir
241 245
        # set it as environmental variable and remove it from self.argv
......
248 252
        try:
249 253
            subcommand = self.argv[1]
250 254
        except IndexError:
251
            subcommand = 'help' # Display help if no arguments were given.
255
            subcommand = 'help'  # Display help if no arguments were given.
252 256

  
253 257
        # Encode stdout. This check is required because of the way python
254
        # checks if something is tty: https://bugzilla.redhat.com/show_bug.cgi?id=841152
258
        # checks if something is tty:
259
        # https://bugzilla.redhat.com/show_bug.cgi?id=841152
255 260
        if not subcommand in ['test'] and not 'shell' in subcommand:
256 261
            sys.stdout = EncodedStdOut(sys.stdout)
257 262

  
......
277 282
        """
278 283
        Returns the script's main help text, as a string.
279 284
        """
280
        usage = ['',"Type '%s help <subcommand>' for help on a specific subcommand." % self.prog_name,'']
285
        usage = ['', ("Type '%s help <subcommand>' for help"
286
                      "on a specific subcommand.") % self.prog_name, '']
281 287
        usage.append('Available subcommands:')
282 288
        commands = get_commands().keys()
283 289
        commands.sort()
......
294 300
        try:
295 301
            app_name = get_commands()[subcommand]
296 302
        except KeyError:
297
            sys.stderr.write("Unknown command: %r\nType '%s help' for usage.\n" % \
298
                (subcommand, self.prog_name))
303
            sys.stderr.write(("Unknown command: %r\n"
304
                              "Type '%s help' for usage.\n") %
305
                             (subcommand, self.prog_name))
299 306
            sys.exit(1)
300 307
        if isinstance(app_name, BaseCommand):
301 308
            # If the command is already loaded, use it directly.

Also available in: Unified diff