当前位置: 首页>>代码示例>>Python>>正文


Python BaseWidget.is_instance_role_client方法代码示例

本文整理汇总了Python中gui.BaseComponents.BaseWidget.is_instance_role_client方法的典型用法代码示例。如果您正苦于以下问题:Python BaseWidget.is_instance_role_client方法的具体用法?Python BaseWidget.is_instance_role_client怎么用?Python BaseWidget.is_instance_role_client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gui.BaseComponents.BaseWidget的用法示例。


在下文中一共展示了BaseWidget.is_instance_role_client方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: select_proposal

# 需要导入模块: from gui.BaseComponents import BaseWidget [as 别名]
# 或者: from gui.BaseComponents.BaseWidget import is_instance_role_client [as 别名]
    def select_proposal(self, selected_proposal):
        beamline_name = api.lims.beamline_name
        proposal = selected_proposal["Proposal"]
        # person = selected_proposal['Person']
        # laboratory = selected_proposal['Laboratory']
        sessions = selected_proposal["Session"]
        # Check if there are sessions in the proposal
        todays_session = None
        if sessions is None or len(sessions) == 0:
            pass
        else:
            # Check for today's session
            for session in sessions:
                beamline = session["beamlineName"]
                start_date = "%s 00:00:00" % session["startDate"].split()[0]
                end_date = "%s 23:59:59" % session["endDate"].split()[0]
                try:
                    start_struct = time.strptime(start_date, "%Y-%m-%d %H:%M:%S")
                except ValueError:
                    pass
                else:
                    try:
                        end_struct = time.strptime(end_date, "%Y-%m-%d %H:%M:%S")
                    except ValueError:
                        pass
                    else:
                        start_time = time.mktime(start_struct)
                        end_time = time.mktime(end_struct)
                        current_time = time.time()

                        # Check beamline name
                        if beamline == beamline_name:
                            # Check date
                            if current_time >= start_time and current_time <= end_time:
                                todays_session = session
                                break

        if todays_session is None:
            is_inhouse = api.session.is_inhouse(
                proposal["code"], proposal["number"]
            )
            if not is_inhouse:
                if BaseWidget.is_instance_role_client():
                    self.refuse_login(
                        None, "You don't have a session scheduled for today!"
                    )
                    return

                # if not self.askForNewSession():
                #    self.refuseLogin(None, None)
                #    return

            current_time = time.localtime()
            start_time = time.strftime("%Y-%m-%d 00:00:00", current_time)
            end_time = time.mktime(current_time) + 60 * 60 * 24
            tomorrow = time.localtime(end_time)
            end_time = time.strftime("%Y-%m-%d 07:59:59", tomorrow)

            # Create a session
            new_session_dict = {}
            new_session_dict["proposalId"] = selected_proposal["Proposal"]["proposalId"]
            new_session_dict["startDate"] = start_time
            new_session_dict["endDate"] = end_time
            new_session_dict["beamlineName"] = beamline_name
            new_session_dict["scheduled"] = 0
            new_session_dict["nbShifts"] = 3
            new_session_dict["comments"] = "Session created by MXCuBE"
            session_id = api.lims.create_session(new_session_dict)
            new_session_dict["sessionId"] = session_id

            todays_session = new_session_dict
            localcontact = None
        else:
            session_id = todays_session["sessionId"]
            logging.getLogger().debug(
                "ProposalBrick: getting local contact for %s" % session_id
            )
            localcontact = api.lims.get_session_local_contact(session_id)

        # self.accept_login(selected_proposal['Proposal'],
        #                 selected_proposal['Person'],
        #                 selected_proposal['Laboratory'],
        #                 todays_session,
        #                 localcontact)
        self.accept_login(selected_proposal["Proposal"], todays_session)
开发者ID:IvarsKarpics,项目名称:mxcube,代码行数:87,代码来源:ProposalBrick.py


注:本文中的gui.BaseComponents.BaseWidget.is_instance_role_client方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。