Command Line Script Launcher

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import sys
from django.utils import termcolors
from django.core.management.base import LabelCommand

style = termcolors.make_style(fg='green', opts=('bold',))

class Command(LabelCommand):
    help = 'Executes the given Python source file under the context of the current Django settings'
    label = 'filename'
    args = '<filename filename ...>'
    requires_model_validation = False

    def handle_label(self, label, **options):
        sys.stderr.write(style('Executing %s' % label) + '\n')
        execfile(label, dict(__name__='__main__'))

More like this

  1. Translation statistics gatherer by ramiro 4 years, 9 months ago
  2. Hackish Way to Execute on manage.py Action by joshua 6 years, 2 months ago
  3. Copy/Paste form generation by dballanc 5 years, 6 months ago
  4. extras.py for management commands by dnordberg 5 years, 9 months ago
  5. syncdata command by graham 4 years, 9 months ago

Comments

(Forgotten your password?)