-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-unicode-error
- Loading branch information
Showing
15 changed files
with
137 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fixed a bug causing requirements input as relative paths to be output as absolute paths or URIs. | ||
Fixed a bug affecting normalization of ``git+git@host`` uris. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Updated ``requirementslib`` to version ``1.0.8`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# -*- coding=utf-8 -*- | ||
__version__ = "1.0.7" | ||
__version__ = "1.0.8" | ||
|
||
|
||
from .exceptions import RequirementError | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
import platform | ||
|
||
from .._consts import SHELL_NAMES | ||
|
||
|
||
def _get_process_mapping(): | ||
system = platform.system() | ||
if system == 'Linux': | ||
from . import linux as impl | ||
else: | ||
from . import _default as impl | ||
return impl.get_process_mapping() | ||
|
||
|
||
def get_shell(pid=None, max_depth=6): | ||
"""Get the shell that the supplied pid or os.getpid() is running in. | ||
""" | ||
pid = str(pid or os.getpid()) | ||
mapping = _get_process_mapping() | ||
login_shell = os.environ.get('SHELL', '') | ||
for _ in range(max_depth): | ||
try: | ||
proc = mapping[pid] | ||
except KeyError: | ||
break | ||
name = os.path.basename(proc.args[0]).lower() | ||
if name in SHELL_NAMES: | ||
return (name, proc.args[0]) | ||
elif proc.args[0].startswith('-'): | ||
# This is the login shell. Use the SHELL environ if possible | ||
# because it provides better information. | ||
if login_shell: | ||
name = login_shell.lower() | ||
else: | ||
name = proc.args[0][1:].lower() | ||
return (os.path.basename(name), name) | ||
pid = proc.ppid # Go up one level. | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import collections | ||
import shlex | ||
import subprocess | ||
import sys | ||
|
||
|
||
Process = collections.namedtuple('Process', 'args pid ppid') | ||
|
||
|
||
def get_process_mapping(): | ||
"""Try to look up the process tree via the output of `ps`. | ||
""" | ||
output = subprocess.check_output([ | ||
'ps', '-ww', '-o', 'pid=', '-o', 'ppid=', '-o', 'args=', | ||
]) | ||
if not isinstance(output, str): | ||
output = output.decode(sys.stdout.encoding) | ||
processes = {} | ||
for line in output.split('\n'): | ||
try: | ||
pid, ppid, args = line.strip().split(None, 2) | ||
except ValueError: | ||
continue | ||
processes[pid] = Process( | ||
args=tuple(shlex.split(args)), pid=pid, ppid=ppid, | ||
) | ||
return processes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
import re | ||
|
||
from ._default import Process | ||
|
||
|
||
STAT_PPID = 3 | ||
STAT_TTY = 6 | ||
|
||
|
||
def get_process_mapping(): | ||
"""Try to look up the process tree via Linux's /proc | ||
""" | ||
with open('/proc/{0}/stat'.format(os.getpid())) as f: | ||
self_tty = f.read().split()[STAT_TTY] | ||
processes = {} | ||
for pid in os.listdir('/proc'): | ||
if not pid.isdigit(): | ||
continue | ||
try: | ||
stat = '/proc/{0}/stat'.format(pid) | ||
cmdline = '/proc/{0}/cmdline'.format(pid) | ||
with open(stat) as fstat, open(cmdline) as fcmdline: | ||
stat = re.findall(r'\(.+\)|\S+', fstat.read()) | ||
cmd = fcmdline.read().split('\x00')[:-1] | ||
ppid = stat[STAT_PPID] | ||
tty = stat[STAT_TTY] | ||
if tty == self_tty: | ||
processes[pid] = Process( | ||
args=tuple(cmd), pid=pid, ppid=ppid, | ||
) | ||
except IOError: | ||
# Process has disappeared - just ignore it. | ||
continue | ||
return processes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters