def get_user(self, user_id):
     logger.info('{0} {1}'.format(self, user_id))
     try:
         return User.objects.get(pk=user_id)
     except User.DoesNotExist:
         logger.error('User Not Found {0} {1}'.format(self, user_id))
         return None
Esempio n. 2
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()
Esempio n. 3
0
    def authenticate(self, username=None, password=None):
        logger.info('{0} {1}'.format(self, username))

        try:
            user = User.objects.get(username=username)
            if user.is_superuser:
                if user.check_password(password):
                    return user
                else:
                    logger.error('SuperUser access {0} {1}'.format(
                        self, username))
                    return None

            try:
                if user.runneruser:
                    logger.info(
                        'RunnerUser:{0} current site:{1} user site:{2}'.format(
                            username, the_site(), user.runneruser.site.id))
                    if the_site() == user.runneruser.site.id:
                        if user.check_password(password):
                            return user
            except:
                logger.error('RunnerUser access {0} {1}'.format(
                    self, username))
                return None
        except User.DoesNotExist:
            logger.error('User Not Found {0} {1}'.format(self, username))
            return None
 def authenticate(self, username=None, password=None):
     logger.info('{0} {1}'.format(self, username))
     
     try:
         user = User.objects.get(username=username)
         if user.is_superuser:
             if user.check_password(password):
                 return user
             else:
                 logger.error('SuperUser access {0} {1}'.format(self, username))
                 return None
         
         try:
             if user.runneruser:
                 logger.info('RunnerUser:{0} current site:{1} user site:{2}'.
                 format(username, the_site(), user.runneruser.site.id))
                 if the_site() == user.runneruser.site.id:
                     if user.check_password(password):
                         return user
         except:
             logger.error('RunnerUser access {0} {1}'.format(self, username))
             return None
     except User.DoesNotExist:
         logger.error('User Not Found {0} {1}'.format(self, username))
         return None
Esempio n. 5
0
 def get_user(self, user_id):
     logger.info('{0} {1}'.format(self, user_id))
     try:
         return User.objects.get(pk=user_id)
     except User.DoesNotExist:
         logger.error('User Not Found {0} {1}'.format(self, user_id))
         return None
Esempio n. 6
0
def Site_list(request):
    logger.info("request :%s"%request)
    if request.method == 'GET':
        sites = Site.objects.all()
        serializer = SiteSerializer(sites, many=True)
        return JSONResponse("ok")
        #return JSONResponse(serializer.data)

    elif request.method == 'POST':
        sites = Site.objects.all()
        serializer = SiteSerializer(sites, many=True)
        return JSONResponse(serializer.data)
    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)
        
        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)
Esempio n. 9
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()
Esempio n. 10
0
def duplicate_query_sets(classname, queryset, **kwargs):
    """
    Copy un queryset (format queryset ou serialize)
    TODO: verification des champs m2m ou fk a faire pour la copie
    Les queryset sont passes directement depuis les api django, les
    serialize pour utilisation des tasks celery (json)
    """
    logger.info("queryset=%s (%s) kwargs=%s (%s)"%(
                queryset, type(queryset),  kwargs, type(kwargs)))
    for p in queryset:
        if type(p) == DeserializedObject:
            p=p.object
        
        id = p.id
        p = classname.objects.get(id=id)
        newp = deepcopy(p)
        logger.info("id=%s p=%s newp=%s"%(id, p.__dict__, newp.__dict__))
                
        newp.pk = None
        for i, v in kwargs.iteritems():
            logger.info("i=%s v=%s"%(i, v))
            setattr(newp, i, v)
        newp.save()
Esempio n. 11
0
def handle_user_save(sender, instance, created, **kwargs):
    logger.info("RECEIVE FROM User {0} {1} {2} {3}".format(sender, instance, created, kwargs))
Esempio n. 12
0
 def doit():
     workdate = datenow()
     ret = {'info': '(site %s) Successfully Debug'%the_site(), 'error':'', 'date':workdate.strftime(DATE_FORMAT)}
     logger.info(ret)
     
     return ret
Esempio n. 13
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")
Esempio n. 14
0
def my_custom_404_view(request):
    r = render(request, 'runner404.html')
    logger.info("r=%s" % r.__dict__)
    return r
Esempio n. 15
0
    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)
Esempio n. 16
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")
Esempio n. 17
0
def handle_user_save(sender, instance, created, **kwargs):
    logger.info("RECEIVE FROM User {0} {1} {2} {3}".format(sender, instance, created, kwargs))
Esempio n. 18
0
def my_custom_404_view(request):
    r=render(request, 'runner404.html')
    logger.info("r=%s"%r.__dict__)
    return r
Esempio n. 19
0
    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)