Browse Source

add mm{shell,syncdb,runserver} commands that allow to choose a Murmur version first

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
ccc8c89dfa
  1. 21
      pyweb/mumble/management/commands/mmrunserver.py
  2. 21
      pyweb/mumble/management/commands/mmshell.py
  3. 21
      pyweb/mumble/management/commands/mmsyncdb.py
  4. 75
      pyweb/mumble/murmurenvutils.py

21
pyweb/mumble/management/commands/mmrunserver.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
"""
* Copyright (C) 2009, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
*
* 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

21
pyweb/mumble/management/commands/mmshell.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
"""
* Copyright (C) 2009, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
*
* 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

21
pyweb/mumble/management/commands/mmsyncdb.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
"""
* Copyright (C) 2009, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
*
* 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

75
pyweb/mumble/murmurenvutils.py

@ -169,3 +169,78 @@ def kill_murmur( process ):
return os.kill( process.pid, signal.SIGTERM ); 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 );
Loading…
Cancel
Save