aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/resources/scripts/import/tosca/importCommon.py
blob: acdb067849f0f84077db5e933b560c0738b3dcb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import pycurl
import sys, getopt
from StringIO import StringIO
import json
import copy

###############################################################################################################
#
#
###############################################################################################################

debugFlag = True

def join_strings(lst):
    concat = ""
    for string in lst:
	if (string != None):
		if (type(string) == int):
			string = str(string)
        	concat += (string + " ")
    return concat

def debug(desc, *args):
	'print only if debug enabled'
	if (debugFlag == True): 
		print desc, join_strings(args)  

def log(desc, arg=None):
	'print log info'
	print desc, arg  

def errorAndExit(errorCode, errorDesc):
	if ( errorCode > 0 ):
		print "status={0}. {1}".format(errorCode, '' if errorDesc == None else errorDesc) 
	else:
		print "status={0}".format(errorCode)
	sys.exit(errorCode)

def printNameAndReturnCode(name, code):
	print "{0:30} | {1:6}".format(name, code)	

def printFrameLine():
	print "----------------------------------------"