From 1e6414d0e8c85b44c91698263d74804349abb980 Mon Sep 17 00:00:00 2001 From: Foo Date: Thu, 11 May 2017 21:09:10 +0300 Subject: [PATCH 01/95] Fix i3 bar bindings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Specifically: - Do not log exceptions to the same location data is output. - Fix format, i3bar is no longer using “pseudo-JSON”, also not sure whether it ever used format `[[right list], [left list]]`, but it definitely does not now. - i3bgbar branch is no longer available. - Yet i3wm supports background color, just with the different key (`background` vs `background_color`). --- docs/source/usage/wm-widgets.rst | 13 ++----------- powerline/bindings/i3/powerline-i3.py | 18 ++++++++++++------ powerline/renderers/i3bar.py | 5 ++--- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/docs/source/usage/wm-widgets.rst b/docs/source/usage/wm-widgets.rst index 1aa1a2de..7dabd275 100644 --- a/docs/source/usage/wm-widgets.rst +++ b/docs/source/usage/wm-widgets.rst @@ -82,20 +82,11 @@ All ``powerline-lemonbar.py`` arguments: I3 bar ====== -.. note:: - As the patch to include background-colors in i3bar is likely not to be - merged, it is recommended to instead run ``bar`` (see above). The source for - i3bgbar is however still available `here - `_. - -Add the following to :file:`~/.i3/config`:: +Add the following to :file:`~/.config/i3/config`:: bar { - i3bar_command i3bgbar - status_command python /path/to/powerline/bindings/i3/powerline-i3.py font pango:PowerlineFont 12 } -where ``i3bgbar`` may be replaced with the path to the custom i3bar binary and -``PowerlineFont`` is any system font with powerline support. +where ``PowerlineFont`` is any system font with powerline support. diff --git a/powerline/bindings/i3/powerline-i3.py b/powerline/bindings/i3/powerline-i3.py index c5e01c8a..ed8920ca 100755 --- a/powerline/bindings/i3/powerline-i3.py +++ b/powerline/bindings/i3/powerline-i3.py @@ -13,28 +13,34 @@ from powerline import Powerline from powerline.lib.monotonic import monotonic +class I3Powerline(Powerline): + '''Powerline child for i3bar + + Currently only changes the default log target. + ''' + default_log_stream = sys.stderr + + if __name__ == '__main__': name = 'wm' if len(sys.argv) > 1: name = sys.argv[1] - powerline = Powerline(name, renderer_module='i3bar') + powerline = I3Powerline(name, renderer_module='i3bar') powerline.update_renderer() interval = 0.5 - print ('{"version": 1, "custom_workspace": true}') + print ('{"version": 1}') print ('[') - print ('\t[[],[]]') + print ('[]') lock = Lock() def render(event=None, data=None, sub=None): global lock with lock: - s = '[\n' + powerline.render(side='right')[:-2] + '\n]\n' - s += ',[\n' + powerline.render(side='left')[:-2] + '\n]' - print (',[\n' + s + '\n]') + print (',[' + powerline.render()[:-1] + ']') sys.stdout.flush() sub = i3.Subscription(render, 'workspace') diff --git a/powerline/renderers/i3bar.py b/powerline/renderers/i3bar.py index dd180941..4124a0f7 100644 --- a/powerline/renderers/i3bar.py +++ b/powerline/renderers/i3bar.py @@ -29,9 +29,8 @@ class I3barRenderer(Renderer): segment['color'] = '#{0:06x}'.format(fg[1]) if bg is not None: if bg is not False and bg[1] is not False: - segment['background_color'] = '#{0:06x}'.format(bg[1]) - # i3bar “pseudo json” requires one line at a time - return json.dumps(segment) + ',\n' + segment['background'] = '#{0:06x}'.format(bg[1]) + return json.dumps(segment) + ',' renderer = I3barRenderer From 8150d38bd26c7bf112502db717ac09511ec73dbe Mon Sep 17 00:00:00 2001 From: Foo Date: Thu, 11 May 2017 23:03:48 +0300 Subject: [PATCH 02/95] Abstract away subscription to workspace event --- powerline/bindings/i3/powerline-i3.py | 5 ++-- powerline/bindings/wm/__init__.py | 37 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/powerline/bindings/i3/powerline-i3.py b/powerline/bindings/i3/powerline-i3.py index ed8920ca..f44e9281 100755 --- a/powerline/bindings/i3/powerline-i3.py +++ b/powerline/bindings/i3/powerline-i3.py @@ -7,7 +7,7 @@ import time from threading import Lock -import i3 +from powerline.bindings.wm import get_i3_connection, i3_subscribe from powerline import Powerline from powerline.lib.monotonic import monotonic @@ -43,7 +43,8 @@ if __name__ == '__main__': print (',[' + powerline.render()[:-1] + ']') sys.stdout.flush() - sub = i3.Subscription(render, 'workspace') + i3 = get_i3_connection() + i3_subscribe(i3, 'workspace', render) while True: start_time = monotonic() diff --git a/powerline/bindings/wm/__init__.py b/powerline/bindings/wm/__init__.py index c635db54..130c0e4f 100644 --- a/powerline/bindings/wm/__init__.py +++ b/powerline/bindings/wm/__init__.py @@ -14,6 +14,43 @@ DEFAULT_UPDATE_INTERVAL = 0.5 conn = None +def i3_subscribe(conn, event, callback): + '''Subscribe to i3 workspace event + + :param conn: + Connection returned by :py:func:`get_i3_connection`. + :param str event: + Event to subscribe to, e.g. ``'workspace'``. + :param func callback: + Function to run on event. + ''' + try: + import i3 + except ImportError: + pass + else: + conn.Subscription(callback, event) + return + + conn.on(event, callback) + + from threading import Thread + + class I3Thread(Thread): + daemon = True + + def __init__(self, conn): + super(I3Thread, self).__init__() + self.__conn = conn + + def run(self): + self.__conn.main() + + thread = I3Thread(conn=conn) + + thread.start() + + def get_i3_connection(): '''Return a valid, cached i3 Connection instance ''' From de899c5fc5c17f3df4fee07a0164471b86d10889 Mon Sep 17 00:00:00 2001 From: Foo Date: Tue, 16 May 2017 18:48:36 +0300 Subject: [PATCH 03/95] Export pipe status in bash bindings --- powerline/bindings/bash/powerline.sh | 65 ++++++++++++++++++++++------ tests/test_python/test_cmdline.py | 5 +++ 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/powerline/bindings/bash/powerline.sh b/powerline/bindings/bash/powerline.sh index 377c41a8..4ec0d72c 100644 --- a/powerline/bindings/bash/powerline.sh +++ b/powerline/bindings/bash/powerline.sh @@ -27,6 +27,31 @@ _powerline_tmux_set_pwd() { fi } +_powerline_return() { + return $1 +} + +_powerline_status_wrapper() { + local last_exit_code=$? last_pipe_status=( "${PIPESTATUS[@]}" ) + + if test "$last_exit_code" != "${last_pipe_status[-1]}" ; then + last_pipe_status=() + fi + "$@" $last_exit_code "${last_pipe_status[*]}" + return $last_exit_code +} + +_powerline_add_status_wrapped_command() { + local action="$1" ; shift + local cmd="$1" ; shift + full_cmd="_powerline_status_wrapper $cmd" + if test "$action" = "append" ; then + PROMPT_COMMAND="$PROMPT_COMMAND"$'\n'"$full_cmd" + else + PROMPT_COMMAND="$full_cmd"$'\n'"$PROMPT_COMMAND" + fi +} + _powerline_tmux_set_columns() { _powerline_tmux_setenv COLUMNS "${COLUMNS:-`_powerline_columns_fallback`}" } @@ -40,41 +65,53 @@ _powerline_init_tmux_support() { _powerline_tmux_set_columns test "$PROMPT_COMMAND" != "${PROMPT_COMMAND/_powerline_tmux_set_pwd}" \ - || PROMPT_COMMAND="${PROMPT_COMMAND}"$'\n_powerline_tmux_set_pwd' + || _powerline_add_status_wrapped_command append _powerline_tmux_set_pwd fi } _powerline_local_prompt() { - # Arguments: side, renderer_module arg, last_exit_code, jobnum, local theme + # Arguments: + # 1: side + # 2: renderer_module arg + # 3: last_exit_code + # 4: last_pipe_status + # 5: jobnum + # 6: local theme "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \ $2 \ --last-exit-code=$3 \ - --jobnum=$4 \ + --last-pipe-status="$4" \ + --jobnum=$5 \ --renderer-arg="client_id=$$" \ - --renderer-arg="local_theme=$5" + --renderer-arg="local_theme=$6" } _powerline_prompt() { - # Arguments: side, last_exit_code, jobnum + # Arguments: + # 1: side + # 2: last_exit_code + # 3: last_pipe_status + # 4: jobnum "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \ --width="${COLUMNS:-$(_powerline_columns_fallback)}" \ -r.bash \ --last-exit-code=$2 \ - --jobnum=$3 \ + --last-pipe-status="$3" \ + --jobnum=$4 \ --renderer-arg="client_id=$$" } _powerline_set_prompt() { - local last_exit_code=$? + local last_exit_code=$1 ; shift + local last_pipe_status=$1 ; shift local jobnum="$(jobs -p|wc -l)" - PS1="$(_powerline_prompt aboveleft $last_exit_code $jobnum)" + PS1="$(_powerline_prompt aboveleft $last_exit_code "$last_pipe_status" $jobnum)" if test -n "$POWERLINE_SHELL_CONTINUATION$POWERLINE_BASH_CONTINUATION" ; then - PS2="$(_powerline_local_prompt left -r.bash $last_exit_code $jobnum continuation)" + PS2="$(_powerline_local_prompt left -r.bash $last_exit_code "$last_pipe_status" $jobnum continuation)" fi if test -n "$POWERLINE_SHELL_SELECT$POWERLINE_BASH_SELECT" ; then - PS3="$(_powerline_local_prompt left '' $last_exit_code $jobnum select)" + PS3="$(_powerline_local_prompt left '' $last_exit_code "$last_pipe_status" $jobnum select)" fi - return $last_exit_code } _powerline_setup_prompt() { @@ -83,9 +120,9 @@ _powerline_setup_prompt() { POWERLINE_COMMAND="$("$POWERLINE_CONFIG_COMMAND" shell command)" fi test "$PROMPT_COMMAND" != "${PROMPT_COMMAND%_powerline_set_prompt*}" \ - || PROMPT_COMMAND=$'_powerline_set_prompt\n'"${PROMPT_COMMAND}" - PS2="$(_powerline_local_prompt left -r.bash 0 0 continuation)" - PS3="$(_powerline_local_prompt left '' 0 0 select)" + || _powerline_add_status_wrapped_command prepend _powerline_set_prompt + PS2="$(_powerline_local_prompt left -r.bash 0 0 0 continuation)" + PS3="$(_powerline_local_prompt left '' 0 0 0 select)" } if test -z "${POWERLINE_CONFIG_COMMAND}" ; then diff --git a/tests/test_python/test_cmdline.py b/tests/test_python/test_cmdline.py index b77988b2..470a7b4c 100644 --- a/tests/test_python/test_cmdline.py +++ b/tests/test_python/test_cmdline.py @@ -125,6 +125,11 @@ class TestParser(TestCase): 'side': 'left', 'config_override': {'common': {}}, }), + (['shell', 'left', '--last-pipe-status='], { + 'ext': ['shell'], + 'side': 'left', + 'last_pipe_status': [], + }), ]: args = parser.parse_args(argv) finish_args(parser, {}, args) From 443679d532f73dc7488338b65145e1b61df3460a Mon Sep 17 00:00:00 2001 From: Foo Date: Tue, 16 May 2017 18:49:10 +0300 Subject: [PATCH 04/95] Make last_pipe_status fallback to last_exit_code --- powerline/segments/shell.py | 5 ++++- tests/test_python/test_segments.py | 29 +++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/powerline/segments/shell.py b/powerline/segments/shell.py index 57847e4f..a9e96092 100644 --- a/powerline/segments/shell.py +++ b/powerline/segments/shell.py @@ -39,7 +39,10 @@ def last_pipe_status(pl, segment_info): Highlight groups used: ``exit_fail``, ``exit_success`` ''' - last_pipe_status = segment_info['args'].last_pipe_status + last_pipe_status = ( + segment_info['args'].last_pipe_status + or (segment_info['args'].last_exit_code,) + ) if any(last_pipe_status): return [ { diff --git a/tests/test_python/test_segments.py b/tests/test_python/test_segments.py index 4aef6a19..7b576d01 100644 --- a/tests/test_python/test_segments.py +++ b/tests/test_python/test_segments.py @@ -52,15 +52,35 @@ class TestShell(TestCase): def test_last_pipe_status(self): pl = Pl() - segment_info = {'args': Args(last_pipe_status=[])} + segment_info = {'args': Args(last_pipe_status=[], last_exit_code=0)} self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info), None) segment_info['args'].last_pipe_status = [0, 0, 0] self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info), None) + segment_info['args'].last_pipe_status = [0, 0] + self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info), None) + segment_info['args'].last_pipe_status = [0] + self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info), None) segment_info['args'].last_pipe_status = [0, 2, 0] self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info), [ {'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True}, {'contents': '2', 'highlight_groups': ['exit_fail'], 'draw_inner_divider': True}, - {'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True} + {'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True}, + ]) + segment_info['args'].last_pipe_status = [2, 0, 0] + self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info), [ + {'contents': '2', 'highlight_groups': ['exit_fail'], 'draw_inner_divider': True}, + {'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True}, + {'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True}, + ]) + segment_info['args'].last_pipe_status = [0, 0, 2] + self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info), [ + {'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True}, + {'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True}, + {'contents': '2', 'highlight_groups': ['exit_fail'], 'draw_inner_divider': True}, + ]) + segment_info['args'].last_pipe_status = [2] + self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info), [ + {'contents': '2', 'highlight_groups': ['exit_fail'], 'draw_inner_divider': True}, ]) segment_info['args'].last_pipe_status = [0, 'sigsegv', 'sigsegv+core'] self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info), [ @@ -80,6 +100,11 @@ class TestShell(TestCase): {'contents': 'sigsegv+core', 'highlight_groups': ['exit_fail'], 'draw_inner_divider': True}, {'contents': '0', 'highlight_groups': ['exit_success'], 'draw_inner_divider': True} ]) + segment_info['args'].last_pipe_status = [] + segment_info['args'].last_exit_code = 5 + self.assertEqual(shell.last_pipe_status(pl=pl, segment_info=segment_info), [ + {'contents': '5', 'highlight_groups': ['exit_fail'], 'draw_inner_divider': True}, + ]) def test_jobnum(self): pl = Pl() From b1e2086fe3b4b68990ec51681fa04ac69ee0a0b9 Mon Sep 17 00:00:00 2001 From: Foo Date: Tue, 16 May 2017 18:49:28 +0300 Subject: [PATCH 05/95] Add some more troubleshooting information --- docs/source/troubleshooting.rst | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst index 542ee9b0..35991325 100644 --- a/docs/source/troubleshooting.rst +++ b/docs/source/troubleshooting.rst @@ -143,6 +143,40 @@ started from.* Shell issues ============ +Pipe status segment displays only last value in bash +---------------------------------------------------- + +Make sure that powerline command that sets prompt appears the very first in +``$PROMPT_COMMAND``. To do this ``powerline.sh`` needs to be sourced the very +last, after all other users of ``$PROMPT_COMMAND``. + +Bash prompt stopped updating +---------------------------- + +Make sure that powerline commands appear in ``$PROMPT_COMMAND``: some users of +``$PROMPT_COMMAND`` have a habit of overwriting the value instead of +prepending/appending to it. All powerline commands start with ``_powerline`` or +``powerline``, e.g. ``_powerline_set_prompt``. + +Bash prompt does not show last exit code +---------------------------------------- + +There are two possibilities here: + +* You are using ``default`` theme in place of ``default_leftonly``. Unlike + ``default_leftonly`` ``default`` theme was designed for shells with right + prompt support (e.g. zsh, tcsh, fish) and status in question is supposed to be + shown on the right side which bash cannot display. + +* There is some other user of ``$PROMPT_COMMAND`` which prepended to this + variable, but did not bother keeping the exit code. For the best experience + powerline must appear first in ``$PROMPT_COMMAND`` which may be achieved by + sourcing powerline bindings the last. + + .. note:: + Resourcing bash bindings will not resolve the problem unless you clear + powerline commands from ``$PROMPT_COMMAND`` first. + When sourcing shell bindings it complains about missing command or file ----------------------------------------------------------------------- From 30acc6ed4cb13011d1440ef461b709cb50b85bf0 Mon Sep 17 00:00:00 2001 From: Foo Date: Tue, 16 May 2017 18:52:29 +0300 Subject: [PATCH 06/95] Make default_leftonly theme use last_pipe_status --- powerline/config_files/themes/shell/default_leftonly.json | 2 +- tests/test_python/test_provided_config_files.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/powerline/config_files/themes/shell/default_leftonly.json b/powerline/config_files/themes/shell/default_leftonly.json index 61e59f81..b5762735 100644 --- a/powerline/config_files/themes/shell/default_leftonly.json +++ b/powerline/config_files/themes/shell/default_leftonly.json @@ -26,7 +26,7 @@ "priority": 20 }, { - "function": "powerline.segments.shell.last_status", + "function": "powerline.segments.shell.last_pipe_status", "priority": 10 } ] diff --git a/tests/test_python/test_provided_config_files.py b/tests/test_python/test_provided_config_files.py index 9478568d..fd8b16e6 100644 --- a/tests/test_python/test_provided_config_files.py +++ b/tests/test_python/test_provided_config_files.py @@ -138,7 +138,7 @@ class TestConfig(TestCase): def test_bash(self): from powerline.shell import ShellPowerline - args = Args(last_exit_code=1, jobnum=0, ext=['shell'], renderer_module='.bash', config_override={'ext': {'shell': {'theme': 'default_leftonly'}}}) + args = Args(last_exit_code=1, last_pipe_status=[], jobnum=0, ext=['shell'], renderer_module='.bash', config_override={'ext': {'shell': {'theme': 'default_leftonly'}}}) with ShellPowerline(args, logger=get_logger(), run_once=False) as powerline: powerline.render(segment_info={'args': args}) with ShellPowerline(args, logger=get_logger(), run_once=False) as powerline: From b0d31181cd3dc0b36b20561762ca8470080c6843 Mon Sep 17 00:00:00 2001 From: Foo Date: Tue, 16 May 2017 19:20:48 +0300 Subject: [PATCH 07/95] Make bash tests check for pipestatus --- tests/test_shells/inputs/bash | 1 + tests/test_shells/outputs/bash.daemon.ok | 3 ++- tests/test_shells/outputs/bash.nodaemon.ok | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_shells/inputs/bash b/tests/test_shells/inputs/bash index beffd308..1b68b6f6 100644 --- a/tests/test_shells/inputs/bash +++ b/tests/test_shells/inputs/bash @@ -55,6 +55,7 @@ cd ../'(echo)' cd ../'$(echo)' cd ../'`echo`' cd ../'«Unicode!»' +(exit 42)|(exit 43) set_theme_option default_leftonly.segments.above "$ABOVE_LEFT" export DISPLAYED_ENV_VAR=foo unset DISPLAYED_ENV_VAR diff --git a/tests/test_shells/outputs/bash.daemon.ok b/tests/test_shells/outputs/bash.daemon.ok index a0aba45b..89907c83 100644 --- a/tests/test_shells/outputs/bash.daemon.ok +++ b/tests/test_shells/outputs/bash.daemon.ok @@ -26,7 +26,8 @@ def   BRANCH  …  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  …  shell  3rd  $(echo)  cd ../'`echo`'   BRANCH  …  shell  3rd  `echo`  cd ../'«Unicode!»' -  BRANCH  …  shell  3rd  «Unicode!»  set_theme_option default_leftonly.segments.above "$ABOVE_LEFT" +  BRANCH  …  shell  3rd  «Unicode!»  (exit 42)|(exit 43) +  BRANCH  …  shell  3rd  «Unicode!»  42  43  set_theme_option default_leftonly.segments.above "$ABOVE_LEFT"   BRANCH  …  shell  3rd  «Unicode!»  export DISPLAYED_ENV_VAR=foo  foo     BRANCH  …  shell  3rd  «Unicode!»  unset DISPLAYED_ENV_VAR diff --git a/tests/test_shells/outputs/bash.nodaemon.ok b/tests/test_shells/outputs/bash.nodaemon.ok index 118dfe50..c65dcc14 100644 --- a/tests/test_shells/outputs/bash.nodaemon.ok +++ b/tests/test_shells/outputs/bash.nodaemon.ok @@ -26,7 +26,8 @@ def   BRANCH  …  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  …  shell  3rd  $(echo)  cd ../'`echo`'   BRANCH  …  shell  3rd  `echo`  cd ../'«Unicode!»' -  BRANCH  …  shell  3rd  «Unicode!»  set_theme_option default_leftonly.segments.above "$ABOVE_LEFT" +  BRANCH  …  shell  3rd  «Unicode!»  (exit 42)|(exit 43) +  BRANCH  …  shell  3rd  «Unicode!»  42  43  set_theme_option default_leftonly.segments.above "$ABOVE_LEFT"   BRANCH  …  shell  3rd  «Unicode!»  export DISPLAYED_ENV_VAR=foo  foo     BRANCH  …  shell  3rd  «Unicode!»  unset DISPLAYED_ENV_VAR From ef3b547558dd14c299f542585b65c3115d20864d Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Wed, 17 May 2017 15:54:54 -0600 Subject: [PATCH 08/95] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Add=20fish=20to=20li?= =?UTF-8?q?st=20of=20supported=20apps=20on=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 071d1f2f..8500db3c 100644 --- a/README.rst +++ b/README.rst @@ -6,8 +6,8 @@ Powerline :Version: beta **Powerline is a statusline plugin for vim, and provides statuslines and -prompts for several other applications, including zsh, bash, tmux, IPython, -Awesome, i3 and Qtile.** +prompts for several other applications, including zsh, bash, fish, tmux, +IPython, Awesome, i3 and Qtile.** * `Support forum`_ (powerline-support@googlegroups.com) * `Development discussion`_ (powerline-dev@googlegroups.com) From 1151449a8cb5619adbb6cd47044e80c889a620f3 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 21 May 2017 02:33:21 +0300 Subject: [PATCH 09/95] =?UTF-8?q?Switch=20vterm=20tests=20to=20use=20?= =?UTF-8?q?=E2=80=9Cstandard=E2=80=9D=20temporary=20directory=20in=20tests?= =?UTF-8?q?/tmp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/modules/lib/terminal.py | 18 ++++++++-------- tests/shlib/vterm.sh | 23 ++++++++------------- tests/test_in_vterm/test_tmux.py | 16 +++++++-------- tests/test_in_vterm/test_tmux.sh | 16 +++++++-------- tests/test_in_vterm/test_vim.py | 35 +++++++++++++++++++++++++------- tests/test_vim/test.sh | 5 ++++- 6 files changed, 65 insertions(+), 48 deletions(-) diff --git a/tests/modules/lib/terminal.py b/tests/modules/lib/terminal.py index 75bcf4e2..860b20e1 100644 --- a/tests/modules/lib/terminal.py +++ b/tests/modules/lib/terminal.py @@ -63,11 +63,13 @@ class ExpectProcess(threading.Thread): self.shutdown_event = threading.Event() def run(self): - child = pexpect.spawn(self.cmd, self.args, cwd=self.cwd, env=self.env) - sleep(0.5) - child.setwinsize(self.dim.rows, self.dim.cols) - sleep(0.5) - self.child = child + with self.child_lock: + child = pexpect.spawn(self.cmd, self.args, cwd=self.cwd, + env=self.env) + sleep(0.5) + child.setwinsize(self.dim.rows, self.dim.cols) + sleep(0.5) + self.child = child status = None while status is None and not self.shutdown_event.is_set(): try: @@ -141,9 +143,8 @@ class ExpectProcess(threading.Thread): return '\n'.join(lines), attrs -def test_expected_result(p, test, last_attempt, last_attempt_cb=None): +def test_expected_result(p, test, last_attempt, last_attempt_cb, attempts): expected_text, attrs = test['expected_result'] - attempts = 3 result = None while attempts: actual_text, all_attrs = p.get_row(test['row'], attrs) @@ -252,7 +253,8 @@ def do_terminal_tests(tests, cmd, dim, args, env, cwd=None, fin_cb=None, ret = ( ret and test_expected_result(p, test, attempts == 0, - last_attempt_cb) + last_attempt_cb, + test.get('attempts', 3)) ) if ret: diff --git a/tests/shlib/vterm.sh b/tests/shlib/vterm.sh index 5017827f..4795bde5 100644 --- a/tests/shlib/vterm.sh +++ b/tests/shlib/vterm.sh @@ -1,26 +1,19 @@ . tests/shlib/common.sh -. tests/bot-ci/scripts/common/main.sh set +x vterm_setup() { - local test_dir="$1" ; shift + local vterm_suf="$1" ; shift - rm -rf "$test_dir" - mkdir "$test_dir" - mkdir "$test_dir/path" + make_test_root "vterm_$vterm_suf" - ln -s "$(which "${PYTHON}")" "$test_dir/path/python" - ln -s "$(which bash)" "$test_dir/path" + mkdir "$TEST_ROOT/path" - cp -r "$ROOT/tests/terminfo" "$test_dir" + ln -s "$(which "${PYTHON}")" "$TEST_ROOT/path/python" + ln -s "$(which bash)" "$TEST_ROOT/path" + + cp -r "$ROOT/tests/terminfo" "$TEST_ROOT" } vterm_shutdown() { - local test_dir="$1" ; shift - - if test $FAILED -eq 0 ; then - rm -rf "$test_dir" - else - echo "$FAIL_SUMMARY" - fi + rm_test_root } diff --git a/tests/test_in_vterm/test_tmux.py b/tests/test_in_vterm/test_tmux.py index 11ba95f3..76b9dffd 100755 --- a/tests/test_in_vterm/test_tmux.py +++ b/tests/test_in_vterm/test_tmux.py @@ -19,7 +19,7 @@ from tests.modules.lib.terminal import (ExpectProcess, MutableDimensions, do_terminal_tests, get_env) -VTERM_TEST_DIR = os.path.abspath('tests/vterm_tmux') +TEST_ROOT = os.path.abspath(os.environ['TEST_ROOT']) def tmux_logs_iter(test_dir): @@ -28,7 +28,7 @@ def tmux_logs_iter(test_dir): def print_tmux_logs(): - for f in tmux_logs_iter(VTERM_TEST_DIR): + for f in tmux_logs_iter(TEST_ROOT): print('_' * 80) print(os.path.basename(f) + ':') print('=' * 80) @@ -57,15 +57,15 @@ def tmux_fin_cb(p, cmd, env): try: check_call([ cmd, '-S', env['POWERLINE_TMUX_SOCKET_PATH'], 'kill-server' - ], env=env, cwd=VTERM_TEST_DIR) + ], env=env, cwd=TEST_ROOT) except Exception: print_exc() - for f in tmux_logs_iter(VTERM_TEST_DIR): + for f in tmux_logs_iter(TEST_ROOT): os.unlink(f) def main(attempts=3): - vterm_path = os.path.join(VTERM_TEST_DIR, 'path') + vterm_path = os.path.join(TEST_ROOT, 'path') tmux_exe = os.path.join(vterm_path, 'tmux') @@ -73,7 +73,7 @@ def main(attempts=3): if os.path.exists(socket_path): os.unlink(socket_path) - env = get_env(vterm_path, VTERM_TEST_DIR, { + env = get_env(vterm_path, TEST_ROOT, { 'POWERLINE_THEME_OVERRIDES': ';'.join(( key + '=' + json.dumps(val) for key, val in ( @@ -99,7 +99,7 @@ def main(attempts=3): conf_path = os.path.abspath('powerline/bindings/tmux/powerline.conf') conf_line = 'source "' + ( conf_path.replace('\\', '\\\\').replace('"', '\\"')) + '"\n' - conf_file = os.path.realpath(os.path.join(VTERM_TEST_DIR, 'tmux.conf')) + conf_file = os.path.realpath(os.path.join(TEST_ROOT, 'tmux.conf')) with open(conf_file, 'w') as cf_fd: cf_fd.write(conf_line) @@ -235,7 +235,7 @@ def main(attempts=3): dim=dim, args=args, env=env, - cwd=VTERM_TEST_DIR, + cwd=TEST_ROOT, fin_cb=tmux_fin_cb, last_attempt_cb=print_tmux_logs, ) diff --git a/tests/test_in_vterm/test_tmux.sh b/tests/test_in_vterm/test_tmux.sh index b2a2ab4b..f60811e4 100755 --- a/tests/test_in_vterm/test_tmux.sh +++ b/tests/test_in_vterm/test_tmux.sh @@ -4,14 +4,12 @@ enter_suite tmux -VTERM_TEST_DIR="$ROOT/tests/vterm_tmux" +vterm_setup tmux -vterm_setup "$VTERM_TEST_DIR" - -ln -s "$(which env)" "$VTERM_TEST_DIR/path" -ln -s "$(which cut)" "$VTERM_TEST_DIR/path" -ln -s "$ROOT/scripts/powerline-render" "$VTERM_TEST_DIR/path" -ln -s "$ROOT/scripts/powerline-config" "$VTERM_TEST_DIR/path" +ln -s "$(which env)" "$TEST_ROOT/path" +ln -s "$(which cut)" "$TEST_ROOT/path" +ln -s "$ROOT/scripts/powerline-render" "$TEST_ROOT/path" +ln -s "$ROOT/scripts/powerline-config" "$TEST_ROOT/path" test_tmux() { if test "$PYTHON_IMPLEMENTATION" = PyPy; then @@ -22,7 +20,7 @@ test_tmux() { if ! which "${POWERLINE_TMUX_EXE}" ; then return 0 fi - ln -sf "$(which "${POWERLINE_TMUX_EXE}")" "$VTERM_TEST_DIR/path/tmux" + ln -sf "$(which "${POWERLINE_TMUX_EXE}")" "$TEST_ROOT/path/tmux" f="$ROOT/tests/test_in_vterm/test_tmux.py" if ! "${PYTHON}" "$f" ; then local test_name="$("$POWERLINE_TMUX_EXE" -V 2>&1 | cut -d' ' -f2)" @@ -41,6 +39,6 @@ else test_tmux || true fi -vterm_shutdown "$VTERM_TEST_DIR" +vterm_shutdown exit_suite diff --git a/tests/test_in_vterm/test_vim.py b/tests/test_in_vterm/test_vim.py index 3403ec46..663d1302 100755 --- a/tests/test_in_vterm/test_vim.py +++ b/tests/test_in_vterm/test_vim.py @@ -4,41 +4,62 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct import os import sys -import json from time import sleep from subprocess import check_call from glob import glob1 from traceback import print_exc +from powerline.lib.dict import updated + from tests.modules.lib.terminal import (ExpectProcess, MutableDimensions, do_terminal_tests, get_env) -VTERM_TEST_DIR = os.path.abspath('tests/vterm_vim') +TEST_ROOT = os.path.abspath(os.environ['TEST_ROOT']) def main(attempts=3): - vterm_path = os.path.join(VTERM_TEST_DIR, 'path') + vterm_path = os.path.join(TEST_ROOT, 'path') vim_exe = os.path.join(vterm_path, 'vim') - env = get_env(vterm_path, VTERM_TEST_DIR) + env = get_env(vterm_path, TEST_ROOT) + env['ROOT'] = os.path.abspath('.') dim = MutableDimensions(rows=50, cols=200) + vimrc = os.path.join(TEST_ROOT, 'init.vim') + vimrc_contents = ''' + set laststatus=2 + set runtimepath=$ROOT/powerline/bindings/vim + ''' + with open(vimrc, 'w') as vd: + vd.write(vimrc_contents) + + base_attrs = { + (( 64, 64, 255), (0, 0, 0), 0, 0, 0): 'NT', # NonText + ((240, 240, 240), (0, 0, 0), 0, 0, 0): 'N', # Normal + } + + args = [ + '-u', vimrc, + '-i', 'NONE', + ] + + def feed(p): + p.send(':echo strtrans(eval(&statusline[2:]))\n') + tests = ( ) - args = [] - return do_terminal_tests( tests=tests, cmd=vim_exe, dim=dim, args=args, env=env, - cwd=VTERM_TEST_DIR, + cwd=TEST_ROOT, ) diff --git a/tests/test_vim/test.sh b/tests/test_vim/test.sh index a522946e..87502a94 100755 --- a/tests/test_vim/test.sh +++ b/tests/test_vim/test.sh @@ -1,10 +1,11 @@ #!/bin/sh . tests/shlib/common.sh +. tests/shlib/vterm.sh . tests/shlib/vim.sh enter_suite vim -make_test_root +vterm_setup vim # Define some overrides. These ones must be ignored and do not affect Vim # status/tab lines. @@ -46,4 +47,6 @@ if test -e "$OLD_VIM" ; then done fi +vterm_shutdown + exit_suite From 8e94773791a7d479d916884ec126a93918a959aa Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 21 May 2017 16:01:22 +0300 Subject: [PATCH 10/95] Fix test_vim.sh: should use standard directory as well --- tests/test_in_vterm/test_vim.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/test_in_vterm/test_vim.sh b/tests/test_in_vterm/test_vim.sh index 18e65265..0e7354aa 100755 --- a/tests/test_in_vterm/test_vim.sh +++ b/tests/test_in_vterm/test_vim.sh @@ -5,9 +5,7 @@ enter_suite vim -VTERM_TEST_DIR="$ROOT/tests/vterm_vim" - -vterm_setup "$VTERM_TEST_DIR" +vterm_setup vim test_vim() { if test "$PYTHON_IMPLEMENTATION" != CPython ; then @@ -17,7 +15,7 @@ test_vim() { if ! which "$POWERLINE_VIM_EXE" ; then return 0 fi - ln -sf "$(which "${POWERLINE_VIM_EXE}")" "$VTERM_TEST_DIR/path/vim" + ln -sf "$(which "${POWERLINE_VIM_EXE}")" "$TEST_ROOT/path/vim" f="$ROOT/tests/test_in_vterm/test_vim.py" if ! "${PYTHON}" "$f" ; then local test_name="$(LANG=C "$POWERLINE_VIM_EXE" --cmd 'echo version' --cmd qa 2>&1)" @@ -36,6 +34,6 @@ else test_vim || true fi -vterm_shutdown "$VTERM_TEST_DIR" +vterm_shutdown exit_suite From 28faebe260a187e7d1d8a787a29668e260c8a67f Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 21 May 2017 16:09:54 +0300 Subject: [PATCH 11/95] Do not provide make_test_root unneeded argument --- tests/shlib/vterm.sh | 4 +--- tests/test_in_vterm/test_tmux.sh | 2 +- tests/test_in_vterm/test_vim.sh | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/shlib/vterm.sh b/tests/shlib/vterm.sh index 4795bde5..56b6c89b 100644 --- a/tests/shlib/vterm.sh +++ b/tests/shlib/vterm.sh @@ -2,9 +2,7 @@ set +x vterm_setup() { - local vterm_suf="$1" ; shift - - make_test_root "vterm_$vterm_suf" + make_test_root mkdir "$TEST_ROOT/path" diff --git a/tests/test_in_vterm/test_tmux.sh b/tests/test_in_vterm/test_tmux.sh index f60811e4..7e1deccf 100755 --- a/tests/test_in_vterm/test_tmux.sh +++ b/tests/test_in_vterm/test_tmux.sh @@ -4,7 +4,7 @@ enter_suite tmux -vterm_setup tmux +vterm_setup ln -s "$(which env)" "$TEST_ROOT/path" ln -s "$(which cut)" "$TEST_ROOT/path" diff --git a/tests/test_in_vterm/test_vim.sh b/tests/test_in_vterm/test_vim.sh index 0e7354aa..064c35a6 100755 --- a/tests/test_in_vterm/test_vim.sh +++ b/tests/test_in_vterm/test_vim.sh @@ -3,9 +3,9 @@ . tests/shlib/vterm.sh . tests/shlib/vim.sh -enter_suite vim +enter_suite vvim -vterm_setup vim +vterm_setup test_vim() { if test "$PYTHON_IMPLEMENTATION" != CPython ; then From 3c49ed1e96df6513528729feee6e61fd101dfef8 Mon Sep 17 00:00:00 2001 From: Foo Date: Fri, 2 Jun 2017 21:12:05 +0300 Subject: [PATCH 12/95] Check that bash has (no) $PIPESTATUS support before using it Ref #1782 --- powerline/bindings/bash/powerline.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/powerline/bindings/bash/powerline.sh b/powerline/bindings/bash/powerline.sh index 4ec0d72c..618cb0d0 100644 --- a/powerline/bindings/bash/powerline.sh +++ b/powerline/bindings/bash/powerline.sh @@ -31,10 +31,26 @@ _powerline_return() { return $1 } +_POWERLINE_HAS_PIPESTATUS= + +_powerline_has_pipestatus() { + if test -z "$_POWERLINE_HAS_PIPESTATUS" ; then + _powerline_return 0 | _powerline_return 43 + if test "${PIPESTATUS[*]}" = "0 43" ; then + _POWERLINE_HAS_PIPESTATUS=0 + else + _POWERLINE_HAS_PIPESTATUS=1 + fi + fi + return $_POWERLINE_HAS_PIPESTATUS +} + _powerline_status_wrapper() { local last_exit_code=$? last_pipe_status=( "${PIPESTATUS[@]}" ) - if test "$last_exit_code" != "${last_pipe_status[-1]}" ; then + if ! _powerline_has_pipestatus \ + || test "${#last_pipe_status[@]}" -eq "0" \ + || test "$last_exit_code" != "${last_pipe_status[-1]}" ; then last_pipe_status=() fi "$@" $last_exit_code "${last_pipe_status[*]}" From d3e5d99a20305d5f71e3d383d1005d232d3efcc9 Mon Sep 17 00:00:00 2001 From: Foo Date: Fri, 2 Jun 2017 21:23:03 +0300 Subject: [PATCH 13/95] Do not spawn jobs With previous variant of code first call has spawned a job which was perfectly reproducibly visible in prompt at bash startup. In subsequent prompts job number segment disappeared because result was cached, but it still was not good. --- powerline/bindings/bash/powerline.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/powerline/bindings/bash/powerline.sh b/powerline/bindings/bash/powerline.sh index 618cb0d0..db831fd5 100644 --- a/powerline/bindings/bash/powerline.sh +++ b/powerline/bindings/bash/powerline.sh @@ -31,17 +31,13 @@ _powerline_return() { return $1 } -_POWERLINE_HAS_PIPESTATUS= +_POWERLINE_HAS_PIPESTATUS="$( + _powerline_return 0 | _powerline_return 43 + test "${PIPESTATUS[*]}" = "0 43" + echo "$?" +)" _powerline_has_pipestatus() { - if test -z "$_POWERLINE_HAS_PIPESTATUS" ; then - _powerline_return 0 | _powerline_return 43 - if test "${PIPESTATUS[*]}" = "0 43" ; then - _POWERLINE_HAS_PIPESTATUS=0 - else - _POWERLINE_HAS_PIPESTATUS=1 - fi - fi return $_POWERLINE_HAS_PIPESTATUS } From 7189f35cf04dfdeeda5a1f9c68a88f7e884ae648 Mon Sep 17 00:00:00 2001 From: Martin Gabelmann Date: Sat, 3 Jun 2017 21:25:44 +0200 Subject: [PATCH 14/95] add awesome4+ support, fixes #1784 --- docs/source/usage/wm-widgets.rst | 12 +++++++++++- powerline/bindings/awesome/powerline.lua | 9 +++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/source/usage/wm-widgets.rst b/docs/source/usage/wm-widgets.rst index 7dabd275..204c008c 100644 --- a/docs/source/usage/wm-widgets.rst +++ b/docs/source/usage/wm-widgets.rst @@ -5,7 +5,7 @@ Window manager widgets Awesome widget ============== -.. note:: Powerline currently only supports awesome 3.5. +.. note:: Powerline currently only supports awesome 3.5 and 4+. .. note:: The Powerline widget will spawn a shell script that runs in the background and updates the statusline with ``awesome-client``. @@ -23,7 +23,17 @@ Then add the ``powerline_widget`` to ``wibox``: .. code-block:: lua + -- awesome3.5 right_layout:add(powerline_widget) + + -- awesome4+ + s.mywibox:setup { + ... + { -- Right widgets + ... + powerline_widget, + }, + } Qtile widget ============ diff --git a/powerline/bindings/awesome/powerline.lua b/powerline/bindings/awesome/powerline.lua index 82a245e0..470901fc 100644 --- a/powerline/bindings/awesome/powerline.lua +++ b/powerline/bindings/awesome/powerline.lua @@ -6,5 +6,10 @@ powerline_widget:set_align('right') function powerline(mode, widget) end -awful.util.spawn_with_shell('powerline-daemon -q') -awful.util.spawn_with_shell('powerline wm.awesome') +if string.find(awesome.version, 'v4') then + awful.spawn.with_shell('powerline-daemon -q') + awful.spawn.with_shell('powerline wm.awesome') +else + awful.util.spawn_with_shell('powerline-daemon -q') + awful.util.spawn_with_shell('powerline wm.awesome') +end From e991b42c1b08f53dc7533985b6cef69ed99cb8a8 Mon Sep 17 00:00:00 2001 From: Whitley Date: Wed, 7 Jun 2017 20:57:01 -0400 Subject: [PATCH 15/95] Spelling Fix --- docs/source/installation/linux.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/installation/linux.rst b/docs/source/installation/linux.rst index aef89508..2ab605fd 100644 --- a/docs/source/installation/linux.rst +++ b/docs/source/installation/linux.rst @@ -94,7 +94,7 @@ After downloading font the following should be done: mv 'SomeFont for Powerline.otf' ~/.fonts/ -#. Update font cache for the path the font was moved to (root priveleges may be +#. Update font cache for the path the font was moved to (root privileges may be needed for updating font cache for some paths):: fc-cache -vf ~/.fonts/ From 234091c95dd6e99dd272367dfe0a42316b29ea73 Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 1 Jul 2017 02:57:53 +0300 Subject: [PATCH 16/95] Specify argparse dependency Fixes #1791 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 setup.py diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index e7b00e9e..0d46ae3e --- a/setup.py +++ b/setup.py @@ -124,7 +124,7 @@ setup( packages=find_packages(exclude=('tests', 'tests.*')), include_package_data=True, zip_safe=False, - install_requires=[], + install_requires=['argparse'] if OLD_PYTHON else [], extras_require={ 'docs': [ 'Sphinx', From 34dc7f9f55f0ab5143225da1e43b3e593646a2ed Mon Sep 17 00:00:00 2001 From: Vartan Christopher Simonian Date: Sat, 1 Jul 2017 20:15:25 -0700 Subject: [PATCH 17/95] Replace ~/.fonts with ~/.local/share/fonts in help `~/.fonts/` has been deprecated in favour of `~/.local/share/fonts/`. References: - https://github.com/behdad/fontconfig/blob/master/fonts.conf.in#L29 - https://lists.freedesktop.org/archives/fontconfig/2014-July/005270.html Fixes #1793 --- docs/source/installation/linux.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/installation/linux.rst b/docs/source/installation/linux.rst index 2ab605fd..15ec6064 100644 --- a/docs/source/installation/linux.rst +++ b/docs/source/installation/linux.rst @@ -60,12 +60,12 @@ with any coding font. #. Move the symbol font to a valid X font path. Valid font paths can be listed with ``xset q``:: - mv PowerlineSymbols.otf ~/.fonts/ + mv PowerlineSymbols.otf ~/.local/share/fonts/ #. Update font cache for the path the font was moved to (root priveleges may be needed to update cache for the system-wide paths):: - fc-cache -vf ~/.fonts/ + fc-cache -vf ~/.local/share/fonts/ #. Install the fontconfig file. For newer versions of fontconfig the config path is ``~/.config/fontconfig/conf.d/``, for older versions it’s @@ -92,12 +92,12 @@ After downloading font the following should be done: #. Move the patched font to a valid X font path. Valid font paths can be listed with ``xset q``:: - mv 'SomeFont for Powerline.otf' ~/.fonts/ + mv 'SomeFont for Powerline.otf' ~/.local/share/fonts/ #. Update font cache for the path the font was moved to (root privileges may be needed for updating font cache for some paths):: - fc-cache -vf ~/.fonts/ + fc-cache -vf ~/.local/share/fonts/ After installing patched font terminal emulator, GVim or whatever application powerline should work with must be configured to use the patched font. The From 73244eb976bae2806c70bf776497738c0bd601c8 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 13 Jul 2017 15:53:09 +0200 Subject: [PATCH 18/95] Make sure any positive integer fits into the buffer Avoids GCC 7.1.0 -Wformat-truncation. --- client/powerline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/powerline.c b/client/powerline.c index cafd3d62..06d6d220 100644 --- a/client/powerline.c +++ b/client/powerline.c @@ -71,7 +71,7 @@ inline size_t true_sun_len(const struct sockaddr_un *ptr) { #endif #define ADDRESS_SIZE sizeof(ADDRESS_TEMPLATE) + (sizeof(uid_t) * 4) -#define NUM_ARGS_SIZE (sizeof(int) * 2) +#define NUM_ARGS_SIZE (sizeof(int) * 2 + 1) #define BUF_SIZE 4096 #define NEW_ARGV_SIZE 200 From 924bbbe92b072a23af2e205568dc03d83fc93a76 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 13 Jul 2017 15:49:36 +0200 Subject: [PATCH 19/95] Make inline function also static After compiling with GCC 7.1.0 it otherwise fails linking for some reason, complaining about that non-static inline function being not found. --- client/powerline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/powerline.c b/client/powerline.c index 06d6d220..edee6d30 100644 --- a/client/powerline.c +++ b/client/powerline.c @@ -42,7 +42,7 @@ void do_write(int sd, const char *raw, size_t len) { } } -inline size_t true_sun_len(const struct sockaddr_un *ptr) { +static inline size_t true_sun_len(const struct sockaddr_un *ptr) { #ifdef __linux__ /* Because SUN_LEN uses strlen and abstract namespace paths begin * with a null byte, SUN_LEN is broken for these. Passing the full From 29ff2b99c47dd0d475c59696f3d749e4ad47999f Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 13 Jul 2017 15:54:16 +0200 Subject: [PATCH 20/95] Avoid a strlen() call --- client/powerline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/powerline.c b/client/powerline.c index edee6d30..ff107ece 100644 --- a/client/powerline.c +++ b/client/powerline.c @@ -88,6 +88,7 @@ int main(int argc, char *argv[]) { char *wd = NULL; char **envp; const char *address; + int len; if (argc < 2) { printf("Must provide at least one argument.\n"); @@ -122,8 +123,8 @@ int main(int argc, char *argv[]) { execvp("powerline-render", newargv); } - snprintf(num_args, NUM_ARGS_SIZE, "%x", argc - 1); - do_write(sd, num_args, strlen(num_args)); + len = snprintf(num_args, NUM_ARGS_SIZE, "%x", argc - 1); + do_write(sd, num_args, len); do_write(sd, eof, 1); for (i = 1; i < argc; i++) { From 338470c11fab863d600bb33b7c1b53d3f11c9208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Rafael=20S=C3=A1nchez?= Date: Sun, 30 Jul 2017 01:06:52 -0400 Subject: [PATCH 21/95] Adding Music On Console (mocp) support, requires >= 2.3.0 version --- powerline/segments/common/players.py | 57 ++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index ccbf116b..4cb1769a 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -528,3 +528,60 @@ Requires ``osascript``. {0} ''').format(_common_args.format('itunes'))) + + +class MocPlayerSegment(PlayerSegment): + def get_player_status(self, pl): + '''Return Music On Console (mocp) player information. + + mocp -i returns current information i.e. + File: filename.format + Title: full title + Artist: artist name + SongTitle: song title + Album: album name + TotalTime: 00:00 + TimeLeft: 00:00 + TotalSec: 000 + CurrentTime: 00:00 + CurrentSec: 000 + Bitrate: 000kbps + AvgBitrate: 000kbps + Rate: 00kHz + + For the information we are looking for we don’t really care if + we have extra-timing information or bit rate level. The + dictionary comprehension in this method takes anything in + ignore_info and brings the key inside that to the right info of + the dictionary. + ''' + now_playing_str = run_cmd(pl, ['mocp', '-i']) + if not now_playing_str: + return + ignore_info = ( + 'File', 'TimeLeft', 'TotalSec', 'Title', + 'Bitrate', 'AvgBitrate', 'Rate' + ) + now_playing = dict( + [line.split(': ') + for line in now_playing_str.split('\n')[:-1]] + ) + state = _convert_state(now_playing.get('State')) + return { + 'state': state, + 'album': now_playing.get('Album'), + 'artist': now_playing.get('Artist'), + 'title': now_playing.get('Title'), + 'elapsed': _convert_seconds(now_playing.get('CurrentTime', 0)), + 'total': _convert_seconds(now_playing.get('TotalTime', 0)), + } + + +mocp = with_docstring(MocPlayerSegment(), +('''Return MOC (Music On Console) player information + +Requires mocp command be acessible from $PATH. + +{0} +''').format(_common_args.format('mocp'))) + From 8a5310806f03111cdf47eeccfeff59b56be22782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Rafael=20S=C3=A1nchez?= Date: Sun, 30 Jul 2017 01:26:13 -0400 Subject: [PATCH 22/95] Adding information filtering conditional on list comprehension --- powerline/segments/common/players.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index 4cb1769a..f44e7547 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -564,7 +564,8 @@ class MocPlayerSegment(PlayerSegment): ) now_playing = dict( [line.split(': ') - for line in now_playing_str.split('\n')[:-1]] + for line in now_playing_str.split('\n')[:-1] + if line.split(': ')[0] not in ignore_info] ) state = _convert_state(now_playing.get('State')) return { From b82769ad4b2733d78a3224b5034e117bac8f2e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Rafael=20S=C3=A1nchez?= Date: Sun, 30 Jul 2017 03:13:21 -0400 Subject: [PATCH 23/95] Fixing some metadata and time calculation for mocp player --- powerline/segments/common/players.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index f44e7547..16394da8 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -559,7 +559,7 @@ class MocPlayerSegment(PlayerSegment): if not now_playing_str: return ignore_info = ( - 'File', 'TimeLeft', 'TotalSec', 'Title', + 'File', 'TimeLeft', 'Title', 'Bitrate', 'AvgBitrate', 'Rate' ) now_playing = dict( @@ -572,9 +572,9 @@ class MocPlayerSegment(PlayerSegment): 'state': state, 'album': now_playing.get('Album'), 'artist': now_playing.get('Artist'), - 'title': now_playing.get('Title'), - 'elapsed': _convert_seconds(now_playing.get('CurrentTime', 0)), - 'total': _convert_seconds(now_playing.get('TotalTime', 0)), + 'title': now_playing.get('SongTitle'), + 'elapsed': _convert_seconds(now_playing.get('CurrentSec', 0)), + 'total': _convert_seconds(now_playing.get('TotalSec', 0)), } From 0595c89f21565488408c470492f4b17d25403b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Rafael=20S=C3=A1nchez?= Date: Mon, 31 Jul 2017 07:26:56 -0400 Subject: [PATCH 24/95] Making code changes requested by @ZyX-I a day ago --- powerline/segments/common/players.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index 16394da8..1122f679 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -534,7 +534,8 @@ class MocPlayerSegment(PlayerSegment): def get_player_status(self, pl): '''Return Music On Console (mocp) player information. - mocp -i returns current information i.e. + `mocp -i` returns current information i.e. + .. code-block:: File: filename.format Title: full title Artist: artist name @@ -562,11 +563,11 @@ class MocPlayerSegment(PlayerSegment): 'File', 'TimeLeft', 'Title', 'Bitrate', 'AvgBitrate', 'Rate' ) - now_playing = dict( - [line.split(': ') + now_playing = dict(( + line.split(': ') for line in now_playing_str.split('\n')[:-1] - if line.split(': ')[0] not in ignore_info] - ) + if line.split(': ')[0] not in ignore_info + )) state = _convert_state(now_playing.get('State')) return { 'state': state, @@ -581,7 +582,7 @@ class MocPlayerSegment(PlayerSegment): mocp = with_docstring(MocPlayerSegment(), ('''Return MOC (Music On Console) player information -Requires mocp command be acessible from $PATH. +Requires version >= 2.3.0 and `mocp` command be acessible from $PATH. {0} ''').format(_common_args.format('mocp'))) From 324432bd12211849feb911b299ef223cbd99adbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Rafael=20S=C3=A1nchez?= Date: Mon, 31 Jul 2017 17:19:57 -0400 Subject: [PATCH 25/95] Avoiding more than 1 colon in strings for file name or song title, this may break the player indicator --- powerline/segments/common/players.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index 1122f679..d61d5b2b 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -564,16 +564,16 @@ class MocPlayerSegment(PlayerSegment): 'Bitrate', 'AvgBitrate', 'Rate' ) now_playing = dict(( - line.split(': ') + line.split(': ', 1) for line in now_playing_str.split('\n')[:-1] - if line.split(': ')[0] not in ignore_info + if line.split(': ', 1)[0] not in ignore_info )) - state = _convert_state(now_playing.get('State')) + state = _convert_state(now_playing.get('State', 'stop')) return { 'state': state, - 'album': now_playing.get('Album'), - 'artist': now_playing.get('Artist'), - 'title': now_playing.get('SongTitle'), + 'album': now_playing.get('Album', ''), + 'artist': now_playing.get('Artist', ''), + 'title': now_playing.get('SongTitle', ''), 'elapsed': _convert_seconds(now_playing.get('CurrentSec', 0)), 'total': _convert_seconds(now_playing.get('TotalSec', 0)), } From 8dd1188bc8e5e3a071eda5844f9ade30b85add74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Rafael=20S=C3=A1nchez?= Date: Tue, 1 Aug 2017 08:10:09 -0400 Subject: [PATCH 26/95] Removing some unnecesary lines --- powerline/segments/common/players.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index d61d5b2b..1fc46d77 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -559,14 +559,10 @@ class MocPlayerSegment(PlayerSegment): now_playing_str = run_cmd(pl, ['mocp', '-i']) if not now_playing_str: return - ignore_info = ( - 'File', 'TimeLeft', 'Title', - 'Bitrate', 'AvgBitrate', 'Rate' - ) + now_playing = dict(( line.split(': ', 1) for line in now_playing_str.split('\n')[:-1] - if line.split(': ', 1)[0] not in ignore_info )) state = _convert_state(now_playing.get('State', 'stop')) return { From 544556f1456040574002634c391319dfeaa17009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Rafael=20S=C3=A1nchez?= Date: Wed, 2 Aug 2017 07:54:53 -0400 Subject: [PATCH 27/95] Making code cleanup and enhancements suggested by @ZyX-I --- powerline/segments/common/players.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index 1fc46d77..fefc38df 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -551,18 +551,18 @@ class MocPlayerSegment(PlayerSegment): Rate: 00kHz For the information we are looking for we don’t really care if - we have extra-timing information or bit rate level. The - dictionary comprehension in this method takes anything in + we have extra-timing information or bit rate level. The + dictionary comprehension in this method takes anything in ignore_info and brings the key inside that to the right info of the dictionary. ''' now_playing_str = run_cmd(pl, ['mocp', '-i']) if not now_playing_str: return - + now_playing = dict(( - line.split(': ', 1) - for line in now_playing_str.split('\n')[:-1] + line.split(': ', 1) + for line in now_playing_str.split('\n')[:-1] )) state = _convert_state(now_playing.get('State', 'stop')) return { From e3ee79d976d5fc2e592be1ca32f1c2208c1933e9 Mon Sep 17 00:00:00 2001 From: Foo Date: Wed, 2 Aug 2017 15:05:35 +0300 Subject: [PATCH 28/95] Some style fixes --- powerline/segments/common/players.py | 47 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index fefc38df..c21dacef 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -534,35 +534,36 @@ class MocPlayerSegment(PlayerSegment): def get_player_status(self, pl): '''Return Music On Console (mocp) player information. - `mocp -i` returns current information i.e. - .. code-block:: - File: filename.format - Title: full title - Artist: artist name - SongTitle: song title - Album: album name - TotalTime: 00:00 - TimeLeft: 00:00 - TotalSec: 000 - CurrentTime: 00:00 - CurrentSec: 000 - Bitrate: 000kbps - AvgBitrate: 000kbps - Rate: 00kHz + ``mocp -i`` returns current information i.e. - For the information we are looking for we don’t really care if - we have extra-timing information or bit rate level. The - dictionary comprehension in this method takes anything in - ignore_info and brings the key inside that to the right info of - the dictionary. + .. code-block:: + + File: filename.format + Title: full title + Artist: artist name + SongTitle: song title + Album: album name + TotalTime: 00:00 + TimeLeft: 00:00 + TotalSec: 000 + CurrentTime: 00:00 + CurrentSec: 000 + Bitrate: 000kbps + AvgBitrate: 000kbps + Rate: 00kHz + + For the information we are looking for we don’t really care if we have + extra-timing information or bit rate level. The dictionary comprehension + in this method takes anything in ignore_info and brings the key inside + that to the right info of the dictionary. ''' now_playing_str = run_cmd(pl, ['mocp', '-i']) if not now_playing_str: return now_playing = dict(( - line.split(': ', 1) - for line in now_playing_str.split('\n')[:-1] + line.split(': ', 1) + for line in now_playing_str.split('\n')[:-1] )) state = _convert_state(now_playing.get('State', 'stop')) return { @@ -578,7 +579,7 @@ class MocPlayerSegment(PlayerSegment): mocp = with_docstring(MocPlayerSegment(), ('''Return MOC (Music On Console) player information -Requires version >= 2.3.0 and `mocp` command be acessible from $PATH. +Requires version >= 2.3.0 and ``mocp`` executable in ``$PATH``. {0} ''').format(_common_args.format('mocp'))) From 9bff8a566040f07def85f80d7ff0cb7d169f17ed Mon Sep 17 00:00:00 2001 From: chester755 Date: Fri, 4 Aug 2017 13:49:26 -0500 Subject: [PATCH 29/95] Adding elapsed time to the dbus player. --- powerline/segments/common/players.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index c21dacef..05aabe3e 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -249,6 +249,7 @@ else: player = bus.get_object(bus_name, player_path) iface = dbus.Interface(player, iface_prop) info = iface.Get(iface_player, 'Metadata') + elapsed = iface.Get(iface_player, 'Position') status = iface.Get(iface_player, 'PlaybackStatus') except dbus.exceptions.DBusException: return @@ -269,6 +270,7 @@ else: 'album': album, 'artist': artist, 'title': title, + 'elapsed': _convert_seconds(elapsed / 1e6), 'total': _convert_seconds(info.get('mpris:length') / 1e6), } From 8d85c4f73b4ab1080414eecce98029e227549c6d Mon Sep 17 00:00:00 2001 From: chester755 Date: Fri, 4 Aug 2017 16:08:59 -0500 Subject: [PATCH 30/95] Add elapsed time to dbus players. --- powerline/segments/common/players.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index 05aabe3e..e1ffe218 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -249,12 +249,19 @@ else: player = bus.get_object(bus_name, player_path) iface = dbus.Interface(player, iface_prop) info = iface.Get(iface_player, 'Metadata') - elapsed = iface.Get(iface_player, 'Position') status = iface.Get(iface_player, 'PlaybackStatus') except dbus.exceptions.DBusException: return if not info: return + + try: + elapsed = iface.Get(iface_player, 'Position') + except dbus.exceptions.DBusException: + pl.warning('Missing player elapsed time') + elapsed = None + else: + elapsed = _convert_seconds(elapsed / 1e6), album = info.get('xesam:album') title = info.get('xesam:title') artist = info.get('xesam:artist') @@ -270,7 +277,7 @@ else: 'album': album, 'artist': artist, 'title': title, - 'elapsed': _convert_seconds(elapsed / 1e6), + 'elapsed': elapsed, 'total': _convert_seconds(info.get('mpris:length') / 1e6), } From 5a53cf9f934cce27eae0856c4ea00a2a3110f46e Mon Sep 17 00:00:00 2001 From: chester755 Date: Fri, 4 Aug 2017 16:26:38 -0500 Subject: [PATCH 31/95] Add elapsed time to Dbus players --- powerline/segments/common/players.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index e1ffe218..eb32f267 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -261,7 +261,7 @@ else: pl.warning('Missing player elapsed time') elapsed = None else: - elapsed = _convert_seconds(elapsed / 1e6), + elapsed = _convert_seconds(elapsed / 1e6) album = info.get('xesam:album') title = info.get('xesam:title') artist = info.get('xesam:artist') From 1b3456a449bad3665135d5b486b9d669af4611fc Mon Sep 17 00:00:00 2001 From: Arslan Ablikim Date: Tue, 8 Aug 2017 11:45:46 +0800 Subject: [PATCH 32/95] fix spotify to use apple script --- powerline/segments/common/players.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index eb32f267..a91fa0d7 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -380,7 +380,7 @@ Requires ``osascript`` available in $PATH. ''').format(_common_args.format('spotify_apple_script'))) -if 'dbus' in globals() or not sys.platform.startswith('darwin'): +if not sys.platform.startswith('darwin'): spotify = spotify_dbus _old_name = 'spotify_dbus' else: From 5d8739b2914a98803b741a22962d56b346602706 Mon Sep 17 00:00:00 2001 From: Arslan Ablikim Date: Tue, 8 Aug 2017 12:08:37 +0800 Subject: [PATCH 33/95] fix spotify track length --- powerline/segments/common/players.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index eb32f267..738b91af 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -341,7 +341,7 @@ class SpotifyAppleScriptPlayerSegment(PlayerSegment): set track_name to name of current track set artist_name to artist of current track set album_name to album of current track - set track_length to duration of current track + set track_length to round ((duration of current track) / 1000) rounding down set now_playing to "" & player state & "{0}" & album_name & "{0}" & artist_name & "{0}" & track_name & "{0}" & track_length return now_playing else From 146cf8994d7f53762be977f0a5a9b163e8cfeaec Mon Sep 17 00:00:00 2001 From: Arslan Ablikim Date: Tue, 8 Aug 2017 12:33:25 +0800 Subject: [PATCH 34/95] fix spotify track length --- powerline/segments/common/players.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index 738b91af..14b769a3 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -341,7 +341,7 @@ class SpotifyAppleScriptPlayerSegment(PlayerSegment): set track_name to name of current track set artist_name to artist of current track set album_name to album of current track - set track_length to round ((duration of current track) / 1000) rounding down + set track_length to duration of current track set now_playing to "" & player state & "{0}" & album_name & "{0}" & artist_name & "{0}" & track_name & "{0}" & track_length return now_playing else @@ -367,7 +367,7 @@ class SpotifyAppleScriptPlayerSegment(PlayerSegment): 'album': spotify_status[1], 'artist': spotify_status[2], 'title': spotify_status[3], - 'total': _convert_seconds(int(spotify_status[4])) + 'total': _convert_seconds(int(spotify_status[4])/1000) } From 2a9a0a8282d482cfa4d3c06254f167aaa86c38dd Mon Sep 17 00:00:00 2001 From: Arslan Ablikim Date: Tue, 8 Aug 2017 13:35:03 +0800 Subject: [PATCH 35/95] added elapsed time to spotify applescript player segment --- powerline/segments/common/players.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index 0240b9e5..21860c69 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -342,7 +342,7 @@ class SpotifyAppleScriptPlayerSegment(PlayerSegment): set artist_name to artist of current track set album_name to album of current track set track_length to duration of current track - set now_playing to "" & player state & "{0}" & album_name & "{0}" & artist_name & "{0}" & track_name & "{0}" & track_length + set now_playing to "" & player state & "{0}" & album_name & "{0}" & artist_name & "{0}" & track_name & "{0}" & track_length & "{0}" & player position return now_playing else return player state @@ -367,7 +367,8 @@ class SpotifyAppleScriptPlayerSegment(PlayerSegment): 'album': spotify_status[1], 'artist': spotify_status[2], 'title': spotify_status[3], - 'total': _convert_seconds(int(spotify_status[4])/1000) + 'total': _convert_seconds(int(spotify_status[4])/1000), + 'elapsed': _convert_seconds(spotify_status[5]) } From 01f2a3ae92d100366a6ac0d0ac53213a7762a349 Mon Sep 17 00:00:00 2001 From: Arslan Ablikim Date: Wed, 9 Aug 2017 21:30:21 +0800 Subject: [PATCH 36/95] added a trailing comma --- powerline/segments/common/players.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index 21860c69..dcd7a100 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -368,7 +368,7 @@ class SpotifyAppleScriptPlayerSegment(PlayerSegment): 'artist': spotify_status[2], 'title': spotify_status[3], 'total': _convert_seconds(int(spotify_status[4])/1000), - 'elapsed': _convert_seconds(spotify_status[5]) + 'elapsed': _convert_seconds(spotify_status[5]), } From 6b3c71bf3be49a8cf210a684c53ecc74a21f48a9 Mon Sep 17 00:00:00 2001 From: Nikolai Aleksandrovich Pavlov Date: Tue, 22 Aug 2017 10:30:49 +0300 Subject: [PATCH 37/95] Do not use negative indexes Ref #1821. --- powerline/bindings/bash/powerline.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerline/bindings/bash/powerline.sh b/powerline/bindings/bash/powerline.sh index db831fd5..f4e933ec 100644 --- a/powerline/bindings/bash/powerline.sh +++ b/powerline/bindings/bash/powerline.sh @@ -46,7 +46,7 @@ _powerline_status_wrapper() { if ! _powerline_has_pipestatus \ || test "${#last_pipe_status[@]}" -eq "0" \ - || test "$last_exit_code" != "${last_pipe_status[-1]}" ; then + || test "$last_exit_code" != "${last_pipe_status[$(( ${#last_pipe_status[@]} - 1 ))]}" ; then last_pipe_status=() fi "$@" $last_exit_code "${last_pipe_status[*]}" From 5adb7d11a3db75faa082377c0618fb2c57032722 Mon Sep 17 00:00:00 2001 From: Nikolai Aleksandrovich Pavlov Date: Sat, 2 Sep 2017 22:39:28 +0300 Subject: [PATCH 38/95] Fix data type in branch segment documentation Closes #1827 --- powerline/segments/common/vcs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerline/segments/common/vcs.py b/powerline/segments/common/vcs.py index 1aa5d110..07679ae5 100644 --- a/powerline/segments/common/vcs.py +++ b/powerline/segments/common/vcs.py @@ -46,7 +46,7 @@ branch = with_docstring(BranchSegment(), :param bool status_colors: Determines whether repository status will be used to determine highlighting. Default: False. -:param bool ignore_statuses: +:param list ignore_statuses: List of statuses which will not result in repo being marked as dirty. Most useful is setting this option to ``["U"]``: this will ignore repository which has just untracked files (i.e. repository with modified, deleted or From d7cbeb902205353a83a7bcddc1b4566a2841d4a5 Mon Sep 17 00:00:00 2001 From: hede Date: Sun, 15 Oct 2017 13:59:49 +0300 Subject: [PATCH 39/95] Typo fix In the first paragraph: s/Presense/Presence of Python support in vim... --- docs/source/usage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/usage.rst b/docs/source/usage.rst index 1ed3b933..5bfd3043 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -8,7 +8,7 @@ Application-specific requirements Vim plugin requirements ^^^^^^^^^^^^^^^^^^^^^^^ -The vim plugin requires a vim version with Python support compiled in. Presense +The vim plugin requires a vim version with Python support compiled in. Presence of Python support in Vim can be checked by running ``vim --version | grep +python``. From c8f361c9ca64712c0a8ab684635f5896e1fa0385 Mon Sep 17 00:00:00 2001 From: Pablo Acosta-Serafini Date: Mon, 23 Oct 2017 12:45:02 -0400 Subject: [PATCH 40/95] Added Vim segment plugin for the Asynchronous Linter Engine (ALE). This segment has the same functionality and interface as the Syntastic Vim segment plugin, and the code is largely adapted from it. Documentation stub is also included --- docs/source/configuration/segments/vim.rst | 6 ++ powerline/segments/vim/plugin/ale.py | 97 ++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 powerline/segments/vim/plugin/ale.py diff --git a/docs/source/configuration/segments/vim.rst b/docs/source/configuration/segments/vim.rst index b0f52c18..5df70d6c 100644 --- a/docs/source/configuration/segments/vim.rst +++ b/docs/source/configuration/segments/vim.rst @@ -9,6 +9,12 @@ Vim segments Plugin-specific segments ======================== +Asynchronous Linter Engine (ALE) segments +----------------------------------------- + +.. automodule:: powerline.segments.vim.plugin.ale + :members: + Syntastic segments ------------------ diff --git a/powerline/segments/vim/plugin/ale.py b/powerline/segments/vim/plugin/ale.py new file mode 100644 index 00000000..c7fb97a3 --- /dev/null +++ b/powerline/segments/vim/plugin/ale.py @@ -0,0 +1,97 @@ +# vim:fileencoding=utf-8:noet +""" +Asynchronous Lint Engine (ALE) plugin + +Largely adapted from Sytastic plugin +""" + +from __future__ import ( + unicode_literals, division, absolute_import, print_function +) +try: + import vim +except ImportError: + vim = object() +from powerline.bindings.vim import vim_global_exists +from powerline.theme import requires_segment_info + + +# To turn on logging, in the Powerline configuration fie config.json, +# in the "common" key, add log_file and log_level key-value pairs as +# appropriate and desired, for example: +# +# "common": { +# "term_truecolor": false, +# "log_file": "/mylogdir/powerline.log", +# "log_level": "INFO" +# }, +# +# and then turn on debug internal variable to True +@requires_segment_info +def ale( + segment_info, + pl, + err_format='ERR:  {first_line} ({num}) ', + warn_format='WARN:  {first_line} ({num}) ' +): + """ + Show whether Asynchronous Lint Engine (ALE) has found any errors + or warnings + + :param str err_format: + Format string for errors. + + :param str warn_format: + Format string for warnings. + + Highlight groups used: ``ale:warning`` or + ``warning``, ``ale:error`` or ``error``. + """ + # pylint: disable=C0103,W0613 + debug = False + bufnr = str(segment_info['bufnr']) + ale_enabled_exists = vim_global_exists('ale_enabled') + ale_enabled = ale_enabled_exists and int(vim.eval('g:ale_enabled')) + if debug: + pl.info('ale_enabled_exists: {0}'.format(ale_enabled_exists)) + pl.info('ale_enabled: {0}'.format(ale_enabled)) + if not ale_enabled: + return None + cmd = 'ale#statusline#Count({0}).total'.format(bufnr) + if debug: + pl.info('cmd: {0}'.format(cmd)) + has_errors = int(vim.eval(cmd)) + if debug: + pl.info('has_errors: {0}'.format(has_errors)) + if not has_errors: + return + cmd = 'ale#engine#GetLoclist({0})'.format(bufnr) + if debug: + pl.info('cmd: {0}'.format(cmd)) + issues = vim.eval(cmd) + errors, warnings = [], [] + for issue in issues: + if issue['type'] == 'E': + errors.append(issue) + elif issue['type'] == 'W': + warnings.append(issue) + segments = [] + if errors: + segments.append( + { + 'contents': err_format.format( + first_line=errors[0]['lnum'], num=len(errors) + ), + 'highlight_groups': ['ale:error', 'error'], + } + ) + if warnings: + segments.append( + { + 'contents': warn_format.format( + first_line=warnings[0]['lnum'], num=len(warnings) + ), + 'highlight_groups': ['ale:warning', 'warning'], + } + ) + return segments From 67683ecbb8792fb2b558af1b60f950d9f44e5152 Mon Sep 17 00:00:00 2001 From: Pablo Acosta-Serafini Date: Tue, 24 Oct 2017 04:40:03 -0400 Subject: [PATCH 41/95] Introduced requested chanages --- powerline/segments/vim/plugin/ale.py | 100 ++++++++------------------- 1 file changed, 27 insertions(+), 73 deletions(-) diff --git a/powerline/segments/vim/plugin/ale.py b/powerline/segments/vim/plugin/ale.py index c7fb97a3..959c1c53 100644 --- a/powerline/segments/vim/plugin/ale.py +++ b/powerline/segments/vim/plugin/ale.py @@ -1,42 +1,17 @@ -# vim:fileencoding=utf-8:noet -""" -Asynchronous Lint Engine (ALE) plugin +from __future__ import (unicode_literals, division, absolute_import, print_function) -Largely adapted from Sytastic plugin -""" - -from __future__ import ( - unicode_literals, division, absolute_import, print_function -) try: import vim except ImportError: vim = object() + from powerline.bindings.vim import vim_global_exists from powerline.theme import requires_segment_info -# To turn on logging, in the Powerline configuration fie config.json, -# in the "common" key, add log_file and log_level key-value pairs as -# appropriate and desired, for example: -# -# "common": { -# "term_truecolor": false, -# "log_file": "/mylogdir/powerline.log", -# "log_level": "INFO" -# }, -# -# and then turn on debug internal variable to True @requires_segment_info -def ale( - segment_info, - pl, - err_format='ERR:  {first_line} ({num}) ', - warn_format='WARN:  {first_line} ({num}) ' -): - """ - Show whether Asynchronous Lint Engine (ALE) has found any errors - or warnings +def ale(segment_info, pl, err_format='ERR: ln {first_line} ({num}) ', warn_format='WARN: ln {first_line} ({num}) '): + '''Show whether ALE has found any errors or warnings :param str err_format: Format string for errors. @@ -44,54 +19,33 @@ def ale( :param str warn_format: Format string for warnings. - Highlight groups used: ``ale:warning`` or - ``warning``, ``ale:error`` or ``error``. - """ - # pylint: disable=C0103,W0613 - debug = False - bufnr = str(segment_info['bufnr']) - ale_enabled_exists = vim_global_exists('ale_enabled') - ale_enabled = ale_enabled_exists and int(vim.eval('g:ale_enabled')) - if debug: - pl.info('ale_enabled_exists: {0}'.format(ale_enabled_exists)) - pl.info('ale_enabled: {0}'.format(ale_enabled)) - if not ale_enabled: + Highlight groups used: ``ale:warning`` or ``warning``, ``ale:error`` or ``error``. + ''' + if not (vim_global_exists('ale_enabled') and int(vim.eval('g:ale_enabled'))): return None - cmd = 'ale#statusline#Count({0}).total'.format(bufnr) - if debug: - pl.info('cmd: {0}'.format(cmd)) - has_errors = int(vim.eval(cmd)) - if debug: - pl.info('has_errors: {0}'.format(has_errors)) + has_errors = int(vim.eval('ale#statusline#Count('+str(segment_info['bufnr'])+').total')) if not has_errors: return - cmd = 'ale#engine#GetLoclist({0})'.format(bufnr) - if debug: - pl.info('cmd: {0}'.format(cmd)) - issues = vim.eval(cmd) - errors, warnings = [], [] - for issue in issues: + error = None + warning = None + errors_count = 0 + warnings_count = 0 + for issue in vim.eval('ale#engine#GetLoclist('+str(segment_info['bufnr'])+')'): if issue['type'] == 'E': - errors.append(issue) + error = error or issue + errors_count += 1 elif issue['type'] == 'W': - warnings.append(issue) + warning = warning or issue + warnings_count += 1 segments = [] - if errors: - segments.append( - { - 'contents': err_format.format( - first_line=errors[0]['lnum'], num=len(errors) - ), - 'highlight_groups': ['ale:error', 'error'], - } - ) - if warnings: - segments.append( - { - 'contents': warn_format.format( - first_line=warnings[0]['lnum'], num=len(warnings) - ), - 'highlight_groups': ['ale:warning', 'warning'], - } - ) + if error: + segments.append({ + 'contents': err_format.format(first_line=error['lnum'], num=errors_count), + 'highlight_groups': ['ale:error', 'error'], + }) + if warning: + segments.append({ + 'contents': warn_format.format(first_line=warning['lnum'], num=warnings_count), + 'highlight_groups': ['ale:warning', 'warning'], + }) return segments From 421a71ee530a5319f0f24b63cfd655d92679227c Mon Sep 17 00:00:00 2001 From: Pablo Acosta-Serafini Date: Fri, 27 Oct 2017 08:44:47 -0400 Subject: [PATCH 42/95] Brought back modeline and added spaces around plus signs --- powerline/segments/vim/plugin/ale.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/powerline/segments/vim/plugin/ale.py b/powerline/segments/vim/plugin/ale.py index 959c1c53..4f4bdee4 100644 --- a/powerline/segments/vim/plugin/ale.py +++ b/powerline/segments/vim/plugin/ale.py @@ -1,3 +1,4 @@ +# vim:fileencoding=utf-8:noet from __future__ import (unicode_literals, division, absolute_import, print_function) try: @@ -23,14 +24,14 @@ def ale(segment_info, pl, err_format='ERR: ln {first_line} ({num}) ', warn_forma ''' if not (vim_global_exists('ale_enabled') and int(vim.eval('g:ale_enabled'))): return None - has_errors = int(vim.eval('ale#statusline#Count('+str(segment_info['bufnr'])+').total')) + has_errors = int(vim.eval('ale#statusline#Count(' + str(segment_info['bufnr']) + ').total')) if not has_errors: return error = None warning = None errors_count = 0 warnings_count = 0 - for issue in vim.eval('ale#engine#GetLoclist('+str(segment_info['bufnr'])+')'): + for issue in vim.eval('ale#engine#GetLoclist(' + str(segment_info['bufnr']) + ')'): if issue['type'] == 'E': error = error or issue errors_count += 1 From 6be991c571e6abc333d5ed1e5884e60e16ec2eed Mon Sep 17 00:00:00 2001 From: Brandon Ewing Date: Fri, 24 Nov 2017 15:03:30 -0600 Subject: [PATCH 43/95] Check for battery percentage if no charge/energy Windows Subsystem for Linux abstracts the batteries in a laptop into a single battery, and only states the percent charge via /sys/power_supply/battery/capacity. If dbus is unavailable, and no charge/energy readings are available for any power supply, search for the first power supply that has a capacity file, and use it (and its state) as the battery status. Tested on a Surface Book 2 running Windows 10 with Windows Subsytem for Linux Ubuntu 16.04 --- powerline/segments/common/bat.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/powerline/segments/common/bat.py b/powerline/segments/common/bat.py index 727810a6..c892f62a 100644 --- a/powerline/segments/common/bat.py +++ b/powerline/segments/common/bat.py @@ -114,6 +114,21 @@ def _fetch_battery_info(pl): return (energy * 100.0 / energy_full), state return _get_battery_status pl.debug('Not using /sys/class/power_supply as no batteries were found') + else: + pl.debug("Checking for first capacity battery percentage") + for batt in os.listdir('/sys/class/power_supply'): + if os.path.exists('/sys/class/power_supply/{0}/capacity'.format(batt)): + def _get_battery_perc(pl): + state = True + with open('/sys/class/power_supply/{0}/capacity'.format(batt), 'r') as f: + perc = int(f.readline().split()[0]) + try: + with open(linux_status_fmt.format(batt), 'r') as f: + state &= (f.readline().strip() != 'Discharging') + except IOError: + state = None + return perc, state + return _get_battery_perc else: pl.debug('Not using /sys/class/power_supply: no directory') From 783b56066fa7961ca92ba1723d71116b93df35ce Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Jul 2017 19:30:25 +0300 Subject: [PATCH 44/95] Use trusty for tests Bot-ci was switched to it, better upgrade upstream tests then downgrade bot-ci. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 7546af90..f9ca0b25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ sudo: false +dist: trusty cache: directories: - $HOME/.cache/pip From e71cc3e9ef8a3f7015d85af2ab08b4f3f000962e Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Jul 2017 19:30:42 +0300 Subject: [PATCH 45/95] Add python-3.6 to build matrix --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f9ca0b25..1212365b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ matrix: - python: "3.3" - python: "3.4" - python: "3.5" + - python: "3.6" - python: "pypy" - python: "pypy3" - python: "2.7" From 468397b22415db8e2a12c14fb821929fc8955b2b Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Jul 2017 19:36:17 +0300 Subject: [PATCH 46/95] Split CI into stages --- .travis.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1212365b..e50bb81e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,20 +18,23 @@ addons: language: python install: tests/install.sh script: tests/test.sh -matrix: +jobs: include: - - python: "2.6" - - python: "2.7" + - stage: Old Python and PyPy + python: "2.6" - python: "3.2" - - python: "3.3" - - python: "3.4" - - python: "3.5" - - python: "3.6" - python: "pypy" - python: "pypy3" + - stage: Latest Python + python: "2.7" - python: "2.7" env: >- USE_UCS2_PYTHON=1 UCS2_PYTHON_VARIANT="2.7" + - python: "3.6" + - stage: Intermediate versions + python: "3.3" + - python: "3.4" + - python: "3.5" # vim: et From 0ad1d9be4041c84b8b7a3b9bb23cc5e81fdc3ff1 Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 5 Aug 2017 13:53:24 +0300 Subject: [PATCH 47/95] More granular failure reports in summary from vterm tests --- tests/modules/lib/__init__.py | 84 ++++++++++++++++++++++++++++++++ tests/modules/lib/terminal.py | 30 ++++++------ tests/shlib/common.sh | 2 +- tests/test_in_vterm/test_tmux.py | 23 +++++---- tests/test_in_vterm/test_vim.py | 19 +++++--- 5 files changed, 125 insertions(+), 33 deletions(-) diff --git a/tests/modules/lib/__init__.py b/tests/modules/lib/__init__.py index 9a18faf2..b5a30d7d 100644 --- a/tests/modules/lib/__init__.py +++ b/tests/modules/lib/__init__.py @@ -3,6 +3,7 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct import imp import sys +import os class Pl(object): @@ -161,3 +162,86 @@ def replace_env(key, new, environ=None, **kwargs): r = kwargs.copy() r['environ'] = environ or {} return ItemReplace(r['environ'], key, new, r) + + +class PowerlineSingleTest(object): + def __init__(self, suite, name): + self.suite = suite + self.name = name + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + if exc_type is not None: + self.exception('Exception while running test: {0!r}'.format( + exc_value)) + + def fail(self, message, allow_failure=False): + return self.suite.fail(self.name, message, allow_failure) + + def exception(self, message, allow_failure=False): + return self.suite.exception(self.name, message, allow_failure) + + +class PowerlineDummyTest(object): + def __enter__(self): + return self + + def __exit__(self, *args): + pass + + def fail(self, *args, **kwargs): + pass + + def exception(self, *args, **kwargs): + pass + + +class PowerlineTestSuite(object): + def __init__(self, name): + self.name = name + + def __enter__(self): + self.saved_current_suite = os.environ['POWERLINE_CURRENT_SUITE'] + os.environ['POWERLINE_CURRENT_SUITE'] = ( + self.saved_current_suite + '/' + self.name) + self.suite = self.saved_current_suite + '/' + self.name + return self + + def __exit__(self, exc_type, exc_value, traceback): + if exc_type is not None: + self.exception( + 'suite_noexcept', + 'Exception while running test suite: {0!r}'.format(exc_value), + ) + os.environ['POWERLINE_CURRENT_SUITE'] = self.saved_current_suite + + def record_test_failure(self, fail_char, test_name, message, allow_failure=False): + if allow_failure: + fail_char = 'A' + fail_char + full_msg = '{fail_char} {suite}|{test_name} :: {message}'.format( + fail_char=fail_char, + suite=self.suite, + test_name=test_name, + message=message, + ) + print('Failed: ' + full_msg) + with open(os.environ['FAILURES_FILE'], 'a') as ffd: + ffd.write(full_msg + '\n') + return False + + def exception(self, test_name, message, allow_failure=False): + return self.record_test_failure('E', test_name, message, allow_failure) + + def fail(self, test_name, message, allow_failure=False): + return self.record_test_failure('F', test_name, message, allow_failure) + + def test(self, name, attempts=0): + if not attempts: + return PowerlineSingleTest(self, name) + else: + return PowerlineDummyTest() + + def subsuite(self, name): + return PowerlineTestSuite(name) diff --git a/tests/modules/lib/terminal.py b/tests/modules/lib/terminal.py index 860b20e1..ab52b8de 100644 --- a/tests/modules/lib/terminal.py +++ b/tests/modules/lib/terminal.py @@ -220,7 +220,7 @@ def get_env(vterm_path, test_dir, *args, **kwargs): return env -def do_terminal_tests(tests, cmd, dim, args, env, cwd=None, fin_cb=None, +def do_terminal_tests(tests, cmd, dim, args, env, suite, cwd=None, fin_cb=None, last_attempt_cb=None, attempts=3): lib = os.environ.get('POWERLINE_LIBVTERM') if not lib: @@ -243,19 +243,21 @@ def do_terminal_tests(tests, cmd, dim, args, env, cwd=None, fin_cb=None, ret = True - for test in tests: - try: - test_prep = test['prep_cb'] - except KeyError: - pass - else: - test_prep(p) - ret = ( - ret - and test_expected_result(p, test, attempts == 0, - last_attempt_cb, - test.get('attempts', 3)) - ) + for i, test in enumerate(tests): + with suite.test(test.get('name', 'test_{0}'.format(i)), + attempts) as ptest: + try: + test_prep = test['prep_cb'] + except KeyError: + pass + else: + test_prep(p) + test_result = test_expected_result(p, test, attempts == 0, + last_attempt_cb, + test.get('attempts', 3)) + if not test_result: + ptest.fail('Result does not match expected') + ret = ret and test_result if ret: return ret diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh index f16a1559..ed4504a9 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -13,7 +13,7 @@ if test -z "$FAILED" ; then FAIL_SUMMARY="" TMP_ROOT="$ROOT/tests/tmp" - FAILURES_FILE="$ROOT/tests/failures" + export FAILURES_FILE="$ROOT/tests/failures" fi ANSI_CLEAR="\033[0K" diff --git a/tests/test_in_vterm/test_tmux.py b/tests/test_in_vterm/test_tmux.py index 76b9dffd..dfccc24e 100755 --- a/tests/test_in_vterm/test_tmux.py +++ b/tests/test_in_vterm/test_tmux.py @@ -17,6 +17,7 @@ from powerline import get_fallback_logger from tests.modules.lib.terminal import (ExpectProcess, MutableDimensions, do_terminal_tests, get_env) +from tests.modules.lib import PowerlineTestSuite TEST_ROOT = os.path.abspath(os.environ['TEST_ROOT']) @@ -229,16 +230,18 @@ def main(attempts=3): 'new-window', 'bash --norc --noprofile -i', ';', ] - return do_terminal_tests( - tests=tests, - cmd=tmux_exe, - dim=dim, - args=args, - env=env, - cwd=TEST_ROOT, - fin_cb=tmux_fin_cb, - last_attempt_cb=print_tmux_logs, - ) + with PowerlineTestSuite('tmux') as suite: + return do_terminal_tests( + tests=tests, + cmd=tmux_exe, + dim=dim, + args=args, + env=env, + cwd=TEST_ROOT, + fin_cb=tmux_fin_cb, + last_attempt_cb=print_tmux_logs, + suite=suite, + ) if __name__ == '__main__': diff --git a/tests/test_in_vterm/test_vim.py b/tests/test_in_vterm/test_vim.py index 663d1302..11da223b 100755 --- a/tests/test_in_vterm/test_vim.py +++ b/tests/test_in_vterm/test_vim.py @@ -14,6 +14,7 @@ from powerline.lib.dict import updated from tests.modules.lib.terminal import (ExpectProcess, MutableDimensions, do_terminal_tests, get_env) +from tests.modules.lib import PowerlineTestSuite TEST_ROOT = os.path.abspath(os.environ['TEST_ROOT']) @@ -53,14 +54,16 @@ def main(attempts=3): tests = ( ) - return do_terminal_tests( - tests=tests, - cmd=vim_exe, - dim=dim, - args=args, - env=env, - cwd=TEST_ROOT, - ) + with PowerlineTestSuite('vim') as suite: + return do_terminal_tests( + tests=tests, + cmd=vim_exe, + dim=dim, + args=args, + env=env, + cwd=TEST_ROOT, + suite=suite, + ) if __name__ == '__main__': From 45e148b3a0f48d30a3e4f5965ec4658fcb78a23b Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 5 Aug 2017 13:58:41 +0300 Subject: [PATCH 48/95] Fix what attempts means for PowerlineTestSuite.test --- tests/modules/lib/__init__.py | 4 ++-- tests/modules/lib/terminal.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/modules/lib/__init__.py b/tests/modules/lib/__init__.py index b5a30d7d..d7089acb 100644 --- a/tests/modules/lib/__init__.py +++ b/tests/modules/lib/__init__.py @@ -237,8 +237,8 @@ class PowerlineTestSuite(object): def fail(self, test_name, message, allow_failure=False): return self.record_test_failure('F', test_name, message, allow_failure) - def test(self, name, attempts=0): - if not attempts: + def test(self, name, attempts_left=0): + if not attempts_left: return PowerlineSingleTest(self, name) else: return PowerlineDummyTest() diff --git a/tests/modules/lib/terminal.py b/tests/modules/lib/terminal.py index ab52b8de..72f7c047 100644 --- a/tests/modules/lib/terminal.py +++ b/tests/modules/lib/terminal.py @@ -245,7 +245,7 @@ def do_terminal_tests(tests, cmd, dim, args, env, suite, cwd=None, fin_cb=None, for i, test in enumerate(tests): with suite.test(test.get('name', 'test_{0}'.format(i)), - attempts) as ptest: + attempts - 1) as ptest: try: test_prep = test['prep_cb'] except KeyError: From 2a4f76e4fad3420cdbdfbe3f2fed2b9c6126c915 Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 5 Aug 2017 14:13:59 +0300 Subject: [PATCH 49/95] Also temporary allow pdp failures --- tests/test_shells/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index d70e8ac8..c6867342 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -453,7 +453,7 @@ if test -z "${ONLY_SHELL}" || test "${ONLY_SHELL}" = "pdb" ; then if ! run_test subclass python $PDB_PYTHON \ "$ROOT/tests/test_shells/pdb-main.py" then - fail "pdb-subclass:test" F \ + fail --allow-failure "pdb-subclass:test" F \ "Failed checking $PDB_PYTHON $ROOT/tests/test_shells/pdb-main.py" fi fi @@ -466,7 +466,7 @@ if test -z "${ONLY_SHELL}" || test "${ONLY_SHELL}" = "pdb" ; then if ! run_test module python "$PDB_PYTHON" -m"$MODULE" \ "$ROOT/tests/test_shells/pdb-script.py" then - fail "pdb-module:test" F \ + fail --allow-failure "pdb-module:test" F \ "Failed checking $PDB_PYTHON -m$MODULE $ROOT/tests/test_shells/pdb-script" fi fi From f0944f840e5e2d63eef4cd46c8d6a29f2a402bb1 Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 5 Aug 2017 17:13:49 +0300 Subject: [PATCH 50/95] Make python tests also print to summary --- tests/modules/__init__.py | 83 +++++++++++++++++++++++++++++++- tests/modules/lib/__init__.py | 63 ------------------------ tests/test_in_vterm/test_tmux.py | 2 +- tests/test_in_vterm/test_vim.py | 2 +- 4 files changed, 83 insertions(+), 67 deletions(-) diff --git a/tests/modules/__init__.py b/tests/modules/__init__.py index 9a961acd..4a7ac971 100644 --- a/tests/modules/__init__.py +++ b/tests/modules/__init__.py @@ -4,8 +4,87 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct import sys if sys.version_info < (2, 7): - from unittest2 import TestCase, main # NOQA + from unittest2 import TestCase as _TestCase # NOQA + from unittest2 import main as _main # NOQA from unittest2.case import SkipTest # NOQA else: - from unittest import TestCase, main # NOQA + from unittest import TestCase as _TestCase # NOQA + from unittest import main as _main # NOQA from unittest.case import SkipTest # NOQA + + +class PowerlineDummyTest(object): + def __enter__(self): + return self + + def __exit__(self, *args): + pass + + def fail(self, *args, **kwargs): + pass + + def exception(self, *args, **kwargs): + pass + + +class PowerlineTestSuite(object): + def __init__(self, name): + self.name = name + + def __enter__(self): + self.saved_current_suite = os.environ['POWERLINE_CURRENT_SUITE'] + os.environ['POWERLINE_CURRENT_SUITE'] = ( + self.saved_current_suite + '/' + self.name) + self.suite = self.saved_current_suite + '/' + self.name + return self + + def __exit__(self, exc_type, exc_value, traceback): + if exc_type is not None: + self.exception( + 'suite_noexcept', + 'Exception while running test suite: {0!r}'.format(exc_value), + ) + os.environ['POWERLINE_CURRENT_SUITE'] = self.saved_current_suite + + def record_test_failure(self, fail_char, test_name, message, allow_failure=False): + if allow_failure: + fail_char = 'A' + fail_char + full_msg = '{fail_char} {suite}|{test_name} :: {message}'.format( + fail_char=fail_char, + suite=self.suite, + test_name=test_name, + message=message, + ) + with open(os.environ['FAILURES_FILE'], 'a') as ffd: + ffd.write(full_msg + '\n') + return False + + def exception(self, test_name, message, allow_failure=False): + return self.record_test_failure('E', test_name, message, allow_failure) + + def fail(self, test_name, message, allow_failure=False): + return self.record_test_failure('F', test_name, message, allow_failure) + + def test(self, name, attempts_left=0): + if not attempts_left: + return PowerlineSingleTest(self, name) + else: + return PowerlineDummyTest() + + def subsuite(self, name): + return PowerlineTestSuite(name) + + +suite = None + + +def main(*args, **kwargs): + global suite + suite = PowerlineTestSuite(sys.argv[0]) + _main(*args, **kwargs) + + +class TestCase(_TestCase): + def fail(self, *args, **kwargs): + super(TestCase, self).fail(*args, **kwargs) + suite.fail(self.__class__.__name__, 'Failed test') diff --git a/tests/modules/lib/__init__.py b/tests/modules/lib/__init__.py index d7089acb..408b1773 100644 --- a/tests/modules/lib/__init__.py +++ b/tests/modules/lib/__init__.py @@ -182,66 +182,3 @@ class PowerlineSingleTest(object): def exception(self, message, allow_failure=False): return self.suite.exception(self.name, message, allow_failure) - - -class PowerlineDummyTest(object): - def __enter__(self): - return self - - def __exit__(self, *args): - pass - - def fail(self, *args, **kwargs): - pass - - def exception(self, *args, **kwargs): - pass - - -class PowerlineTestSuite(object): - def __init__(self, name): - self.name = name - - def __enter__(self): - self.saved_current_suite = os.environ['POWERLINE_CURRENT_SUITE'] - os.environ['POWERLINE_CURRENT_SUITE'] = ( - self.saved_current_suite + '/' + self.name) - self.suite = self.saved_current_suite + '/' + self.name - return self - - def __exit__(self, exc_type, exc_value, traceback): - if exc_type is not None: - self.exception( - 'suite_noexcept', - 'Exception while running test suite: {0!r}'.format(exc_value), - ) - os.environ['POWERLINE_CURRENT_SUITE'] = self.saved_current_suite - - def record_test_failure(self, fail_char, test_name, message, allow_failure=False): - if allow_failure: - fail_char = 'A' + fail_char - full_msg = '{fail_char} {suite}|{test_name} :: {message}'.format( - fail_char=fail_char, - suite=self.suite, - test_name=test_name, - message=message, - ) - print('Failed: ' + full_msg) - with open(os.environ['FAILURES_FILE'], 'a') as ffd: - ffd.write(full_msg + '\n') - return False - - def exception(self, test_name, message, allow_failure=False): - return self.record_test_failure('E', test_name, message, allow_failure) - - def fail(self, test_name, message, allow_failure=False): - return self.record_test_failure('F', test_name, message, allow_failure) - - def test(self, name, attempts_left=0): - if not attempts_left: - return PowerlineSingleTest(self, name) - else: - return PowerlineDummyTest() - - def subsuite(self, name): - return PowerlineTestSuite(name) diff --git a/tests/test_in_vterm/test_tmux.py b/tests/test_in_vterm/test_tmux.py index dfccc24e..c1e126bf 100755 --- a/tests/test_in_vterm/test_tmux.py +++ b/tests/test_in_vterm/test_tmux.py @@ -17,7 +17,7 @@ from powerline import get_fallback_logger from tests.modules.lib.terminal import (ExpectProcess, MutableDimensions, do_terminal_tests, get_env) -from tests.modules.lib import PowerlineTestSuite +from tests.modules import PowerlineTestSuite TEST_ROOT = os.path.abspath(os.environ['TEST_ROOT']) diff --git a/tests/test_in_vterm/test_vim.py b/tests/test_in_vterm/test_vim.py index 11da223b..0fbc3190 100755 --- a/tests/test_in_vterm/test_vim.py +++ b/tests/test_in_vterm/test_vim.py @@ -14,7 +14,7 @@ from powerline.lib.dict import updated from tests.modules.lib.terminal import (ExpectProcess, MutableDimensions, do_terminal_tests, get_env) -from tests.modules.lib import PowerlineTestSuite +from tests.modules import PowerlineTestSuite TEST_ROOT = os.path.abspath(os.environ['TEST_ROOT']) From 278785500805d5d28857ab7400fa116b2cf7ffb8 Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 5 Aug 2017 17:17:25 +0300 Subject: [PATCH 51/95] Disable travis hack Assuming it is outdated. --- tests/test_python/test_lib.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tests/test_python/test_lib.py b/tests/test_python/test_lib.py index 6260659c..e6c3afa6 100644 --- a/tests/test_python/test_lib.py +++ b/tests/test_python/test_lib.py @@ -497,15 +497,7 @@ class TestUnicode(TestCase): if sys.maxunicode < 0x10FFFF: raise SkipTest('Can only test strwidth_ucs_4 in UCS-4 Pythons') - def east_asian_width(ch): - assert (len(ch) == 1) - assert ord(ch) == 0x1F48E - return 'F' - - with replace_attr(plu, 'east_asian_width', east_asian_width): - # Warning: travis unicodedata.east_asian_width for some reason - # thinks this character is 5 symbols wide. - self.assertEqual(2, plu.strwidth_ucs_4(width_data, '\U0001F48E')) + self.assertEqual(2, plu.strwidth_ucs_4(width_data, '\U0001F48E')) def test_strwidth_ucs_2(self): self.assertEqual(4, plu.strwidth_ucs_2(width_data, 'abcd')) From f111a95b0d70cd739004b6327fc02dfda7bb562e Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 5 Aug 2017 17:21:32 +0300 Subject: [PATCH 52/95] Change width to 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit May make test fail on older Python’s --- tests/test_python/test_lib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_python/test_lib.py b/tests/test_python/test_lib.py index e6c3afa6..eb53be03 100644 --- a/tests/test_python/test_lib.py +++ b/tests/test_python/test_lib.py @@ -497,14 +497,14 @@ class TestUnicode(TestCase): if sys.maxunicode < 0x10FFFF: raise SkipTest('Can only test strwidth_ucs_4 in UCS-4 Pythons') - self.assertEqual(2, plu.strwidth_ucs_4(width_data, '\U0001F48E')) + self.assertEqual(1, plu.strwidth_ucs_4(width_data, '\U0001F48E')) def test_strwidth_ucs_2(self): self.assertEqual(4, plu.strwidth_ucs_2(width_data, 'abcd')) self.assertEqual(4, plu.strwidth_ucs_2(width_data, 'AB')) if not sys.maxunicode < 0x10FFFF: raise SkipTest('Can only test strwidth_ucs_2 in UCS-2 Pythons') - self.assertEqual(2, plu.strwidth_ucs_2(width_data, '\ud83d\udc8e')) + self.assertEqual(1, plu.strwidth_ucs_2(width_data, '\ud83d\udc8e')) class TestVCS(TestCase): From 0a1cf1780ff7eec32177fefc055866471fb71e38 Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 5 Aug 2017 18:02:38 +0300 Subject: [PATCH 53/95] Use better failure message --- tests/modules/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/modules/__init__.py b/tests/modules/__init__.py index 4a7ac971..a1e3a4fe 100644 --- a/tests/modules/__init__.py +++ b/tests/modules/__init__.py @@ -85,6 +85,7 @@ def main(*args, **kwargs): class TestCase(_TestCase): - def fail(self, *args, **kwargs): + def fail(self, msg=None): super(TestCase, self).fail(*args, **kwargs) - suite.fail(self.__class__.__name__, 'Failed test') + suite.fail(self.__class__.__name__, + msg or 'Test failed without message') From 55d9c320dccaae494e15a81814d4e79b6e486dbf Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 5 Aug 2017 18:04:58 +0300 Subject: [PATCH 54/95] Add missing import --- tests/modules/__init__.py | 1 + tests/modules/lib/__init__.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/modules/__init__.py b/tests/modules/__init__.py index a1e3a4fe..b0b3dc59 100644 --- a/tests/modules/__init__.py +++ b/tests/modules/__init__.py @@ -2,6 +2,7 @@ from __future__ import (unicode_literals, division, absolute_import, print_function) import sys +import os if sys.version_info < (2, 7): from unittest2 import TestCase as _TestCase # NOQA diff --git a/tests/modules/lib/__init__.py b/tests/modules/lib/__init__.py index 408b1773..d45ccae4 100644 --- a/tests/modules/lib/__init__.py +++ b/tests/modules/lib/__init__.py @@ -3,7 +3,6 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct import imp import sys -import os class Pl(object): From b047abcd9a50d82db82b4bf802a2de70507c25a4 Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 5 Aug 2017 18:06:07 +0300 Subject: [PATCH 55/95] First call suite.fail, then super().fail --- tests/modules/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/modules/__init__.py b/tests/modules/__init__.py index b0b3dc59..42a67171 100644 --- a/tests/modules/__init__.py +++ b/tests/modules/__init__.py @@ -87,6 +87,6 @@ def main(*args, **kwargs): class TestCase(_TestCase): def fail(self, msg=None): - super(TestCase, self).fail(*args, **kwargs) suite.fail(self.__class__.__name__, msg or 'Test failed without message') + super(TestCase, self).fail(*args, **kwargs) From 335be73d3e0e846aab2f1cfc9b1e7d61f51fdc35 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 6 Aug 2017 02:34:40 +0300 Subject: [PATCH 56/95] Check unidata_version to determine width Did not actually determine whether this check is correct. --- tests/test_python/test_lib.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test_python/test_lib.py b/tests/test_python/test_lib.py index eb53be03..f7b47858 100644 --- a/tests/test_python/test_lib.py +++ b/tests/test_python/test_lib.py @@ -6,6 +6,7 @@ import os import sys import re import shutil +import unicodedata from time import sleep from subprocess import call, PIPE @@ -429,6 +430,13 @@ width_data = { 'F': 2, # Fullwidth } +unidata_version = tuple(( + int(c) for c in unicodedata.unidata_version.split('.'))) + +U1F48E_WIDTH = ( + 1 if unidata_version >= (6,) else 2 +) + class TestUnicode(TestCase): def assertStringsIdentical(self, s1, s2): @@ -497,14 +505,14 @@ class TestUnicode(TestCase): if sys.maxunicode < 0x10FFFF: raise SkipTest('Can only test strwidth_ucs_4 in UCS-4 Pythons') - self.assertEqual(1, plu.strwidth_ucs_4(width_data, '\U0001F48E')) + self.assertEqual(U1F48E_WIDTH, plu.strwidth_ucs_4(width_data, '\U0001F48E')) def test_strwidth_ucs_2(self): self.assertEqual(4, plu.strwidth_ucs_2(width_data, 'abcd')) self.assertEqual(4, plu.strwidth_ucs_2(width_data, 'AB')) if not sys.maxunicode < 0x10FFFF: raise SkipTest('Can only test strwidth_ucs_2 in UCS-2 Pythons') - self.assertEqual(1, plu.strwidth_ucs_2(width_data, '\ud83d\udc8e')) + self.assertEqual(U1F48E_WIDTH, plu.strwidth_ucs_2(width_data, '\ud83d\udc8e')) class TestVCS(TestCase): From eb5834cf3e8cddfa77c4a8fd5d1ee5cc450bd8f9 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 6 Aug 2017 02:59:10 +0300 Subject: [PATCH 57/95] Move version I do not actually see this character in diff of EastAsianWidth.txt though, but it appears that test with 5.1.0 uses 2 and succeeds, tests with 6.0.0 and 8.0.0 use 1 and succeed, but test with 5.2.0 uses 2 and fails. --- tests/test_python/test_lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_python/test_lib.py b/tests/test_python/test_lib.py index f7b47858..bef5901c 100644 --- a/tests/test_python/test_lib.py +++ b/tests/test_python/test_lib.py @@ -434,7 +434,7 @@ unidata_version = tuple(( int(c) for c in unicodedata.unidata_version.split('.'))) U1F48E_WIDTH = ( - 1 if unidata_version >= (6,) else 2 + 1 if unidata_version >= (5, 2) else 2 ) From cbea5357a9c65dc71ebefd83dc02783916a738b8 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 17 Sep 2017 16:58:54 +0300 Subject: [PATCH 58/95] Use different character for strwidth tests --- tests/test_python/test_lib.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/test_python/test_lib.py b/tests/test_python/test_lib.py index bef5901c..6dd61902 100644 --- a/tests/test_python/test_lib.py +++ b/tests/test_python/test_lib.py @@ -430,13 +430,6 @@ width_data = { 'F': 2, # Fullwidth } -unidata_version = tuple(( - int(c) for c in unicodedata.unidata_version.split('.'))) - -U1F48E_WIDTH = ( - 1 if unidata_version >= (5, 2) else 2 -) - class TestUnicode(TestCase): def assertStringsIdentical(self, s1, s2): @@ -505,14 +498,14 @@ class TestUnicode(TestCase): if sys.maxunicode < 0x10FFFF: raise SkipTest('Can only test strwidth_ucs_4 in UCS-4 Pythons') - self.assertEqual(U1F48E_WIDTH, plu.strwidth_ucs_4(width_data, '\U0001F48E')) + self.assertEqual(1, plu.strwidth_ucs_4(width_data, '\U0001F063')) def test_strwidth_ucs_2(self): self.assertEqual(4, plu.strwidth_ucs_2(width_data, 'abcd')) self.assertEqual(4, plu.strwidth_ucs_2(width_data, 'AB')) if not sys.maxunicode < 0x10FFFF: raise SkipTest('Can only test strwidth_ucs_2 in UCS-2 Pythons') - self.assertEqual(U1F48E_WIDTH, plu.strwidth_ucs_2(width_data, '\ud83d\udc8e')) + self.assertEqual(1, plu.strwidth_ucs_2(width_data, '\ud83c\udc30')) class TestVCS(TestCase): From 29d0a3c171e27f3af8ee2b4c36dc49b232d38ba4 Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 21 Oct 2017 20:38:31 +0300 Subject: [PATCH 59/95] =?UTF-8?q?Remove=20=E2=80=9Coutput=20is=20not=20to?= =?UTF-8?q?=20a=20terminal=E2=80=9D=20from=20Vim=20output?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_in_vterm/test_vim.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_in_vterm/test_vim.sh b/tests/test_in_vterm/test_vim.sh index 064c35a6..57c195ed 100755 --- a/tests/test_in_vterm/test_vim.sh +++ b/tests/test_in_vterm/test_vim.sh @@ -18,7 +18,7 @@ test_vim() { ln -sf "$(which "${POWERLINE_VIM_EXE}")" "$TEST_ROOT/path/vim" f="$ROOT/tests/test_in_vterm/test_vim.py" if ! "${PYTHON}" "$f" ; then - local test_name="$(LANG=C "$POWERLINE_VIM_EXE" --cmd 'echo version' --cmd qa 2>&1)" + local test_name="$(LANG=C "$POWERLINE_VIM_EXE" --cmd 'echo version' --cmd qa 2>&1 | tail -n2)" fail "$test_name" F "Failed vterm test $f" fi } From 44e0a30b802642637c8944de1bd6681f3d13bc17 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 22 Oct 2017 19:17:48 +0300 Subject: [PATCH 60/95] Ignore some files generated by tests --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index dbae1ed8..893e30dd 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ build message.fail client/powerline + +/tests/tmp +/tests/failures From 96f9c62d86780ffe0970ed6e23ce2f5b22137d31 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 22 Oct 2017 19:38:32 +0300 Subject: [PATCH 61/95] Start creating shell vterm tests Should replace #1448. --- tests/modules/__init__.py | 2 + tests/modules/lib/terminal.py | 13 ++- tests/test_in_vterm/shell/inits/dash | 12 +++ tests/test_in_vterm/test_shell.py | 114 +++++++++++++++++++++++++++ tests/test_in_vterm/test_shells.sh | 99 +++++++++++++++++++++++ 5 files changed, 236 insertions(+), 4 deletions(-) create mode 100644 tests/test_in_vterm/shell/inits/dash create mode 100755 tests/test_in_vterm/test_shell.py create mode 100755 tests/test_in_vterm/test_shells.sh diff --git a/tests/modules/__init__.py b/tests/modules/__init__.py index 42a67171..12aae20d 100644 --- a/tests/modules/__init__.py +++ b/tests/modules/__init__.py @@ -13,6 +13,8 @@ else: from unittest import main as _main # NOQA from unittest.case import SkipTest # NOQA +from tests.modules.lib import PowerlineSingleTest + class PowerlineDummyTest(object): def __enter__(self): diff --git a/tests/modules/lib/terminal.py b/tests/modules/lib/terminal.py index 72f7c047..7f4bee58 100644 --- a/tests/modules/lib/terminal.py +++ b/tests/modules/lib/terminal.py @@ -221,7 +221,11 @@ def get_env(vterm_path, test_dir, *args, **kwargs): def do_terminal_tests(tests, cmd, dim, args, env, suite, cwd=None, fin_cb=None, - last_attempt_cb=None, attempts=3): + last_attempt_cb=None, attempts=None): + debugging_tests = not not os.environ.get('_POWERLINE_DEBUGGING_TESTS') + default_attempts = 1 if debugging_tests else 3 + if attempts is None: + attempts = default_attempts lib = os.environ.get('POWERLINE_LIBVTERM') if not lib: if os.path.exists('tests/bot-ci/deps/libvterm/libvterm.so'): @@ -252,9 +256,10 @@ def do_terminal_tests(tests, cmd, dim, args, env, suite, cwd=None, fin_cb=None, pass else: test_prep(p) - test_result = test_expected_result(p, test, attempts == 0, - last_attempt_cb, - test.get('attempts', 3)) + test_result = test_expected_result( + p, test, attempts == 0, last_attempt_cb, + test.get('attempts', default_attempts) + ) if not test_result: ptest.fail('Result does not match expected') ret = ret and test_result diff --git a/tests/test_in_vterm/shell/inits/dash b/tests/test_in_vterm/shell/inits/dash new file mode 100644 index 00000000..2bf62e6c --- /dev/null +++ b/tests/test_in_vterm/shell/inits/dash @@ -0,0 +1,12 @@ +# vim: ft=sh + +set_theme_option() { + export POWERLINE_THEME_OVERRIDES="${POWERLINE_THEME_OVERRIDES};$1=$2" +} +set_theme() { + export POWERLINE_CONFIG_OVERRIDES="ext.shell.theme=$1" +} +set_theme_option default_leftonly.segment_data.hostname.args.only_if_ssh false +set_theme default_leftonly +. "$ROOT/powerline/bindings/shell/powerline.sh" +export VIRTUAL_ENV= diff --git a/tests/test_in_vterm/test_shell.py b/tests/test_in_vterm/test_shell.py new file mode 100755 index 00000000..4da7bafb --- /dev/null +++ b/tests/test_in_vterm/test_shell.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python +# vim:fileencoding=utf-8:noet +from __future__ import (unicode_literals, division, absolute_import, print_function) + +import os +import sys + +from time import sleep +from subprocess import check_call +from glob import glob1 +from traceback import print_exc + +from argparse import ArgumentParser + +from powerline.lib.dict import updated + +from tests.modules.lib.terminal import (ExpectProcess, MutableDimensions, + do_terminal_tests, get_env) +from tests.modules import PowerlineTestSuite + + +TEST_ROOT = os.path.abspath(os.environ['TEST_ROOT']) + + +def get_parser(): + parser = ArgumentParser() + parser.add_argument('--type', action='store') + parser.add_argument('--client', action='store') + parser.add_argument('--binding', action='store') + parser.add_argument('args', action='append') + return parser + + +BINDING_OPTIONS = { + 'dash': { + 'cmd': 'dash', + 'args': ['-i'], + 'init': [ + '. "$ROOT/tests/test_in_vterm/shell/inits/dash"', + ], + }, +} + + +def main(argv): + script_args = get_parser().parse_args(argv) + + vterm_path = os.path.join(TEST_ROOT, 'path') + + env = get_env(vterm_path, TEST_ROOT) + env['ROOT'] = os.path.abspath('.') + env['TEST_ROOT'] = TEST_ROOT + env['TEST_TYPE'] = script_args.type + env['TEST_CLIENT'] = script_args.client + env['LANG'] = 'en_US.UTF_8' + + dim = MutableDimensions(rows=50, cols=200) + + binding_opts = BINDING_OPTIONS[script_args.binding] + + cmd = os.path.join(vterm_path, binding_opts['cmd']) + args = binding_opts['args'] + + def gen_init(binding): + def init(p): + for line in binding_opts['init']: + p.send(line + '\n') + while not p[dim.rows - 1, 0].text: + p.send('\n') + sleep(0.01) + + return init + + base_attrs = { + ((255, 204,0), (204, 51, 0), 0, 0, 0): 'N', + ((204, 51, 0), (0, 102, 153), 0, 0, 0): 'H', + ((255, 255, 255), (0, 102, 153), 1, 0, 0): 'sHU', + ((0, 102, 153), (44, 44, 44), 0, 0, 0): 'U', + ((199, 199, 199), (44, 44, 44), 0, 0, 0): 'sUB', + ((44, 44, 44), (88, 88, 88), 0, 0, 0): 'B', + ((199, 199, 199), (88, 88, 88), 0, 0, 0): 'sBD', + ((144, 144, 144), (88, 88, 88), 0, 0, 0): 'D', + ((221, 221, 221), (88, 88, 88), 1, 0, 0): 'sD', + ((88, 88, 88), (0, 0, 0), 0, 0, 0): 'C', + ((240, 240, 240), (0, 0, 0), 0, 0, 0): 'sCp', + } + + tests = ( + { + 'expected_result': ( + '', base_attrs + ), + 'prep_cb': gen_init(script_args.binding), + 'row': dim.rows - 1, + }, + ) + + with PowerlineTestSuite('shell') as suite: + return do_terminal_tests( + tests=tests, + cmd=cmd, + dim=dim, + args=args, + env=env, + cwd=TEST_ROOT, + suite=suite, + ) + + +if __name__ == '__main__': + if main(sys.argv[1:]): + raise SystemExit(0) + else: + raise SystemExit(1) diff --git a/tests/test_in_vterm/test_shells.sh b/tests/test_in_vterm/test_shells.sh new file mode 100755 index 00000000..25a49200 --- /dev/null +++ b/tests/test_in_vterm/test_shells.sh @@ -0,0 +1,99 @@ +#!/bin/sh +. tests/shlib/common.sh +. tests/shlib/vterm.sh + +enter_suite vshells + +vterm_setup + +HAS_SOCAT= +HAS_C_CLIENT= + +ln -s "$(which env)" "$TEST_ROOT/path" +ln -s "$(which git)" "$TEST_ROOT/path" +ln -s "$(which sleep)" "$TEST_ROOT/path" +ln -s "$(which cat)" "$TEST_ROOT/path" +ln -s "$(which false)" "$TEST_ROOT/path" +ln -s "$(which true)" "$TEST_ROOT/path" +ln -s "$(which kill)" "$TEST_ROOT/path" +ln -s "$(which echo)" "$TEST_ROOT/path" +ln -s "$(which which)" "$TEST_ROOT/path" +ln -s "$(which dirname)" "$TEST_ROOT/path" +ln -s "$(which wc)" "$TEST_ROOT/path" +ln -s "$(which stty)" "$TEST_ROOT/path" +ln -s "$(which cut)" "$TEST_ROOT/path" +ln -s "$(which bc)" "$TEST_ROOT/path" +ln -s "$(which expr)" "$TEST_ROOT/path" +ln -s "$(which mktemp)" "$TEST_ROOT/path" +ln -s "$(which grep)" "$TEST_ROOT/path" +ln -s "$(which sed)" "$TEST_ROOT/path" +ln -s "$(which rm)" "$TEST_ROOT/path" +ln -s "$(which tr)" "$TEST_ROOT/path" +ln -s "$(which uname)" "$TEST_ROOT/path" +ln -s "$(which test)" "$TEST_ROOT/path" +ln -s "$(which pwd)" "$TEST_ROOT/path" +ln -s "$(which hostname)" "$TEST_ROOT/path" +ln -s "$ROOT/tests/test_shells/bgscript.sh" "$TEST_ROOT/path" +ln -s "$ROOT/tests/test_shells/waitpid.sh" "$TEST_ROOT/path" + +ln -s "$ROOT/scripts/powerline-config" "$TEST_ROOT/path" +ln -s "$ROOT/scripts/powerline-render" "$TEST_ROOT/path" +ln -s "$ROOT/client/powerline.py" "$TEST_ROOT/path" + +if test -e "$ROOT/scripts/powerline" ; then + ln -s "$ROOT/scripts/powerline" "$TEST_ROOT/path" +elif test -e client/powerline ; then + ln -s "$ROOT/client/powerline" "$TEST_ROOT/path" +else + echo "Executable powerline was not found" + exit 1 +fi + +if test "$( + file --mime-type --brief --dereference "$TEST_ROOT/path/powerline" \ + | cut -d/ -f1)" = "application" ; then + HAS_C_CLIENT=1 +fi + +if which socat ; then + HAS_SOCAT=1 + ln -s "$(which socat)" "$TEST_ROOT/path" + ln -s "$ROOT/client/powerline.sh" "$TEST_ROOT/path" +fi + +# Test type: daemon, renderer, … +# Test client: python, shell, c, none +# Test binding: *sh, ipython, pdb, … +test_shell() { + local test_type="$1" ; shift + local test_client="$1" ; shift + local test_binding="$1" ; shift + + if test "$test_client" = shell && test -z "$HAS_SOCAT" ; then + echo "Skipping test, socat not available" + return + fi + if test "$test_client" = c && test -z "$HAS_C_CLIENT" ; then + echo "Skipping test, C client not available" + return + fi + if which "$test_binding" ; then + ln -s "$(which "$test_binding")" "$TEST_ROOT/path" + fi + + if ! "${PYTHON}" "$ROOT/tests/test_in_vterm/test_shell.py" \ + --type=$test_type \ + --client=$test_client \ + --binding=$test_binding \ + -- "$@" + then + local test_name="$test_type-$test_client-$test_binding" + fail "$test_name" F "Failed vterm shell test" + fi +} + +test_shell renderer python dash -i || true + +vterm_shutdown + +exit_suite From 3fca2f8d024b9588b208e4b687a8ae471e4d48ab Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 12 Sep 2015 20:55:27 +0300 Subject: [PATCH 62/95] Add skip command, rename tests/failures to tests/status --- .gitignore | 4 ++-- tests/shlib/common.sh | 11 +++++++++-- tests/test.sh | 8 ++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 893e30dd..6491a772 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ build message.fail -client/powerline +/client/powerline /tests/tmp -/tests/failures +/tests/status diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh index ed4504a9..1faa3333 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -13,7 +13,7 @@ if test -z "$FAILED" ; then FAIL_SUMMARY="" TMP_ROOT="$ROOT/tests/tmp" - export FAILURES_FILE="$ROOT/tests/failures" + export FAILURES_FILE="$ROOT/tests/status" fi ANSI_CLEAR="\033[0K" @@ -56,15 +56,22 @@ fail() { local test_name="$1" ; shift local fail_char="$allow_failure$1" ; shift local message="$1" ; shift + local verb="${1:-Failed}" ; shift local full_msg="$fail_char $POWERLINE_CURRENT_SUITE|$test_name :: $message" FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}" - echo "Failed: $full_msg" + echo "$verb: $full_msg" echo "$full_msg" >> "$FAILURES_FILE" if test -z "$allow_failure" ; then FAILED=1 fi } +skip() { + local test_name="$1" ; shift + local message="$1" ; shift + fail --allow-failure "$test_name" S "$message" "Skipped" +} + make_test_root() { local suffix="${POWERLINE_CURRENT_SUITE##*/}" diff --git a/tests/test.sh b/tests/test.sh index 1c6f9881..1beb5c6f 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -33,10 +33,10 @@ for script in "$ROOT"/tests/test_*/test.sh ; do fi done -if test -e tests/failures ; then - echo "Some tests failed. Summary:" - cat tests/failures - rm tests/failures +if test -e "$FAILURES_FILE" ; then + echo "Fails and skips summary:" + cat "$FAILURES_FILE" + rm "$FAILURES_FILE" fi exit_suite From 6bbcb610c75ce9a54bffdf08a6b66c696b4697ec Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 13 Sep 2015 17:12:21 +0300 Subject: [PATCH 63/95] Make vterm UTF-8 --- tests/modules/lib/vterm.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/modules/lib/vterm.py b/tests/modules/lib/vterm.py index 4c0ec568..1984e1b9 100644 --- a/tests/modules/lib/vterm.py +++ b/tests/modules/lib/vterm.py @@ -116,6 +116,7 @@ def get_functions(lib): ('cell', ctypes.POINTER(VTermScreenCell_s)) )), vterm_free=(None, (('vt', VTerm_p),)), + vterm_set_utf8=(None, (('vt', VTerm_p), ('is_utf8', ctypes.c_int))), ) @@ -173,6 +174,7 @@ class VTerm(object): def __init__(self, lib, dim): self.functions = get_functions(lib) self.vt = self.functions.vterm_new(dim.rows, dim.cols) + self.functions.vterm_set_utf8(self.vt, 1) self.vtscreen = VTermScreen(self.functions, self.functions.vterm_obtain_screen(self.vt)) self.vtscreen.reset(True) From 870de7be2188acc60e2453ce2894a2e5555e8ecb Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 22 Oct 2017 21:04:59 +0300 Subject: [PATCH 64/95] Improve terminal.py: 1. Make it print true color escape sequences when debugging. 2. Add support for automatic row detection. --- tests/modules/lib/terminal.py | 62 +++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/tests/modules/lib/terminal.py b/tests/modules/lib/terminal.py index 7f4bee58..7d2c7667 100644 --- a/tests/modules/lib/terminal.py +++ b/tests/modules/lib/terminal.py @@ -111,21 +111,33 @@ class ExpectProcess(threading.Thread): with self.child_lock: self.child.send(data) - def get_highlighted_text(self, text, attrs, default_props=()): + def get_highlighted_text(self, text, attrs, default_props=(), + use_escapes=False): ret = [] new_attrs = attrs.copy() for cell_properties, segment_text in text: - segment_text = segment_text.translate({'{': '{{', '}': '}}'}) - if cell_properties not in new_attrs: - new_attrs[cell_properties] = len(new_attrs) + 1 - props_name = new_attrs[cell_properties] - if props_name in default_props: - ret.append(segment_text) + if use_escapes: + escapes = ('\033[38;2;{0};{1};{2};48;2;{3};{4};{5}'.format( + *(cell_properties[0] + cell_properties[1]))) + ( + ';1' if cell_properties[2] else '' + ) + ( + ';3' if cell_properties[3] else '' + ) + ( + ';4' if cell_properties[4] else '' + ) + 'm' + ret.append(escapes + segment_text + '\033[0m') else: - ret.append('{' + str(props_name) + ':' + segment_text + '}') + segment_text = segment_text.translate({'{': '{{', '}': '}}'}) + if cell_properties not in new_attrs: + new_attrs[cell_properties] = len(new_attrs) + 1 + props_name = new_attrs[cell_properties] + if props_name in default_props: + ret.append(segment_text) + else: + ret.append('{' + str(props_name) + ':' + segment_text + '}') return ''.join(ret), new_attrs - def get_row(self, row, attrs, default_props=()): + def get_row(self, row, attrs, default_props=(), use_escapes=False): with self.lock: return self.get_highlighted_text(( (key, ''.join((cell.text for cell in subline))) @@ -133,34 +145,48 @@ class ExpectProcess(threading.Thread): self.vterm.vtscreen[row, col] for col in range(self.dim.cols) ), lambda cell: cell.cell_properties_key) - ), attrs, default_props) + ), attrs, default_props, use_escapes) - def get_screen(self, attrs, default_props=()): + def get_screen(self, attrs, default_props=(), use_escapes=False): lines = [] for row in range(self.dim.rows): - line, attrs = self.get_row(row, attrs, default_props) + line, attrs = self.get_row(row, attrs, default_props, use_escapes) lines.append(line) return '\n'.join(lines), attrs def test_expected_result(p, test, last_attempt, last_attempt_cb, attempts): + debugging_tests = not not os.environ.get('_POWERLINE_DEBUGGING_TESTS') expected_text, attrs = test['expected_result'] result = None while attempts: - actual_text, all_attrs = p.get_row(test['row'], attrs) + if 'row' in test: + row = test['row'] + else: + row = p.dim.rows - 1 + while row >= 0 and not p[row, 0].text: + row -= 1 + if row < 0: + row = 0 + actual_text, all_attrs = p.get_row(row, attrs) if actual_text == expected_text: return True attempts -= 1 - print('Actual result does not match expected. Attempts left: {0}.'.format(attempts)) + print('Actual result does not match expected for row {0}. Attempts left: {1}.'.format( + row, attempts)) sleep(2) - print('Result:') + print('Result (row {0}):'.format(row)) print(actual_text) print('Expected:') print(expected_text) print('Attributes:') - print(all_attrs) + for v, k in sorted( + ((v, k) for k, v in all_attrs.items()), + key=(lambda t: '%02u'.format(t[0]) if isinstance(t[0], int) else t[0]), + ): + print('{k!r}: {v!r},'.format(v=v, k=k)) print('Screen:') - screen, screen_attrs = p.get_screen(attrs) + screen, screen_attrs = p.get_screen(attrs, use_escapes=debugging_tests) print(screen) print(screen_attrs) print('_' * 80) @@ -223,7 +249,7 @@ def get_env(vterm_path, test_dir, *args, **kwargs): def do_terminal_tests(tests, cmd, dim, args, env, suite, cwd=None, fin_cb=None, last_attempt_cb=None, attempts=None): debugging_tests = not not os.environ.get('_POWERLINE_DEBUGGING_TESTS') - default_attempts = 1 if debugging_tests else 3 + default_attempts = 2 if debugging_tests else 3 if attempts is None: attempts = default_attempts lib = os.environ.get('POWERLINE_LIBVTERM') From eb17b5374b936443e6f59709edd511e909116256 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 22 Oct 2017 21:05:20 +0300 Subject: [PATCH 65/95] Add some working dash tests --- powerline/segments/common/env.py | 8 ++- powerline/segments/common/net.py | 5 ++ tests/test_in_vterm/shell/inits/dash | 4 ++ tests/test_in_vterm/test_shell.py | 80 ++++++++++++++++++++++------ tests/test_in_vterm/test_shells.sh | 18 +++++++ 5 files changed, 98 insertions(+), 17 deletions(-) diff --git a/powerline/segments/common/env.py b/powerline/segments/common/env.py index e4a2428b..61f516e2 100644 --- a/powerline/segments/common/env.py +++ b/powerline/segments/common/env.py @@ -159,7 +159,8 @@ username = False _geteuid = getattr(os, 'geteuid', lambda: 1) -def user(pl, hide_user=None, hide_domain=False): +@requires_segment_info +def user(pl, segment_info, hide_user=None, hide_domain=False): '''Return the current user. :param str hide_user: @@ -172,6 +173,11 @@ def user(pl, hide_user=None, hide_domain=False): Highlight groups used: ``superuser`` or ``user``. It is recommended to define all highlight groups. ''' global username + if ( + segment_info['environ'].get('_POWERLINE_RUNNING_SHELL_TESTS') + == 'ee5bcdc6-b749-11e7-9456-50465d597777' + ): + return 'user' if username is False: username = _get_user() if username is None: diff --git a/powerline/segments/common/net.py b/powerline/segments/common/net.py index 47c2ce71..b5d9062d 100644 --- a/powerline/segments/common/net.py +++ b/powerline/segments/common/net.py @@ -22,6 +22,11 @@ def hostname(pl, segment_info, only_if_ssh=False, exclude_domain=False): :param bool exclude_domain: return the hostname without domain if there is one ''' + if ( + segment_info['environ'].get('_POWERLINE_RUNNING_SHELL_TESTS') + == 'ee5bcdc6-b749-11e7-9456-50465d597777' + ): + return 'hostname' if only_if_ssh and not segment_info['environ'].get('SSH_CLIENT'): return None if exclude_domain: diff --git a/tests/test_in_vterm/shell/inits/dash b/tests/test_in_vterm/shell/inits/dash index 2bf62e6c..7b146ff4 100644 --- a/tests/test_in_vterm/shell/inits/dash +++ b/tests/test_in_vterm/shell/inits/dash @@ -6,7 +6,11 @@ set_theme_option() { set_theme() { export POWERLINE_CONFIG_OVERRIDES="ext.shell.theme=$1" } +set_virtual_env() { + export VIRTUAL_ENV="$HOME/.virtenvs/$1" +} set_theme_option default_leftonly.segment_data.hostname.args.only_if_ssh false set_theme default_leftonly . "$ROOT/powerline/bindings/shell/powerline.sh" export VIRTUAL_ENV= +cd "$TEST_ROOT/3rd" diff --git a/tests/test_in_vterm/test_shell.py b/tests/test_in_vterm/test_shell.py index 4da7bafb..faf79767 100755 --- a/tests/test_in_vterm/test_shell.py +++ b/tests/test_in_vterm/test_shell.py @@ -53,6 +53,8 @@ def main(argv): env['TEST_TYPE'] = script_args.type env['TEST_CLIENT'] = script_args.client env['LANG'] = 'en_US.UTF_8' + env['_POWERLINE_RUNNING_SHELL_TESTS'] = ( + 'ee5bcdc6-b749-11e7-9456-50465d597777') dim = MutableDimensions(rows=50, cols=200) @@ -65,33 +67,79 @@ def main(argv): def init(p): for line in binding_opts['init']: p.send(line + '\n') - while not p[dim.rows - 1, 0].text: - p.send('\n') - sleep(0.01) + sleep(1) return init + def gen_feed(line): + def feed(p): + p.send(line + '\n') + sleep(0.1) + + return feed + base_attrs = { - ((255, 204,0), (204, 51, 0), 0, 0, 0): 'N', - ((204, 51, 0), (0, 102, 153), 0, 0, 0): 'H', - ((255, 255, 255), (0, 102, 153), 1, 0, 0): 'sHU', - ((0, 102, 153), (44, 44, 44), 0, 0, 0): 'U', - ((199, 199, 199), (44, 44, 44), 0, 0, 0): 'sUB', - ((44, 44, 44), (88, 88, 88), 0, 0, 0): 'B', - ((199, 199, 199), (88, 88, 88), 0, 0, 0): 'sBD', - ((144, 144, 144), (88, 88, 88), 0, 0, 0): 'D', - ((221, 221, 221), (88, 88, 88), 1, 0, 0): 'sD', - ((88, 88, 88), (0, 0, 0), 0, 0, 0): 'C', - ((240, 240, 240), (0, 0, 0), 0, 0, 0): 'sCp', + ((255, 204,0), (204, 51, 0), 0, 0, 0): 'H', + ((204, 51, 0), (0, 102, 153), 0, 0, 0): 'sHU', + ((255, 255, 255), (0, 102, 153), 1, 0, 0): 'U', + ((0, 102, 153), (44, 44, 44), 0, 0, 0): 'sUB', + ((199, 199, 199), (44, 44, 44), 0, 0, 0): 'B', + ((44, 44, 44), (88, 88, 88), 0, 0, 0): 'sBD', + ((199, 199, 199), (88, 88, 88), 0, 0, 0): 'D', + ((144, 144, 144), (88, 88, 88), 0, 0, 0): 'sD', + ((221, 221, 221), (88, 88, 88), 1, 0, 0): 'C', + ((88, 88, 88), (0, 0, 0), 0, 0, 0): 'sDN', + ((240, 240, 240), (0, 0, 0), 0, 0, 0): 'N', + ((0, 102, 153), (51, 153, 204), 0, 0, 0): 'sUE', + ((255, 255, 255), (51, 153, 204), 0, 0, 0): 'E', + ((51, 153, 204), (44, 44, 44), 0, 0, 0): 'sEB', } tests = ( { 'expected_result': ( - '', base_attrs + '{H:  hostname }{sHU: }' + '{U:user }{sUB: }' + '{B: BRANCH }{sBD: }' + '{D:… }{sD: }{D:tmp }{sD: }{D:vshells }{sD: }{C:3rd }{sDN: }' + '{N:}', + base_attrs, ), 'prep_cb': gen_init(script_args.binding), - 'row': dim.rows - 1, + }, + { + 'expected_result': ( + '{H:  hostname }{sHU: }' + '{U:user }{sUB: }' + '{B: BRANCH }{sBD: }' + '{D:… }{sD: }{D:vshells }{sD: }{D:3rd }{sD: }{C:.git }{sDN: }' + '{N:}', + base_attrs + ), + 'prep_cb': gen_feed('cd .git'), + }, + { + 'expected_result': ( + '{H:  hostname }{sHU: }' + '{U:user }{sUB: }' + '{B: BRANCH }{sBD: }' + '{D:… }{sD: }{D:tmp }{sD: }{D:vshells }{sD: }{C:3rd }{sDN: }' + '{N:}', + base_attrs, + ), + 'prep_cb': gen_feed('cd ..'), + }, + { + 'expected_result': ( + '{H:  hostname }{sHU: }' + '{U:user }{sUE: }' + '{E:(e) some-venv }{sEB: }' + '{B: BRANCH }{sBD: }' + '{D:… }{sD: }{D:tmp }{sD: }{D:vshells }{sD: }{C:3rd }{sDN: }' + '{N:}', + base_attrs, + ), + 'prep_cb': gen_feed('set_virtual_env some-venv'), }, ) diff --git a/tests/test_in_vterm/test_shells.sh b/tests/test_in_vterm/test_shells.sh index 25a49200..9643c439 100755 --- a/tests/test_in_vterm/test_shells.sh +++ b/tests/test_in_vterm/test_shells.sh @@ -9,6 +9,24 @@ vterm_setup HAS_SOCAT= HAS_C_CLIENT= +git init "$TEST_ROOT/3rd" +git --git-dir="$TEST_ROOT/3rd/.git" checkout -b BRANCH +export DIR1="" +export DIR2="" +mkdir "$TEST_ROOT/3rd/$DIR1" +mkdir "$TEST_ROOT/3rd/$DIR2" +mkdir "$TEST_ROOT"/3rd/'\[\]' +mkdir "$TEST_ROOT"/3rd/'%%' +mkdir "$TEST_ROOT"/3rd/'#[bold]' +mkdir "$TEST_ROOT"/3rd/'(echo)' +mkdir "$TEST_ROOT"/3rd/'$(echo)' +mkdir "$TEST_ROOT"/3rd/'`echo`' +mkdir "$TEST_ROOT"/3rd/'«Unicode!»' +mkdir "$TEST_ROOT/fish_home" +mkdir "$TEST_ROOT/fish_home/fish" +mkdir "$TEST_ROOT/fish_home/fish/generated_completions" +cp -r "$ROOT/tests/test_shells/ipython_home" "$TEST_ROOT" + ln -s "$(which env)" "$TEST_ROOT/path" ln -s "$(which git)" "$TEST_ROOT/path" ln -s "$(which sleep)" "$TEST_ROOT/path" From 436b4b680a362bcad7fdb5ebaa14dd20c0feb4ae Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 2 Dec 2017 17:04:15 +0300 Subject: [PATCH 66/95] Rename test_shell.py to test_shells.py --- tests/test_in_vterm/{test_shell.py => test_shells.py} | 0 tests/test_in_vterm/test_shells.sh | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/test_in_vterm/{test_shell.py => test_shells.py} (100%) diff --git a/tests/test_in_vterm/test_shell.py b/tests/test_in_vterm/test_shells.py similarity index 100% rename from tests/test_in_vterm/test_shell.py rename to tests/test_in_vterm/test_shells.py diff --git a/tests/test_in_vterm/test_shells.sh b/tests/test_in_vterm/test_shells.sh index 9643c439..c563dcad 100755 --- a/tests/test_in_vterm/test_shells.sh +++ b/tests/test_in_vterm/test_shells.sh @@ -99,7 +99,7 @@ test_shell() { ln -s "$(which "$test_binding")" "$TEST_ROOT/path" fi - if ! "${PYTHON}" "$ROOT/tests/test_in_vterm/test_shell.py" \ + if ! "${PYTHON}" "$ROOT/tests/test_in_vterm/test_shells.py" \ --type=$test_type \ --client=$test_client \ --binding=$test_binding \ From d18b58821b612daefb7a42b02deedef1b3486b5d Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 2 Dec 2017 17:14:56 +0300 Subject: [PATCH 67/95] Separate PyPy tests from old python tests in a different stage --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e50bb81e..41bfb783 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,10 +20,11 @@ install: tests/install.sh script: tests/test.sh jobs: include: - - stage: Old Python and PyPy + - stage: Old Python python: "2.6" - python: "3.2" - - python: "pypy" + - stage: PyPy + python: "pypy" - python: "pypy3" - stage: Latest Python python: "2.7" From 0c594b0b3473f7bb651f952c71ab932f714259df Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 2 Dec 2017 17:20:16 +0300 Subject: [PATCH 68/95] Use verboser installation, check for installed powerline --- tests/install.sh | 4 ++-- tests/test_in_vterm/test_shells.sh | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/install.sh b/tests/install.sh index 7ecf3b88..6925a341 100755 --- a/tests/install.sh +++ b/tests/install.sh @@ -46,13 +46,13 @@ if test -n "$USE_UCS2_PYTHON" ; then mkvirtualenv -p "$PYTHON" cpython-ucs2-$UCS2_PYTHON_VARIANT set -e . tests/bot-ci/scripts/common/main.sh - pip install . + pip install --verbose --verbose --verbose . if test "$UCS2_PYTHON_VARIANT" = "2.6" ; then rm tests/bot-ci/deps/wheels/ucs2-CPython-${UCS2_PYTHON_VARIANT}*/pyuv*.whl fi pip install --no-deps tests/bot-ci/deps/wheels/ucs2-CPython-${UCS2_PYTHON_VARIANT}*/*.whl else - pip install . + pip install --verbose --verbose --verbose . # FIXME Uv watcher sometimes misses events and INotify is not available in # Python-2.6, thus pyuv should be removed in order for VCS tests to # pass. diff --git a/tests/test_in_vterm/test_shells.sh b/tests/test_in_vterm/test_shells.sh index c563dcad..b08b4e9e 100755 --- a/tests/test_in_vterm/test_shells.sh +++ b/tests/test_in_vterm/test_shells.sh @@ -62,6 +62,8 @@ if test -e "$ROOT/scripts/powerline" ; then ln -s "$ROOT/scripts/powerline" "$TEST_ROOT/path" elif test -e client/powerline ; then ln -s "$ROOT/client/powerline" "$TEST_ROOT/path" +elif which powerline ; then + ln -s "$(which powerline)" "$TEST_ROOT/path" else echo "Executable powerline was not found" exit 1 From 1b0df9c2bd488bde74f73e585f1fee3db6275938 Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 2 Dec 2017 17:32:42 +0300 Subject: [PATCH 69/95] Wait for thread to start --- tests/modules/lib/terminal.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/modules/lib/terminal.py b/tests/modules/lib/terminal.py index 7d2c7667..540135dc 100644 --- a/tests/modules/lib/terminal.py +++ b/tests/modules/lib/terminal.py @@ -61,6 +61,7 @@ class ExpectProcess(threading.Thread): self.buffer = [] self.child_lock = threading.Lock() self.shutdown_event = threading.Event() + self.started_event = threading.Event() def run(self): with self.child_lock: @@ -70,6 +71,7 @@ class ExpectProcess(threading.Thread): child.setwinsize(self.dim.rows, self.dim.cols) sleep(0.5) self.child = child + self.started_event.set() status = None while status is None and not self.shutdown_event.is_set(): try: @@ -270,6 +272,7 @@ def do_terminal_tests(tests, cmd, dim, args, env, suite, cwd=None, fin_cb=None, env=env, ) p.start() + p.started_event.wait() ret = True From b558d200fe60c3351b70f7280ece8e8569381f6f Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 2 Dec 2017 18:24:01 +0300 Subject: [PATCH 70/95] Only shift if verb was supplied --- tests/shlib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh index 1faa3333..5edf86b8 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -56,7 +56,7 @@ fail() { local test_name="$1" ; shift local fail_char="$allow_failure$1" ; shift local message="$1" ; shift - local verb="${1:-Failed}" ; shift + local verb="${1:-Failed}" ; test $# -ge 1 && shift local full_msg="$fail_char $POWERLINE_CURRENT_SUITE|$test_name :: $message" FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}" echo "$verb: $full_msg" From 2a01c4687e1200a443189880083e675c4be2cad3 Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 2 Dec 2017 18:30:24 +0300 Subject: [PATCH 71/95] Supply segment_info to powerline.segments.env.user() segment in tests --- tests/test_python/test_segments.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/test_python/test_segments.py b/tests/test_python/test_segments.py index 7b576d01..3f094703 100644 --- a/tests/test_python/test_segments.py +++ b/tests/test_python/test_segments.py @@ -527,6 +527,11 @@ class TestEnv(TestCommon): if hasattr(self.module, 'psutil') and not callable(self.module.psutil.Process.username): username = property(username) + segment_info = {'environ': {}} + + def user(*args, **kwargs): + return self.module.user(pl=pl, segment_info=segment_info, *args, **kwargs) + struct_passwd = namedtuple('struct_passwd', ('pw_name',)) new_psutil = new_module('psutil', Process=Process) new_pwd = new_module('pwd', getpwuid=lambda uid: struct_passwd(pw_name='def@DOMAIN.COM')) @@ -537,21 +542,21 @@ class TestEnv(TestCommon): with replace_attr(self.module, 'os', new_os): with replace_attr(self.module, 'psutil', new_psutil): with replace_attr(self.module, '_geteuid', lambda: 5): - self.assertEqual(self.module.user(pl=pl), [ + self.assertEqual(user(), [ {'contents': 'def@DOMAIN.COM', 'highlight_groups': ['user']} ]) - self.assertEqual(self.module.user(pl=pl, hide_user='abc'), [ + self.assertEqual(user(hide_user='abc'), [ {'contents': 'def@DOMAIN.COM', 'highlight_groups': ['user']} ]) - self.assertEqual(self.module.user(pl=pl, hide_domain=False), [ + self.assertEqual(user(hide_domain=False), [ {'contents': 'def@DOMAIN.COM', 'highlight_groups': ['user']} ]) - self.assertEqual(self.module.user(pl=pl, hide_user='def@DOMAIN.COM'), None) - self.assertEqual(self.module.user(pl=pl, hide_domain=True), [ + self.assertEqual(user(hide_user='def@DOMAIN.COM'), None) + self.assertEqual(user(hide_domain=True), [ {'contents': 'def', 'highlight_groups': ['user']} ]) with replace_attr(self.module, '_geteuid', lambda: 0): - self.assertEqual(self.module.user(pl=pl), [ + self.assertEqual(user(), [ {'contents': 'def', 'highlight_groups': ['superuser', 'user']} ]) From cee07a69b13f28e7cbc70ed7d3210331090e881b Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 2 Dec 2017 19:06:38 +0300 Subject: [PATCH 72/95] Always supply verb argument --- tests/shlib/common.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh index 5edf86b8..f2bef71f 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -47,7 +47,7 @@ exit_suite() { fi } -fail() { +_fail() { local allow_failure= if test "$1" = "--allow-failure" ; then shift @@ -56,7 +56,7 @@ fail() { local test_name="$1" ; shift local fail_char="$allow_failure$1" ; shift local message="$1" ; shift - local verb="${1:-Failed}" ; test $# -ge 1 && shift + local verb="$1" ; shift local full_msg="$fail_char $POWERLINE_CURRENT_SUITE|$test_name :: $message" FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}" echo "$verb: $full_msg" @@ -66,10 +66,14 @@ fail() { fi } +fail() { + _fail "$@" "Failed" +} + skip() { local test_name="$1" ; shift local message="$1" ; shift - fail --allow-failure "$test_name" S "$message" "Skipped" + _fail --allow-failure "$test_name" S "$message" "Skipped" } make_test_root() { From 9d836d70e001c8ef0e33d950d03938190ad984bc Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 2 Dec 2017 19:25:01 +0300 Subject: [PATCH 73/95] Use virtualenv for tmux and vshells tests as well --- tests/test_in_vterm/test_shells.sh | 2 +- tests/test_in_vterm/test_tmux.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_in_vterm/test_shells.sh b/tests/test_in_vterm/test_shells.sh index b08b4e9e..d4d0eef3 100755 --- a/tests/test_in_vterm/test_shells.sh +++ b/tests/test_in_vterm/test_shells.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash . tests/shlib/common.sh . tests/shlib/vterm.sh diff --git a/tests/test_in_vterm/test_tmux.sh b/tests/test_in_vterm/test_tmux.sh index 7e1deccf..d6cd6a51 100755 --- a/tests/test_in_vterm/test_tmux.sh +++ b/tests/test_in_vterm/test_tmux.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash . tests/shlib/common.sh . tests/shlib/vterm.sh From f507a6370aa3babe6a772bd32e9419b112630f7a Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 2 Dec 2017 23:16:17 +0300 Subject: [PATCH 74/95] Do commit code which is actually using virtualenv --- tests/shlib/common.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh index f2bef71f..ad775ba4 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -5,6 +5,13 @@ set +x : ${USER:=`id -un`} : ${HOME:=`getent passwd $USER | cut -d: -f6`} +if test -n "$USE_UCS2_PYTHON" && test -n "$BASH_VERSION" ; then + set +e + . virtualenvwrapper.sh + workon cpython-ucs2-$UCS2_PYTHON_VARIANT + set -e +fi + export USER HOME if test -z "$FAILED" ; then From ed0630d074d0859e0fbbadd34bff4b14098adee0 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 3 Dec 2017 00:17:08 +0300 Subject: [PATCH 75/95] Make UCS2 Python a separate stage and run that first --- .travis.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 41bfb783..cf7c4077 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,11 @@ install: tests/install.sh script: tests/test.sh jobs: include: + - stage: UCS2 python + python: "2.7" + env: >- + USE_UCS2_PYTHON=1 + UCS2_PYTHON_VARIANT="2.7" - stage: Old Python python: "2.6" - python: "3.2" @@ -28,10 +33,6 @@ jobs: - python: "pypy3" - stage: Latest Python python: "2.7" - - python: "2.7" - env: >- - USE_UCS2_PYTHON=1 - UCS2_PYTHON_VARIANT="2.7" - python: "3.6" - stage: Intermediate versions python: "3.3" From 910c6a33ddc40a9857bcb39bbf06155913ed520f Mon Sep 17 00:00:00 2001 From: Foo Date: Sat, 16 Dec 2017 16:28:56 +0300 Subject: [PATCH 76/95] Define PYTHON and LD_LIBRARY_PATH before sourcing main.sh --- tests/shlib/common.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh index ad775ba4..f60d1dd6 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -1,10 +1,25 @@ -. tests/bot-ci/scripts/common/main.sh set +x -: ${PYTHON:=python} : ${USER:=`id -un`} : ${HOME:=`getent passwd $USER | cut -d: -f6`} +if test -z "${PYTHON}" ; then + if test -n "$USE_UCS2_PYTHON" ; then + PYTHON="$HOME/opt/cpython-ucs2-$UCS2_PYTHON_VARIANT/bin/python$UCS2_PYTHON_VARIANT" + LD_LIBRARY_PATH="$HOME/opt/cpython-ucs2-$UCS2_PYTHON_VARIANT/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}" + else + PYTHON=python + fi +fi + +export PYTHON +export LD_LIBRARY_PATH +export USER +export HOME + +. tests/bot-ci/scripts/common/main.sh +set +x + if test -n "$USE_UCS2_PYTHON" && test -n "$BASH_VERSION" ; then set +e . virtualenvwrapper.sh From 3b3d546e898dcc45f9a356d63aa8c4ca0fb21e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Fr=C3=B3es=20Franco?= Date: Wed, 10 Jan 2018 00:49:28 -0200 Subject: [PATCH 77/95] (fix) updated linux spotify app dbus config --- powerline/segments/common/players.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index dcd7a100..5b3a789d 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -311,10 +311,10 @@ class SpotifyDbusPlayerSegment(PlayerSegment): return _get_dbus_player_status( pl=pl, player_name='Spotify', - bus_name='com.spotify.qt', - player_path='/', + bus_name='org.mpris.MediaPlayer2.spotify', + player_path='/org/mpris/MediaPlayer2', iface_prop='org.freedesktop.DBus.Properties', - iface_player='org.freedesktop.MediaPlayer2', + iface_player='org.mpris.MediaPlayer2.Player', ) From b53708b577c78c9c4e27467f41e3f6ecffaaea08 Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Tue, 13 Feb 2018 10:27:31 -0600 Subject: [PATCH 78/95] Added support for truecolor in tmux status line --- powerline/bindings/config.py | 5 ++++- powerline/renderers/tmux.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/powerline/bindings/config.py b/powerline/bindings/config.py index f0617f10..529cdb1f 100644 --- a/powerline/bindings/config.py +++ b/powerline/bindings/config.py @@ -164,7 +164,10 @@ def init_tmux_environment(pl, args, set_tmux_environment=set_tmux_environment): # But it does not support empty attributes as well. or 'none')) else: - set_tmux_environment(varname, 'colour' + str(get_highlighting(group)[attr][0])) + if powerline.common_config['term_truecolor'] is True: + set_tmux_environment(varname, '#{0:06x}'.format(get_highlighting(group)[attr][1])) + else: + set_tmux_environment(varname, 'colour' + str(get_highlighting(group)[attr][0])) left_dividers = powerline.renderer.theme.dividers['left'] set_tmux_environment('_POWERLINE_LEFT_HARD_DIVIDER', left_dividers['hard']) diff --git a/powerline/renderers/tmux.py b/powerline/renderers/tmux.py index 840bbdda..ee6c09c2 100644 --- a/powerline/renderers/tmux.py +++ b/powerline/renderers/tmux.py @@ -48,12 +48,18 @@ class TmuxRenderer(Renderer): if fg is False or fg[0] is False: tmux_attrs += ['fg=default'] else: - tmux_attrs += ['fg=colour' + str(fg[0])] + if self.term_truecolor and fg[1]: + tmux_attrs += ['fg=#{0:06x}'.format(int(fg[1]))] + else: + tmux_attrs += ['fg=colour' + str(fg[0])] if bg is not None: if bg is False or bg[0] is False: tmux_attrs += ['bg=default'] else: - tmux_attrs += ['bg=colour' + str(bg[0])] + if self.term_truecolor and bg[1]: + tmux_attrs += ['bg=#{0:06x}'.format(int(bg[1]))] + else: + tmux_attrs += ['bg=colour' + str(bg[0])] if attrs is not None: tmux_attrs += attrs_to_tmux_attrs(attrs) return '#[' + ','.join(tmux_attrs) + ']' From a5e5ed00d49812791a171310ac85d93acad1e824 Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Tue, 13 Feb 2018 15:50:06 -0600 Subject: [PATCH 79/95] Removed unnecessary code --- powerline/bindings/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerline/bindings/config.py b/powerline/bindings/config.py index 529cdb1f..31006330 100644 --- a/powerline/bindings/config.py +++ b/powerline/bindings/config.py @@ -164,7 +164,7 @@ def init_tmux_environment(pl, args, set_tmux_environment=set_tmux_environment): # But it does not support empty attributes as well. or 'none')) else: - if powerline.common_config['term_truecolor'] is True: + if powerline.common_config['term_truecolor']: set_tmux_environment(varname, '#{0:06x}'.format(get_highlighting(group)[attr][1])) else: set_tmux_environment(varname, 'colour' + str(get_highlighting(group)[attr][0])) From 466ee2e295c383f50938460ed69c8327b51d9f57 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 25 Feb 2018 21:37:47 +0300 Subject: [PATCH 80/95] Print more detailed diagnostics Specifically, disable set -x from main.sh, but add nicer print_environ function executed before each test suite, also setting `set -x` in `enter_suite`. --- tests/shlib/common.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh index f60d1dd6..7a3c6a16 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -1,5 +1,3 @@ -set +x - : ${USER:=`id -un`} : ${HOME:=`getent passwd $USER | cut -d: -f6`} @@ -17,8 +15,7 @@ export LD_LIBRARY_PATH export USER export HOME -. tests/bot-ci/scripts/common/main.sh -set +x +. tests/bot-ci/scripts/common/main.sh silent if test -n "$USE_UCS2_PYTHON" && test -n "$BASH_VERSION" ; then set +e @@ -48,10 +45,22 @@ travis_fold() { echo -en "travis_fold:${action}:${name}\r${ANSI_CLEAR}" } +print_environ() { + echo "Using $PYTHON_IMPLEMENTATION version $PYTHON_VERSION." + echo "Path to Python executable: $PYTHON." + echo "Root: $ROOT." + echo "Branch: $BRANCH_NAME." + echo "sys.path:" + "$PYTHON" -c "for path in __import__('sys').path: print(' %r' % path)" +} + enter_suite() { + set +x local suite_name="$1" ; shift export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE}/$suite_name" travis_fold start "$POWERLINE_CURRENT_SUITE" + print_environ + set -x } exit_suite() { @@ -62,6 +71,7 @@ exit_suite() { echo "Suite ${POWERLINE_CURRENT_SUITE} failed, summary:" echo "${FAIL_SUMMARY}" fi + set +x travis_fold end "$POWERLINE_CURRENT_SUITE" export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE%/*}" if test "$1" != "--continue" ; then From 23bec031a4dd0607fa59d4f7ae0b03dd8feb1c34 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 25 Feb 2018 21:53:24 +0300 Subject: [PATCH 81/95] Do not use python from ~/opt directly It causes problems with sys.path: interpreter could not use installed packages. --- tests/shlib/common.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh index 7a3c6a16..d1cfbbf1 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -3,14 +3,10 @@ if test -z "${PYTHON}" ; then if test -n "$USE_UCS2_PYTHON" ; then - PYTHON="$HOME/opt/cpython-ucs2-$UCS2_PYTHON_VARIANT/bin/python$UCS2_PYTHON_VARIANT" LD_LIBRARY_PATH="$HOME/opt/cpython-ucs2-$UCS2_PYTHON_VARIANT/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}" - else - PYTHON=python fi fi -export PYTHON export LD_LIBRARY_PATH export USER export HOME From 4a834f38aaf49f6af4cb1ab0322c0d2160af03ae Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 25 Feb 2018 22:16:05 +0300 Subject: [PATCH 82/95] =?UTF-8?q?Only=20enable=20tracing=20for=20=E2=80=9C?= =?UTF-8?q?final=E2=80=9D=20suites:=20suites=20not=20having=20subsuites?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/shlib/common.sh | 9 ++++++++- tests/test_awesome/test.sh | 4 ++-- tests/test_bar/test.sh | 4 ++-- tests/test_daemon/test.sh | 2 +- tests/test_in_vterm/test_tmux.sh | 2 +- tests/test_in_vterm/test_vim.sh | 2 +- tests/test_lint/test.sh | 2 +- tests/test_python/test.sh | 2 +- tests/test_shells/test.sh | 2 +- tests/test_vim/test.sh | 2 +- 10 files changed, 19 insertions(+), 12 deletions(-) diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh index d1cfbbf1..e6ff6d33 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -53,10 +53,17 @@ print_environ() { enter_suite() { set +x local suite_name="$1" ; shift + local final="$1" export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE}/$suite_name" travis_fold start "$POWERLINE_CURRENT_SUITE" print_environ - set -x + if test "$final" = final ; then + if test -n "$POWERLINE_SUITE_FINAL" ; then + fail __suite__/enter/final E "Final suites do not allow nesting" + fi + export POWERLINE_SUITE_FINAL=1 + set -x + fi } exit_suite() { diff --git a/tests/test_awesome/test.sh b/tests/test_awesome/test.sh index 93d50303..fc85dc21 100755 --- a/tests/test_awesome/test.sh +++ b/tests/test_awesome/test.sh @@ -102,7 +102,7 @@ if ! test -e "$DEPRECATED_SCRIPT" ; then # skip "deprecated" "Missing deprecated bar bindings script" : else - enter_suite "deprecated" + enter_suite "deprecated" final for args in "" "0.5"; do rm -rf "$TEST_ROOT/results" mkdir "$TEST_ROOT/results" @@ -132,7 +132,7 @@ else exit_suite --continue fi -enter_suite "awesome" +enter_suite "awesome" final ADDRESS="powerline-ipc-test-$$" echo "Powerline address: $ADDRESS" rm -rf "$TEST_ROOT/results" diff --git a/tests/test_bar/test.sh b/tests/test_bar/test.sh index d6522eed..a0838fa6 100755 --- a/tests/test_bar/test.sh +++ b/tests/test_bar/test.sh @@ -94,7 +94,7 @@ if ! test -e "$DEPRECATED_SCRIPT" ; then # skip "deprecated" "Missing deprecated bar bindings script" : else - enter_suite "deprecated" + enter_suite "deprecated" final run python "$DEPRECATED_SCRIPT" $args > "$TEST_ROOT/deprecated.log" 2>&1 & SPID=$! sleep 5 @@ -122,7 +122,7 @@ else sleep 5 killscript $SPID sleep 0.5 - enter_suite "args($args)" + enter_suite "args($args)" final fnum=0 for file in "$TEST_ROOT/results"/*.log ; do if ! test -e "$file" ; then diff --git a/tests/test_daemon/test.sh b/tests/test_daemon/test.sh index 6538e4fd..a5c12c11 100755 --- a/tests/test_daemon/test.sh +++ b/tests/test_daemon/test.sh @@ -1,7 +1,7 @@ #!/bin/sh . tests/shlib/common.sh -enter_suite daemon +enter_suite daemon final export ADDRESS="powerline-ipc-test-$$" echo "Powerline address: $ADDRESS" diff --git a/tests/test_in_vterm/test_tmux.sh b/tests/test_in_vterm/test_tmux.sh index d6cd6a51..062e02ba 100755 --- a/tests/test_in_vterm/test_tmux.sh +++ b/tests/test_in_vterm/test_tmux.sh @@ -2,7 +2,7 @@ . tests/shlib/common.sh . tests/shlib/vterm.sh -enter_suite tmux +enter_suite tmux final vterm_setup diff --git a/tests/test_in_vterm/test_vim.sh b/tests/test_in_vterm/test_vim.sh index 57c195ed..a7e61686 100755 --- a/tests/test_in_vterm/test_vim.sh +++ b/tests/test_in_vterm/test_vim.sh @@ -3,7 +3,7 @@ . tests/shlib/vterm.sh . tests/shlib/vim.sh -enter_suite vvim +enter_suite vvim final vterm_setup diff --git a/tests/test_lint/test.sh b/tests/test_lint/test.sh index f73ea981..03c2f8a8 100755 --- a/tests/test_lint/test.sh +++ b/tests/test_lint/test.sh @@ -1,7 +1,7 @@ #!/bin/sh . tests/shlib/common.sh -enter_suite lint +enter_suite lint final if ! "$PYTHON" "$ROOT/scripts/powerline-lint" -p "$ROOT/powerline/config_files" ; then fail "test" F "Running powerline-lint failed" diff --git a/tests/test_python/test.sh b/tests/test_python/test.sh index 667d642d..f0422372 100755 --- a/tests/test_python/test.sh +++ b/tests/test_python/test.sh @@ -1,7 +1,7 @@ #!/bin/sh . tests/shlib/common.sh -enter_suite python +enter_suite python final for file in "$ROOT"/tests/test_python/test_*.py ; do test_name="${file##*/test_}" diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index c6867342..44943029 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -1,7 +1,7 @@ #!/bin/sh . tests/shlib/common.sh -enter_suite shell +enter_suite shell final if test $# -eq 0 ; then FAST=1 diff --git a/tests/test_vim/test.sh b/tests/test_vim/test.sh index 87502a94..cd5ca622 100755 --- a/tests/test_vim/test.sh +++ b/tests/test_vim/test.sh @@ -3,7 +3,7 @@ . tests/shlib/vterm.sh . tests/shlib/vim.sh -enter_suite vim +enter_suite vim final vterm_setup vim From 2fc0e8e520aabe6c16937823e9fb2db5f79a5c4b Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 25 Feb 2018 22:26:00 +0300 Subject: [PATCH 83/95] Use proper $PYTHON in case of UCS2 build and non-bash script --- tests/shlib/common.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh index e6ff6d33..732f872d 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -11,15 +11,19 @@ export LD_LIBRARY_PATH export USER export HOME -. tests/bot-ci/scripts/common/main.sh silent - -if test -n "$USE_UCS2_PYTHON" && test -n "$BASH_VERSION" ; then - set +e - . virtualenvwrapper.sh - workon cpython-ucs2-$UCS2_PYTHON_VARIANT - set -e +if test -n "$USE_UCS2_PYTHON" ; then + POWERLINE_VIRTUALENV="cpython-ucs2-$UCS2_PYTHON_VARIANT" + PYTHON="$HOME/.virtualenvs/$POWERLINE_VIRTUALENV/bin/python" + if test -n "$BASH_VERSION" ; then + set +e + . virtualenvwrapper.sh + workon "$POWERLINE_VIRTUALENV" + set -e + fi fi +. tests/bot-ci/scripts/common/main.sh silent + export USER HOME if test -z "$FAILED" ; then From d27961f0b08556f5d65ad73d9409febbdf524a22 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 25 Feb 2018 22:35:11 +0300 Subject: [PATCH 84/95] Unset POWERLINE_SUITE_FINAL if exit_suite is continuing --- tests/shlib/common.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh index 732f872d..2f8cea61 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -83,6 +83,8 @@ exit_suite() { export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE%/*}" if test "$1" != "--continue" ; then exit $FAILED + else + unset POWERLINE_SUITE_FINAL fi } From 3c4ec09281cc6d25df1ef665649c9b1474d4e555 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 25 Feb 2018 22:36:52 +0300 Subject: [PATCH 85/95] Do not set -x, it fails some tests and makes some output not readable --- tests/shlib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh index 2f8cea61..63302625 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -66,7 +66,7 @@ enter_suite() { fail __suite__/enter/final E "Final suites do not allow nesting" fi export POWERLINE_SUITE_FINAL=1 - set -x + # set -x fi } From cc965526fbef33297c4cd4fd3b1fa1a8d01ad520 Mon Sep 17 00:00:00 2001 From: ruben Date: Wed, 14 Mar 2018 09:13:26 +0100 Subject: [PATCH 86/95] Added detection of old Spotify DBus protocol Ref #1754 --- powerline/segments/common/players.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index 5b3a789d..55bf69ae 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -308,6 +308,16 @@ Requires ``dbus`` python module. Only for players that support specific protocol class SpotifyDbusPlayerSegment(PlayerSegment): def get_player_status(self, pl): + legacy_player_status = _get_dbus_player_status( + pl=pl, + player_name='Spotify', + bus_name='com.spotify.qt', + player_path='/', + iface_prop='org.freedesktop.DBus.Properties', + iface_player='org.freedesktop.MediaPlayer2', + ) + if legacy_player_status is not None: + return legacy_player_status return _get_dbus_player_status( pl=pl, player_name='Spotify', From 74c08cd538df7a1777bec2e0b2c9ad6657607188 Mon Sep 17 00:00:00 2001 From: ruben Date: Thu, 15 Mar 2018 08:22:44 +0100 Subject: [PATCH 87/95] Spotify segment checks for new protocol first --- powerline/segments/common/players.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/powerline/segments/common/players.py b/powerline/segments/common/players.py index 55bf69ae..9298bc90 100644 --- a/powerline/segments/common/players.py +++ b/powerline/segments/common/players.py @@ -308,17 +308,7 @@ Requires ``dbus`` python module. Only for players that support specific protocol class SpotifyDbusPlayerSegment(PlayerSegment): def get_player_status(self, pl): - legacy_player_status = _get_dbus_player_status( - pl=pl, - player_name='Spotify', - bus_name='com.spotify.qt', - player_path='/', - iface_prop='org.freedesktop.DBus.Properties', - iface_player='org.freedesktop.MediaPlayer2', - ) - if legacy_player_status is not None: - return legacy_player_status - return _get_dbus_player_status( + player_status = _get_dbus_player_status( pl=pl, player_name='Spotify', bus_name='org.mpris.MediaPlayer2.spotify', @@ -326,6 +316,17 @@ class SpotifyDbusPlayerSegment(PlayerSegment): iface_prop='org.freedesktop.DBus.Properties', iface_player='org.mpris.MediaPlayer2.Player', ) + if player_status is not None: + return player_status + # Fallback for legacy spotify client with different DBus protocol + return _get_dbus_player_status( + pl=pl, + player_name='Spotify', + bus_name='com.spotify.qt', + player_path='/', + iface_prop='org.freedesktop.DBus.Properties', + iface_player='org.freedesktop.MediaPlayer2', + ) spotify_dbus = with_docstring(SpotifyDbusPlayerSegment(), From 166013aab09b3feecb4a38c34b18dc4e6f9766a1 Mon Sep 17 00:00:00 2001 From: Stephon Harris Date: Wed, 21 Mar 2018 00:32:17 -0400 Subject: [PATCH 88/95] grammar fix Including `, the` for readability --- docs/source/installation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 2e6dc8ba..eb40ed02 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -41,7 +41,7 @@ Generic requirements .. _repository-root: .. note:: - When using ``pip`` ``{repository_root}`` directory referenced in + When using ``pip``, the ``{repository_root}`` directory referenced in documentation may be found using ``pip show powerline-status``. In the output of ``pip show`` there is a line like ``Location: {path}``, that ``{path}`` is ``{repository_root}``. Unless it is ``--editable`` installation this is only From 80156fb8408d97453b8836cb86355f13d1ccb86b Mon Sep 17 00:00:00 2001 From: yparisien Date: Tue, 8 May 2018 22:18:51 +0200 Subject: [PATCH 89/95] Transparency doesn't need to be disabled --- docs/source/troubleshooting/osx.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/troubleshooting/osx.rst b/docs/source/troubleshooting/osx.rst index c2251e66..82953d10 100644 --- a/docs/source/troubleshooting/osx.rst +++ b/docs/source/troubleshooting/osx.rst @@ -27,7 +27,7 @@ The colors look weird in iTerm2! * The arrows may have the wrong colors if you have changed the “minimum contrast” slider in the color tab of your OS X settings. -* Please disable background transparency to resolve this issue. +* If you're using transparency, check "Keep background colors opaque" Statusline is getting wrapped to the next line in iTerm2 -------------------------------------------------------- From f813171596ae0fba1e7dd0212d760f47cf709a7a Mon Sep 17 00:00:00 2001 From: yparisien Date: Wed, 9 May 2018 10:21:33 +0200 Subject: [PATCH 90/95] Correcting markdown --- docs/source/troubleshooting/osx.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/troubleshooting/osx.rst b/docs/source/troubleshooting/osx.rst index 82953d10..c9d34e5b 100644 --- a/docs/source/troubleshooting/osx.rst +++ b/docs/source/troubleshooting/osx.rst @@ -26,8 +26,8 @@ The colors look weird in iTerm2! -------------------------------- * The arrows may have the wrong colors if you have changed the “minimum - contrast” slider in the color tab of your OS X settings. -* If you're using transparency, check "Keep background colors opaque" + contrast“ slider in the color tab of your OS X settings. +* If you're using transparency, check “Keep background colors opaque“. Statusline is getting wrapped to the next line in iTerm2 -------------------------------------------------------- From 052260ad4d59d115a1605492210f752807be2b63 Mon Sep 17 00:00:00 2001 From: yparisien Date: Wed, 9 May 2018 10:29:29 +0200 Subject: [PATCH 91/95] Markdown correction --- docs/source/troubleshooting/osx.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/troubleshooting/osx.rst b/docs/source/troubleshooting/osx.rst index c9d34e5b..b61063e6 100644 --- a/docs/source/troubleshooting/osx.rst +++ b/docs/source/troubleshooting/osx.rst @@ -26,8 +26,8 @@ The colors look weird in iTerm2! -------------------------------- * The arrows may have the wrong colors if you have changed the “minimum - contrast“ slider in the color tab of your OS X settings. -* If you're using transparency, check “Keep background colors opaque“. + contrast” slider in the color tab of your OS X settings. +* If you're using transparency, check “Keep background colors opaque”. Statusline is getting wrapped to the next line in iTerm2 -------------------------------------------------------- From 1da9485f5fb601d2457902b5c2415ba5cc90319e Mon Sep 17 00:00:00 2001 From: Aurze Date: Tue, 29 May 2018 23:18:02 -0400 Subject: [PATCH 92/95] Fix if you have i3ipc and i3 on your system. Will prioritize i3ipc --- powerline/bindings/wm/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/powerline/bindings/wm/__init__.py b/powerline/bindings/wm/__init__.py index 130c0e4f..646b701a 100644 --- a/powerline/bindings/wm/__init__.py +++ b/powerline/bindings/wm/__init__.py @@ -25,12 +25,13 @@ def i3_subscribe(conn, event, callback): Function to run on event. ''' try: - import i3 + import i3ipc except ImportError: - pass - else: + import i3 conn.Subscription(callback, event) return + else: + pass conn.on(event, callback) From 4a8e8b5b0ca4a6a5237ec3eadb6fb9fe8e106a81 Mon Sep 17 00:00:00 2001 From: Doug Krieger Date: Tue, 5 Jun 2018 08:45:55 -0700 Subject: [PATCH 93/95] Recognize Terminal-Job mode (added in vim 8) --- powerline/config_files/themes/ascii.json | 3 ++- powerline/config_files/themes/powerline.json | 3 ++- powerline/config_files/themes/powerline_terminus.json | 3 ++- powerline/config_files/themes/powerline_unicode7.json | 3 ++- powerline/config_files/themes/unicode.json | 3 ++- powerline/config_files/themes/unicode_terminus.json | 3 ++- powerline/segments/vim/__init__.py | 1 + 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/powerline/config_files/themes/ascii.json b/powerline/config_files/themes/ascii.json index 1012a56d..0ea05e75 100644 --- a/powerline/config_files/themes/ascii.json +++ b/powerline/config_files/themes/ascii.json @@ -117,7 +117,8 @@ "r": "PROMPT", "rm": "-MORE-", "r?": "CNFIRM", - "!": "!SHELL" + "!": "!SHELL", + "t": "TERM " } } }, diff --git a/powerline/config_files/themes/powerline.json b/powerline/config_files/themes/powerline.json index b0120b14..366a7ea4 100644 --- a/powerline/config_files/themes/powerline.json +++ b/powerline/config_files/themes/powerline.json @@ -115,7 +115,8 @@ "r": "PROMPT", "rm": "-MORE-", "r?": "CNFIRM", - "!": "!SHELL" + "!": "!SHELL", + "t": "TERM " } } }, diff --git a/powerline/config_files/themes/powerline_terminus.json b/powerline/config_files/themes/powerline_terminus.json index 5481ca4a..e5fb1c8c 100644 --- a/powerline/config_files/themes/powerline_terminus.json +++ b/powerline/config_files/themes/powerline_terminus.json @@ -115,7 +115,8 @@ "r": "PROMPT", "rm": "-MORE-", "r?": "CNFIRM", - "!": "!SHELL" + "!": "!SHELL", + "t": "TERM " } } }, diff --git a/powerline/config_files/themes/powerline_unicode7.json b/powerline/config_files/themes/powerline_unicode7.json index 023eb43d..bd628267 100644 --- a/powerline/config_files/themes/powerline_unicode7.json +++ b/powerline/config_files/themes/powerline_unicode7.json @@ -129,7 +129,8 @@ "r": "PROMPT", "rm": "-MORE-", "r?": "CNFIRM", - "!": "!SHELL" + "!": "!SHELL", + "t": "TERM " } } }, diff --git a/powerline/config_files/themes/unicode.json b/powerline/config_files/themes/unicode.json index 33d96346..08028523 100644 --- a/powerline/config_files/themes/unicode.json +++ b/powerline/config_files/themes/unicode.json @@ -115,7 +115,8 @@ "r": "PROMPT", "rm": "-MORE-", "r?": "CNFIRM", - "!": "!SHELL" + "!": "!SHELL", + "t": "TERM " } } }, diff --git a/powerline/config_files/themes/unicode_terminus.json b/powerline/config_files/themes/unicode_terminus.json index b0e51bd1..9c76985d 100644 --- a/powerline/config_files/themes/unicode_terminus.json +++ b/powerline/config_files/themes/unicode_terminus.json @@ -115,7 +115,8 @@ "r": "PROMPT", "rm": "-MORE-", "r?": "CNFIRM", - "!": "!SHELL" + "!": "!SHELL", + "t": "TERM " } } }, diff --git a/powerline/segments/vim/__init__.py b/powerline/segments/vim/__init__.py index f89b9659..b6379611 100644 --- a/powerline/segments/vim/__init__.py +++ b/powerline/segments/vim/__init__.py @@ -63,6 +63,7 @@ vim_modes = { 'rm': '-MORE-', 'r?': 'CNFIRM', '!': '!SHELL', + 't': 'TERM ', } From a92bc7280187b8b30a2f0512c5a41980ecd5b773 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 12 Aug 2018 22:09:45 +0300 Subject: [PATCH 94/95] fix! Allow failing old vim test when running with Python-2.7 --- tests/test_vim/test.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/test_vim/test.sh b/tests/test_vim/test.sh index cd5ca622..ecd02850 100755 --- a/tests/test_vim/test.sh +++ b/tests/test_vim/test.sh @@ -15,6 +15,7 @@ export POWERLINE_THEME_OVERRIDES='default.segments.left=[]' test_script() { local vim="$1" ; shift local script="$1" ; shift + local allow_failure_arg="$1" ; shift echo "Running script $script with $vim" if ! test -e "$vim" ; then return 0 @@ -23,7 +24,8 @@ test_script() { || test -f message.fail then local test_name="${script##*/}" - fail "${test_name%.vim}" F "Failed script $script run with $vim" + fail $allow_failure_arg "${test_name%.vim}" \ + F "Failed script $script run with $vim" if test -e message.fail ; then cat message.fail >&2 rm message.fail @@ -37,13 +39,19 @@ cd "$TEST_ROOT" for script in "$TEST_SCRIPT_ROOT"/*.vim ; do if test "${script%.old.vim}" = "${script}" ; then - test_script "$NEW_VIM" "$script" + test_script "$NEW_VIM" "$script" "" fi done +if test "$PYTHON_VERSION_MAJOR.$PYTHON_VERSION_MINOR" = "2.7" ; then + ALLOW_FAILURE_ARG=--allow-failure +else + ALLOW_FAILURE_ARG= +fi + if test -e "$OLD_VIM" ; then for script in "$TEST_SCRIPT_ROOT"/*.old.vim ; do - test_script "$OLD_VIM" "$script" + test_script "$OLD_VIM" "$script" "$ALLOW_FAILURE_ARG" done fi From b7a68da865709e7bf33cc88bc81d91549a51fd6e Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 12 Aug 2018 22:41:43 +0300 Subject: [PATCH 95/95] Update base version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 setup.py diff --git a/setup.py b/setup.py old mode 100755 new mode 100644 index 0d46ae3e..30bcddbe --- a/setup.py +++ b/setup.py @@ -59,7 +59,7 @@ else: def get_version(): - base_version = '2.6' + base_version = '2.7' base_version += '.dev9999' try: return base_version + '+git.' + str(subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip())