Changeset 9163 for src/django_gheat/gheat
- Timestamp:
- May 8, 2011, 7:45:17 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/gheat/management/commands/import_droidstumbler.py
r9162 r9163 26 26 27 27 from django.core.management import setup_environ 28 from django.core.management.base import BaseCommand 28 from django.core.management.base import BaseCommand, CommandError 29 29 from optparse import OptionParser, make_option 30 30 from gheat.models import * 31 import csv 31 32 import datetime 32 import csv 33 import os 34 import sys 33 35 34 36 def import_droidstumbler(location, meetrondje, gebruiker, email): … … 49 51 50 52 class Command(BaseCommand): 53 args = '<csvfile>' 51 54 option_list = BaseCommand.option_list + ( 52 make_option('-f', '--location', dest='location', default='location'),53 55 make_option('-m', '--meetrondje', dest='meetrondje', default='rondje'), 54 56 make_option('-g', '--gebruiker', dest='gebruiker', default='username'), … … 57 59 58 60 def handle(self, *args, **options): 59 import_droidstumbler(options['location'],options['meetrondje'],options['gebruiker'],options['email']) 61 try: 62 (csv_file,) = args 63 except ValueError: 64 self.print_help(sys.argv[0],sys.argv[1]) 65 raise CommandError("Not all arguments are provided") 66 if not os.path.isfile(csv_file): 67 raise CommandError("csv file '%s' does not exists" % csv_file) 68 import_droidstumbler(csv_file,options['meetrondje'],options['gebruiker'],options['email'])
Note:
See TracChangeset
for help on using the changeset viewer.