Skip to content

debug info command #643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Nov 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,10 @@
* For general technical questions, problems or feature requests related to the code **in this repository** file an issue.

### Step 2: Provide tmuxp details
* Python version
* system PATH
* tmux version
* tmuxp version
* tmux path
* tmuxp path,
* libtmux version
* shell
* output of `tmux list-sessions`, `tmux list-windows`, `tmux list-panes`
* output of `tmux show-options -g`, `tmux show-window-options -g`
* output of `tmuxp freeze <SESSION_NAME>`
* Include output of `tmuxp debug-info`
* Include any other pertinant system info not captured

### Step 3: Describe your environment
* Architecture: _____
* OS version: _____

### Step 4: Describe the problem:
### Step 3: Describe the problem:
#### Steps to reproduce:
1. _____
2. _____
Expand Down
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Here you can find the recent changes to tmuxp

current
-------
- :issue:`352` New command ``tmuxp debug-info`` for creating github issues
- *Insert changes/features/fixes for next release here*

tmuxp 1.6.1 (2020-11-07)
Expand Down
15 changes: 15 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,21 @@ You can auto confirm the prompt. In this case no preview will be shown.
$ tmuxp convert --yes filename


Debug Info
---------

Collect system info to submit with a Github issue

.. code-block:: sh

$ tmuxp debug-info
--------------------------
environment:
system: Linux
arch: x86_64
...


Docs / Reading material
-----------------------

Expand Down
16 changes: 16 additions & 0 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,22 @@ are created, the last session is named from the terminal.

$ tmxup load -s <new_session_name> <filename1> ...

.. _cli_debug_info:

Debug Info
----------

Use to collect all relevant information for submitting an issue to the project.

.. code-block:: bash

$ tmuxp debug-info
--------------------------
environment:
system: Linux
arch: x86_64
...

.. _cli_import:

Import
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ skip-string-normalization = true

[tool.poetry]
name = "tmuxp"
version = "1.6.1"
version = "1.6.2"
description = "tmux session manager"
license = "MIT"
authors = ["Tony Narlock <tony@git-pull.com>"]
Expand Down
22 changes: 22 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from tmuxp import cli, config, exc
from tmuxp.cli import (
command_ls,
command_debug_info,
get_config_dir,
is_pure_name,
load_workspace,
Expand Down Expand Up @@ -953,3 +954,24 @@ def test_ls_cli(monkeypatch, tmpdir):
runner = CliRunner()
cli_output = runner.invoke(command_ls).output
assert cli_output == '\n'.join(stems) + '\n'


def test_debug_info_cli(monkeypatch, tmpdir):
monkeypatch.setenv('SHELL', '/bin/bash')

runner = CliRunner()
cli_output = runner.invoke(command_debug_info).output
assert 'environment' in cli_output
assert 'python version' in cli_output
assert 'system PATH' in cli_output
assert 'tmux version' in cli_output
assert 'libtmux version' in cli_output
assert 'tmuxp version' in cli_output
assert 'tmux path' in cli_output
assert 'tmuxp path' in cli_output
assert 'shell' in cli_output
assert 'tmux session' in cli_output
assert 'tmux windows' in cli_output
assert 'tmux panes' in cli_output
assert 'tmux global options' in cli_output
assert 'tmux window options' in cli_output
2 changes: 1 addition & 1 deletion tmuxp/__about__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__title__ = 'tmuxp'
__package_name__ = 'tmuxp'
__version__ = '1.6.1'
__version__ = '1.6.2'
__description__ = 'tmux session manager'
__email__ = 'tony@git-pull.com'
__author__ = 'Tony Narlock'
Expand Down
76 changes: 74 additions & 2 deletions tmuxp/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,26 @@

import logging
import os
import platform
import sys

import click
import kaptan
from click.exceptions import FileError

from libtmux.common import has_gte_version, has_minimum_version, which
from libtmux.common import (
has_gte_version,
has_minimum_version,
which,
get_version,
tmux_cmd,
)
from libtmux.exc import TmuxCommandNotFound
from libtmux.server import Server

from . import config, exc, log, util
from libtmux import __version__ as libtmux_version

from . import config, exc, log, util, __file__ as tmuxp_path
from .__about__ import __version__
from ._compat import PY3, PYMINOR, string_types
from .workspacebuilder import WorkspaceBuilder, freeze
Expand Down Expand Up @@ -1054,3 +1063,66 @@ def command_ls():
if os.path.isdir(f) or ext not in VALID_CONFIG_DIR_FILE_EXTENSIONS:
continue
print(stem)


@cli.command(name='debug-info', short_help='Print out all diagnostic info')
def command_debug_info():
"""
Print debug info to submit with Issues.
"""

def prepend_tab(strings):
"""
Prepend tab to strings in list.
"""
return list(map(lambda x: '\t%s' % x, strings))

def output_break():
"""
Generate output break.
"""
return '-' * 25

def format_tmux_resp(std_resp):
"""
Format tmux command response for tmuxp stdout.
"""
return '\n'.join(
[
'\n'.join(prepend_tab(std_resp.stdout)),
click.style('\n'.join(prepend_tab(std_resp.stderr)), fg='red'),
]
)

output = [
output_break(),
'environment:\n%s'
% '\n'.join(
prepend_tab(
[
'dist: %s' % platform.platform(),
'arch: %s' % platform.machine(),
'uname: %s' % '; '.join(platform.uname()[:3]),
'version: %s' % platform.version(),
]
)
),
output_break(),
'python version: %s' % ' '.join(sys.version.split('\n')),
'system PATH: %s' % os.environ['PATH'],
'tmux version: %s' % get_version(),
'libtmux version: %s' % libtmux_version,
'tmuxp version: %s' % __version__,
'tmux path: %s' % which('tmux'),
'tmuxp path: %s' % tmuxp_path,
'shell: %s' % os.environ['SHELL'],
output_break(),
'tmux sessions:\n%s' % format_tmux_resp(tmux_cmd('list-sessions')),
'tmux windows:\n%s' % format_tmux_resp(tmux_cmd('list-windows')),
'tmux panes:\n%s' % format_tmux_resp(tmux_cmd('list-panes')),
'tmux global options:\n%s' % format_tmux_resp(tmux_cmd('show-options', '-g')),
'tmux window options:\n%s'
% format_tmux_resp(tmux_cmd('show-window-options', '-g')),
]

click.echo('\n'.join(output))