Skip to content

Commit

Permalink
Refs #9403 Save Workspaces dialog can now be opened offline
Browse files Browse the repository at this point in the history
The Save workspaces dialog can now be opened under all the following circumstances, whereas before it would raise an exception and not show:

* The workstation is not connected to a network or loses it's connection to a network
* The archives aren't available or aren't mounted
* A config.xml file isn't in place or doesn't contain a mount point location
  • Loading branch information
keithnbrown committed Jun 3, 2014
1 parent 9dd0d9f commit 5a9954b
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions Code/Mantid/scripts/Interface/ui/reflectometer/refl_save.py
Expand Up @@ -17,14 +17,16 @@
class Ui_SaveWindow(object):
def __init__(self):

self.__has_mount_point = True;

self.__instrument = config['default.instrument'].strip().upper()

try:
usersettings = Settings() # This will throw a missing config exception if no config file is available.
self.__mountpoint = usersettings.get_named_setting("DataMountPoint")
except KeyError:
print "DataMountPoint is missing from the config.xml file."
raise
self.__has_mount_point = False;

def setupUi(self, SaveWindow):
self.SavePath=""
Expand Down Expand Up @@ -245,28 +247,31 @@ def populateList(self):
if (self.SavePath!=''):
self.lineEdit.setText(self.SavePath)
else:
base_path = os.path.join(self.__mountpoint, 'NDX'+ self.__instrument, 'Instrument','logs','journal')
print base_path
main_journal_path = os.path.join(base_path, 'journal_main.xml')
tree1=xml.parse(main_journal_path)
root1=tree1.getroot()
currentJournal=root1[len(root1)-1].attrib.get('name')
cycle_journal_path = os.path.join(base_path, currentJournal)
tree=xml.parse(cycle_journal_path)
root=tree.getroot()

i=0
try:
while root[i][4].text!=str(RB_Number):
i+=1
if root[i][1].text.find(',')>0:
user=root[i][1].text[0:root[i][1].text.find(',')]
else:
user=root[i][1].text[0:root[i][1].text.find(' ')]
SavePath = os.path.join('U:', user)
self.lineEdit.setText(SavePath)
except LookupError:
print "Not found!"
if self.__has_mount_point:
try:
base_path = os.path.join(self.__mountpoint, 'NDX'+ self.__instrument, 'Instrument','logs','journal')
print "Loading journal from", base_path
main_journal_path = os.path.join(base_path, 'journal_main.xml')
tree1=xml.parse(main_journal_path)
root1=tree1.getroot()
currentJournal=root1[len(root1)-1].attrib.get('name')
cycle_journal_path = os.path.join(base_path, currentJournal)
tree=xml.parse(cycle_journal_path)
root=tree.getroot()
i=0
try:
while root[i][4].text!=str(RB_Number):
i+=1
if root[i][1].text.find(',')>0:
user=root[i][1].text[0:root[i][1].text.find(',')]
else:
user=root[i][1].text[0:root[i][1].text.find(' ')]
SavePath = os.path.join('U:', user)
self.lineEdit.setText(SavePath)
except LookupError:
print "Couldn't find user name in archives!"
except:
print "Journal does not exist or is unreachable, please check your network connection."

#--------- If "Save" button pressed, selcted workspaces are saved -------------
def buttonClickHandler1(self):
Expand Down

0 comments on commit 5a9954b

Please sign in to comment.