0c2b404c37baea20806181a395f944a40131dbaf
[auf_rh_dae.git] / project / dae / management / commands / dae.py
1 # -*- encoding: utf-8 -*-
2
3 from django.core.management.base import BaseCommand
4
5 from project.dae import models as dae
6
7 class Command(BaseCommand):
8
9
10 def handle(self, *args, **options):
11
12 if len(args) < 2:
13 print len(args)
14 self.stdout.write("dae <modele> <id> <run>\n")
15 return
16
17 classname = args[0]
18 klass = getattr(dae, classname, None)
19 if klass is None:
20 self.stdout.write("Le modèle %s n'existe pas dans DAE.\n" % classname)
21
22 id = int(args[1])
23 try:
24 obj = klass.objects.get(id=id)
25 except:
26 self.stdout.write("L'id %s n'existe pas pour le modèle %s dans DAE.\n" % \
27 (id, classname))
28 return
29
30
31 copy = obj.importer()
32 self.stdout.write(u"\n[%s] DAE:%s => RH:%s\n" %
33 (obj.__class__.__name__, obj.id, copy.id))
34