From f715b3715377069ac88cd38e3dc44a634791a452 Mon Sep 17 00:00:00 2001 From: agnewee Date: Fri, 8 Dec 2017 23:33:04 +0800 Subject: [PATCH 1/3] modify run method --- pydu/cmd.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/pydu/cmd.py b/pydu/cmd.py index 09880f0..55fdbce 100644 --- a/pydu/cmd.py +++ b/pydu/cmd.py @@ -10,16 +10,14 @@ def run(cmd, wait=True, shell=True, timeout=0, timeinterval=1): if not wait: return p - if not timeout: - stdout, _ = p.communicate() - return p.poll(), stdout + if timeout: + while timeout > 0 and p.poll() is None: + timeout = timeout - timeinterval + time.sleep(timeinterval) + if p.poll() is None: + p.kill() + return p.poll(), 'Run timeout' - while timeout > 0 and p.poll() is None: - timeout = timeout - timeinterval - time.sleep(timeinterval) - if p.poll() is None: - p.kill() - return p.poll(), 'Run timeout' stdout, _ = p.communicate() return p.poll(), stdout From 1acb66c1671d13d68c40ce32a6e7d9b9ec4c7896 Mon Sep 17 00:00:00 2001 From: agnewee Date: Fri, 8 Dec 2017 23:56:29 +0800 Subject: [PATCH 2/3] replace useless variable --- pydu/network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydu/network.py b/pydu/network.py index f2dfe25..2d082b5 100644 --- a/pydu/network.py +++ b/pydu/network.py @@ -25,6 +25,6 @@ def is_ipv4_address(ip): def get_free_port(): s = socket.socket(socket.AF_INET, type=socket.SOCK_STREAM) s.bind(('127.0.0.1', 0)) - address, port = s.getsockname() + _, port = s.getsockname() s.close() return port From f707b8108d96d8ca57ec5b59697a989e7e0931f7 Mon Sep 17 00:00:00 2001 From: Prodesire Date: Sun, 10 Dec 2017 22:39:39 +0800 Subject: [PATCH 3/3] fix doc format erro in file --- docs/file.rst | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/docs/file.rst b/docs/file.rst index 3811cb6..1648778 100644 --- a/docs/file.rst +++ b/docs/file.rst @@ -75,7 +75,8 @@ File symlink will be created instead of copying the file it points to,else the contents of the file pointed to by symbolic links is copied. - example:copy a symlink + Example: Copy a symlink + >>> from pydu.file import copy,symlink >>> from pydu.file import makedirs,open_fle >>> open_fle('test/test.txt') @@ -85,7 +86,7 @@ File .. py:function:: pydu.file.touch(path): - open a file as write,and then close it. + Open a file as write,and then close it. >>> from pydu.file import touch >>> touch('test.txt') @@ -107,8 +108,3 @@ File >>> from pydu.file import link >>> link('test.txt','test.link') - - - - -