From 408cb5fa09239aec34dab9917a2cec23b612de8b Mon Sep 17 00:00:00 2001 From: Vladimir Iakovlev Date: Mon, 13 Mar 2017 23:26:57 +0100 Subject: [PATCH] #611: Fix python 2 support --- thefuck/not_configured.py | 9 +++++---- thefuck/shells/bash.py | 2 +- thefuck/shells/fish.py | 2 +- thefuck/shells/powershell.py | 2 +- thefuck/shells/tcsh.py | 2 +- thefuck/shells/zsh.py | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/thefuck/not_configured.py b/thefuck/not_configured.py index 06d20265..af6f418d 100644 --- a/thefuck/not_configured.py +++ b/thefuck/not_configured.py @@ -5,6 +5,7 @@ init_output() import os # noqa: E402 from psutil import Process # noqa: E402 +import six # noqa: E402 from . import logs # noqa: E402 from .shells import shell # noqa: E402 from .conf import settings # noqa: E402 @@ -30,7 +31,7 @@ def _get_not_configured_usage_tracker_path(): def _record_first_run(): """Records shell pid to tracker file.""" with _get_not_configured_usage_tracker_path().open('w') as tracker: - tracker.write(str(_get_shell_pid())) + tracker.write(six.text_type(_get_shell_pid())) def _is_second_run(): @@ -41,7 +42,7 @@ def _is_second_run(): current_pid = _get_shell_pid() with tracker_path.open('r') as tracker: - return tracker.read() == str(current_pid) + return tracker.read() == six.text_type(current_pid) def _is_already_configured(configuration_details): @@ -55,9 +56,9 @@ def _configure(configuration_details): """Adds alias to shell config.""" path = Path(configuration_details.path).expanduser() with path.open('a') as shell_config: - shell_config.write('\n') + shell_config.write(u'\n') shell_config.write(configuration_details.content) - shell_config.write('\n') + shell_config.write(u'\n') def main(): diff --git a/thefuck/shells/bash.py b/thefuck/shells/bash.py index 8122d697..23c23086 100644 --- a/thefuck/shells/bash.py +++ b/thefuck/shells/bash.py @@ -46,6 +46,6 @@ class Bash(Generic): config = 'bash config' return self._create_shell_configuration( - content='eval $(thefuck --alias)', + content=u'eval $(thefuck --alias)', path=config, reload=u'source {}'.format(config)) diff --git a/thefuck/shells/fish.py b/thefuck/shells/fish.py index 03bdc9b1..d20c5f89 100644 --- a/thefuck/shells/fish.py +++ b/thefuck/shells/fish.py @@ -68,7 +68,7 @@ class Fish(Generic): def how_to_configure(self): return self._create_shell_configuration( - content=r"eval (thefuck --alias | tr '\n' ';')", + content=u"eval (thefuck --alias | tr '\n' ';')", path='~/.config/fish/config.fish', reload='fish') diff --git a/thefuck/shells/powershell.py b/thefuck/shells/powershell.py index e00dc809..938b3d4e 100644 --- a/thefuck/shells/powershell.py +++ b/thefuck/shells/powershell.py @@ -19,7 +19,7 @@ class Powershell(Generic): def how_to_configure(self): return ShellConfiguration( - content='iex "thefuck --alias"', + content=u'iex "thefuck --alias"', path='$profile', reload='& $profile', can_configure_automatically=False) diff --git a/thefuck/shells/tcsh.py b/thefuck/shells/tcsh.py index d43e258e..b1967a9b 100644 --- a/thefuck/shells/tcsh.py +++ b/thefuck/shells/tcsh.py @@ -32,6 +32,6 @@ class Tcsh(Generic): def how_to_configure(self): return self._create_shell_configuration( - content='eval `thefuck --alias`', + content=u'eval `thefuck --alias`', path='~/.tcshrc', reload='tcsh') diff --git a/thefuck/shells/zsh.py b/thefuck/shells/zsh.py index 14a74a16..5bfd2bec 100644 --- a/thefuck/shells/zsh.py +++ b/thefuck/shells/zsh.py @@ -46,6 +46,6 @@ class Zsh(Generic): def how_to_configure(self): return self._create_shell_configuration( - content='eval $(thefuck --alias)', + content=u'eval $(thefuck --alias)', path='~/.zshrc', reload='source ~/.zshrc')