ó
ÉÝ{Tc           @   sö   d  Z  d d l m Z m Z d d l Z d d l Z d d l Z d d l Z e d „ Z	 d „  Z
 d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d e j f d „  ƒ  YZ e d k rò d e j k rÏ e j ƒ  n  e ƒ  GHe ƒ  GHe ƒ  GHe ƒ  GHn  d S(   s   
Technical information
iÿÿÿÿ(   t   QtCoret   QtGuiNc         C   s>   t  j ƒ  } t | d ƒ s- t | ƒ | _ n  | j j ƒ  d  S(   Nt   tech_dialog(   t   MGApplicationt   GetMainWindowt   hasattrt	   AboutTechR   t   UnClose(   t   checkedt   mainwin(    (    sH   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/plugins/TechnicalInfo.pyt   handleTechDialog   s    c          C   sš   t  j ƒ  }  t j j d ƒ s– i  } d | d <t j j t j j t	 ƒ ƒ | d <d | d <d | d <|  j
 | d | d d	 t ƒ} | j j t ƒ n  d  S(
   Ns   -quitt   technicalinfot   icont	   icon_paths   Technical informationt   textt   tipt   Toolst	   draw_menu(   R   R   t   syst   argvt   countt   ost   patht   normpatht   dirnamet   __file__t   addMenuDefinitiont   Falset	   triggeredt   connectR
   (   R	   t	   menu_defnt   window_item(    (    sH   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/plugins/TechnicalInfo.pyt   initializePlugin#   s    
"

c          C   sœ   d }  t  j j t  j j t  j d d d ƒ ƒ r˜ yT t t  j j t  j d d d ƒ ƒ } | j ƒ  } x | D] } |  | d 7}  ql WWq˜ d }  q˜ Xn  |  S(   Nt    t   CCP4MGt   libt	   TIMESTAMPs   <br>t   Unknown(   R   R   t   existst   joint   environt   opent	   readlines(   R   t   ft   linest   l(    (    sH   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/plugins/TechnicalInfo.pyt   getBuildInfo.   s    +%c          C   s°   y¡ d d  l  }  |  j d  |  j ƒ } |  j | d ƒ } xM t d ƒ D]? } y/ |  j | | ƒ \ } } } | d k rw | SWqC qC XqC W|  j | ƒ |  j | ƒ Wn d SXd S(   Niÿÿÿÿs.   HARDWARE\DESCRIPTION\System\CentralProcessor\0i   t   ProcessorNameStringR!   (   t   _winregt   ConnectRegistryt   Nonet   HKEY_LOCAL_MACHINEt   OpenKeyt   ranget	   EnumValuet   CloseKey(   R0   t   regt   keyt   it   namet   valuet   type(    (    sH   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/plugins/TechnicalInfo.pyt   getProcessorNameFromRegistry:   s     c          C   sÃ  d d  l  }  |  j ƒ  } d |  j  ƒ  d } t j  d k r€| d |  j ƒ  d 7} | d |  j ƒ  d d 7} yl d d  l } | j d d	 d
 d g d | j ƒj ƒ  d } | j d d d
 d g d | j ƒj ƒ  d } Wn d } d } n X| j	 d ƒ d k r%t
 | | j	 d ƒ ƒ d k r%| | j	 d ƒ d j	 d ƒ d k r%| | j	 d ƒ d } | | j	 d ƒ  j ƒ  } d } | j	 d ƒ d k rt
 | | j	 d ƒ ƒ d k r| | j	 d ƒ d j	 d ƒ d k r| | j	 d ƒ d } | | j	 d ƒ  j ƒ  } n  d } | j	 d ƒ d k r·t
 | | j	 d ƒ ƒ t
 d ƒ k r·| | j	 d ƒ t
 d ƒ j	 d ƒ d k r·| | j	 d ƒ t
 d ƒ d } | | j	 d ƒ  j ƒ  } n  t
 | ƒ d k r%| d | 7} | rî| d | 7} n  | d k r| d t | ƒ d 7} n  | d 7} q%n  | d 7} | | j d d ƒ j d d ƒ 7} | | j d d ƒ j d d ƒ 7} | d 7} n?t j  d  k rô| d |  j ƒ  d 7} t |  d! ƒ rù| d" |  j ƒ  d d |  j ƒ  d d |  j ƒ  d# d 7} nR t |  d$ ƒ rK| d" |  j ƒ  d d |  j ƒ  d d |  j ƒ  d# d 7} n  y` d d  l } | j d% d& g d | j ƒj ƒ  d }	 | j d% d' g d | j ƒj ƒ  d }
 Wn d }	 d }
 n X|	 j	 d( ƒ d k r±t
 |	 |	 j	 d( ƒ ƒ d) k r±|	 |	 j	 d( ƒ d) j	 d ƒ d k r±|	 |	 j	 d( ƒ d) } | | j	 d ƒ  j ƒ  } |	 j d* ƒ } t
 | ƒ d k r±| d | 7} | d k r¡| d t | ƒ d+ 7} n  | d 7} q±n  | d, 7} | |	 j d d ƒ 7} | |
 j d d ƒ 7} | d- 7} nË t j  d. k r§| d/ t ƒ  7} t j j d0 ƒ rB| d t j d0 d+ 7} n  | d 7} | d |  j ƒ  d 7} | d1 |  j ƒ  d d |  j ƒ  d d |  j ƒ  d# d 7} n | d |  j ƒ  d 7} | S(2   Niÿÿÿÿs
   Platform: s   <br>
t   darwins   Processor: s   OS X version: i    t   system_profilert   SPHardwareDataTypes   -detailLevelt   minit   stdoutt   SPDisplaysDataTypeR!   s   Processor Namei   s   
s   Processor Speedi   s   Total Number Of Coresi   s   Processor details: t    s    (s    cores available)sí   
<span> Further information:
<span id="opensystem_profile"><a href="javascript:switchDiv('system_profile','system_profile','opensystem_profile');">
(+)</a>
</span>
<span id="system_profile" style="position:absolute;display:none;"><br>
		s   <br>s           s$   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s0   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s€   
<a href="javascript:clickedMinus('system_profile','system_profile','opensystem_profile');">(close)</a></span>
</span>
        	t   linux2t   linux_distributions   Linux distribution: i   t   distt   cats   /proc/cpuinfos   /proc/meminfos
   model namei   s   
model name	s    processors available)sÏ   
<span> Further information:
<span id="openprocinfo"><a href="javascript:switchDiv('procinfo','procinfo','openprocinfo');">
(+)</a>
</span>
<span id="procinfo" style="position:absolute;display:none;"><br>
		sg   
<a href="javascript:clickedMinus('procinfo','procinfo','openprocinfo');">(close)</a></span>
</span>
		t   win32s   Processor Name: t   NUMBER_OF_PROCESSORSs   Windows version: (   t   platformt   systemR   t	   processort   mac_vert
   subprocesst   Popent   PIPEt   communicatet   findt   lent   stript   strt   replaceR   RG   RH   R   R>   R   R(   t   has_keyt	   win32_ver(   RL   RM   R   RP   t   hardinfot   dispinfot   modelt   speedt   nproct   cpuinfot   meminfo(    (    sH   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/plugins/TechnicalInfo.pyt   getSystemInfoM   s”    .2
ZZf! ""
CC(,
Z

Cc          C   sI   d }  |  d t  j d 7}  |  d t  j d 7}  |  d t j d 7}  |  S(   NR!   s   Qt version: s   <br>
s   PyQt4 version: s   Python version: (   R    t   QT_VERSION_STRt   PYQT_VERSION_STRR   t   version(   R   (    (    sH   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/plugins/TechnicalInfo.pyt   getOtherInfo©   s
    c          C   sL  d }  t  j ƒ  } y d d  l } | j j ƒ  } Wn d } n Xt | d ƒ rH| j j ƒ  rH| j j ƒ  d d  l	 } |  d t
 | j j ƒ  j ƒ  j ƒ  ƒ d 7}  |  d | j | j ƒ d 7}  |  d | j | j ƒ d 7}  |  d	 | j | j ƒ d 7}  |  d
 | d 7}  |  d 7}  |  d 7}  |  | j | j ƒ 7}  |  d 7}  n  |  S(   NR!   iÿÿÿÿs   OpenGL shaders not availablet   glWidgets   Direct rendering: s   <br>s   GL vendor: s   GL renderer: s   GL version: s   GL shader version: s   <span>GL extensions: s¤   
<span id="openglext"><a href="javascript:switchDiv('glext','glext','openglext');">
(+)</a>
</span>
<span id="glext" style="position:absolute;display:none;"><br>
		s^   
<a href="javascript:clickedMinus('glext','glext','openglext');">(close)</a></span>
</span>
		(   R   R   t	   glShaderst
   MGGLShadert   getShadingLanguageVersionR   Rg   t   isValidt   makeCurrentt   openglRW   t   contextt   formatt   directRenderingt   glGetStringt	   GL_VENDORt   GL_RENDERERt
   GL_VERSIONt   GL_EXTENSIONS(   R   R	   Rh   t   shaderVersionRm   (    (    sH   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/plugins/TechnicalInfo.pyt	   getGLInfo°   s,    
-

R   c           B   s&   e  Z d  „  Z d „  Z d d „ Z RS(   c         C   s0   |  j  ƒ  } |  j j | ƒ t j j |  ƒ d  S(   N(   t   getLabelTextt   labelt   setHtmlt   MGSimpleDialogR   (   t   selft
   label_text(    (    sH   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/plugins/TechnicalInfo.pyR   Ð   s    c         C   sÆ   d } | d 7} | d 7} t  ƒ  } | d | d 7} | d 7} t ƒ  } | d | d 7} | d 7} t ƒ  } | d | d 7} | d 7} t ƒ  } | d | d 7} | d	 7} | d
 7} | d 7} | S(   Ns§	  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <title>CCP4MG Technical Information</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function jsrsArrayFromString(s, delim){ 
 var d = (delim==null)? '~' : delim; 
 return s.split(d); 
}
function changeObjectPosition(objectId, newPosition) {
    // first get the object's stylesheet
    var styleObject = getStyleObject(objectId);

    // then if we find a stylesheet, set its position
    // as requested
    //
    if (styleObject) {
	styleObject.position = newPosition;
	return true;
    } else {
	return false;
    }
}

function changeObjectDisplay(objectId, newDisplay) {
    // first get the object's stylesheet
    var styleObject = getStyleObject(objectId);

    // then if we find a stylesheet, set its display
    // as requested
    //
    if (styleObject) {
	styleObject.display = newDisplay;
	return true;
    } else {
	return false;
    }
}

function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {  
	return document.all(objectId).style;
   } 
   else if (document.layers && document.layers[objectId]) { 
	return document.layers[objectId];
   } else {
	return false;
   }
}

function hideAll(all_div_ids_str)
{
  all_div_ids = jsrsArrayFromString(all_div_ids_str,'~');
  for(i=0;i<all_div_ids.length;i++){
    changeObjectPosition(all_div_ids[i],"absolute");
    changeObjectDisplay(all_div_ids[i],"none");
  }
}

function clickedMinus(div_id,all_div_ids_str,opener_id){
  var style_sheet = getStyleObject(div_id);
  if (style_sheet)
  {
    hideAll(all_div_ids_str);
    document.getElementById(opener_id).innerHTML = "<a href=\"javascript:switchDiv('"+div_id+"','"+all_div_ids_str+"','"+opener_id+"');\">(+)<\/a>";
  }
}

function switchDiv(div_id,all_div_ids_str,opener_id){
  var style_sheet = getStyleObject(div_id);
  if (style_sheet)
  {
    hideAll(all_div_ids_str);
    changeObjectDisplay(div_id, "block");
    changeObjectPosition(div_id, "relative");
    document.getElementById(opener_id).innerHTML ="<a href=\"javascript:clickedMinus('"+div_id+"','"+all_div_ids_str+"','"+opener_id+"');\">(-)<\/a>"; 
  }
  else 
  {
    alert("Problem switching object visibility.");
  }
}
</script>
</head>
<body>
	s   <ul>sO   <li><b><span style="font-family:sans;">CCP4MG Build Information:</span></b><br>s    <span style="font-family:sans;">s   </span>sI   <li><b><span style="font-family:sans;">System Information:</span></b><br>sI   <li><b><span style="font-family:sans;">OpenGL Information:</span></b><br>sH   <li><b><span style="font-family:sans;">Other Information:</span></b><br>s   </ul>s   </body>s   </html>(   R.   Rb   Rw   Rf   (   R|   R}   t   gl_text(    (    sH   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/plugins/TechnicalInfo.pyRx   Ö   s$    [

	
	
	
	


c         C   s·   t  j  j |  | ƒ |  j |  j d ƒ ƒ t j |  ƒ } d d l m } | j ƒ  |  _	 | j
 |  j	 ƒ |  j | ƒ |  j d ƒ d |  j d <t j j t j j t ƒ ƒ |  j d <d  S(   Ns   Technical Informationiÿÿÿÿ(   t   QtWebKiti    R   R   R   (   R{   t   __init__t   setWindowTitlet   trR   t   QVBoxLayoutt   PyQt4R   t   QWebViewRy   t	   addWidgett	   setLayoutt   setSizeGripEnabledR   R   R   R   R   R   (   R|   t   parentt   layoutR   (    (    sH   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/plugins/TechnicalInfo.pyR€   I  s    N(   t   __name__t
   __module__R   Rx   R2   R€   (    (    (    sH   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/plugins/TechnicalInfo.pyR   Î   s   		st   __main__s   -quit(   t   __doc__R„   R    R   R{   R   R   R   R   R
   R    R.   R>   Rb   Rf   Rw   R   R‹   R   t   exit(    (    (    sH   /opt/xtal/ccp4-6.5-linux32/lib/py2/ccp4mg/qtgui/plugins/TechnicalInfo.pyt   <module>   s&   				\		ˆ