Salome HOME
set VARS.user to Unknown is USER var not set (no more exception), extend printings...
authorcrouzet <nicolas.crouzet@cea.fr>
Fri, 29 Nov 2019 10:27:35 +0000 (11:27 +0100)
committercrouzet <nicolas.crouzet@cea.fr>
Fri, 29 Nov 2019 10:27:35 +0000 (11:27 +0100)
commands/config.py
src/architecture.py

index c089074dc8fec98974bbd2959041db698cde0fd6..ca3da051c2c6093d20fdc4d92f1a7537a667d21c 100644 (file)
@@ -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:
index b6b368896234bd0f3eefcbf4fdf5d696058212ec..7d66a03d96c31fca332b525691f28987e1561ecc 100644 (file)
@@ -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):