def duplicatem2m_query_sets(queryset, **kwargs):
    logger.debug("queryset=%s (%s) kwargs=%s (%s)"%(
                queryset, type(queryset),  kwargs, type(kwargs)))
    
    for p in queryset:
        newp = deepcopy(p)
        newp.pk=None
        newp.save()
Beispiel #2
0
 def allow_relation(self, obj1, obj2, **hints):
     """Allow any relation between apps that use the same database."""
     logger.debug('self=%s obj1=%s obj2=%s' % (self, obj1, obj2))
     db_obj1 = settings.DATABASE_APPS_MAPPING.get(obj1._meta.app_label)
     db_obj2 = settings.DATABASE_APPS_MAPPING.get(obj2._meta.app_label)
     if db_obj1 and db_obj2:
         if db_obj1 == db_obj2:
             return True
         else:
             return False
     return None
Beispiel #3
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)
Beispiel #4
0
 def allow_relation(self, obj1, obj2, **hints):
     """Allow any relation between apps that use the same database."""
     logger.debug("self=%s obj1=%s obj2=%s" % (self, obj1, obj2))
     db_obj1 = settings.DATABASE_APPS_MAPPING.get(obj1._meta.app_label)
     db_obj2 = settings.DATABASE_APPS_MAPPING.get(obj2._meta.app_label)
     if db_obj1 and db_obj2:
         if db_obj1 == db_obj2:
             return True
         else:
             return False
     return None
    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['reseller'] is None:
            logger.error("reseller \n%s"%Reseller.info_resellers())
            raise CommandError("Please specifie option reseller")
        
        try:
            resel=Reseller.objects.get(id=options['reseller'])
        except ObjectDoesNotExist:
            logger.error("reseller \n%s"%Reseller.info_resellers())
            raise CommandError("Please specifie option reseller")
            
        ie_Cdr().export_cdr(reseller=resel, datefrom=options['datefrom'], dateto=options['dateto'])
        self.stdout.write('Successfully export CDRs')
    def render(self, name, value, attrs=None, **kwargs):
        field_id = attrs['id']
        field = field_id.split('_', 1)[1]
                    
        context = {
            'field_id': field_id,
            'field': field,
            'value': value or '',
            'STATIC_URL': settings.STATIC_URL
        }

        logger.debug("self=%r"%self.__dict__)
        logger.debug("name=%s value=%s attrs=%r kwargs=%r"%(name, value, attrs, kwargs))
        
#        widget_html = mark_safe(render_to_string('jsoneditor/jsoneditor_widget.html', context))
#        post_html = mark_safe(render_to_string('jsoneditor/jsoneditor_post.html', context))
#        return widget_html + post_html
        return mark_safe(render_to_string('jsoneditor/jsoneditor.html', context))
    def handle(self, *args, **options):
        if options['debug'] == True:
            logdebug()
        logger.debug("options=%s" % options)

        if options['reseller'] is None:
            logger.error("reseller \n%s" % Reseller.info_resellers())
            raise CommandError("Please specifie option reseller")

        try:
            resel = Reseller.objects.get(id=options['reseller'])
        except ObjectDoesNotExist:
            logger.error("reseller \n%s" % Reseller.info_resellers())
            raise CommandError("Please specifie option reseller")

        ie_Cdr().export_cdr(reseller=resel,
                            datefrom=options['datefrom'],
                            dateto=options['dateto'])
        self.stdout.write('Successfully export CDRs')
Beispiel #11
0
    def get_files(self, rep, filenameext=""):
        logger.debug("rep=%s filenameext=%s" % (rep, filenameext))

        for kind in filenameext.split(','):
            #logger.debug("kind=%s"%kind)

            for root, dirs, files in os.walk(rep):
                logger.debug("root=%s dirs=%s files=%s" % (root, dirs, files))

                if 'save' in dirs:
                    dirs.remove('save')

                for f in files:
                    (shortname, extension) = os.path.splitext(f)
                    if kind:
                        if extension[1:] in kind:
                            self.thelist.append(os.path.join(root, f))
                    else:
                        self.thelist.append(os.path.join(root, f))
        return self.thelist
    def get_files(self, rep, filenameext=""):
        logger.debug("rep=%s filenameext=%s" % (rep, filenameext))

        for kind in filenameext.split(","):
            # logger.debug("kind=%s"%kind)

            for root, dirs, files in os.walk(rep):
                logger.debug("root=%s dirs=%s files=%s" % (root, dirs, files))

                if "save" in dirs:
                    dirs.remove("save")

                for f in files:
                    (shortname, extension) = os.path.splitext(f)
                    if kind:
                        if extension[1:] in kind:
                            self.thelist.append(os.path.join(root, f))
                    else:
                        self.thelist.append(os.path.join(root, f))
        return self.thelist
Beispiel #13
0
    def render(self, name, value, attrs=None, **kwargs):
        field_id = attrs['id']
        field = field_id.split('_', 1)[1]

        context = {
            'field_id': field_id,
            'field': field,
            'value': value or '',
            'STATIC_URL': settings.STATIC_URL
        }

        logger.debug("self=%r" % self.__dict__)
        logger.debug("name=%s value=%s attrs=%r kwargs=%r" %
                     (name, value, attrs, kwargs))

        #        widget_html = mark_safe(render_to_string('jsoneditor/jsoneditor_widget.html', context))
        #        post_html = mark_safe(render_to_string('jsoneditor/jsoneditor_post.html', context))
        #        return widget_html + post_html
        return mark_safe(
            render_to_string('jsoneditor/jsoneditor.html', context))
    def doit(self, options):
        if len(self.thelist):
            lstndis = []
            Fake = options["fake"]

            if options["client"]:
                for cl in options["client"].split(","):
                    try:
                        lstndiclient = Client.objects.get(code=cl).sipaccount_set.all().values_list("cli", flat=True)
                        logger.debug("NDIS CLIENT (%s) %s" % (cl, lstndiclient))
                        lstndis += lstndiclient
                    except:
                        logger.error("NO NDI FOR CLIENT %s" % cl)

            logger.debug("LIST NDIS %s" % lstndis)

            for filename in self.thelist:
                logger.info("FILENAME %s" % filename)
                if not Fake:
                    try:
                        self.cdrs += ie_Cdr().import_cdr(
                            workdate=self.workdate,
                            fromtelco=self.telco,
                            injector=self.telcoinjector,
                            filename=filename,
                            force=options["force"],
                            clientndis=lstndis,
                            check=options["check"],
                        )
                    except ie_Exception, e:
                        logger.error("%s %s" % (e, filename))

                if self.djangodebug:
                    logger.debug("Garbage Django Debug")
                    db.reset_queries()
Beispiel #15
0
 def allow_syncdb(self, db, model):
     """Make sure that apps only appear in the related database."""
     logger.debug("self=%s db=%s model=%s" % (self.__dict__, db, model))
     if db in settings.DATABASE_APPS_MAPPING.values():
         logger.debug("ALLOW db=%s" % db)
         return settings.DATABASE_APPS_MAPPING.get(model._meta.app_label) == db
     elif settings.DATABASE_APPS_MAPPING.has_key(model._meta.app_label):
         logger.debug("NOT ALLOW db=%s" % db)
         return False
     return None
Beispiel #16
0
 def allow_syncdb(self, db, model):
     """Make sure that apps only appear in the related database."""
     logger.debug('self=%s db=%s model=%s' % (self.__dict__, db, model))
     if db in settings.DATABASE_APPS_MAPPING.values():
         logger.debug('ALLOW db=%s' % db)
         return settings.DATABASE_APPS_MAPPING.get(model._meta.app_label) == db
     elif settings.DATABASE_APPS_MAPPING.has_key(model._meta.app_label):
         logger.debug('NOT ALLOW db=%s' % db)
         return False
     return None
Beispiel #17
0
    def doit(self, options):
        if len(self.thelist):
            lstndis = []
            Fake = options['fake']

            if options['client']:
                for cl in options['client'].split(','):
                    try:
                        lstndiclient = Client.objects.get(
                            code=cl).sipaccount_set.all().values_list(
                                'cli', flat=True)
                        logger.debug("NDIS CLIENT (%s) %s" %
                                     (cl, lstndiclient))
                        lstndis += lstndiclient
                    except:
                        logger.error("NO NDI FOR CLIENT %s" % cl)

            logger.debug("LIST NDIS %s" % lstndis)

            for filename in self.thelist:
                logger.info("FILENAME %s" % filename)
                if not Fake:
                    try:
                        self.cdrs += ie_Cdr().import_cdr(
                            workdate=self.workdate,
                            fromtelco=self.telco,
                            injector=self.telcoinjector,
                            filename=filename,
                            force=options['force'],
                            clientndis=lstndis,
                            check=options['check'])
                    except ie_Exception, e:
                        logger.error("%s %s" % (e, filename))

                if self.djangodebug:
                    logger.debug("Garbage Django Debug")
                    db.reset_queries()
Beispiel #18
0
def format_datatable(request, withrowid=True):
    data = {'data':{}}
    
    for x in request:
        logger.debug("Working %s=%s"%(x, request.get(x)))
        
        if x == 'id' and not data['data'].has_key('id') and withrowid==True:
            m='id'
        elif x.startswith('data['):
            m=x[x.find("[")+1:x.find("]")]
            #if len(m) == 0 and not data['data'].has_key('id') and withrowid==True:
            #    m='id'
        elif x.startswith('id['):
            m=x[x.find("[")+1:x.find("]")]
            if len(m) == 0 and not data['data'].has_key('id') and withrowid==True:
                m='id'
        else:
            continue
            
        data['data'][m] = request.get(x)
        logger.debug("data %s=%s"%(m, data['data'][m]))
    
    logger.debug("data %s"%data)
    return data
    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)
Beispiel #20
0
 def get(self, request, pk, format=None):
     logger.debug("request = %s pk = %s"%(request, pk))
     juri = self.get_object(pk) 
     serializer = JuridictionSerializer(juri)
     return Response(serializer.data)
    def handle(self, *args, **options):
        if getattr(settings, "DEBUG", False):
            self.djangodebug = True

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

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

        if options["auto"] is False:  # automatic, TelcoInjectors par Telco
            logger.debug("NO AUTO")
            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 ObjectDoesNotExist, e:
                    self.stdout.write(Telco.info_telcos())
                    raise CommandError("Telco not found")

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

            if options["injector"] is None:
                lsttelco = Telco.objects.all()
                for t in lsttelco:
                    if t.injectors:
                        self.stdout.write(40 * "-")
                        self.stdout.write("Telco %s" % t)
                        for p in t.injectors.all():
                            self.stdout.write(
                                "Injectors : %s"
                                % "(%s) %s [%s] [%s]"
                                % (int(p.id), p.name, p.get_bizzone_display(), p.get_typeconnexion_display())
                            )
                        self.stdout.write(40 * "-")
                raise CommandError("Please specifie option injector")

            try:
                self.telcoinjector = TelcoInjector.objects.get(pk=options["injector"])
                logger.debug("injector=%s" % self.telcoinjector)
                if options["extention"]:
                    self.extention = options["extention"]
                else:
                    self.extention = self.telcoinjector.get_typefile_display()

                if options["filename"]:
                    self.thelist = glob.glob(options["filename"])
                else:
                    if options["directory"]:
                        self.directory = options["directory"]
                    else:
                        self.directory = normpath(self.telcoinjector.path_dest)

                    logger.debug(
                        "directory=%s extention=%s list=%s"
                        % (self.directory, self.extention, self.get_files(self.directory, self.extention))
                    )

            except ObjectDoesNotExist, e:
                logger.error("Telco Injector Info %s %s" % (options["injector"], e))
                raise CommandError("Please specifie option injector")
                        self.directory = options["directory"]
                    else:
                        self.directory = normpath(self.telcoinjector.path_dest)

                    logger.debug(
                        "directory=%s extention=%s list=%s"
                        % (self.directory, self.extention, self.get_files(self.directory, self.extention))
                    )

            except ObjectDoesNotExist, e:
                logger.error("Telco Injector Info %s %s" % (options["injector"], e))
                raise CommandError("Please specifie option injector")

            self.doit(options)
        else:
            logger.debug("AUTO")
            for i in TelcoInjector.injectorauto.values("id", "name", "telco", "telco__name", "name").order_by(
                "telco", "id"
            ):
                self.thelist = []
                injector = None
                telco = None
                logger.debug("Telco (%s) %s Injector (%s) %s" % (i["telco"], i["telco__name"], i["id"], i["name"]))
                injector = TelcoInjector.objects.get(id=i["id"])
                telco = Telco.objects.get(id=i["telco"])
                path_dest = normpath(injector.path_dest)
                logger.debug("--> Working (%s) path=%s" % (injector, path_dest))
                logger.debug("YEAR=%s MONTH=%s" % (yearofdate(self.workdate), monthofdate(self.workdate)))
                logger.debug("PYEAR=%s PMONTH=%s" % (prevyearofdate(self.workdate), prevmonthofdate(self.workdate)))
                # traitement m-1 et m
                self.telcoinjector = injector
Beispiel #23
0
 def db_for_write(self, model, **hints):
     """Point all write operations to the specific database."""
     logger.debug("self=%s model=%s" % (self, model.__dict__))
     if settings.DATABASE_APPS_MAPPING.has_key(model._meta.app_label):
         return settings.DATABASE_APPS_MAPPING[model._meta.app_label]
     return None
Beispiel #24
0
    def handle(self, *args, **options):
        if getattr(settings, 'DEBUG', False):
            self.djangodebug = True

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

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

        if options['auto'] is False:  #automatic, TelcoInjectors par Telco
            logger.debug("NO AUTO")
            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 ObjectDoesNotExist, e:
                    self.stdout.write(Telco.info_telcos())
                    raise CommandError("Telco not found")

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

            if options['injector'] is None:
                lsttelco = Telco.objects.all()
                for t in lsttelco:
                    if t.injectors:
                        self.stdout.write(40 * '-')
                        self.stdout.write("Telco %s" % t)
                        for p in t.injectors.all():
                            self.stdout.write(
                                "Injectors : %s" % "(%s) %s [%s] [%s]" %
                                (int(p.id), p.name, p.get_bizzone_display(),
                                 p.get_typeconnexion_display()))
                        self.stdout.write(40 * '-')
                raise CommandError("Please specifie option injector")

            try:
                self.telcoinjector = TelcoInjector.objects.get(
                    pk=options['injector'])
                logger.debug("injector=%s" % self.telcoinjector)
                if options['extention']:
                    self.extention = options['extention']
                else:
                    self.extention = self.telcoinjector.get_typefile_display()

                if options['filename']:
                    self.thelist = glob.glob(options['filename'])
                else:
                    if options['directory']:
                        self.directory = options['directory']
                    else:
                        self.directory = normpath(self.telcoinjector.path_dest)

                    logger.debug(
                        "directory=%s extention=%s list=%s" %
                        (self.directory, self.extention,
                         self.get_files(self.directory, self.extention)))

            except ObjectDoesNotExist, e:
                logger.error("Telco Injector Info %s %s" %
                             (options['injector'], e))
                raise CommandError("Please specifie option injector")
Beispiel #25
0
 def get(self, request, pk, format=None):
     logger.debug("request = %s pk = %s" % (request, pk))
     juri = self.get_object(pk)
     serializer = JuridictionSerializer(juri)
     return Response(serializer.data)
Beispiel #26
0
                    else:
                        self.directory = normpath(self.telcoinjector.path_dest)

                    logger.debug(
                        "directory=%s extention=%s list=%s" %
                        (self.directory, self.extention,
                         self.get_files(self.directory, self.extention)))

            except ObjectDoesNotExist, e:
                logger.error("Telco Injector Info %s %s" %
                             (options['injector'], e))
                raise CommandError("Please specifie option injector")

            self.doit(options)
        else:
            logger.debug("AUTO")
            for i in TelcoInjector.injectorauto.values('id', 'name', 'telco',
                                                       'telco__name',
                                                       'name').order_by(
                                                           'telco', 'id'):
                self.thelist = []
                injector = None
                telco = None
                logger.debug(
                    "Telco (%s) %s Injector (%s) %s" %
                    (i['telco'], i['telco__name'], i['id'], i['name']))
                injector = TelcoInjector.objects.get(id=i['id'])
                telco = Telco.objects.get(id=i['telco'])
                path_dest = normpath(injector.path_dest)
                logger.debug("--> Working (%s) path=%s" %
                             (injector, path_dest))
Beispiel #27
0
 def db_for_write(self, model, **hints):
     """Point all write operations to the specific database."""
     logger.debug('self=%s model=%s' % (self, model.__dict__))
     if settings.DATABASE_APPS_MAPPING.has_key(model._meta.app_label):
         return settings.DATABASE_APPS_MAPPING[model._meta.app_label]
     return None
    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)