def parse(self, line): ''' Driftnet output line parser. ''' # This parser is about as simple as they come. Every line is simply a # filename of the image that driftnet carved out. All we need to do is # open it up, send the data to the API, then remove the file. filename = line.strip('\r\n ') log.debug('DRIFTNET: sending image %s' % filename) self.api.image(filename) try: os.remove(filename) except: log.warn('DRIFTNET: could not remove %s' % filename)
def parse(self, line): ''' Driftnet output line parser. ''' # This parser is about as simple as they come. Every line is simply a # filename of the image that driftnet carved out. All we need to do is # open it up, send the data to the API, then remove the file. filename = line.strip('\r\n ') # Check if the picture is "p**n" try: im = Image.open(filename) skinratio = self.checkporn(Image.open(filename)) * 100 if skinratio > 30: log.debug('DRIFTNET: skipping image %s (detected as p**n - skin: %s%%)' % (filename, skinratio)) else: log.debug('DRIFTNET: sending image %s (skin: %s%%)' % (filename, skinratio)) self.api.image(filename) except: log.debug('DRIFTNET: skipping image %s (not readable)' % filename) try: os.remove(filename) except: log.warn('DRIFTNET: cannot remove %s' % filename)
def rollback_callback(rb_future): try: rb_future.result() except Exception as rb_error: log.warn("Failed to ROLLBACK transaction %s", rb_error) transaction_future.set_exception(error)