Ejemplo n.º 1
0
    def get_client():
        """
        Build Splash Client

        :return SplashClient
        """
        from splashpy.client import SplashClient
        if isinstance(OdooClient.__splash_client, SplashClient):
            # ====================================================================#
            # Ensure Framework is in Client Mode
            Framework.setServerMode(False)
            return OdooClient.__splash_client
        # ====================================================================#
        # Init Odoo User & Company
        # SettingsManager.ensure_company()
        # ====================================================================#
        # Build Splash Client with Common Options
        OdooClient.__splash_client = SplashClient(
            SettingsManager.get_id(), SettingsManager.get_key(),
            OdooClient.get_mapped_objects(), OdooClient.get_mapped_widgets(),
            OdooClient())
        # ====================================================================#
        # Ensure Framework is in Client Mode
        Framework.setServerMode(False)
        # ====================================================================#
        # Force Ws Host if Needed
        if SettingsManager.is_expert():
            Framework.config().force_host(SettingsManager.get_host())

        return OdooClient.__splash_client
Ejemplo n.º 2
0
    def decrypt(data):
        """Decrypt Splash Messages"""

        # ====================================================================#
        # Safety Checks
        if not Encryption.verify(data):
            return False
        # ====================================================================#
        # Encrypt Data
        if Framework.config().method() == "AES-256-CBC":
            wsId, wsKey, wsHost = Framework.config().identifiers()
            return AESCipher(wsKey, wsId).decrypt(data)

        return False
Ejemplo n.º 3
0
    def encrypt(data):
        """Encrypt Splash Messages"""

        # ====================================================================#
        # Safety Checks
        if not Encryption.verify(data):
            return False

        # ====================================================================#
        # Encrypt Data
        if Framework.config().method() == "AES-256-CBC":
            logging.debug("Encrypt using AES-256-CBC Method")
            wsId, wsKey, wsHost = Framework.config().identifiers()
            return AESCipher(wsKey, wsId).encrypt(data)

        return False
Ejemplo n.º 4
0
    def getInstance():
        """
        Safe Access to Splash WebService Client

        :rtype: SplashClient
        """
        wsId, wsKey, wsHost = Framework.config().identifiers()

        return SplashClient(wsId, wsKey, None, None, Framework.getClientInfo(), Framework.getServerDetails(), Framework.config())
Ejemplo n.º 5
0
    def verify(data):
        """Verify Client Configuration & Input Data"""
        # Check Configuration
        if not Framework.config().is_valid():
            return False
        # Check Inputs
        if not isinstance(data, str):
            return False

        return True
Ejemplo n.º 6
0
    def get_server():
        """
        Build Splash Server

        :return SplashServer
        """
        from splashpy.server import SplashServer
        # ====================================================================#
        # Init Odoo User & Company
        SettingsManager.ensure_company()
        # ====================================================================#
        # Build Splash Server with Common Options
        splash_server = SplashServer(SettingsManager.get_id(),
                                     SettingsManager.get_key(),
                                     OdooClient.get_mapped_objects(),
                                     OdooClient.get_mapped_widgets(),
                                     OdooClient())
        # ====================================================================#
        # Force Ws Host if Needed
        if SettingsManager.is_expert():
            Framework.config().force_host(SettingsManager.get_host())

        return splash_server
Ejemplo n.º 7
0
    def test(self, **kw):
        """
         Respond to User Debug Requests
         """
        from splashpy.client import SplashClient

        # ====================================================================#
        # Init Splash Framework
        try:
            OdooClient.get_server()
        except Exception as exception:
            Framework.log().fromException(exception, False)
            return Framework.log().to_html_list(True)
        # ====================================================================#
        # Load Server Info
        wsId, wsKey, wsHost = Framework.config().identifiers()
        raw_html = "<h3>Server Debug</h3>"
        # ====================================================================#
        # Execute Ping Test
        ping = SplashClient.getInstance().ping()
        raw_html += Framework.log().to_html_list(True)
        if not ping:
            Framework.log().error('Ping Test Fail: ' + str(wsHost))
        # ====================================================================#
        # Execute Connect Test
        connect = SplashClient.getInstance().connect()
        raw_html += Framework.log().to_html_list(True)
        if not connect:
            Framework.log().error('Connect Test Fail: ' + str(wsHost))
        # ====================================================================#
        # Show Server Info
        infos = Framework.getClientInfo().get()
        Framework.log().info('Server Type: ' + str(infos['shortdesc']))
        Framework.log().info('Server Url: ' + str(infos["serverurl"]))
        Framework.log().info('Module Version: ' + str(infos["moduleversion"]))

        return raw_html + Framework.log().to_html_list(True)