Пример #1
0
    def find_windows_for_process(self, process_id, display_name):
        """Return visible windows belonging to a process."""
        pids = self.get_process_ids(process_id)
        if not pids:
            return []

        logger.info(
            'Waiting for 30 seconds to ensure all windows appear: '
            'pid=%s, display=%s', pids, display_name)
        time.sleep(30)

        visible_windows = set()
        for pid in pids:
            _, windows = common.execute(
                'xdotool',
                'search --all --pid %s --onlyvisible --name ".*"' % pid,
                '.',
                env={'DISPLAY': display_name},
                exit_on_error=False,
                print_command=False,
                print_output=False,
                stdin=common.BlockStdin())
            for line in windows.splitlines():
                if not line.isdigit():
                    continue
                visible_windows.add(line)

        logger.info('Found windows: %s', ', '.join(list(visible_windows)))
        return visible_windows
Пример #2
0
 def xdotool_command(self, command, display_name):
     """Run a command, returning its output."""
     common.execute('xdotool',
                    command,
                    '.',
                    env={'DISPLAY': display_name},
                    stdin=common.BlockStdin())
Пример #3
0
 def test_stdin(self):
     """Test stdin."""
     stdin = common.BlockStdin()
     self.assertEqual(subprocess.PIPE, stdin.get())
     self.assertEqual('cmd', stdin.update_cmd_log('cmd'))