Source
81
81
82
82
83
83
"""
84
84
85
85
##
86
86
## (1) save current *viewer*server* path
87
87
## (2) have viewer() task follow casapy/python's cwd
88
88
try:
89
89
old_path = viewertool.cwd(gui)
90
90
except:
91
-
raise Exception("msview() failed to get the current working directory")
91
+
raise RuntimeError("msview() failed to get the current working directory")
92
92
93
93
try:
94
94
viewertool.cwd(os.path.abspath(os.curdir),gui)
95
95
except:
96
-
raise Exception("msview() failed to change to the new working directory")
96
+
raise RuntimeError("msview() failed to change to the new working directory")
97
97
98
98
data = None
99
99
if type(infile) == str and len(infile) > 0 :
100
100
info = viewertool.fileinfo(infile,gui);
101
101
if info['type'] != 'ms' :
102
102
if info['type'] == 'image' :
103
-
raise Exception("msview() only displays images, try 'imview()'...")
103
+
raise ValueError("msview() only displays images, try 'imview()'...")
104
104
elif info['type'] == 'nonexistent' :
105
-
raise Exception("ms (" + infile + ") could not be found...")
105
+
raise RuntimeError("ms (" + infile + ") could not be found...")
106
106
else :
107
-
raise Exception("unknow error...")
107
+
raise RuntimeError("unknow error...")
108
108
109
109
panel = viewertool.panel("viewer",gui)
110
110
if type(displaytype) == str:
111
111
data = viewertool.load( infile, displaytype, panel=panel )
112
112
else:
113
113
data = viewertool.load( infile, panel=panel )
114
114
115
115
if type(channel) == int and channel > 0 :
116
116
viewertool.channel(channel,panel=panel)
117
117
if type(zoom) == int and zoom != 1 :
131
131
orientation="landscape"
132
132
viewertool.output(outfile,scale=scale,dpi=dpi,format=format,orientation=orientation,panel=panel)
133
133
else:
134
134
panel = vwr.panel("viewer")
135
135
viewertool.popup( 'open', panel=panel )
136
136
137
137
## (3) restore original path
138
138
try:
139
139
viewertool.cwd(old_path,gui)
140
140
except:
141
-
raise Exception("msview() failed to restore the old working directory")
142
-
143
-
return None
141
+
raise RuntimeError("msview() failed to restore the old working directory")
144
142
145
143
msview = __msview_class( )