]> git.ipfire.org Git - pakfire.git/commitdiff
py-compile: Make script more robust for errors.
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Oct 2012 12:56:41 +0000 (14:56 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Oct 2012 12:56:41 +0000 (14:56 +0200)
tools/py-compile

index 5ccd8f9e6198f0c4e06d19182bd7597061ec3dc1..27490426e1c535df38faac05021dfe3fb6dccad6 100755 (executable)
@@ -33,14 +33,18 @@ tempfile=$(mktemp)
 trap "rm -f ${tempfile}" EXIT
 
 cat > ${tempfile} <<EOF
+import os
 import py_compile
 import sys
 
 for file in sys.argv[1:]:
+       if not os.path.exists(file):
+               continue
+
        py_compile.compile(file, doraise=0)
 EOF
 
-filelist=$(find ${paths} -type f -a -name "*.py")
+filelist=$(find ${paths} -type f -a -name "*.py" 2>/dev/null)
 
 # Compile with optimization.
 ${python_interpreter} -O ${tempfile} ${filelist}
@@ -49,7 +53,7 @@ ${python_interpreter} -O ${tempfile} ${filelist}
 ${python_interpreter} ${tempfile} ${filelist}
 
 # Hardlink identical files.
-for pyc in $(find ${paths} -type f -a -name "*.pyc"); do
+for pyc in $(find ${paths} -type f -a -name "*.pyc" 2>/dev/null); do
        pyo="${pyc/.pyc/.pyo}"
 
        if cmp -s "${pyc}" "${pyo}"; then