Bug fixe version info print 39/60939/1
authorshangxdy <shang.xiaodong@zte.com.cn>
Tue, 14 Aug 2018 14:03:34 +0000 (22:03 +0800)
committershangxdy <shang.xiaodong@zte.com.cn>
Tue, 14 Aug 2018 14:03:34 +0000 (22:03 +0800)
If parser Tosca error happens, it may not exist version info;
So it needs a process before print it.

JIRA: PARSER-183

Change-Id: I283d1d794b0db19f83a9abc0eee3962e94e21572
Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
tosca2heat/tosca-parser/toscaparser/shell.py

index 88c7473..83a015c 100644 (file)
@@ -97,9 +97,10 @@ class ParserShell(object):
             else:
                 raise e
 
-        version = tosca.version if tosca else "unknown"
-        if tosca and tosca.version:
-            print("\nversion: " + version)
+        if tosca and hasattr(tosca, 'version'):
+            print("\nversion: " + tosca.version)
+        else:
+            print("\nversion: " + "unknown")
 
         if tosca and hasattr(tosca, 'description'):
             description = tosca.description