Ejemplo n.º 1
0
 def str_found_cb(self, buf, regex, verbose, search=True):
     '''
     Return sshcbreturn type setting stop to True if given regex matches against given string buf
     '''
     if verbose:
         self.debug(str(buf))
     return sshconnection.SshCbReturn(
         stop=self.str_found(buf, regex=regex, search=search))
Ejemplo n.º 2
0
 def wget_status_cb(self, buf):
     ret = sshconnection.SshCbReturn(stop=False)
     try:
         buf = buf.strip()
         val = buf.split()[0]
         if val != self.wget_last_status:
             if re.match('^\d+\%', buf):
                 sys.stdout.write("\r\x1b[K" + str(buf))
                 sys.stdout.flush()
                 self.wget_last_status = val
             else:
                 print buf
     except Exception, e:
         pass
Ejemplo n.º 3
0
 def wget_status_cb(self, buf):
     ret = sshconnection.SshCbReturn(stop=False)
     ret.buf = ''
     try:
         buf = buf.strip()
         val = buf.split()[0]
         if val != self.wget_last_status:
             if re.match('^\d+\%', buf):
                 sys.stdout.write("\r\x1b[K" + str(buf))
                 sys.stdout.flush()
                 self.wget_last_status = val
             else:
                 # Grab the saved location and save it as the only returned item in the
                 # command's 'output' buffer.
                 dest_search = re.search('Saving\s*to:\s*".*"', buf)
                 if dest_search:
                     line = str(dest_search.group()).decode(
                         'ascii', 'ignore')
                     splitline = line.split(':')
                     if len(splitline) > 1:
                         ret.buf = str(splitline[1].strip())
                 print buf
     except Exception, e:
         pass