products.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:fg21sim 作者: liweitianux 项目源码 文件源码
def _open_hpx(self, comp_id, freq_id, viewer):
        """
        Open the HPX image of a specified product using a sub-process

        NOTE
        ----
        Only allowed when accessing from the localhost

        Parameters
        ----------
        comp_id : str
            ID of the component whose product will be checksum'ed
        freq_id : int
            The frequency ID of the specific product within the component.
        viewer : str
            The executable name or path to the FITS viewer.

        Returns
        -------
        pid : int
            ID of the sub process which opened the HPX image.
            ``None`` if failed to open the image.
        error : str
            If failed, this ``error`` saves the details, otherwise, ``None``.
        """
        pid = None
        error = None
        if self.from_localhost:
            try:
                filepath = self.products.get_product_abspath(
                    comp_id, freq_id, ptype="hpx")
                cmd = [viewer, filepath]
                p = tornado.process.Subprocess(cmd)
                pid = p.pid
                logger.info("(PID: {0}) ".format(pid) +
                            "Opened HPX image: {0}".format(" ".join(cmd)))
            except (ValueError, KeyError) as e:
                error = str(e)
        else:
            error = "Action 'open' only allowed from localhost"
        return (pid, error)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号