mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-20 20:09:07 +00:00
#165 fix python 2 support
This commit is contained in:
parent
608d48e408
commit
5864faadef
@ -1,14 +1,15 @@
|
||||
import subprocess
|
||||
from thefuck.utils import DEVNULL
|
||||
|
||||
|
||||
def __command_available(command):
|
||||
try:
|
||||
subprocess.check_output([command], stderr=subprocess.DEVNULL)
|
||||
subprocess.check_output([command], stderr=DEVNULL)
|
||||
return True
|
||||
except subprocess.CalledProcessError:
|
||||
# command exists but is not happy to be called without any argument
|
||||
return True
|
||||
except FileNotFoundError:
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
|
@ -8,9 +8,7 @@ from subprocess import Popen, PIPE
|
||||
from time import time
|
||||
import os
|
||||
from psutil import Process
|
||||
|
||||
|
||||
FNULL = open(os.devnull, 'w')
|
||||
from .utils import DEVNULL
|
||||
|
||||
|
||||
class Generic(object):
|
||||
@ -58,7 +56,7 @@ class Bash(Generic):
|
||||
return name, value
|
||||
|
||||
def _get_aliases(self):
|
||||
proc = Popen('bash -ic alias', stdout=PIPE, stderr=FNULL, shell=True)
|
||||
proc = Popen('bash -ic alias', stdout=PIPE, stderr=DEVNULL, shell=True)
|
||||
return dict(
|
||||
self._parse_alias(alias)
|
||||
for alias in proc.stdout.read().decode('utf-8').split('\n')
|
||||
@ -80,7 +78,7 @@ class Zsh(Generic):
|
||||
return name, value
|
||||
|
||||
def _get_aliases(self):
|
||||
proc = Popen('zsh -ic alias', stdout=PIPE, stderr=FNULL, shell=True)
|
||||
proc = Popen('zsh -ic alias', stdout=PIPE, stderr=DEVNULL, shell=True)
|
||||
return dict(
|
||||
self._parse_alias(alias)
|
||||
for alias in proc.stdout.read().decode('utf-8').split('\n')
|
||||
|
@ -4,6 +4,9 @@ import six
|
||||
from .types import Command
|
||||
|
||||
|
||||
DEVNULL = open(os.devnull, 'w')
|
||||
|
||||
|
||||
def which(program):
|
||||
"""Returns `program` path or `None`."""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user