gui.py 文件源码

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

项目:high-quality-chat 作者: b6938236 项目源码 文件源码
def get_text(self, conn_string):
        if conn_string is not None and len(conn_string) != 0:  # Use the provided connection string
            connection_details = self.app.config.parse_conn_string()

            if not connection_details['server'] \
                    and not connection_details['user'] \
                    and not connection_details['password'] \
                    and not connection_details['call_no']:
                self.app.config.update_setting('ConnectionDetails', 'server', connection_details['server'])
                self.app.config.update_setting('ConnectionDetails', 'user', connection_details['user'])
                self.app.config.update_setting('ConnectionDetails', 'password', connection_details['password'])
                self.app.config.update_setting('ConnectionDetails', 'call_no', connection_details['call_no'])

            else:
                print "Bad connection string"
                error_message = 'Sorry, that string is not valid'
                popup = Popup(title='Connection String Error',
                              content=Label(text=error_message),
                              size_hint=(None, None), size=(400, 400))
                popup.open()

        else:  # Use the saved config values
            connection_details = self.app.config.get_section('ConnectionDetails')

            def is_valid(value):
                if value != '' and value != 'None' and value is not None:
                    return True
                return False

            if not is_valid(connection_details['server']) \
                    or not is_valid(connection_details['user']) \
                    or not is_valid(connection_details['password']) \
                    or not is_valid(connection_details['call_no']):
                # If the stored values aren't valid, nogood
                print "No connection string and bad config values"
                error_message = 'Sorry, the configuration is not valid'
                popup = Popup(title='Connection String Error',
                              content=Label(text=error_message),
                              size_hint=(None, None), size=(400, 400))
                popup.open()

        if self.app.config.get('ChatSettings', 'role') == "ARTIST":
            self.parent.current = 'artist_session'
        else:
            self.parent.current = 'listener_session'

        filename = self.app.config.get_file_name(self.app.session_name, datetime.now().strftime(constants.DATETIME_LQ))
        self.app.phone.make_call(connection_details['call_no'], connection_details['server'], filename)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号