Repository: conda/conda

Issue:
conda info to show a bit more about operating system
There is some general architecture and bit-width information in the `conda info` output but it would be really handy for debugging if we provided a few more hints that would allow someone looking at the output to make a good guess as to:

* Windows version (7, 8, 10, etc)
* Linux variant and version (CentOS, RHEL, SUSE, etc.)
* Special privileges of user running `conda` command (root, Administrator)
* Variations in ownership between "root" Conda environment and user executing `conda info`


Discussion:
4.3.x conda info

OSX

```
kfranz@0283:~/continuum/conda *4.3.x ❯ python -m conda info
Current conda install:

               platform : osx-64
          conda version : 4.3.17.post60+8807d9c06
       conda is private : False
      conda-env version : 4.3.17.post60+8807d9c06
    conda-build version : 2.1.10+6.g99aaa148
         python version : 3.5.2.final.0
       requests version : 2.10.0
       root environment : /usr/local/bin/../Cellar/python3/3.5.2_1/bin/../Frameworks/Python.framework/Versions/3.5  (writable)
    default environment : /usr/local/bin/../Cellar/python3/3.5.2_1/bin/../Frameworks/Python.framework/Versions/3.5
       envs directories : /usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/envs
                          /Users/kfranz/.conda/envs
          package cache : /usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/pkgs
                          /Users/kfranz/.conda/pkgs
           channel URLs : https://repo.continuum.io/pkgs/free/osx-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/osx-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/osx-64
                          https://repo.continuum.io/pkgs/pro/noarch
            config file : /Users/kfranz/.condarc
           offline mode : False
             user-agent : conda/4.3.17.post60+8807d9c06 requests/2.10.0 CPython/3.5.2 Darwin/16.5.0 OSX/10.12.4
                UID:GID : 502:20
```

windows

```
Current conda install:
               platform : win-64
          conda version : 4.3.11
       conda is private : False
      conda-env version : 4.3.11
    conda-build version : not installed
         python version : 3.6.0.final.0
       requests version : 2.12.4
       root environment : C:\Python36_64  (writable)
    default environment : C:\Python36_64
       envs directories : C:\Python36_64\envs
                          C:\Users\appveyor\AppData\Local\conda\conda\envs
                          C:\Users\appveyor\.conda\envs
          package cache : C:\Python36_64\pkgs
                          C:\Users\appveyor\AppData\Local\conda\conda\pkgs
           channel URLs : https://repo.continuum.io/pkgs/free/win-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/win-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/win-64
                          https://repo.continuum.io/pkgs/pro/noarch
                          https://repo.continuum.io/pkgs/msys2/win-64
                          https://repo.continuum.io/pkgs/msys2/noarch
            config file : None
           offline mode : False
             user-agent : conda/4.3.11 requests/2.12.4 CPython/3.6.0 Windows/2012ServerR2 Windows/6.3.9600

```

linux

```
Current conda install:

               platform : linux-64
          conda version : 4.3.17.post61+81fba00d
       conda is private : False
      conda-env version : 4.3.17.post61+81fba00d
    conda-build version : not installed
         python version : 3.6.1.final.0
       requests version : 2.13.0
       root environment : /home/ubuntu/miniconda  (writable)
    default environment : /home/ubuntu/miniconda
       envs directories : /home/ubuntu/miniconda/envs
                          /home/ubuntu/.conda/envs
          package cache : /home/ubuntu/miniconda/pkgs
                          /home/ubuntu/.conda/pkgs
           channel URLs : https://repo.continuum.io/pkgs/free/linux-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/linux-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/linux-64
                          https://repo.continuum.io/pkgs/pro/noarch
            config file : /home/ubuntu/.condarc
           offline mode : False
             user-agent : conda/4.3.17.post61+81fba00d requests/2.13.0 CPython/3.6.1 Linux/3.13.0-117-generic debian/jessie/sid glibc/2.19    
                UID:GID : 1000:1000
```
user-agent and UID:GID get us almost all the way there I think.  UID:GID isn't applicable on windows.
> Windows version (7, 8, 10, etc)

Done.  `Windows/2012ServerR2 Windows/6.3.9600`

> Linux variant and version (CentOS, RHEL, SUSE, etc.)

Done.  `Linux/3.13.0-117-generic debian/jessie/sid glibc/2.19`

> Special privileges of user running conda command (root, Administrator)

UID:GID provides this on unix.  We should probably figure out how to add something on Windows to answer "is this user running in Admin mode."

> Variations in ownership between "root" Conda environment and user executing conda info

Done.   `root environment : /home/ubuntu/miniconda  (writable)` vs `root environment : /usr/local  (read only)` from the test at https://travis-ci.org/conda/conda/jobs/228998961#L988
Note UID:GID are actually "effective" uid and gid.  This is the information we actually want in this case I think.

Resolving patch:
diff --git a/conda/cli/main_info.py b/conda/cli/main_info.py
--- a/conda/cli/main_info.py
+++ b/conda/cli/main_info.py
@@ -223,7 +223,10 @@ def get_info_dict(system=False):
         user_agent=user_agent,
         conda_location=CONDA_PACKAGE_ROOT,
     )
-    if not on_win:
+    if on_win:
+        from ..common.platform import is_admin_on_windows
+        info_dict['is_windows_admin'] = is_admin_on_windows()
+    else:
         info_dict['UID'] = os.geteuid()
         info_dict['GID'] = os.getegid()
 
@@ -275,10 +278,10 @@ def get_main_info_str(info_dict):
                  user-agent : %(user_agent)s\
     """) % info_dict)
 
-    if not on_win:
-        builder.append("                UID:GID : %(UID)s:%(GID)s" % info_dict)
+    if on_win:
+        builder.append("          administrator : %(is_windows_admin)s" % info_dict)
     else:
-        builder.append("")
+        builder.append("                UID:GID : %(UID)s:%(GID)s" % info_dict)
 
     return '\n'.join(builder)
 
diff --git a/conda/common/platform.py b/conda/common/platform.py
--- a/conda/common/platform.py
+++ b/conda/common/platform.py
@@ -7,12 +7,26 @@
 from logging import getLogger
 import sys
 
+from .compat import iteritems, on_win
 from .._vendor.auxlib.decorators import memoize
-from .compat import iteritems
 
 log = getLogger(__name__)
 
 
+def is_admin_on_windows():  # pragma: unix no cover
+    # http://stackoverflow.com/a/1026626/2127762
+    if not on_win:  # pragma: no cover
+        return False
+    try:
+        from ctypes.windll.shell32 import IsUserAnAdmin
+        return IsUserAnAdmin() != 0
+    except ImportError:
+        return 'unknown'
+    except Exception as e:
+        log.warn(repr(e))
+        return 'unknown'
+
+
 @memoize
 def linux_get_libc_version():
     """


Test patch: