55import random as ran
66import sys
77import os
8+ import wx
89import numpy as np
910import numpy .linalg as nl
1011from . import GSASIIpath
1314from . import GSASIIlattice as G2lat
1415from . import GSASIIElem as G2elem
1516from . import GSASIIctrlGUI as G2G
16- bilbaoSite = 'https ://www.cryst. ehu.es/cgi-bin/cryst/programs/'
17- submagSite = bilbaoSite + 'subgrmag1_general_GSAS.pl? '
17+ bilbaoURL = "http ://webbdcrista2. ehu.es"
18+ bilbaoSite = f' { bilbaoURL } /cgi-bin/cryst/programs/ '
1819pseudosym = 'pseudosym/nph-pseudosym'
19- timeout = 150 # time to wait for www.cryst.ehu.es to respond; 2.5 minutes
20+ timeout = 150 # time to wait for Bilbao to respond; 2.5 minutes
21+
22+ def postpostURL (page ):
23+ '''warn on Bilbao down
24+ '''
25+ if "currently down" in page :
26+ # Bilbao is down. Tell user
27+ import re
28+ print (f"Website down? See message below:\n \n { re .sub ('<.+>' ,'' ,page )} " )
29+ try :
30+ dlg = G2G .viewWebPage (wx .GetApp ().GetMainTopWindow (),URL ,HTML = page )
31+ except :
32+ pass
33+ return True
34+ return False
2035
2136def GetNonStdSubgroups (SGData , kvec ,star = False ,landau = False ,maximal = False ):
2237 '''Run Bilbao's SUBGROUPS for a non-standard space group.
@@ -72,7 +87,8 @@ def getMatVec(item):
7287 break
7388 for i ,k in zip (('x' ,'y' ,'z' ),kvec [3 * j - 3 :3 * j ]):
7489 postdict ['knm%d%s' % (j ,i )] = k
75- page = GSASIIpath .postURL (submagSite ,postdict )
90+ page = GSASIIpath .postURL (bilbaoSite + 'subgrmag1_general_GSAS.pl?' ,postdict )
91+ if postpostURL (page ): return None ,None
7692 if not page :
7793 print ('connection error - not on internet?' )
7894 return None ,None
@@ -185,7 +201,8 @@ def getMatVec(item):
185201 break
186202 for i ,k in zip (('x' ,'y' ,'z' ),kvec [3 * j - 3 :3 * j ]):
187203 postdict ['km%d%s' % (j ,i )] = k
188- page = GSASIIpath .postURL (submagSite ,postdict )
204+ page = GSASIIpath .postURL (bilbaoSite + 'subgrmag1_general_GSAS.pl?' ,postdict )
205+ if postpostURL (page ): return None ,None
189206 if not page :
190207 print ('connection error - not on internet?' )
191208 return None ,None
@@ -246,7 +263,9 @@ def subBilbaoCheckLattice(spgNum,cell,tol=5):
246263 cellstr = '+' .join (['{:.5f}' .format (i ) for i in cell ])
247264 datastr = "sgr={:}&cell={:}&tol={:}&submit=Show" .format (
248265 str (int (spgNum )),cellstr ,str (int (tol )))
266+ # self-tested?
249267 page = GSASIIpath .postURL (psSite ,datastr ,timeout = timeout )
268+ if postpostURL (page ): return None
250269 if not page :
251270 print ('connection error - not on internet?' )
252271 return None
@@ -303,7 +322,7 @@ def GetStdSGset(SGData=None, oprList=[]):
303322 G2G .GetCite ('Bilbao: k-SUBGROUPSMAG' ,wrap = 70 ,indent = 5 ))
304323 postdict = {'tipog' :'gesp' ,'generators' :'\n ' .join (oprList )}
305324 page = GSASIIpath .postURL (Site ,postdict ,timeout = timeout )
306- if not page :
325+ if not page or postpostURL ( page ) :
307326 print ('error:' ,'No response' )
308327 return [None ,None ,None ,None ]
309328
@@ -349,7 +368,9 @@ def GetSupergroup(SGnum,dlg=None):
349368 import re
350369 Site = bilbaoSite + 'nph-minsup'
351370 if dlg : dlg .Update (0 ,newmsg = 'Waiting for initial web response' )
371+ # self-tested?
352372 out = GSASIIpath .postURL (Site ,{'gnum' :f'{ SGnum :} ' },timeout = timeout )
373+ if postpostURL (out ): return None
353374 if not out : return None
354375
355376 if dlg : dlg .Update (1 ,newmsg = 'Initial table of supergroups returned' )
@@ -375,8 +396,10 @@ def GetSupergroup(SGnum,dlg=None):
375396 for i ,line in enumerate (xforms ):
376397 click = line [- 1 ]
377398 print (SGnum ,click )
399+ # self-tested?
378400 out1 = GSASIIpath .postURL (Site ,{'gnum' :SGnum ,'show' :'show' ,'click' :click }
379401 ,timeout = timeout )
402+ if postpostURL (out1 ): return None
380403 if not out1 : return None
381404 #with open(f'/tmp/{click}.html','w') as fp:
382405 # fp.write(out1)
@@ -549,8 +572,10 @@ def BilbaoSymSearch1(sgnum, phase, maxdelta=2, angtol=None,
549572 postdict ["stru" ] += f"{ el :4s} { i } - { atom [cx ]:.5f} { atom [cx + 1 ]:.5f} { atom [cx + 2 ]:.5f} \n "
550573# if GSASIIpath.GetConfigValue('debug'): print(postdict["stru"])
551574 savedcookies = {}
575+ # self-tested?
552576 page0 = GSASIIpath .postURL (bilbaoSite + pseudosym ,postdict ,
553577 getcookie = savedcookies ,timeout = timeout )
578+ if postpostURL (page0 ): return None
554579 if not page0 : return None
555580 if pagelist is not None :
556581 pagelist [0 ] = page0
@@ -641,9 +666,10 @@ def BilbaoLowSymSea1(valsdict,row,savedcookies,pagelist=None):
641666 num = row [0 ]
642667 if GSASIIpath .GetConfigValue ('debug' ): print (f"processing cell #{ num } " )
643668 postdict ['lattice' ] = num
669+ # self-tested?
644670 page1 = GSASIIpath .postURL (bilbaoSite + pseudosym ,postdict ,
645671 usecookie = savedcookies ,timeout = timeout )
646- if not page1 : return None ,None ,None ,None
672+ if postpostURL ( page1 ) or not page1 : return None ,None ,None ,None
647673
648674 lbl = f'cell{ num } '
649675 if pagelist is not None :
@@ -677,9 +703,10 @@ def BilbaoLowSymSea2(num,valsdict,row,savedcookies,pagelist=None):
677703 postdict .update (valsdict )
678704 postdict ['super_numind' ] = row [1 ]
679705 if GSASIIpath .GetConfigValue ('debug' ): print (f"processing cell #{ num } supergroup { row [1 ]} " )
706+ # self-tested?
680707 page1 = GSASIIpath .postURL (bilbaoSite + pseudosym ,postdict ,
681708 usecookie = savedcookies ,timeout = timeout )
682- if page1 is None : return '' ,None
709+ if postpostURL ( page1 ) or page1 is None : return '' ,None
683710 lbl = f'cell{ num } _{ row [1 ]} '
684711 if pagelist is not None :
685712 pagelist [lbl ] = page1
@@ -707,9 +734,10 @@ def BilbaoSymSearch2(valsdict,csdict,rowdict,savedcookies,
707734 postdict = {}
708735 postdict .update (valsdict )
709736 postdict ['cs' ] = num
737+ # self-tested?
710738 page1 = GSASIIpath .postURL (bilbaoSite + pseudosym ,postdict ,
711739 usecookie = savedcookies ,timeout = timeout )
712- if pagelist is not None :
740+ if postpostURL ( page1 ) or pagelist is not None :
713741 pagelist [num ] = page1
714742 if page1 is None :
715743 structures [num ] = "No response, likely web timeout"
@@ -769,9 +797,10 @@ def BilbaoReSymSearch(key,postdict,pagelist=None):
769797
770798 '''
771799 savedcookies = {}
800+ # self-tested?
772801 page1 = GSASIIpath .postURL (bilbaoSite + pseudosym ,postdict
773802 ,getcookie = savedcookies ,timeout = timeout )
774- if pagelist is not None :
803+ if postpostURL ( page1 ) or pagelist is not None :
775804 pagelist [key ] = page1
776805 if page1 is None : return {},{},{},savedcookies
777806 valsdict ,csdict ,rowdict = scanBilbaoSymSearch1 (page1 ,postdict )
@@ -830,6 +859,22 @@ def test():
830859 are accessible and produce output that we can parse. The output
831860 is displayed but not checked to see that it agrees with what
832861 has been provided previously.
862+
863+
864+ The list of routines that access the Bilbao site and are tested here are:
865+ * GetNonStdSubgroupsmag (uses subgrmag1_general_GSAS.pl)
866+ * GetNonStdSubgroups (subgrmag1_general_GSAS.pl)
867+ * GetStdSGset (checkgr.pl)
868+
869+ The other routines are not yet tested that access the Bilbao site are:
870+
871+ * subBilbaoCheckLattice
872+ * GetSupergroup
873+ * BilbaoSymSearch1
874+ * BilbaoSymSearch2
875+ * BilbaoReSymSearch
876+ * createStdSetting
877+
833878 '''
834879 SGData = G2spc .SpcGroup ('f d -3 m' )[1 ]
835880
0 commit comments