ó
ù2¢\c           @@  s“   d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m	 Z	 m
 Z
 d d l Z d „  Z d „  Z d „  Z d S(   sQ   
Utilities for getting information about Jupyter and the system it's running in.
i    (   t   absolute_importN(   t	   py3compatt   encodingc         C@  så   t  j } d } |  } xÉ | | k rà | } | j | j | d ƒ ƒ rÎ yI t j d d d d g d t j d t j d |  ƒ} | j ƒ  \ } } Wn t	 k
 r§ d } n X| rÇ d	 | j
 ƒ  j d
 ƒ f Sd Sn  | j | ƒ } q Wd S(   sÂ  Get short form of commit hash given directory `pkg_path`

    We get the commit hash from git if it's a repo.

    If this fail, we return a not-found placeholder tuple

    Parameters
    ----------
    pkg_path : str
       directory containing package
       only used for getting commit from active repo

    Returns
    -------
    hash_from : str
       Where we got the hash from - description
    hash_str : str
       short form of hash
    s   .gitt   gits	   rev-parses   --shortt   HEADt   stdoutt   stderrt   cwdt
   repositoryt   asciiu    N(   u    u    (   u    u    (   t   ost   patht   Nonet   existst   joint
   subprocesst   Popent   PIPEt   communicatet   OSErrort   stript   decodet   dirname(   t   pkg_patht   pt   cur_patht   par_patht   proct   repo_committ   _(    (    s0   lib/python2.7/site-packages/notebook/_sysinfo.pyt   pkg_commit_hash   s&    				
c         C@  sm   t  |  ƒ \ } } t d t j d |  d | d | d t j d t j d t j d t j ƒ  d	 t j	 d
 t
 j ƒ 
S(   sí   Return dict describing the context of this package

    Parameters
    ----------
    pkg_path : str
       path containing __init__.py for package

    Returns
    -------
    context : dict
       with named parameters of interest
    t   notebook_versiont   notebook_patht   commit_sourcet   commit_hasht   sys_versiont   sys_executablet   sys_platformt   platformt   os_namet   default_encoding(   R   t   dictt   notebookt   __version__t   syst   versiont
   executableR&   R
   t   nameR   t   DEFAULT_ENCODING(   R   t   srct   hsh(    (    s0   lib/python2.7/site-packages/notebook/_sysinfo.pyt   pkg_infoC   s    					c          C@  s@   t  j }  |  j |  j |  j |  j t j ƒ ƒ ƒ ƒ } t | ƒ S(   s5   Return useful information about the system as a dict.(	   R
   R   t   realpathR   t   abspathR   R*   t   __file__R3   (   R   R   (    (    s0   lib/python2.7/site-packages/notebook/_sysinfo.pyt   get_sys_info^   s    	-(   t   __doc__t
   __future__R    R
   R&   t   pprintR,   R   t   ipython_genutilsR   R   R*   R   R3   R7   (    (    (    s0   lib/python2.7/site-packages/notebook/_sysinfo.pyt   <module>   s   	.	