diff options
author | 2018-12-19 00:58:53 +0000 | |
---|---|---|
committer | 2019-01-15 23:56:02 -0800 | |
commit | fe2ab7484a101b8539c765cc02ece39e989aead7 (patch) | |
tree | 8874f386ca0945c48aed0f8cca09102a2b06218a | |
parent | 79d9ce794b1af2032cc83544eaa8044aa53d203f (diff) | |
download | srtool-fe2ab7484a101b8539c765cc02ece39e989aead7.tar.gz srtool-fe2ab7484a101b8539c765cc02ece39e989aead7.tar.bz2 srtool-fe2ab7484a101b8539c765cc02ece39e989aead7.zip |
views: use subprocess directly
-rw-r--r-- | lib/srtgui/views.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/srtgui/views.py b/lib/srtgui/views.py index 6532dbe1..088a716d 100644 --- a/lib/srtgui/views.py +++ b/lib/srtgui/views.py @@ -1654,15 +1654,10 @@ def xhr_investigation_commit(request): try: cmd_list = SrtSetting.objects.get(name='SRTOOL_DEFECT_ADD').value.split(' ') cmd_list.append(query) - returncode, stdout, stderr = run(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - if 0 == returncode: - defect = Defect.objects.get(name=query) - else: - _log("ERROR:submit-attachdefect:%s:STDOUT='%s':STDERR='%s':" % (returncode,stdout,stderr)) - defect = None - return HttpResponse(json.dumps({"error":stderr + "\n"}), content_type = "application/json") - except Exception as e: - _log("xhr_investigation_commit:Error in defect attach query:(%s)\n" % e) + subprocess.check_output(cmd_list, stderr=subprocess.STDOUT, universal_newlines=True) + defect = Defect.objects.get(name=query) + except subprocess.CalledProcessError as e: + _log("ERROR:submit-attachdefect:%d:STDOUT='%s':" % (e.returncode, e.output)) return HttpResponse(json.dumps({"error":str(e) + "\n"}), content_type = "application/json") if defect: InvestigationToDefect.objects.get_or_create(investigation_id=invst_id, defect_id=defect.id, product_id=product_id) |