Skip to content

Commit

Permalink
Merge branch '1.0.x' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Jul 9, 2020
2 parents 0e390ad + 5104de9 commit 9163d3d
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 42 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ jobs:
;;
checks)
flake8 --ignore=E731,W504
find scripts -name '*.py' -exec flake8 {} +
diff -q reprozip/reprozip/common.py reprounzip/reprounzip/common.py
diff -q reprozip/reprozip/utils.py reprounzip/reprounzip/utils.py
find reprozip reprounzip reprozip-* reprounzip-* .travis -name '*.py' -or -name '*.sh' -or -name '*.h' -or -name '*.c' | (set +x; while read i; do
Expand Down
2 changes: 1 addition & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Besides Python and pip, each component or plugin to be used may have additional
.. [#bug3] ``reprozip`` and ``reprounzip graph`` will not work before 2.7.3 due to `Python bug 13676 <https://bugs.python.org/issue13676>`__ related to sqlite3. Python 2.6 is ancient and unsupported.
.. [#pycrypto3] A working C compiler is required to build PyCrypto. For installation without building from source, please see `this page <https://stackoverflow.com/questions/11405549/how-do-i-install-pycrypto-on-windows>`__.
.. [#vis3] `VisTrails v2.2.3+ <https://www.vistrails.org/>`__ is required to run the workflow generated by the plugin.
.. [#windowshome] Windows Professional Edition is required for Docker, it will not work on Windows Home Edition; `see FAQ <https://docs.docker.com/docker-for-windows/faqs/#why-is-windows-10-home-not-supported#can-i-install-docker-desktop-on-windows-10-home>`__.
.. [#windowshome] Windows Professional Edition is required for Docker, it will not work on Windows Home Edition; `see FAQ <https://docs.docker.com/docker-for-windows/faqs/#can-i-install-docker-desktop-on-windows-10-home>`__.
Installing *reprounzip*
-----------------------
Expand Down
19 changes: 14 additions & 5 deletions docs/packing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,27 @@ When reproducing an experiment that communicates with a server, the experiment w

and use *reprozip* to trace the script execution, rather than the experiment itself. In this way, ReproZip is able to capture the local server as well, which ensures that the server will be alive at the time of the reproduction.

For example, if you have an web app that uses PostgreSQL and that runs until ``Ctrl+C`` is received, you can use the following script::
For example, if you have an web app that uses MySQL and that runs until ``Ctrl+C`` is received, you can use the following script::

#!/bin/sh

/etc/init.d/postgresql start # Start PostgreSQL
if [ "$(id -u)" != 0 ]; then echo "This script needs to run as root so that it can execute MySQL" >&2; exit 1; fi

trap ' ' INT # Don't exit the whole script on Ctrl+C
# Start MySQL
sudo -u mysql /usr/sbin/mysqld --pid-file=/run/mysqld/mysqld.pid &
sleep 5

# Don't exit the whole script on Ctrl+C
trap ' ' INT

# Execute actual experiment that uses the database
./manage.py runserver 0.0.0.0:8000

trap - INT

/etc/init.d/postgresql stop # Stop PostgreSQL
# Graceful shutdown
/usr/bin/mysqladmin shutdown

Note the use of ``trap`` to avoid exiting the entire script when pressing ``Ctrl+C``, to make sure that the database gets shutdown via the next command.

Excluding Sensitive and Third-Party Information
Expand Down
8 changes: 2 additions & 6 deletions docs/troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@ Please feel free to contact us at users@reprozip.org if you encounter issues whi

$ reprozip trace service mysql start

you can trace either the `init` script::

$ reprozip trace /etc/init.d/mysql start

or the binary::
you can trace the binary::

$ reprozip trace /usr/bin/mysqld

Note that, if you choose to trace the binary, you need to figure out the right command line options to use.
Also, make sure that systemd is not called, since ReproZip and systemd currently do not get along well.
Also, note that running the init script in ``/etc/init.d/...`` is not enough, since those scripts get subverted to call `systemctl` when systemd is installed.

------------

Expand Down
10 changes: 5 additions & 5 deletions reprounzip/reprounzip/unpackers/common/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def get_packages_info(packages):
pkgs_dict = dict((pkg.name, (pkg, PKG_NOT_INSTALLED))
for pkg in packages)
try:
for l in p.stdout:
fields = l.split()
for line in p.stdout:
fields = line.split()
if len(fields) == 2:
name = fields[0].decode('ascii')
status = fields[1].decode('ascii')
Expand Down Expand Up @@ -124,9 +124,9 @@ def get_packages_info(packages):
pkgs_dict = dict((pkg.name, (pkg, PKG_NOT_INSTALLED))
for pkg in packages)
try:
for l in p.stdout:
if l[0] == b'+':
fields = l[1:].split()
for line in p.stdout:
if line[0] == b'+':
fields = line[1:].split()
if len(fields) == 2:
name = fields[0].decode('ascii')
status = fields[1].decode('ascii')
Expand Down
8 changes: 4 additions & 4 deletions reprounzip/reprounzip/unpackers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ def directory_run(args):
stderr=subprocess.PIPE)
stdout, _ = p.communicate()
try:
for l in stdout.splitlines():
if len(l) < 2 or l[0] in (b' ', b'\t'):
for line in stdout.splitlines():
if len(line) < 2 or line[0] in (b' ', b'\t'):
continue
if l.endswith(b':'):
lib_dirs.append(Path(l[:-1]))
if line.endswith(b':'):
lib_dirs.append(Path(line[:-1]))
finally:
if p.returncode != 0:
raise subprocess.CalledProcessError(p.returncode,
Expand Down
4 changes: 2 additions & 2 deletions reprozip/reprozip/tracer/linux_pkgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def search_for_files(self, files):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = proc.communicate()
for l in out.splitlines():
pkgname, path = l.split(b': ', 1)
for line in out.splitlines():
pkgname, path = line.split(b': ', 1)
path = Path(path.strip())
# 8-bit safe encoding, because this might be a localized error
# message (that we don't care about)
Expand Down
4 changes: 2 additions & 2 deletions scripts/conda/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def build_pkg(python_ver, package_name):
with open(join(temp_dir, package_name, 'meta.yaml')) as fp:
lines = fp.readlines()
# Changes version in recipe
lines = [l.replace('_REPLACE_version_REPLACE_', version)
for l in lines]
lines = [line.replace('_REPLACE_version_REPLACE_', version)
for line in lines]
with open(join(temp_dir, package_name, 'meta.yaml'), 'w') as fp:
for line in lines:
# Changes version
Expand Down
30 changes: 16 additions & 14 deletions tests/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ def functional_tests(raise_warnings, interactive, run_vagrant, run_docker):
#

output = check_output(rpz + ['testrun', '/bin/echo', 'outputhere'])
assert any(b' 1 | /bin/echo outputhere ' in l
for l in output.splitlines())
assert any(b' 1 | /bin/echo outputhere ' in line
for line in output.splitlines())

output = check_output(rpz + ['testrun', '-a', '/fake/path/echo',
'/bin/echo', 'outputhere'])
assert any(b' 1 | (/bin/echo) /fake/path/echo outputhere ' in l
for l in output.splitlines())
assert any(b' 1 | (/bin/echo) /fake/path/echo outputhere ' in line
for line in output.splitlines())

# ########################################
# testrun multiple commands
Expand Down Expand Up @@ -549,8 +549,8 @@ def check_simple(args, stream, infile=1):
build('threads', ['threads.c'], ['-lpthread'])
# Trace
output = check_output(rpz + ['testrun', './threads'], 'err')
assert any(b'successfully exec\'d /bin/./echo' in l
for l in output.splitlines())
assert any(b'successfully exec\'d /bin/./echo' in line
for line in output.splitlines())

# ########################################
# 'threads2' program: testrun
Expand All @@ -560,8 +560,8 @@ def check_simple(args, stream, infile=1):
build('threads2', ['threads2.c'], ['-lpthread'])
# Trace
output = check_output(rpz + ['testrun', './threads2'], 'err')
assert any(b'successfully exec\'d /bin/echo' in l
for l in output.splitlines())
assert any(b'successfully exec\'d /bin/echo' in line
for line in output.splitlines())

# ########################################
# 'segv' program: testrun
Expand Down Expand Up @@ -634,9 +634,10 @@ def check_simple(args, stream, infile=1):
# Trace
err = check_output(rpz + ['testrun', './connect'], 'err')
err = err.split(b'\n')
assert not any(b'program exited with non-zero code' in l for l in err)
assert any(re.search(br'process connected to [0-9.]+:80', l)
for l in err)
assert not any(b'program exited with non-zero code' in line
for line in err)
assert any(re.search(br'process connected to [0-9.]+:80', line)
for line in err)

# ########################################
# 'vfork' program: testrun
Expand All @@ -647,7 +648,8 @@ def check_simple(args, stream, infile=1):
# Trace
err = check_output(rpz + ['testrun', './vfork'], 'err')
err = err.split(b'\n')
assert not any(b'program exited with non-zero code' in l for l in err)
assert not any(b'program exited with non-zero code' in line
for line in err)

# ########################################
# 'rename' program: trace
Expand Down Expand Up @@ -813,7 +815,7 @@ def check_simple(args, stream, infile=1):
'94627ebfafbf81cd77a17d4ed646a80c94bf4202'],
'err')
err = err.split(b'\n')
assert any(b'executing set-uid binary!' in l for l in err)
assert any(b'executing set-uid binary!' in line for line in err)

# ########################################
# Test set-gid warning
Expand All @@ -828,7 +830,7 @@ def check_simple(args, stream, infile=1):
# Pass a wrong username to su to make it exit without reading a password
_, err = call_output(rpz + ['testrun', executable, '-l'], 'err')
err = err.split(b'\n')
assert any(b'executing set-gid binary!' in l for l in err)
assert any(b'executing set-gid binary!' in line for line in err)

# ########################################
# Test old packages
Expand Down
4 changes: 2 additions & 2 deletions tests/test_reprozip.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ def fail(s):
set(fi.path for fi in files))
self.assertEqualPaths([set(["/some/r", "/some/rw"]),
set(["/some/cli", "/some/r"])],
[set(l) for l in inputs])
[set(run) for run in inputs])
self.assertEqualPaths([set(["/some/cli"]), set(["/some/rw"])],
[set(l) for l in outputs])
[set(run) for run in outputs])
finally:
Path.is_file, Path.stat = old

Expand Down

0 comments on commit 9163d3d

Please sign in to comment.