Skip to content

Commit

Permalink
New distribution [0.3.3.post1]
Browse files Browse the repository at this point in the history
 - lint files
 - bugfix in make.sh
  • Loading branch information
JarryShaw committed Mar 3, 2019
1 parent f775b5d commit 06b0a1e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 53 deletions.
5 changes: 2 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"python.pythonPath": "/Users/jarryshaw/.virtualenvs/ptyng-pFkoxdfX/bin/python",
"cSpell.words": [
"FILENO",
"PQRST",
Expand Down Expand Up @@ -29,6 +28,6 @@
"waitpid",
"writen"
],
"restructuredtext.confPath": "",
"python.linting.pylintEnabled": true
"python.linting.pylintEnabled": true,
"python.pythonPath": "/Users/jarryshaw/.virtualenvs/ptyng-pFkoxdfX/bin/python"
}
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# basic info
FROM library/ubuntu
LABEL version 2019.02.26
LABEL version 2019.03.03
LABEL description "Ubuntu Environment"

# prepare environment
Expand Down
47 changes: 18 additions & 29 deletions make.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env bash

# print a trace of simple commands
set -x
set -ex

# prepare for PyPI distribution
rm -rf build 2> /dev/null
mkdir eggs \
sdist \
wheels 2> /dev/null
mv -f dist/*.egg eggs/ 2> /dev/null
mv -f dist/*.whl wheels/ 2> /dev/null
mv -f dist/*.tar.gz sdist/ 2> /dev/null
rm -rf dist 2> /dev/null
rm -rf build
mkdir -p eggs \
sdist \
wheels
mv -f dist/*.egg eggs/
mv -f dist/*.whl wheels/
mv -f dist/*.tar.gz sdist/
rm -rf dist

# fetch platform spec
platform=$( python3 -c "import distutils.util; print(distutils.util.get_platform().replace('-', '_').replace('.', '_'))" )
Expand All @@ -33,26 +33,23 @@ docker-compose up --build
cd ..

# distribute to PyPI and TestPyPI
twine check dist/*
twine upload dist/* -r pypi --skip-existing
twine upload dist/* -r pypitest --skip-existing

# get version string
version=$( cat setup.py | grep "^__version__" | sed "s/__version__ = '\(.*\)'/\1/" )

# upload to GitHub
git pull && \
git tag "v${version}" && \
git add . && \
git pull
git tag "v${version}"
git add .
if [[ -z "$1" ]] ; then
git commit -a -S
else
git commit -a -S -m "$1"
fi && \
git push
ret="$?"
if [[ $ret -ne "0" ]] ; then
exit $ret
fi
git push

# file new release
go run github.com/aktau/github-release release \
Expand All @@ -61,22 +58,14 @@ go run github.com/aktau/github-release release \
--tag "v${version}" \
--name "ptyng v${version}" \
--description "$1"
ret="$?"
if [[ $ret -ne "0" ]] ; then
exit $ret
fi

# update maintenance information
# maintainer changelog && \
maintainer contributor && \
maintainer contributor
maintainer contributing
ret="$?"
if [[ $ret -ne "0" ]] ; then
exit $ret
fi

# aftermath
git pull && \
git add . && \
git commit -a -S -m "Regular update after distribution" && \
git pull
git add .
git commit -a -S -m "Regular update after distribution"
git push
29 changes: 13 additions & 16 deletions ptyng.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@
import warnings
from select import select

try:
import threading
except ImportError:
import dummy_threading as threading

try:
from shutil import which
except ImportError:
from backports.shutil_which import which

if sys.version_info[:2] < (3, 4):
import subprocess32 as subprocess
from backports.shutil_which import which
else:
import subprocess
from shutil import which

try:
import threading
except ImportError:
import dummy_threading as threading

try:
import psutil
Expand Down Expand Up @@ -138,7 +135,7 @@ def fork():
os.dup2(slave_fd, STDIN_FILENO)
os.dup2(slave_fd, STDOUT_FILENO)
os.dup2(slave_fd, STDERR_FILENO)
if (slave_fd > STDERR_FILENO):
if slave_fd > STDERR_FILENO:
os.close(slave_fd)

# Explicitly open the tty to make it become a controlling tty.
Expand Down Expand Up @@ -175,7 +172,7 @@ def _is_zombie(pid):
for line in proc.strip().splitlines():
_pid, stat = line.strip().decode().split()
if int(_pid) == pid:
return ('Z' in stat)
return 'Z' in stat
raise OSError(3, 'No such process')

def _fetch_child(ppid):
Expand All @@ -195,7 +192,7 @@ def _fetch_child(ppid):
def _is_zombie(pid):
"""Check if pid is in zombie stat."""
try:
return (psutil.Process(pid).status() == psutil.STATUS_ZOMBIE)
return psutil.Process(pid).status() == psutil.STATUS_ZOMBIE
except psutil.NoSuchProcess:
raise OSError(3, 'No such process')

Expand Down Expand Up @@ -234,16 +231,16 @@ def _copy(pid, master_fd, master_read=_read, stdin_read=_read):
_writen(master_fd, data)


def _kill(pid, signal, master_read):
def _kill(pid, sig, master_read):
"""Kill a process with a signal."""
class FileObject(io.IOBase):
def write(self, data):
def write(self, data): # pylint: disable=no-self-use
os.write(master_read, bytes(data, 'utf-8', 'replace'))

file = FileObject(master_read)
for chld in reversed(_fetch_child(pid)):
try:
os.kill(chld, signal)
os.kill(chld, sig)
except OSError as error:
with contextlib.suppress(OSError):
os.kill(chld, signal.SIGTERM)
Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
import subprocess

try:
import pty
import pty # pylint: disable=unused-import
except ImportError:
print('Unsupported operating system!', file=sys.stderr)
raise
sys.exit('Unsupported operating system!')

# version string
__version__ = '0.3.3'
__version__ = '0.3.3.post1'

# install requires
try:
Expand Down

0 comments on commit 06b0a1e

Please sign in to comment.