Skip to content

Commit

Permalink
Merge branch '0.6.x' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Mar 9, 2015
2 parents b978e6a + 20c8782 commit 370ca8a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

0.6.2 (???)
-----------

Bugfixes:
* Fixes installation on Python 3 with 7-bit locale
* Fixes reprozip not showing traceback on exception
* Fixes bug with multiple runs (`trace --continue`)

0.6.1 (2015-02-17)
------------------

Expand Down
3 changes: 3 additions & 0 deletions reprozip/native/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ int db_init(const char *filename)
" timestamp INTEGER NOT NULL,"
" exitcode INTEGER"
" );",
"CREATE INDEX proc_parent_idx ON processes(parent);",
"CREATE TABLE opened_files("
" id INTEGER NOT NULL PRIMARY KEY,"
" name TEXT NOT NULL,"
Expand All @@ -97,6 +98,7 @@ int db_init(const char *filename)
" is_directory BOOLEAN NOT NULL,"
" process INTEGER NOT NULL"
" );",
"CREATE INDEX open_proc_idx ON opened_files(process);",
"CREATE TABLE executed_files("
" id INTEGER NOT NULL PRIMARY KEY,"
" name TEXT NOT NULL,"
Expand All @@ -106,6 +108,7 @@ int db_init(const char *filename)
" envp TEXT NOT NULL,"
" workingdir TEXT NOT NULL"
" );",
"CREATE INDEX exec_proc_idx ON executed_files(process);",
};
size_t i;
for(i = 0; i < count(sql); ++i)
Expand Down
42 changes: 28 additions & 14 deletions reprozip/reprozip/tracer/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def list_directories(conn):
WHERE mode = ? OR mode = ?
''',
(FILE_WDIR, FILE_WRITE))
executed_files = ((Path(n), m) for n, m in executed_files)
executed_files = ((Path(n).resolve(), m) for n, m in executed_files)
# If WDIR, the name is a folder that was used as working directory
# If WRITE, the name is a file that was written to; its directory must
# exist
Expand Down Expand Up @@ -326,37 +326,51 @@ def write_configuration(directory, sort_packages, overwrite=False):
distribution = platform.linux_distribution()[0:2]
oldconfig = not overwrite and config.exists()
cur = conn.cursor()
if oldconfig:
if not oldconfig:
runs = []
# This gets all the top-level processes (p.parent ISNULL) and the first
# executed file for that process (sorting by ids, which are
# chronological)
executions = cur.execute(
'''
SELECT e.name, e.argv, e.envp, e.workingdir, p.exitcode
FROM processes p
JOIN executed_files e ON e.id=(
SELECT id FROM executed_files e2
WHERE e2.process=p.id
ORDER BY e2.id
LIMIT 1
)
WHERE p.parent ISNULL;
''')
else:
# Loads in previous config
runs, oldpkgs, oldfiles, patterns = load_config(config,
canonical=False,
File=TracedFile)
# Here, additional patterns are discarded

# Same query as previous block but only gets last process
executions = cur.execute(
'''
SELECT e.name, e.argv, e.envp, e.workingdir, p.exitcode
FROM executed_files e
INNER JOIN processes p on p.id=e.id
FROM processes p
JOIN executed_files e ON e.id=(
SELECT id FROM executed_files e2
WHERE e2.process=p.id
ORDER BY e2.id
LIMIT 1
)
WHERE p.parent ISNULL
ORDER BY p.id DESC
LIMIT 1;
''')
inputs = inputs[-1:]
outputs = outputs[-1:]

files, packages = merge_files(files, packages,
oldfiles,
oldpkgs)
else:
runs = []
executions = cur.execute(
'''
SELECT e.name, e.argv, e.envp, e.workingdir, p.exitcode
FROM executed_files e
INNER JOIN processes p on p.id=e.id
WHERE p.parent ISNULL
ORDER BY p.id;
''')
for ((r_name, r_argv, r_envp, r_workingdir, r_exitcode),
input_files, output_files) in izip(executions, inputs, outputs):
# Decodes command-line
Expand Down

0 comments on commit 370ca8a

Please sign in to comment.