]>
Commit | Line | Data |
---|---|---|
4fec525d MT |
1 | From 61918bfab20eaba61bb8ce7e8397a28806d029d2 Mon Sep 17 00:00:00 2001 |
2 | From: Michael Tremer <michael.tremer@ipfire.org> | |
3 | Date: Wed, 3 Oct 2012 14:56:41 +0200 | |
4 | Subject: [PATCH 8/8] py-compile: Make script more robust for errors. | |
5 | ||
6 | --- | |
7 | tools/py-compile | 8 ++++++-- | |
8 | 1 file changed, 6 insertions(+), 2 deletions(-) | |
9 | ||
10 | diff --git a/tools/py-compile b/tools/py-compile | |
11 | index 5ccd8f9..2749042 100755 | |
12 | --- a/tools/py-compile | |
13 | +++ b/tools/py-compile | |
14 | @@ -33,14 +33,18 @@ tempfile=$(mktemp) | |
15 | trap "rm -f ${tempfile}" EXIT | |
16 | ||
17 | cat > ${tempfile} <<EOF | |
18 | +import os | |
19 | import py_compile | |
20 | import sys | |
21 | ||
22 | for file in sys.argv[1:]: | |
23 | + if not os.path.exists(file): | |
24 | + continue | |
25 | + | |
26 | py_compile.compile(file, doraise=0) | |
27 | EOF | |
28 | ||
29 | -filelist=$(find ${paths} -type f -a -name "*.py") | |
30 | +filelist=$(find ${paths} -type f -a -name "*.py" 2>/dev/null) | |
31 | ||
32 | # Compile with optimization. | |
33 | ${python_interpreter} -O ${tempfile} ${filelist} | |
34 | @@ -49,7 +53,7 @@ ${python_interpreter} -O ${tempfile} ${filelist} | |
35 | ${python_interpreter} ${tempfile} ${filelist} | |
36 | ||
37 | # Hardlink identical files. | |
38 | -for pyc in $(find ${paths} -type f -a -name "*.pyc"); do | |
39 | +for pyc in $(find ${paths} -type f -a -name "*.pyc" 2>/dev/null); do | |
40 | pyo="${pyc/.pyc/.pyo}" | |
41 | ||
42 | if cmp -s "${pyc}" "${pyo}"; then | |
43 | -- | |
44 | 1.7.11.4 | |
45 |