Exemplo n.º 1
0
    def __init__(self):
        super().__init__()

        left_box_1 = oasysgui.widgetBox(self.controlArea, "X0h Request Form", addSpace=True, orientation="vertical",
                                         width=610, height=640)

        html = self.clear_input_form(HttpManager.send_xray_server_direct_request("/cgi/www_form.exe?template=x0h_form.htm"))

        self.x0h_input = QWebView(left_box_1)
        self.x0h_input.setHtml(html)

        left_box_1.layout().addWidget(self.x0h_input)

        self.x0h_input.setFixedHeight(540)
        self.x0h_input.setFixedWidth(590)

        button = gui.button(self.controlArea, self, "Get X0h!", callback=self.submit)
        button.setFixedHeight(30)

        gui.rubber(self.controlArea)

        self.tabs = []
        self.tabs_widget = oasysgui.tabWidget(self.mainArea)
        self.initializeTabs()

        self.x0h_output = QWebView(self.tabs[0])

        self.tabs[0].layout().addWidget(self.x0h_output)

        self.x0h_output.setFixedHeight(630)
        self.x0h_output.setFixedWidth(740)
Exemplo n.º 2
0
    def get_help(cls, x0hdb=""):

        parameters = {}
        parameters.update({"x0hdb": x0hdb})

        try:
            return HttpManager.send_xray_server_request_POST(
                APPLICATION, parameters)

        except Exception as e:
            return ""
Exemplo n.º 3
0
    def submit(self):
        self.progressBarInit()
        self.setStatusMessage("Submitting Request")
        
        self.checkFields()

        parameters = {}

        parameters.update({"xway" : str(self.xway + 1)})
        parameters.update({"wave" : str(self.wave)})
        parameters.update({"line" : self.line})
        parameters.update({"code" : self.code})
        parameters.update({"hkl11" : str(self.hkl11)})
        parameters.update({"hkl12" : str(self.hkl12)})
        parameters.update({"hkl13" : str(self.hkl13)})
        parameters.update({"hkl21" : str(self.hkl21)})
        parameters.update({"hkl22" : str(self.hkl22)})
        parameters.update({"hkl23" : str(self.hkl23)})
        parameters.update({"qb1" : str(self.qb1)})
        parameters.update({"qb2" : str(self.qb2)})
        parameters.update({"prcmin" : str(self.prcmin)})
        parameters.update({"df1df2" : self.decode_df1df2()})
        parameters.update({"base1" : str(self.base1)})
        parameters.update({"base2" : str(self.base2)})
        parameters.update({"base3" : str(self.base3)})
        parameters.update({"modesearch" : self.decode_modesearch()})
        parameters.update({"q1" : str(self.q1)})
        parameters.update({"q2" : str(self.q2)})

        try:
            response = HttpManager.send_xray_server_request_GET(APPLICATION, parameters)
            response = response.split("<hr>")[0] + "\n </body></html>"

            temp_1, temp_2 = response.split("style.css")
            output = temp_1 + XRAY_SERVER_URL + "/style.css" + temp_2

            response = response.split("<td><img src=\"images/x.gif\" width=31 height=32 border=0></td>")[0] + "</tr></tr></body></html>"

            self.x0h_output.setHtml(response)

        except urllib.error.HTTPError as e:
            self.x0h_output.setHtml('The server couldn\'t fulfill the request.\nError Code: '
                                    + str(e.code) + "\n\n" +
                                    server.BaseHTTPRequestHandler.responses[e.code][1])
        except urllib.error.URLError as e:
            self.x0h_output.setHtml('We failed to reach a server.\nReason: '
                                    + e.reason)
        except XrayServerException as e:
            ShowHtmlDialog.show_html("X-ray Server Error", e.response, width=750, height=500, parent=self)
        except Exception as e:
            ShowTextDialog.show_text("Error", 'Error Occurred.\nReason: ' + str(e), parent=self)

        self.setStatusMessage("")
        self.progressBarFinished()
Exemplo n.º 4
0
        def __init__(self, image_url):
            super(FigureWidget, self).__init__()

            self.setFixedWidth(600)
            self.setFixedHeight(600)

            box_general = oasysgui.widgetBox(self, "", addSpace=False, orientation="vertical", width=600, height=600)

            gui.separator(box_general, height=30)

            box_top = oasysgui.widgetBox(box_general, "", addSpace=False, orientation="vertical", width=600, height=50)
            title = gui.label(box_top, self, "         Standing Waves plot")

            font = QFont(title.font())
            font.setBold(True)
            font.setPointSize(36)
            palette =  QPalette(title.palette())
            palette.setColor(QPalette.Foreground, QColor('blue'))
            title.setFont(font)
            title.setPalette(palette)

            gui.separator(box_general, height=10)

            box_center = oasysgui.widgetBox(box_general, "", addSpace=False, orientation="horizontal", width=600)

            box_label = oasysgui.widgetBox(box_center, "", addSpace=False, orientation="vertical", width=50)

            oasysgui.widgetBox(box_label, "", addSpace=False, orientation="vertical", height=50)

            label_y_axis = VerticalLabel("Incidence Angle", 200, 50)
            font = QFont(label_y_axis.font())
            font.setBold(True)
            font.setPointSize(24)
            label_y_axis.setFont(font)
            #label_y_axis.setFixedHeight(200)
            #label_y_axis.setFixedWidth(50)

            box_label.layout().addWidget(label_y_axis)

            image_label = QLabel(box_center)
            image = QImage()
            image.loadFromData(HttpManager.send_xray_server_direct_request("/" + image_url, decode=False))
            image_label.setPixmap(QPixmap(image))

            box_center.layout().addWidget(image_label)

            box_bottom = oasysgui.widgetBox(box_general, "", addSpace=False, orientation="horizontal", width=600)
            label_x_axis = gui.label(box_bottom, self, "                                Offset [Å]")
            font = QFont(label_x_axis.font())
            font.setBold(True)
            font.setPointSize(24)
            label_x_axis.setFont(font)
Exemplo n.º 5
0
    def get_list(cls, x0hdb=""):

        parameters = {}
        parameters.update({"x0hdb": x0hdb})
        parameters.update({"textout": "1"})
        parameters.update({"namesonly": "1"})

        try:
            response = HttpManager.send_xray_server_request_POST(
                APPLICATION, parameters)

            list = response.split('\n')
            return [x.strip() for x in list[1:len(list) - 1]]

        except Exception as e:
            return []
Exemplo n.º 6
0
    def __init__(self):
        super().__init__()

        left_box_1 = oasysgui.widgetBox(self.controlArea,
                                        "X0h Request Form",
                                        addSpace=True,
                                        orientation="vertical",
                                        width=610,
                                        height=640)

        html = self.clear_input_form(
            HttpManager.send_xray_server_direct_request(
                "/cgi/www_form.exe?template=X0h_form.htm"))

        self.x0h_input = QWebView(left_box_1)
        self.x0h_input.setHtml(html)

        left_box_1.layout().addWidget(self.x0h_input)

        self.x0h_input.setFixedHeight(540)
        self.x0h_input.setFixedWidth(590)

        button = gui.button(self.controlArea,
                            self,
                            "Get X0h!",
                            callback=self.submit)
        button.setFixedHeight(30)

        gui.rubber(self.controlArea)

        self.tabs = []
        self.tabs_widget = oasysgui.tabWidget(self.mainArea)
        self.initializeTabs()

        self.x0h_output = QWebView(self.tabs[0])

        self.tabs[0].layout().addWidget(self.x0h_output)

        self.x0h_output.setFixedHeight(630)
        self.x0h_output.setFixedWidth(740)
Exemplo n.º 7
0
    def get_data_file_from_response(self, response):
        rows = response.split("\n")

        job_id = None
        data = None

        for row in rows:
            if "Job ID" in row:
                job_id = (row.split("<b>"))[1].split("</b>")[0]

            if not job_id is None:
                if not job_id + ".png" in response:
                    raise XrayServerException(response)

                if job_id + ".dat" in row:
                    data = HttpManager.send_xray_server_direct_request(
                        (row.split("href=\"")[1]).split("\"")[0])
                    break

        if not data is None:
            rows = data.split("\r\n")

            x = []
            y = []

            for row in rows:
                values_string = row.strip().split(" ")

                if len(values_string) > 1:
                    x.append(float(values_string[0].strip()))
                    y.append(
                        float(values_string[len(values_string) - 1].strip()))

            return x, y
        else:
            if job_id is None:
                raise Exception("Job ID not present")
            else:
                raise Exception("Empty data file: " + job_id + ".dat")
    def get_data_file_from_response(self, response):
        rows = response.split("\n")

        job_id = None
        data = None

        for row in rows:
            if "Job ID" in row:
                job_id = (row.split("<b>"))[1].split("</b>")[0]

            if not job_id is None:
                if not job_id+".png" in response:
                    raise XrayServerException(response)

                if job_id+".dat" in row:
                    data = HttpManager.send_xray_server_direct_request((row.split("href=\"")[1]).split("\"")[0])
                    break

        if not data is None:
            rows = data.split("\n")

            x = []
            y = []

            for row in rows:
                values_string = row.strip().split(" ")

                if len(values_string) > 1:
                    x.append(float(values_string[0].strip()))
                    y.append(float(values_string[len(values_string)-1].strip()))

            return x, y
        else:
            if job_id is None:
                raise Exception("Job ID not present")
            else:
                raise Exception("Empty data file: " + job_id + ".dat")
Exemplo n.º 9
0
    def submit(self):
        self.progressBarInit()
        self.setStatusMessage("Submitting Request")

        self.checkFields()

        parameters = {}

        parameters.update({"xway": self.decode_xway()})
        parameters.update({"wave": str(self.wave)})
        parameters.update({"line": self.line})
        parameters.update({"ipol": str(self.ipol + 1)})
        parameters.update({"subway": str(self.subway + 1)})
        parameters.update({"code": self.code})
        parameters.update({"df1df2": self.decode_df1df2()})
        parameters.update({"chem": self.chem})
        parameters.update({"rho": str(self.rho)})
        parameters.update({"x0": str(self.x0)})
        parameters.update({"w0": str(self.w0)})
        parameters.update({"sigma": str(self.sigma)})
        parameters.update({"tr": str(self.tr)})
        parameters.update({"scanmin": str(self.scanmin)})
        parameters.update({"scanmax": str(self.scanmax)})
        parameters.update({"unis": str(self.unis)})
        parameters.update({"nscan": str(self.nscan)})
        parameters.update({"swflag": self.decode_swflag()})

        if self.swflag == True or self.swflag == 1:
            parameters.update({"swref": str(self.swref)})
            parameters.update({"swmin": str(self.swmin)})
            parameters.update({"swmax": str(self.swmax)})
            parameters.update({"swpts": str(self.swpts)})

        parameters.update({"profile": self.profile})

        try:
            self.progressBarSet(10)

            response = HttpManager.send_xray_server_request_POST(
                APPLICATION, parameters)

            self.progressBarSet(50)

            data = self.extract_plots(response)

            exchange_data = DataExchangeObject("XRAYSERVER", "TER_SL")
            exchange_data.add_content("ter_sl_result", data)
            exchange_data.add_content("ter_sl_result_units_to_degrees",
                                      self.get_units_to_degrees())

            self.send("xrayserver_data", exchange_data)

        except urllib.error.HTTPError as e:
            ShowTextDialog.show_text(
                "Error",
                'The server couldn\'t fulfill the request.\nError Code: ' +
                str(e.code) + "\n\n" +
                server.BaseHTTPRequestHandler.responses[e.code][1],
                parent=self)
        except urllib.error.URLError as e:
            ShowTextDialog.show_text("Error",
                                     'We failed to reach a server.\nReason: ' +
                                     e.reason,
                                     parent=self)
        except XrayServerException as e:
            ShowHtmlDialog.show_html("X-ray Server Error",
                                     e.response,
                                     width=750,
                                     height=500,
                                     parent=self)
        except Exception as e:
            ShowTextDialog.show_text("Error",
                                     'Error Occurred.\nReason: ' + str(e),
                                     parent=self)

            raise e

        self.setStatusMessage("")
        self.progressBarFinished()
Exemplo n.º 10
0
    def get_plots_from_form(self, application, form):
        response = HttpManager.send_xray_server_request_GET(application, self.get_parameters_from_form(form))

        return self.get_data_file_from_response(response)
Exemplo n.º 11
0
    def submit(self):
        self.progressBarInit()
        self.setStatusMessage("Submitting Request")
        
        self.checkFields()

        parameters = {}

        parameters.update({"xway" : self.decode_xway()})
        parameters.update({"wave" : str(self.wave)})
        parameters.update({"line" : self.line})
        parameters.update({"ipol" : str(self.ipol + 1)})
        parameters.update({"code" : self.code})
        parameters.update({"df1df2" : self.decode_df1df2()})
        parameters.update({"sigma" : str(self.sigma)})
        parameters.update({"w0" : str(self.w0)})
        parameters.update({"wh" : str(self.wh)})
        parameters.update({"i1" : str(self.i1)})
        parameters.update({"i2" : str(self.i2)})
        parameters.update({"i3" : str(self.i3)})
        parameters.update({"daa" : str(self.daa)})
        parameters.update({"igie" : self.decode_igie()})
        parameters.update({"fcentre" : str(self.fcentre)})
        parameters.update({"unic" : str(self.unic - 1)})
        parameters.update({"n1" : str(self.n1)})
        parameters.update({"n2" : str(self.n2)})
        parameters.update({"n3" : str(self.n3)})
        parameters.update({"m1" : str(self.m1)})
        parameters.update({"m2" : str(self.m2)})
        parameters.update({"m3" : str(self.m3)})
        parameters.update({"miscut" : str(self.miscut)})
        parameters.update({"unim" : str(self.unim)})
        parameters.update({"a1" : str(self.a1)})
        parameters.update({"a2" : str(self.a2)})
        parameters.update({"a3" : str(self.a3)})
        parameters.update({"scanmin" : str(self.scanmin)})
        parameters.update({"scanmax" : str(self.scanmax)})
        parameters.update({"unis" : str(self.unis)})
        parameters.update({"nscan" : str(self.nscan)})
        parameters.update({"invert" : str(self.invert)})
        parameters.update({"axis" : self.decode_axis()})
        parameters.update({"column" : self.decode_column()})
        parameters.update({"alphamax" : str(self.alphamax)})
        parameters.update({"profile" : self.profile})

        try:
            self.progressBarSet(10)

            response = HttpManager.send_xray_server_request_GET(APPLICATION, parameters)

            self.progressBarSet(50)

            data = self.extract_plots(response)

            exchange_data = DataExchangeObject("XRAYSERVER", "GID_SL")
            exchange_data.add_content("x-ray_diffraction_profile", data)
            exchange_data.add_content("x-ray_diffraction_profile_units_to_degrees", self.get_units_to_degrees())

            self.send("xrayserver_data", exchange_data)

        except urllib.error.HTTPError as e:
            ShowTextDialog.show_text("Error", 'The server couldn\'t fulfill the request.\nError Code: '
                                     + str(e.code) + "\n\n" +
                                     server.BaseHTTPRequestHandler.responses[e.code][1], parent=self)
        except urllib.error.URLError as e:
            ShowTextDialog.show_text("Error", 'We failed to reach a server.\nReason: ' + e.reason, parent=self)
        except XrayServerException as e:
            ShowHtmlDialog.show_html("X-ray Server Error", e.response, width=750, height=500, parent=self)
        except Exception as e:
            ShowTextDialog.show_text("Error", 'Error Occurred.\nReason: ' + str(e), parent=self)

        self.setStatusMessage("")
        self.progressBarFinished()
Exemplo n.º 12
0
    def submit(self):
        self.progressBarInit()
        self.setStatusMessage("Submitting Request")
        
        self.checkFields()

        parameters = {}

        parameters.update({"xway" : str(self.xway + 1)})
        parameters.update({"wave" : str(self.wave)})
        parameters.update({"line" : self.line})
        parameters.update({"coway" : str(self.coway)})
        parameters.update({"code" : self.code})
        parameters.update({"amor" : self.amor})
        parameters.update({"chem" : self.chem})
        parameters.update({"rho" : str(self.rho)})

        parameters.update({"i1" : str(self.i1)})
        parameters.update({"i2" : str(self.i2)})
        parameters.update({"i3" : str(self.i3)})
        parameters.update({"df1df2" : self.decode_df1df2()})

        parameters.update({"modeout" : "0" })
        parameters.update({"detail" : str(self.detail)})

        try:
            response = HttpManager.send_xray_server_request_GET(APPLICATION, parameters)

            response = self.clear_response(response)

            self.tabs_widget.setCurrentIndex(0)
            self.x0h_output.setHtml(response)

            data0, data1, data2 = self.extract_plots(response)

            try:
                exchange_data = DataExchangeObject("XRAYSERVER", "X0H")

                if self.coway == 0: # crystals
                    dictionary = self.extract_structure_data(response)

                    exchange_data.add_content("structure", dictionary["structure"])
                    exchange_data.add_content("h", self.i1)
                    exchange_data.add_content("k", self.i2)
                    exchange_data.add_content("l", self.i3)
                    exchange_data.add_content("d_spacing",  dictionary["d_spacing"])
                    exchange_data.add_content("energy", dictionary["energy"])
                    exchange_data.add_content("bragg_angle",  dictionary["bragg_angle"])
                    exchange_data.add_content("xr0",  dictionary["xr0"])
                    exchange_data.add_content("xi0",  dictionary["xi0"])
                    exchange_data.add_content("xrh_s",  dictionary["xrh_s"])
                    exchange_data.add_content("xih_s",  dictionary["xih_s"])
                    exchange_data.add_content("xrh_p",  dictionary["xrh_p"])
                    exchange_data.add_content("xih_p",  dictionary["xih_p"])

                exchange_data.add_content("reflectivity", data0)
                exchange_data.add_content("reflectivity_units_to_degrees", 1.0)
                exchange_data.add_content("x-ray_diffraction_profile_sigma", data1)
                exchange_data.add_content("x-ray_diffraction_profile_sigma_units_to_degrees", 0.000277777805)
                exchange_data.add_content("x-ray_diffraction_profile_pi", data2)
                exchange_data.add_content("x-ray_diffraction_profile_pi_units_to_degrees", 0.000277777805)

                self.send("xrayserver_data", exchange_data)
            except: #problems with xrayserver, no data found
                pass
        except urllib.error.HTTPError as e:
            self.x0h_output.setHtml('The server couldn\'t fulfill the request.\nError Code: '
                                    + str(e.code) + "\n\n" +
                                    server.BaseHTTPRequestHandler.responses[e.code][1])
        except urllib.error.URLError as e:
            self.x0h_output.setHtml('We failed to reach a server.\nReason: ' + e.reason)
        except XrayServerException as e:
            ShowHtmlDialog.show_html("X-ray Server Error", e.response, width=750, height=500, parent=self)
        except Exception as e:
            ShowTextDialog.show_text("Error", 'Error Occurred.\nReason: ' + str(e), parent=self)

        self.setStatusMessage("")
        self.progressBarFinished()
Exemplo n.º 13
0
    def submit(self):
        self.progressBarInit()
        self.setStatusMessage("Submitting Request")

        self.checkFields()

        parameters = {}

        parameters.update({"xway": str(self.xway + 1)})
        parameters.update({"wave": str(self.wave)})
        parameters.update({"line": self.line})
        parameters.update({"coway": str(self.coway)})
        parameters.update({"code": self.code})
        parameters.update({"amor": self.amor})
        parameters.update({"chem": self.chem})
        parameters.update({"rho": str(self.rho)})

        parameters.update({"i1": str(self.i1)})
        parameters.update({"i2": str(self.i2)})
        parameters.update({"i3": str(self.i3)})
        parameters.update({"df1df2": self.decode_df1df2()})

        parameters.update({"modeout": "0"})
        parameters.update({"detail": str(self.detail)})

        try:
            response = HttpManager.send_xray_server_request_POST(
                APPLICATION, parameters)
            response = self.clear_response(response)

            self.tabs_widget.setCurrentIndex(0)
            self.x0h_output.setHtml(response)

            data0, data1, data2 = self.extract_plots(response)

            exchange_data = DataExchangeObject("XRAYSERVER", "X0H")
            exchange_data.add_content("reflectivity", data0)
            exchange_data.add_content("reflectivity_units_to_degrees", 1.0)
            exchange_data.add_content("x-ray_diffraction_profile_sigma", data1)
            exchange_data.add_content(
                "x-ray_diffraction_profile_sigma_units_to_degrees",
                0.000277777805)
            exchange_data.add_content("x-ray_diffraction_profile_pi", data2)
            exchange_data.add_content(
                "x-ray_diffraction_profile_pi_units_to_degrees",
                0.000277777805)

            self.send("xrayserver_data", exchange_data)

        except urllib.error.HTTPError as e:
            self.x0h_output.setHtml(
                'The server couldn\'t fulfill the request.\nError Code: ' +
                str(e.code) + "\n\n" +
                server.BaseHTTPRequestHandler.responses[e.code][1])
            raise e

        except urllib.error.URLError as e:
            self.x0h_output.setHtml('We failed to reach a server.\nReason: ' +
                                    e.reason)
            raise e

        except XrayServerException as e:
            ShowHtmlDialog.show_html("X-ray Server Error",
                                     e.response,
                                     width=750,
                                     height=500,
                                     parent=self)

            raise e
        except Exception as e:
            self.x0h_output.setHtml('We failed to reach a server.\nReason: ' +
                                    str(e))

            raise e

        self.setStatusMessage("")
        self.progressBarFinished()
Exemplo n.º 14
0
    def submit(self):
        self.progressBarInit()
        self.setStatusMessage("Submitting Request")
        
        self.checkFields()

        parameters = {}

        parameters.update({"xway" : self.decode_xway()})
        parameters.update({"wave" : str(self.wave)})
        parameters.update({"line" : self.line})
        parameters.update({"ipol" : str(self.ipol + 1)})
        parameters.update({"code" : self.code})
        parameters.update({"df1df2" : self.decode_df1df2()})
        parameters.update({"sigma" : str(self.sigma)})
        parameters.update({"w0" : str(self.w0)})
        parameters.update({"wh" : str(self.wh)})
        parameters.update({"i1" : str(self.i1)})
        parameters.update({"i2" : str(self.i2)})
        parameters.update({"i3" : str(self.i3)})
        parameters.update({"daa" : str(self.daa)})
        parameters.update({"igie" : self.decode_igie()})
        parameters.update({"fcentre" : str(self.fcentre)})
        parameters.update({"unic" : str(self.unic - 1)})
        parameters.update({"n1" : str(self.n1)})
        parameters.update({"n2" : str(self.n2)})
        parameters.update({"n3" : str(self.n3)})
        parameters.update({"m1" : str(self.m1)})
        parameters.update({"m2" : str(self.m2)})
        parameters.update({"m3" : str(self.m3)})
        parameters.update({"miscut" : str(self.miscut)})
        parameters.update({"unim" : str(self.unim)})
        parameters.update({"a1" : str(self.a1)})
        parameters.update({"a2" : str(self.a2)})
        parameters.update({"a3" : str(self.a3)})
        parameters.update({"scanmin" : str(self.scanmin)})
        parameters.update({"scanmax" : str(self.scanmax)})
        parameters.update({"unis" : str(self.unis)})
        parameters.update({"nscan" : str(self.nscan)})
        parameters.update({"invert" : str(self.invert)})
        parameters.update({"axis" : self.decode_axis()})
        parameters.update({"column" : self.decode_column()})
        parameters.update({"alphamax" : str(self.alphamax)})
        parameters.update({"profile" : self.profile})

        try:
            self.progressBarSet(10)

            response = HttpManager.send_xray_server_request_POST(APPLICATION, parameters)

            self.progressBarSet(50)

            data = self.extract_plots(response)

            exchange_data = DataExchangeObject("XRAYSERVER", "GID_SL")
            exchange_data.add_content("x-ray_diffraction_profile", data)
            exchange_data.add_content("x-ray_diffraction_profile_units_to_degrees", self.get_units_to_degrees())

            self.send("xrayserver_data", exchange_data)

        except urllib.error.HTTPError as e:
            ShowTextDialog.show_text("Error", 'The server couldn\'t fulfill the request.\nError Code: '
                                     + str(e.code) + "\n\n" +
                                     server.BaseHTTPRequestHandler.responses[e.code][1], parent=self)
        except urllib.error.URLError as e:
            ShowTextDialog.show_text("Error", 'We failed to reach a server.\nReason: ' + e.reason, parent=self)
        except XrayServerException as e:
            ShowHtmlDialog.show_html("X-ray Server Error", e.response, width=750, height=500, parent=self)
        except Exception as e:
            ShowTextDialog.show_text("Error", 'Error Occurred.\nReason: ' + str(e), parent=self)

        self.setStatusMessage("")
        self.progressBarFinished()
Exemplo n.º 15
0
    def submit(self):
        self.progressBarInit()
        self.setStatusMessage("Submitting Request")
        
        self.checkFields()

        parameters = {}

        parameters.update({"xway" : self.decode_xway()})
        parameters.update({"wave" : str(self.wave)})
        parameters.update({"line" : self.line})
        parameters.update({"ipol" : str(self.ipol + 1)})
        parameters.update({"subway" : str(self.subway + 1)})
        parameters.update({"code" : self.code})
        parameters.update({"df1df2" : self.decode_df1df2()})
        parameters.update({"chem" : self.chem})
        parameters.update({"rho" : str(self.rho)})
        parameters.update({"x0" : str(self.x0)})
        parameters.update({"w0" : str(self.w0)})
        parameters.update({"sigma" : str(self.sigma)})
        parameters.update({"tr" : str(self.tr)})
        parameters.update({"scanmin" : str(self.scanmin)})
        parameters.update({"scanmax" : str(self.scanmax)})
        parameters.update({"unis" : str(self.unis)})
        parameters.update({"nscan" : str(self.nscan)})
        parameters.update({"swflag" : self.decode_swflag()})

        if self.swflag == True or self.swflag == 1:
            parameters.update({"swref" : str(self.swref)})
            parameters.update({"swmin" : str(self.swmin)})
            parameters.update({"swmax" : str(self.swmax)})
            parameters.update({"swpts" : str(self.swpts)})

        parameters.update({"profile" : self.profile})

        try:
            self.progressBarSet(10)

            response = HttpManager.send_xray_server_request_GET(APPLICATION, parameters)

            self.progressBarSet(50)

            data = self.extract_plots(response)

            exchange_data = DataExchangeObject("XRAYSERVER", "TER_SL")
            exchange_data.add_content("ter_sl_result", data)
            exchange_data.add_content("ter_sl_result_units_to_degrees", self.get_units_to_degrees())

            self.send("xrayserver_data", exchange_data)

        except urllib.error.HTTPError as e:
            ShowTextDialog.show_text("Error", 'The server couldn\'t fulfill the request.\nError Code: '
                                     + str(e.code) + "\n\n" +
                                     server.BaseHTTPRequestHandler.responses[e.code][1], parent=self)
        except urllib.error.URLError as e:
            ShowTextDialog.show_text("Error", 'We failed to reach a server.\nReason: ' + e.reason, parent=self)
        except XrayServerException as e:
            ShowHtmlDialog.show_html("X-ray Server Error", e.response, width=750, height=500, parent=self)
        except Exception as e:
            ShowTextDialog.show_text("Error", 'Error Occurred.\nReason: ' + str(e), parent=self)


        self.setStatusMessage("")
        self.progressBarFinished()
Exemplo n.º 16
0
    def __init__(self, image_url):
        super(FigureWidget, self).__init__()

        self.setFixedWidth(600)
        self.setFixedHeight(600)

        box_general = oasysgui.widgetBox(self,
                                         "",
                                         addSpace=False,
                                         orientation="vertical",
                                         width=600,
                                         height=600)

        gui.separator(box_general, height=30)

        box_top = oasysgui.widgetBox(box_general,
                                     "",
                                     addSpace=False,
                                     orientation="vertical",
                                     width=600,
                                     height=50)
        title = gui.label(box_top, self, "         Standing Waves plot")

        font = QFont(title.font())
        font.setBold(True)
        font.setPointSize(36)
        palette = QPalette(title.palette())
        palette.setColor(QPalette.Foreground, QColor('blue'))
        title.setFont(font)
        title.setPalette(palette)

        gui.separator(box_general, height=10)

        box_center = oasysgui.widgetBox(box_general,
                                        "",
                                        addSpace=False,
                                        orientation="horizontal",
                                        width=600)

        box_label = oasysgui.widgetBox(box_center,
                                       "",
                                       addSpace=False,
                                       orientation="vertical",
                                       width=50)

        oasysgui.widgetBox(box_label,
                           "",
                           addSpace=False,
                           orientation="vertical",
                           height=50)

        label_y_axis = VerticalLabel("Incidence Angle", 200, 50)
        font = QFont(label_y_axis.font())
        font.setBold(True)
        font.setPointSize(24)
        label_y_axis.setFont(font)
        #label_y_axis.setFixedHeight(200)
        #label_y_axis.setFixedWidth(50)

        box_label.layout().addWidget(label_y_axis)

        image_label = QLabel(box_center)
        image = QImage()
        image.loadFromData(
            HttpManager.send_xray_server_direct_request("/" + image_url,
                                                        decode=False))
        image_label.setPixmap(QPixmap(image))

        box_center.layout().addWidget(image_label)

        box_bottom = oasysgui.widgetBox(box_general,
                                        "",
                                        addSpace=False,
                                        orientation="horizontal",
                                        width=600)
        label_x_axis = gui.label(box_bottom, self,
                                 "                                Offset [Å]")
        font = QFont(label_x_axis.font())
        font.setBold(True)
        font.setPointSize(24)
        label_x_axis.setFont(font)
Exemplo n.º 17
0
    def get_plots_from_form(self, application, form):
        response = HttpManager.send_xray_server_request_POST(
            application, self.get_parameters_from_form(form))

        return self.get_data_file_from_response(response)