From: crouzet Date: Fri, 29 Nov 2019 10:27:35 +0000 (+0100) Subject: set VARS.user to Unknown is USER var not set (no more exception), extend printings... X-Git-Tag: 5.5.0~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=46f6029af905d76f63468622e56ddcb8fa4a8c59;p=tools%2Fsat.git set VARS.user to Unknown is USER var not set (no more exception), extend printings of show_properties option in config --- diff --git a/commands/config.py b/commands/config.py index c089074..ca3da05 100644 --- a/commands/config.py +++ b/commands/config.py @@ -810,18 +810,23 @@ def show_properties(config, logger): :param config Config: the global configuration. :param logger Logger: The logger instance to use for the display ''' + if "properties" in config.APPLICATION: + # some properties are defined at application level, we display them + logger.write("Application properties:\n", 1) + for prop in config.APPLICATION.properties: + logger.write(src.printcolors.printcInfo(" %s : %s\n" % (prop, config.APPLICATION.properties[prop])), 1) oneOrMore = False for product in sorted(config.APPLICATION.products): try: product_info = src.product.get_product_config(config, product) done = False try: - for i in product_info.properties: + for prop in product_info.properties: if not done: logger.write("%s:\n" % product, 1) done = True oneOrMore = True - logger.write(src.printcolors.printcInfo(" %s\n" % i), 1) + logger.write(src.printcolors.printcInfo(" %s : %s\n" % (prop, product_info.properties[prop])), 1) except Exception as e: pass except Exception as e: diff --git a/src/architecture.py b/src/architecture.py index b6b3688..7d66a03 100644 --- a/src/architecture.py +++ b/src/architecture.py @@ -35,14 +35,16 @@ def get_user(): :rtype: str ''' - # In windows case, the USERNAME environment variable has to be set - if is_windows(): - if not 'USERNAME' in os.environ: - raise Exception('USERNAME environment variable not set') - return os.environ['USERNAME'] - else: # linux - import pwd - return pwd.getpwuid(os.getuid())[0] + try : + if is_windows(): + # In windows case, the USERNAME environment variable has to be set + user_name=os.environ['USERNAME'] + else: # linux + import pwd + user_name=pwd.getpwuid(os.getuid())[0] + except : + user_name="Unknown" + return user_name def get_distribution(codes):