summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Shetye2025-05-22 18:01:01 +0530
committerSunil Shetye2025-05-22 18:01:01 +0530
commit8b10e91010159297b848bd6e1c0a13976a973d42 (patch)
treeaab951cff87fdfc926f6fde1385c6ed50876fe06
parentdf3e9b12c44efb317396ea19b47eb0452df964d6 (diff)
downloadCommon-Interface-Project-8b10e91010159297b848bd6e1c0a13976a973d42.tar.gz
Common-Interface-Project-8b10e91010159297b848bd6e1c0a13976a973d42.tar.bz2
Common-Interface-Project-8b10e91010159297b848bd6e1c0a13976a973d42.zip
push last error message to frontend
-rwxr-xr-xblocks/Xcos/XmlToXcos.sh28
-rw-r--r--blocks/simulationAPI/helpers/ngspice_helper.py10
-rw-r--r--blocks/simulationAPI/tasks.py9
-rwxr-xr-xblocks/xcos2xml/replacesplitblocks.sh40
4 files changed, 47 insertions, 40 deletions
diff --git a/blocks/Xcos/XmlToXcos.sh b/blocks/Xcos/XmlToXcos.sh
index df8a32c2..99cdc57b 100755
--- a/blocks/Xcos/XmlToXcos.sh
+++ b/blocks/Xcos/XmlToXcos.sh
@@ -2,11 +2,11 @@
usage() {
echo "Usage:" >&2
- echo " $0 input-file.xml workspace.dat" >&2
+ echo " $0 input-file.xml [workspace.dat]" >&2
exit 101
}
-if test $# -ne 2; then
+if test $# -lt 1 -o $# -gt 2; then
usage
fi
@@ -24,6 +24,16 @@ else
fi
WORKSPACE="$2"
+if test -n "$WORKSPACE"; then
+ if test ! -f "$WORKSPACE"; then
+ echo "$WORKSPACE: not found" >&2
+ usage
+ fi
+ if test "${WORKSPACE%.dat}" = "$WORKSPACE"; then
+ echo "$WORKSPACE: not dat" >&2
+ usage
+ fi
+fi
CONTEXT=""
@@ -36,8 +46,8 @@ rm -f "$BASE-"*.xml
oldrv=100
-echo "Running Xcos/XmlParser.py $INPUT1" >&2
-Xcos/XmlParser.py "$INPUT1" >&2 && rv=$? || rv=$?
+echo "Running Xcos/XmlParser.py $INPUT1"
+Xcos/XmlParser.py "$INPUT1" && rv=$? || rv=$?
if ((rv >= oldrv)); then
echo "ERROR: $rv >= $oldrv" >&2
@@ -50,8 +60,8 @@ while test $rv -gt 0; do
INPUT1="$BASE-$rv.xml"
xmllint --format "$INPUT1" >"$TMPFILE2"
cp -f "$TMPFILE2" "$INPUT1"
- echo "Running Xcos/XmlParser.py $INPUT1" >&2
- Xcos/XmlParser.py "$INPUT1" >&2 && rv=$? || rv=$?
+ echo "Running Xcos/XmlParser.py $INPUT1"
+ Xcos/XmlParser.py "$INPUT1" && rv=$? || rv=$?
if ((rv >= oldrv)); then
echo "ERROR: $rv >= $oldrv" >&2
@@ -63,9 +73,9 @@ INPUT1="$BASE-$rv.xml"
xmllint --format "$INPUT1" >"$TMPFILE2"
cp -f "$TMPFILE2" "$INPUT1"
-echo "Running Xcos/MxGraphParser.py $INPUT1 $WORKSPACE $CONTEXT" >&2
-Xcos/MxGraphParser.py "$INPUT1" "$WORKSPACE" "$CONTEXT" >&2
+echo "Running Xcos/MxGraphParser.py $INPUT1 $WORKSPACE $CONTEXT"
+Xcos/MxGraphParser.py "$INPUT1" "$WORKSPACE" "$CONTEXT"
INPUT1="$BASE.xcos"
-echo "Created $INPUT1" >&2
+echo "Created $INPUT1"
exit 0
diff --git a/blocks/simulationAPI/helpers/ngspice_helper.py b/blocks/simulationAPI/helpers/ngspice_helper.py
index 58104749..52cb356b 100644
--- a/blocks/simulationAPI/helpers/ngspice_helper.py
+++ b/blocks/simulationAPI/helpers/ngspice_helper.py
@@ -91,11 +91,17 @@ def CreateXml(file_path, parameters, task_id, workspace_file):
if proc.returncode != 0:
logger.error('%s error encountered', 'XmlToXcos')
logger.error('rv=%s', proc.returncode)
+ msg = 'exited with error'
if stdout:
logger.info('Stdout:\n%s', stdout.decode())
if stderr:
- logger.error('Stderr:\n%s', stderr.decode())
- raise CannotRunParser('exited with error')
+ stderr = stderr.decode()
+ logger.error('Stderr:\n%s', stderr)
+ # Get last non-empty line from stderr
+ last_line = next((line for line in reversed(stderr.strip().splitlines()) if line.strip()), None)
+ if last_line:
+ msg = last_line
+ raise CannotRunParser(msg)
logger.info('Ran %s', 'XmlToXcos')
return xcosfile
diff --git a/blocks/simulationAPI/tasks.py b/blocks/simulationAPI/tasks.py
index c26ab3da..3e2b791b 100644
--- a/blocks/simulationAPI/tasks.py
+++ b/blocks/simulationAPI/tasks.py
@@ -61,15 +61,6 @@ def process_task(self, task_id):
return output
- except Exception as e:
- update_task_status(task_id, 'FAILURE',
- meta={
- 'exc_type': type(e).__name__,
- 'exc_message': str(e)
- })
- logger.exception('Exception Occurred:')
- raise Ignore()
-
finally:
release_lock(lock) # Ensure lock is always released
diff --git a/blocks/xcos2xml/replacesplitblocks.sh b/blocks/xcos2xml/replacesplitblocks.sh
index 6c5a29c5..0b5f751a 100755
--- a/blocks/xcos2xml/replacesplitblocks.sh
+++ b/blocks/xcos2xml/replacesplitblocks.sh
@@ -2,16 +2,16 @@
usage() {
echo "Usage:" >&2
- echo " $0 input-file.xcos [workspace.dat] [context]" >&2
- echo " $0 input-file.xml [workspace.dat] [context]" >&2
+ echo " $0 input-file.xcos [workspace.dat]" >&2
+ echo " $0 input-file.xml [workspace.dat]" >&2
exit 101
}
-if test $# -lt 1 -o $# -gt 3; then
+if test $# -lt 1 -o $# -gt 2; then
usage
fi
-make -s >&2
+make -s
SPLITXSL="eda-frontend/public/splitblock.xsl"
if test ! -f "$SPLITXSL"; then
@@ -72,7 +72,7 @@ if test -n "$WORKSPACE"; then
fi
fi
-CONTEXT="$3"
+CONTEXT=""
set -e
@@ -82,19 +82,19 @@ trap "rm -f $TMPFILE1 $TMPFILE2" 0 1 2 15
if test -n "$INPUTXML"; then
xmllint --format "$INPUTXML" >"$TMPFILE2"
- if ! diff -q "$TMPFILE2" "$INPUTXML" >&2; then
+ if ! diff -q "$TMPFILE2" "$INPUTXML"; then
cp -f "$TMPFILE2" "$INPUTXML"
- echo "$INPUTXML updated" >&2
+ echo "$INPUTXML updated"
fi
# MxGraphParser creates $INPUT
- echo "Running Xcos/MxGraphParser.py $INPUTXML $WORKSPACE $CONTEXT" >&2
- Xcos/MxGraphParser.py "$INPUTXML" "$WORKSPACE" "$CONTEXT" >&2
+ echo "Running Xcos/MxGraphParser.py $INPUTXML $WORKSPACE $CONTEXT"
+ Xcos/MxGraphParser.py "$INPUTXML" "$WORKSPACE" "$CONTEXT"
fi
count=$(grep -c '^ <SplitBlock' "$INPUT") || :
INPUT1="$BASE-$count.xml"
-echo "Creating $INPUT1" >&2
+echo "Creating $INPUT1"
cp -f "$INPUT" "$INPUT1"
while test $count -gt 0; do
@@ -104,7 +104,7 @@ while test $count -gt 0; do
xmllint --format "$TMPFILE1" >"$TMPFILE2"
count=$(grep -c '^ <SplitBlock' "$TMPFILE2") || :
INPUT1="$BASE-$count.xml"
- echo "Creating $INPUT1" >&2
+ echo "Creating $INPUT1"
cp -f "$TMPFILE2" "$INPUT1"
if ((count != oldcount - 1)); then
@@ -116,7 +116,7 @@ done
xsltproc "$XSL" "$INPUT1" >"$TMPFILE1"
xmllint --format "$TMPFILE1" >"$TMPFILE2"
INPUT1="$BASE-xcos2xml.xml"
-echo "Creating $INPUT1" >&2
+echo "Creating $INPUT1"
cp -f "$TMPFILE2" "$INPUT1"
# Change BASE
@@ -125,15 +125,15 @@ BASE="$BASE-geometry"
xsltproc "$GEOMETRYXSL" "$INPUT1" >"$TMPFILE1"
xmllint --format "$TMPFILE1" >"$TMPFILE2"
INPUT1="$BASE.xml"
-echo "Creating $INPUT1" >&2
+echo "Creating $INPUT1"
cp -f "$TMPFILE2" "$INPUT1"
rm -f "$BASE-"*.xml
oldrv=100
-echo "Running Xcos/XmlParser.py $INPUT1" >&2
-Xcos/XmlParser.py "$INPUT1" >&2 && rv=$? || rv=$?
+echo "Running Xcos/XmlParser.py $INPUT1"
+Xcos/XmlParser.py "$INPUT1" && rv=$? || rv=$?
if ((rv >= oldrv)); then
echo "ERROR: $rv >= $oldrv" >&2
@@ -146,8 +146,8 @@ while test $rv -gt 0; do
INPUT1="$BASE-$rv.xml"
xmllint --format "$INPUT1" >"$TMPFILE2"
cp -f "$TMPFILE2" "$INPUT1"
- echo "Running Xcos/XmlParser.py $INPUT1" >&2
- Xcos/XmlParser.py "$INPUT1" >&2 && rv=$? || rv=$?
+ echo "Running Xcos/XmlParser.py $INPUT1"
+ Xcos/XmlParser.py "$INPUT1" && rv=$? || rv=$?
if ((rv >= oldrv)); then
echo "ERROR: $rv >= $oldrv" >&2
@@ -159,9 +159,9 @@ INPUT1="$BASE-$rv.xml"
xmllint --format "$INPUT1" >"$TMPFILE2"
cp -f "$TMPFILE2" "$INPUT1"
-echo "Running Xcos/MxGraphParser.py $INPUT1 $WORKSPACE $CONTEXT" >&2
-Xcos/MxGraphParser.py "$INPUT1" "$WORKSPACE" "$CONTEXT" >&2
+echo "Running Xcos/MxGraphParser.py $INPUT1 $WORKSPACE $CONTEXT"
+Xcos/MxGraphParser.py "$INPUT1" "$WORKSPACE" "$CONTEXT"
INPUT1="$BASE.xcos"
-echo "Created $INPUT1" >&2
+echo "Created $INPUT1"
exit 0