Ajouter un commentaire

Charlie

Bonjour fredericmazue,

Merci pour ta réplique ...
Apres l'ajout de ta ligne de commande, j'ai ce msg d'erreur:

Traceback (most recent call last):
File "E:/Carl Python/13 Sept 2007/test1.txt", line 104, in
mo = re.search("loss", chaine)
File "C:\Python25\lib\re.py", line 134, in search
return _compile(pattern, flags).search(string)
TypeError: expected string or buffer

tu aurais une petite idée sur la façon d'améliorer mon script ce-dessous ?


class testit(Thread):
   def __init__ (self,ip):
      Thread.__init__(self)
      self.ip = ip
      self.status = -1
   def run(self):
      pingaling = os.popen("ping "+self.ip+" -n 10 ","r")
      
# This code is what each parallel thread does
# the 'run' method is triggered when 'start' is called
      while 1:
         #read, readline, readlines
         line = pingaling.read()
         if not line: break
         print
         print line

def chaine():
      while 1: 
         chaine = "Packets: Sent = 3, Received = 0, Lost = 3 (100% loss)" 
mo = re.search("loss", chaine) 

if mo: 
   print "trouve a ", mo.start() ,mo.end() 
  
else:
    print 'not working'

Filtered HTML

Plain text

CAPTCHA
Cette question permet de vérifier que vous n'êtes pas un robot spammeur :-)
  CCC  Y   Y  U   U  U   U   GGG  
C Y Y U U U U G
C Y U U U U G GG
C Y U U U U G G
CCC Y UUU UUU GGG