Thursday 15 May 2014

ip - Django - Model Boolean Check with Python Ping -


I have a working DSLAM management site for the current DSL connection I currently do want me to work, DSLAM IP By automatically developing the address, the DSLAM status updates itself. If a good request, he Boolean = true will return and save Boolean = false and against. So far it is not working and it is not sure where to go from here.

models.py
  import models from import os, sys class DslamManager (models.Manager): def dslam_status (self, ip_address): If os.system ( 'ping '+ ip_address): dslam_status = Super (DslamManager, self) .Get (ip_address) dslam_status = true dslam_status.save () and: dslam_status = Super (DslamManager, self) dslam_status = false dslam_status.save () class location (models.Model ): LOCATION_NAME = models.CharField (MAX_LENGTH = 30) island_name = models.CharField (MAX_LENGTH = 30) class meta: command = ['LOCATION_NAME'] def __unicode __ (self): return self.location_name class DSLAM (models.Model) : dslam_name = models.CharField (MAX_LENGTH = 32) ip_address = models.CharField (MAX_LENGTH = 128) location = models.ForeignKey (location) Note = models.TextField (empty = S ) Dslam_status = models.BooleanField () objects = DslamManager () class meta: command = ['location', 'id'] def __unicode __ (self): return self.dslam_name    

I've decided adding ModelAdmin. It takes a little time to refresh, but it is trying to ping the list of IP addresses.

  list_display = DSLAM_STATUS DEF ('DSLAM_STATUS',) (self, obj): if os.system ('Ping W1-n 1' + obj.ip_address): DSLAM_STATUS = Any other false : DSLAM_STATUS = true return DSLAM_STATUS DSLAM_STATUS.boolean = true DSLAM_STATUS.allow_tags = true   

It only does some work of time, but I believe the time it starts pinging ip_address It's too early at times

No comments:

Post a Comment