diff --git a/pyweb/mumble/management/commands/mmrunserver.py b/pyweb/mumble/management/commands/mmrunserver.py new file mode 100644 index 0000000..a2abfe0 --- /dev/null +++ b/pyweb/mumble/management/commands/mmrunserver.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + +""" + * Copyright (C) 2009, Michael "Svedrin" Ziegler + * + * Mumble-Django is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. +""" + +from django.core.management.commands.runserver import Command as OrigCommand +from mumble.murmurenvutils import MumbleCommandWrapper + +class Command( MumbleCommandWrapper, OrigCommand ): + pass diff --git a/pyweb/mumble/management/commands/mmshell.py b/pyweb/mumble/management/commands/mmshell.py new file mode 100644 index 0000000..a90f7ca --- /dev/null +++ b/pyweb/mumble/management/commands/mmshell.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + +""" + * Copyright (C) 2009, Michael "Svedrin" Ziegler + * + * Mumble-Django is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. +""" + +from django.core.management.commands.shell import Command as OrigCommand +from mumble.murmurenvutils import MumbleCommandWrapper_noargs + +class Command( MumbleCommandWrapper_noargs, OrigCommand ): + pass diff --git a/pyweb/mumble/management/commands/mmsyncdb.py b/pyweb/mumble/management/commands/mmsyncdb.py new file mode 100644 index 0000000..6567486 --- /dev/null +++ b/pyweb/mumble/management/commands/mmsyncdb.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + +""" + * Copyright (C) 2009, Michael "Svedrin" Ziegler + * + * Mumble-Django is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. +""" + +from django.core.management.commands.syncdb import Command as OrigCommand +from mumble.murmurenvutils import MumbleCommandWrapper_noargs + +class Command( MumbleCommandWrapper_noargs, OrigCommand ): + pass diff --git a/pyweb/mumble/murmurenvutils.py b/pyweb/mumble/murmurenvutils.py index 9626be0..498da5e 100644 --- a/pyweb/mumble/murmurenvutils.py +++ b/pyweb/mumble/murmurenvutils.py @@ -169,3 +169,78 @@ def kill_murmur( process ): return os.kill( process.pid, signal.SIGTERM ); +class MumbleCommandWrapper_noargs( object ): + """ Mixin used to run a standard Django command inside MurmurEnvUtils. + + To modify a standard Django command for MEU, you will need to create + a new command and derive its Command class from the wrapper, and the + Command class of the original command: + + from django.core.management.commands.shell import Command as ShellCommand + from mumble.murmurenvutils import MumbleCommandWrapper + + class Command( MumbleCommandWrapper, ShellCommand ): + pass + + That will run the original command, after the user has had the chance to + select the version of Murmur to run. + """ + + def _choose_version( self ): + print "Choose version:"; + + vv = get_available_versions(); + for idx in range(len(vv)): + print " #%d %s" % ( idx, vv[idx] ); + + chosen = int( raw_input("#> ") ); + + return vv[chosen]; + + def handle_noargs( self, **options ): + self.origOpts = options; + + run_callback( self._choose_version(), self.runOrig ); + + def runOrig( self, proc ): + super( MumbleCommandWrapper_noargs, self ).handle_noargs( **self.origOpts ); + + +class MumbleCommandWrapper( object ): + """ Mixin used to run a standard Django command inside MurmurEnvUtils. + + To modify a standard Django command for MEU, you will need to create + a new command and derive its Command class from the wrapper, and the + Command class of the original command: + + from django.core.management.commands.shell import Command as ShellCommand + from mumble.murmurenvutils import MumbleCommandWrapper + + class Command( MumbleCommandWrapper, ShellCommand ): + pass + + That will run the original command, after the user has had the chance to + select the version of Murmur to run. + """ + + def _choose_version( self ): + print "Choose version:"; + + vv = get_available_versions(); + for idx in range(len(vv)): + print " #%d %s" % ( idx, vv[idx] ); + + chosen = int( raw_input("#> ") ); + + return vv[chosen]; + + def handle( self, *args, **options ): + self.origArgs = args; + self.origOpts = options; + + run_callback( self._choose_version(), self.runOrig ); + + def runOrig( self, proc ): + super( MumbleCommandWrapper, self ).handle( *self.origArgs, **self.origOpts ); + +