Salome HOME
set VARS.user to Unknown is USER var not set (no more exception), extend printings...
[tools/sat.git] / src / architecture.py
index 5b8711b4a05d3e87e2a519da7fa767a3d00e8a66..7d66a03d96c31fca332b525691f28987e1561ecc 100644 (file)
@@ -35,16 +35,18 @@ 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):
     '''Gets the code for the distribution
     
@@ -54,7 +56,7 @@ def get_distribution(codes):
     :rtype: str
     '''
     if is_windows():
-        return "Win"
+        return "W"
 
     # else get linux distribution description from platform, and encode it with code
     lin_distrib = platform.dist()[0].lower()