Example #1
0
    def handle(self, *args, **options):
        if options['debug'] == True:
            logdebug()

        logger.debug("options=%s" % options)

        if options['telco'] is None:
            lsttelco = Telco.objects.all()
            self.stdout.write(40 * '-')
            for t in lsttelco:
                self.stdout.write("Telco %s" % t)
            self.stdout.write(40 * '-')
            raise CommandError("Please specifie option telco")
        else:
            try:
                self.telco = Telco.objects.get(pk=options['telco'])
            except:
                self.stdout.write(Telco.info_telcos())
                raise CommandError("Telco not found")

        if options['typezone'] is None or not options[
                'typezone'] in list_typezone():
            logger.error("typezone \n%s" % info_typezone())
            raise CommandError("Please specifie option typezone")

#        if options['bizzone'] is None:
#            logger.error("bizzone \n%s"%info_bizzone())
#            raise CommandError("Please specifie option bizzone")

        if options['infoconfig'] is None:
            self.stdout.write(ConfigImport.info_configimport())
            raise CommandError("InfoConfig not found")

        try:
            self.infoconfig = ConfigImport.objects.get(
                pk=options['infoconfig'])
            logger.debug("infoconfig=%s" % self.infoconfig)
        except (ObjectDoesNotExist, ValueError) as e:
            logger.error("ConfigImport Info %s %s" %
                         (options['infoconfig'], e))
            self.stdout.write(ConfigImport.info_configimport())
            raise CommandError("Please specifie option config")

        if options['filename'] is None:
            raise CommandError("Filename not found")

        try:
            ie_Price().import_price(type=options['typezone'],
                                    fromtelco=self.telco,
                                    config=self.infoconfig,
                                    filename=options['filename'],
                                    force=options['force'])
        except Exception, e:
            raise CommandError("%s" % e)
    def handle(self, *args, **options):

        if options['debug'] == True:
            logdebug()
        logger.debug("options=%s" % options)

        self.workdate = datenow()
        logger.info("WORKDATE %s" % self.workdate)

        if options['reseller'] is None:
            lst = Reseller.objects.all()
            self.stdout.write(40 * '-')
            for t in lst:
                self.stdout.write("Reseller %s" % t)
            self.stdout.write(40 * '-')
            raise CommandError("Please specifie option reseller")
        else:
            try:
                self.reseller = Reseller.objects.get(pk=options['reseller'])
            except:
                self.stdout.write(Reseller.info_resellers())
                raise CommandError("Reseller not found")

        if options['infoconfig'] is None:
            self.stdout.write(ConfigImport.info_configimport())
            raise CommandError("InfoConfig not found")

        try:
            self.infoconfig = ConfigImport.objects.get(
                pk=options['infoconfig'])
            logger.debug("infoconfig=%s" % self.infoconfig)
        except (ObjectDoesNotExist, ValueError) as e:
            logger.error("ConfigImport Info %s %s" %
                         (options['infoconfig'], e))
            self.stdout.write(ConfigImport.info_configimport())
            raise CommandError("Please specifie option config")

        if options['filename'] is None:
            raise CommandError("Filename not found")

        if options['contrat']:
            self.myfunc = ie_Customer().import_contrat
        else:
            self.myfunc = ie_Customer().import_customer

        try:
            self.myfunc(reseller=self.reseller,
                        config=self.infoconfig,
                        filename=options['filename'],
                        force=options['force'])
        except Exception, e:
            raise CommandError("%s" % e)
    def handle(self, *args, **options):
        if options['debug'] == True:
            logdebug()

        logger.debug("options=%s"%options)

        if options['telco'] is None:
            lsttelco = Telco.objects.all()
            self.stdout.write(40 * '-')
            for t in lsttelco:
                self.stdout.write("Telco %s"%t)
            self.stdout.write(40 * '-')
            raise CommandError("Please specifie option telco")
        else:
            try:
                self.telco=Telco.objects.get(pk=options['telco'])
            except:
                self.stdout.write(Telco.info_telcos())
                raise CommandError("Telco not found")

        if options['typezone'] is None or not options['typezone'] in list_typezone():
            logger.error("typezone \n%s"%info_typezone())
            raise CommandError("Please specifie option typezone")

#        if options['bizzone'] is None:
#            logger.error("bizzone \n%s"%info_bizzone())
#            raise CommandError("Please specifie option bizzone")
 
        if options['infoconfig'] is None:
            self.stdout.write(ConfigImport.info_configimport())
            raise CommandError("InfoConfig not found")

        try:
            self.infoconfig = ConfigImport.objects.get(pk=options['infoconfig'])
            logger.debug("infoconfig=%s"%self.infoconfig)
        except (ObjectDoesNotExist, ValueError) as e:
            logger.error("ConfigImport Info %s %s"%(options['infoconfig'], e))
            self.stdout.write(ConfigImport.info_configimport())
            raise CommandError("Please specifie option config")

        if options['filename'] is None:
            raise CommandError("Filename not found")
        
        try:
            ie_Price().import_price(type=options['typezone'],
                    fromtelco=self.telco, config=self.infoconfig,
                    filename=options['filename'], force=options['force'])
        except Exception, e:
            raise CommandError("%s"%e)
    def handle(self, *args, **options):
          
        if options['debug'] == True:
            logdebug()
        logger.debug("options=%s"%options)
        
        self.workdate = datenow()
        logger.info("WORKDATE %s"%self.workdate)
        
        if options['reseller'] is None:
            lst = Reseller.objects.all()
            self.stdout.write(40 * '-')
            for t in lst:
                self.stdout.write("Reseller %s"%t)
            self.stdout.write(40 * '-')
            raise CommandError("Please specifie option reseller")
        else:
            try:
                self.reseller=Reseller.objects.get(pk=options['reseller'])
            except:
                self.stdout.write(Reseller.info_resellers())
                raise CommandError("Reseller not found")

        
        if options['infoconfig'] is None:
            self.stdout.write(ConfigImport.info_configimport())
            raise CommandError("InfoConfig not found")

        try:
            self.infoconfig = ConfigImport.objects.get(pk=options['infoconfig'])
            logger.debug("infoconfig=%s"%self.infoconfig)
        except (ObjectDoesNotExist, ValueError) as e:
            logger.error("ConfigImport Info %s %s"%(options['infoconfig'], e))
            self.stdout.write(ConfigImport.info_configimport())
            raise CommandError("Please specifie option config")

        if options['filename'] is None:
            raise CommandError("Filename not found")

        if options['contrat']:
            self.myfunc = ie_Customer().import_contrat
        else:
            self.myfunc = ie_Customer().import_customer
        
        try:
            self.myfunc(reseller=self.reseller, config=self.infoconfig,
                    filename=options['filename'], force=options['force'])
        except Exception, e:
            raise CommandError("%s"%e)
    def handle(self, *args, **options):

        if options['debug'] == True:
            logdebug()
        logger.debug("options=%s" % options)

        if options['grilleprice']:
            options['grillename'] = options['grilleclient'] = False

        if options['grilleclient']:
            options['grillename'] = options['grilleprice'] = False

        self.workdate = datenow()
        logger.info("WORKDATE %s" % self.workdate)

        if options['reseller'] is None:
            lst = Reseller.objects.all()
            self.stdout.write(40 * '-')
            for t in lst:
                self.stdout.write("Reseller %s" % t)
            self.stdout.write(40 * '-')
            raise CommandError("Please specifie option reseller")
        else:
            try:
                self.reseller = Reseller.objects.get(pk=options['reseller'])
            except:
                self.stdout.write(Reseller.info_resellers())
                raise CommandError("Reseller not found")

        if options['ga'] is None and options['grillename']:
            lst = GA_Telco.objects.all()
            self.stdout.write(40 * '-')
            for t in lst:
                self.stdout.write("Grille Achat %s" % t)
            self.stdout.write(40 * '-')
            raise CommandError("Please specifie option ga")
        else:
            if options['ga'] and options['grillename']:
                try:
                    self.ga = GA_Telco.objects.get(pk=options['ga'])
                except:
                    self.stdout.write(GA_Telco.info_gas())
                    raise CommandError("GA_Telco not found")

        if options['infoconfig'] is None:
            self.stdout.write(ConfigImport.info_configimport())
            raise CommandError("InfoConfig not found")

        try:
            self.infoconfig = ConfigImport.objects.get(
                pk=options['infoconfig'])
            logger.debug("infoconfig=%s" % self.infoconfig)
        except (ObjectDoesNotExist, ValueError) as e:
            logger.error("ConfigImport Info %s %s" %
                         (options['infoconfig'], e))
            self.stdout.write(ConfigImport.info_configimport())
            raise CommandError("Please specifie option config")

        if options['filename'] is None:
            raise CommandError("Filename not found")

        try:
            if options['grillename']:
                ie_Grille().import_grillename(reseller=self.reseller,
                                              ga=self.ga,
                                              config=self.infoconfig,
                                              filename=options['filename'],
                                              force=options['force'])

            if options['grilleprice']:
                ie_Grille().import_grilleprice(reseller=self.reseller,
                                               config=self.infoconfig,
                                               filename=options['filename'],
                                               force=options['force'])

            if options['grilleclient']:
                ie_Grille().import_grilleclient(reseller=self.reseller,
                                                config=self.infoconfig,
                                                filename=options['filename'],
                                                force=options['force'])

        except Exception, e:
            raise CommandError("%s" % e)
    def handle(self, *args, **options):

        if options["debug"] == True:
            logdebug()
        logger.debug("options=%s" % options)

        if options["grilleprice"]:
            options["grillename"] = options["grilleclient"] = False

        if options["grilleclient"]:
            options["grillename"] = options["grilleprice"] = False

        self.workdate = datenow()
        logger.info("WORKDATE %s" % self.workdate)

        if options["reseller"] is None:
            lst = Reseller.objects.all()
            self.stdout.write(40 * "-")
            for t in lst:
                self.stdout.write("Reseller %s" % t)
            self.stdout.write(40 * "-")
            raise CommandError("Please specifie option reseller")
        else:
            try:
                self.reseller = Reseller.objects.get(pk=options["reseller"])
            except:
                self.stdout.write(Reseller.info_resellers())
                raise CommandError("Reseller not found")

        if options["ga"] is None and options["grillename"]:
            lst = GA_Telco.objects.all()
            self.stdout.write(40 * "-")
            for t in lst:
                self.stdout.write("Grille Achat %s" % t)
            self.stdout.write(40 * "-")
            raise CommandError("Please specifie option ga")
        else:
            if options["ga"] and options["grillename"]:
                try:
                    self.ga = GA_Telco.objects.get(pk=options["ga"])
                except:
                    self.stdout.write(GA_Telco.info_gas())
                    raise CommandError("GA_Telco not found")

        if options["infoconfig"] is None:
            self.stdout.write(ConfigImport.info_configimport())
            raise CommandError("InfoConfig not found")

        try:
            self.infoconfig = ConfigImport.objects.get(pk=options["infoconfig"])
            logger.debug("infoconfig=%s" % self.infoconfig)
        except (ObjectDoesNotExist, ValueError) as e:
            logger.error("ConfigImport Info %s %s" % (options["infoconfig"], e))
            self.stdout.write(ConfigImport.info_configimport())
            raise CommandError("Please specifie option config")

        if options["filename"] is None:
            raise CommandError("Filename not found")

        try:
            if options["grillename"]:
                ie_Grille().import_grillename(
                    reseller=self.reseller,
                    ga=self.ga,
                    config=self.infoconfig,
                    filename=options["filename"],
                    force=options["force"],
                )

            if options["grilleprice"]:
                ie_Grille().import_grilleprice(
                    reseller=self.reseller, config=self.infoconfig, filename=options["filename"], force=options["force"]
                )

            if options["grilleclient"]:
                ie_Grille().import_grilleclient(
                    reseller=self.reseller, config=self.infoconfig, filename=options["filename"], force=options["force"]
                )

        except Exception, e:
            raise CommandError("%s" % e)