コード例 #1
0
ファイル: rdesktop.py プロジェクト: midnightslacker/RatMuseum
    def run(self, args):
        self.web_handlers = [
            (r'/?', IndexHandler, {
                'client': self.client
            }),
            (r'/ws', RdesktopWebSocketHandler, {
                'client': self.client,
                'refresh_interval': args.refresh_interval,
                'module': self
            }),
        ]

        conninfo = self.start_webplugin()
        if not conninfo:
            self.error('WebServer is not enabled')
            self.info('Enable with "config set pupyd webserver true"')
            return

        port, path = conninfo
        self.success("Web handler started on http://127.0.0.1:%d%s" %
                     (port, path))
        if args.view:
            config = self.client.pupsrv.config
            viewer = config.get('default_viewers', 'browser')
            subprocess.Popen([viewer, path])
コード例 #2
0
ファイル: rdesktop.py プロジェクト: tugdualnicolas/pupy
    def run(self, args):
        self.web_handlers = [
            (r'/?', IndexHandler, {
                'client': self.client
            }),
            (r'/ws', RdesktopWebSocketHandler, {
                'client': self.client,
                'refresh_interval': args.refresh_interval,
                'module': self
            }),
        ]

        conninfo = self.start_webplugin()
        if not conninfo:
            self.error('WebServer is not enabled')
            self.info('Enable with "config set pupyd webserver true"')
            return

        port, path = conninfo
        self.success("Web handler started on http://127.0.0.1:%d%s" %
                     (port, path))
        self.info(
            "By default, web handler accepts connections from localhost only")
        self.info(
            "Use the following pupy command for allowing another ip address to connect to web handler:"
        )
        self.info("'config set webserver local_ips X.Y.Z.A'")
        if args.view:
            config = self.client.pupsrv.config
            viewer = config.get('default_viewers', 'browser')
            try:
                subprocess.Popen([viewer, path])
            except Exception as e:
                self.error("Impossible to execute '{0} {1}': {2}".format(
                    viewer, path, str(e)))
コード例 #3
0
    def run(self, args):
        screens = self.client.remote('screenshot', 'screens')
        screenshot = self.client.remote('screenshot', 'screenshot')

        if self.client.is_android():
            self.error("Android target, not implemented yet...")

        else:
            if args.enum:
                self.rawlog('{:>2} {:>9} {:>9}\n'.format('IDX', 'SIZE', 'LEFT'))
                for i, screen in enumerate(screens()):
                    if not (screen['width'] and screen['height']):
                        continue

                    self.rawlog('{:>2}: {:>9} {:>9}\n'.format(
                        i,
                        '{}x{}'.format(screen['width'], screen['height']),
                        '({}x{})'.format(screen['top'], screen['left'])))
                return

            config = self.client.pupsrv.config or PupyConfig()
            filepath_base = config.get_file('screenshots', {'%c': self.client.short_name()})

            try:
                screenshots, error = screenshot(args.screen)
            except Exception, e:
                self.error('Impossible to take a screenshot ("{0}"). Abording...'.format(e))
                return -1
            if not screenshots:
                self.error(error)
                return -1
            else:
                self.success('number of monitor detected: %s' % str(len(screenshots)))

                for i, screenshot in enumerate(screenshots):
                    filepath = filepath_base + '-{}.png'.format(i)
                    with open(filepath, 'w') as out:
                        out.write(screenshot)
                        self.success(filepath)

                    if args.view:
                        viewer = config.get('default_viewers', 'image_viewer') or 'xdg-open'

                        found = False
                        for p in os.environ.get('PATH', '').split(':'):
                            if os.path.exists(os.path.join(p, viewer)):
                                with open(os.devnull, 'w') as DEVNULL:
                                    subprocess.Popen(
                                        [viewer, filepath],
                                        stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL)

                                found = True
                                break

                        if not found:
                            self.error('Default viewer not found: %s' % viewer)
コード例 #4
0
ファイル: screenshot.py プロジェクト: kefkahacks/pupy
    def run(self, args):
        screens = self.client.remote('screenshot', 'screens')
        screenshot = self.client.remote('screenshot', 'screenshot')

        if self.client.is_android() == True:
            self.error("Android target, not implemented yet...")

        else:
            if args.enum:
                self.rawlog('{:>2} {:>9} {:>9}\n'.format(
                    'IDX', 'SIZE', 'LEFT'))
                for i, screen in enumerate(screens()):
                    if not (screen['width'] and screen['height']):
                        continue

                    self.rawlog('{:>2}: {:>9} {:>9}\n'.format(
                        i, '{}x{}'.format(screen['width'], screen['height']),
                        '({}x{})'.format(screen['top'], screen['left'])))
                return

            config = self.client.pupsrv.config or PupyConfig()
            filepath_base = config.get_file('screenshots',
                                            {'%c': self.client.short_name()})

            screenshots, error = screenshot(args.screen)
            if not screenshots:
                self.error(error)
            else:
                self.success('number of monitor detected: %s' %
                             str(len(screenshots)))

                for i, screenshot in enumerate(screenshots):
                    filepath = filepath_base + '-{}.png'.format(i)
                    with open(filepath, 'w') as out:
                        out.write(screenshot)
                        self.success(filepath)

                    if args.view:
                        viewer = config.get('default_viewers', 'image_viewer')
                        subprocess.Popen([viewer, filepath])
コード例 #5
0
    def run(self, args):
        self.web_handlers = [
            (r'/?', IndexHandler, {
                'client': self.client
            }),
            (r'/ws', RdesktopWebSocketHandler, {
                'client': self.client,
                'refresh_interval': args.refresh_interval,
                'module': self
            }),
        ]

        url = self.start_webplugin()
        if not url:
            self.error('WebServer is not enabled')
            self.info('Enable with "config set pupyd webserver true"')
            return

        self.success("Web handler started on %s" % url)
        if args.view:
            config = self.client.pupsrv.config or PupyConfig()
            viewer = config.get('default_viewers', 'browser')
            subprocess.Popen([viewer, url])