Skip to content

Commit 654b03b

Browse files
committed
update Bilbao website location; some cleanup
1 parent ef84de5 commit 654b03b

File tree

4 files changed

+64
-26
lines changed

4 files changed

+64
-26
lines changed

GSASII/GSASIIpath.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,9 +1147,9 @@ def exceptHook(*args):
11471147
else: # older IPython (still needed?)
11481148
ipshell = IPython.terminal.embed.InteractiveShellEmbed()
11491149
# traceback display routines
1150-
def TB(): print(IPython.core.ultratb.FormattedTB().text(*args))
1150+
def TB(depth=None): print(IPython.core.ultratb.FormattedTB().text(*args,depth))
11511151
def vTB(depth=-1): print(IPython.core.ultratb.VerboseTB().text(*args,depth))
1152-
def bwTB(): print(IPython.core.ultratb.ListTB().text(*args)) # uncolored
1152+
def bwTB(depth=None): print(IPython.core.ultratb.ListTB().text(*args,depth)) # uncolored
11531153
try: # get to the right frame
11541154
import inspect
11551155
frame = inspect.getinnerframes(args[2])[-1][0]
@@ -1158,7 +1158,7 @@ def bwTB(): print(IPython.core.ultratb.ListTB().text(*args)) # uncolored
11581158
locals['vTB'] = vTB
11591159
locals['bwTB'] = bwTB
11601160
msg = f'IPython console: {frame.f_code.co_filename}, line {frame.f_lineno}'
1161-
msg += '\n[TB(), vTB(-n)/vTB(0) & bwTB() for tracebacks to n levels back]'
1161+
msg += '\n[TB()/TB(-n), vTB()/vTB(-n)/vTB(0) & bwTB() for tracebacks to n levels back]'
11621162
ipshell(msg,local_ns=locals,global_ns=frame.f_globals)
11631163
except:
11641164
msg = 'Entering IPython console (not in error contex)'
@@ -1855,16 +1855,6 @@ def postURL(URL,postdict,getcookie=None,usecookie=None,
18551855
if r.status_code == 200:
18561856
if GetConfigValue('debug'): print('request OK')
18571857
page = r.text
1858-
if 'cryst.ehu.es' in URL and "currently down" in page:
1859-
# Bilbao is down. Tell user
1860-
import re
1861-
print(f"Website down? See message below:\n\n{re.sub('<.+>','',page)}")
1862-
try:
1863-
import wx
1864-
import GSASII.GSASIIctrlGUI as G2G
1865-
dlg = G2G.viewWebPage(wx.GetApp().GetMainTopWindow(),URL,HTML=page)
1866-
except:
1867-
pass
18681858
if getcookie is not None:
18691859
getcookie.update(r.cookies)
18701860
return page # success

GSASII/GSASIIphsGUI.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3252,7 +3252,7 @@ def _showWebPage(event):
32523252
with open(tmp.name,'w') as fp:
32533253
fp.write(pagelist[num].replace(
32543254
'<head>',
3255-
'<head><base href="https://www.cryst.ehu.es/">',
3255+
f'<head><base href="{SUBGROUPS.bilbaoURL}/">',
32563256
))
32573257
fileList.append(tmp.name)
32583258
G2G.ShowWebPage('file://'+tmp.name,G2frame)
@@ -3439,7 +3439,7 @@ def _showWebPage(event):
34393439
with open(tmp.name,'w') as fp:
34403440
fp.write(f.replace(
34413441
'<head>',
3442-
'<head><base href="https://www.cryst.ehu.es/">',
3442+
f'<head><base href="{SUBGROUPS.bilbaoURL}/">',
34433443
))
34443444
fileList.append(tmp.name)
34453445
G2G.ShowWebPage('file://'+tmp.name,G2frame)
@@ -3919,6 +3919,9 @@ def OnTransform2Std(event):
39193919
generalData = data['General']
39203920
cx,ct,cs,cia = generalData['AtomPtrs']
39213921
sgnum,sgsym,xmat,xoff = SUBGROUPS.GetStdSGset(generalData['SGData'])
3922+
if xmat is None:
3923+
G2G.G2MessageBox(G2frame,"Unable to reach web site.",'No connection')
3924+
return
39223925
if np.allclose(np.eye(3),xmat) and np.allclose(xoff,np.zeros_like(xoff)):
39233926
msg = "Nothing to do. Structure is already set in the standard setting."
39243927
G2G.G2MessageBox(G2frame,msg,'No change needed')

GSASII/SUBGROUPS.py

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import random as ran
66
import sys
77
import os
8+
import wx
89
import numpy as np
910
import numpy.linalg as nl
1011
from . import GSASIIpath
@@ -13,10 +14,24 @@
1314
from . import GSASIIlattice as G2lat
1415
from . import GSASIIElem as G2elem
1516
from . 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/'
1819
pseudosym = '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

2136
def 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

docs/source/packages.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ The following web services can also be accessed from computers that
485485
have internet access. All software needed for this access is included
486486
with GSAS-II.
487487

488-
**Bilbao Crystallographic Server** (https://www.cryst.ehu.es):
488+
**Bilbao Crystallographic Server** (http://webbdcrista2.ehu.es/):
489489
GSAS-II can directly access the Bilbao Crystallographic Server to
490490
utilize the k-SUBGROUPSMAG, k-SUBGROUPS and PseudoLattice web utilities for
491491
computation of space group subgroups, color (magnetic) subgroups &

0 commit comments

Comments
 (0)