o
    i	                     @   sH   d Z ddlZddlZddlZddlZddlZdd Zdd Zdd ZdS )	zQ
Utilities for getting information about Jupyter and the system it's running in.
    Nc                 C   s   t j}d}| }||krM|}|||drDztjg dtjtj| d}| \}}W n ty6   d}Y nw |rBd|	 
dfS dS ||}||ksdS )a  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
    Nz.git)gitz	rev-parsez--shortHEAD)stdoutstderrcwd
repositoryascii) r	   )ospathexistsjoin
subprocessPopenPIPEcommunicateOSErrorstripdecodedirname)pkg_pathpcur_pathpar_pathprocrepo_commit_ r   R/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/jupyter_server/_sysinfo.pypkg_commit_hash   s.   
r   c              
   C   s2   t | \}}tj| ||tjtjtjt tjd	S )zReturn 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
    )	jupyter_server_versionjupyter_server_pathcommit_sourcecommit_hashsys_versionsys_executablesys_platformplatformos_name)	r   jupyter_server__version__sysversion
executabler'   r
   name)r   srchshr   r   r   pkg_info>   s   r1   c               	   C   s,   t j} | | | | tj}t|S )z5Return useful information about the system as a dict.)	r
   r   realpathr   abspathr   r)   __file__r1   )r   r   r   r   r   get_sys_infoY   s   r5   )	__doc__r
   r'   r   r+   r)   r   r1   r5   r   r   r   r   <module>   s    0