def run(self): """Run screenshotting. @return: operation status. """ if not Screenshot().have_pil(): log.warning("Python Image Library is not installed, screenshots are disabled") return False img_counter = 0 img_last = None while self.do_run: img_current = Screenshot().take() if img_last: if Screenshot().equal(img_last, img_current): time.sleep(SHOT_DELAY) continue img_counter += 1 save_at = os.path.join(self.save_path, "%s.jpg" % str(img_counter).rjust(4, '0')) img_current.save(save_at) img_last = img_current time.sleep(SHOT_DELAY) return True
def run(self): """Run screenshotting. @return: operation status. """ if "screenshots" in self.options: shot_delay = int(self.options["screenshots"]) if shot_delay == 0: self.do_run = False else: shot_delay = 1 if not Screenshot().have_pil(): log.warning("Python Image Library is not installed, " "screenshots are disabled") return False img_counter = 0 img_last = None while self.do_run: time.sleep(shot_delay) try: img_current = Screenshot().take() except IOError as e: log.error("Cannot take screenshot: %s", e) continue if img_last: if Screenshot().equal(img_last, img_current, SKIP_AREA): continue img_counter += 1 # workaround as PIL can't write to the socket file object :( tmpio = StringIO.StringIO() img_current.save(tmpio, format="JPEG") tmpio.seek(0) # now upload to host from the StringIO nf = NetlogFile() nf.init("shots/%s.jpg" % str(img_counter).rjust(4, "0")) for chunk in tmpio: nf.sock.sendall(chunk) nf.close() img_last = img_current return True
def run(self): """Run screenshotting. @return: operation status. """ if not Screenshot().have_pil(): log.warning("Python Image Library is not installed, " "screenshots are disabled") return False img_counter = 0 img_last = None while self.do_run: time.sleep(SHOT_DELAY) try: img_current = Screenshot().take() except IOError as e: log.error("Cannot take screenshot: %s", e) continue if img_last: if Screenshot().equal(img_last, img_current): continue img_counter += 1 #send a return keystroke for installers self.sendKey(0x24) try: # workaround as PIL can't write to the socket file object :( tmpio = StringIO.StringIO() img_current.save(tmpio, format="PNG") tmpio.seek(0) except: log.exception("Unable to write screenshot to disk.") # now upload to host from the StringIO nf = NetlogFile("shots/%s.png" % str(img_counter).rjust(4, "0")) for chunk in tmpio: nf.sock.sendall(chunk) nf.close() img_last = img_current return True
def run(self): """Run screenshotting. @return: operation status. """ if not self.enabled: return False if not Screenshot().have_pil(): log.warning( "Python Image Library is not installed, screenshots are disabled" ) return False img_counter = 0 img_last = None while self.do_run: time.sleep(SHOT_DELAY) try: img_current = Screenshot().take() except IOError as e: log.error("Cannot take screenshot: %s", e) continue if img_last: if Screenshot().equal(img_last, img_current, SKIP_AREA): continue img_counter += 1 # workaround as PIL can't write to the socket file object :( tmpio = BytesIO() img_current.save(tmpio, format="JPEG") tmpio.seek(0) # now upload to host from the StringIO nf = NetlogFile() nf.init(f"shots/{str(img_counter).rjust(4, '0')}.jpg") for chunk in tmpio: nf.sock.send(chunk) nf.close() img_last = img_current return True