[gfal2-util/el5] Patch for wrong use of is_alive (not available in Python 2.4)
Alejandro Alvarez
aalvarez at fedoraproject.org
Wed Oct 22 14:20:01 UTC 2014
commit 3ad7fa1f5a8de670ce7cab616527371c8fe1e48a
Author: Alejandro Alvarez Ayllon <alejandro.alvarez.ayllon at cern.ch>
Date: Wed Oct 22 16:19:40 2014 +0200
Patch for wrong use of is_alive (not available in Python 2.4)
gfal2-util-isAlive.patch | 151 ++++++++++++++++++++++++++++++++++++++++++++++
gfal2-util.spec | 9 +++-
2 files changed, 159 insertions(+), 1 deletions(-)
---
diff --git a/gfal2-util-isAlive.patch b/gfal2-util-isAlive.patch
new file mode 100644
index 0000000..780afb6
--- /dev/null
+++ b/gfal2-util-isAlive.patch
@@ -0,0 +1,151 @@
+Index: test/functional/test_copy.py
+===================================================================
+--- test/functional/test_copy.py (revision 7052)
++++ test/functional/test_copy.py (revision 7054)
+@@ -1,6 +1,5 @@
+ import unittest
+ import utils
+-import shutil
+ import os
+ from base import TestBase
+
+@@ -113,5 +112,24 @@
+ os.unlink(dst_path)
+ os.rmdir('/tmp/make/')
+
++ def test_copy_pseudotty(self):
++ """
++ Regression test for DMC-522
++ Trick gfal-copy into thinking it is inside a tty so we trigger some logic that would not
++ be executed otherwise
++ """
++ ffname3 = self.ffname1 + "_copy"
++ self.assertFalse(os.path.isfile(ffname3))
++
++ (ret, out, err) = utils.run_command_pty('gfal-copy', \
++ 'file://' + self.ffname1 + ' file://' + ffname3)
++
++ self.assertTrue(os.path.isfile(ffname3))
++ self.assertNotEqual(len(out), 0) # this makes sure the interactive mode works!
++ self.assertEqual(ret, 0)
++
++ if os.path.isfile(ffname3):
++ os.remove(ffname3)
++
+ if __name__ == '__main__':
+ unittest.main()
+Index: test/functional/utils.py
+===================================================================
+--- test/functional/utils.py (revision 7052)
++++ test/functional/utils.py (revision 7054)
+@@ -1,6 +1,8 @@
+ import subprocess
+ import datetime
+ import os
++import pty
++import select
+ import stat
+ import inspect
+
+@@ -8,22 +10,48 @@
+ fout = open(path, 'w')
+ fout.write(os.urandom(size))
+ fout.close()
+-
+-
++
++
+ def create_random_suffix():
+ return datetime.datetime.now().strftime("%y%m%d_%H%M%S")
+
+ def remove_file(path):
+ os.remove(path)
+-
++
+ def run_command(cmd, args):
+ script_path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
+ cmd = script_path + '/../../src/' + cmd
+ p = subprocess.Popen([cmd] + args.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+- out,err = p.communicate()
+-
++ out, err = p.communicate()
++
+ return (p.returncode, out, err)
+
++def run_command_pty(cmd, args):
++ script_path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
++ cmd = script_path + '/../../src/' + cmd
++
++ master, slave = pty.openpty()
++ p = subprocess.Popen([cmd] + args.split(), stdout=slave, stderr=slave, close_fds=True)
++ os.close(slave)
++
++ output = ''
++ while True:
++ ready, _, _ = select.select([master], [], [], 1)
++ if ready:
++ try:
++ data = os.read(ready[0], 512)
++ except:
++ data = None
++ if data:
++ output += data
++ else:
++ break
++ os.close(master)
++
++ rstatus = p.wait()
++
++ return (rstatus, output, None)
++
+ def num_entries(directory):
+ return len([name for name in os.listdir(directory)])
+
+Index: src/gfal2_util/progress.py
+===================================================================
+--- src/gfal2_util/progress.py (revision 7052)
++++ src/gfal2_util/progress.py (revision 7054)
+@@ -3,7 +3,7 @@
+
+ @author: Duarte Meneses <duarte.meneses at cern.ch>
+ """
+-import os
++import subprocess
+ import sys
+ import datetime
+ import math
+@@ -47,8 +47,10 @@
+ if self.stopped or not self.started:
+ break
+
+- self._update()
+- self.lock.release()
++ try:
++ self._update()
++ finally:
++ self.lock.release()
+ time.sleep(0.5)
+
+ self.lock.release()
+@@ -163,7 +165,7 @@
+ if not self.started:
+ return
+
+- if self.t_main.is_alive():
++ if self.t_main.isAlive():
+ self.lock.acquire()
+ if self.stopped:
+ self.lock.release()
+@@ -194,7 +196,11 @@
+
+ @staticmethod
+ def _get_width():
+- return int(os.popen('stty size', 'r').read().split()[1])
++ p = subprocess.Popen(['stty', 'size'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
++ out, err = p.communicate()
++ if p.returncode != 0:
++ return 80 # Asume default
++ return int(out.split()[1])
+
+ @staticmethod
+ def _clean():
diff --git a/gfal2-util.spec b/gfal2-util.spec
index 4667ca3..dc52f2a 100644
--- a/gfal2-util.spec
+++ b/gfal2-util.spec
@@ -4,7 +4,7 @@
Name: gfal2-util
Version: 1.0.0
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: GFAL2 utility tools
Group: Applications/Internet
License: GPLv3
@@ -14,6 +14,9 @@ URL: https://svnweb.cern.ch/trac/lcgutil/wiki/gfal2
Source0: %{name}-%{version}.tar.gz
# Disable one test broken because of gfal2, not gfal2-util
Patch0: %{name}-disable-mkparent.patch
+# is_alive is not available in Python 2.4
+# https://its.cern.ch/jira/browse/DMC-522
+Patch1: %{name}-isAlive.patch
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildArch: noarch
@@ -39,6 +42,7 @@ python setup.py clean
%prep
%setup -q
%patch0 -p1
+%patch1 -p0
%build
python setup.py build
@@ -59,6 +63,9 @@ python test/functional/test_all.py
%changelog
+* Wed Oct 22 2014 Alejandro Alvarez <aalvarez at cern.ch> - 1.0.0-2
+- Patch for wrong use of is_alive (not available in Python 2.4)
+
* Wed Jul 02 2014 Alejandro Alvarez <aalvarez at cern.ch> - 1.0.0-1
- Update for new upstream 1.0.0 release
- Installation done with distutils
More information about the scm-commits
mailing list