Esempio n. 1
0
    def disable_autologin(self):
        # creating `KiwoomOpenApiPlusQAxWidget` object in main process locks OpenAPI module file, even after deleting the object,
        # which prevents version update process from deleting and overwriting the original module file.
        # so here we are creating the object in subprocess and disables auto login based on the checked module path

        def main():
            from koapy import (  # pylint: disable=redefined-outer-name
                KiwoomOpenApiPlusVersionUpdater, )

            KiwoomOpenApiPlusVersionUpdater.disable_autologin_impl()

        cmd = function_to_subprocess_args(main)
        return subprocess.check_call(cmd)
Esempio n. 2
0
    def ConnectUsingPywinauto_RunScriptInSubprocess(cls, credential=None):
        def main():
            # pylint: disable=redefined-outer-name,reimported,import-self
            import json
            import sys

            from koapy import CybosPlusEntrypoint

            credential = json.load(sys.stdin)
            CybosPlusEntrypoint.ConnectUsingPywinauto_Impl(credential)

        args = function_to_subprocess_args(main)
        return subprocess.run(args,
                              input=json.dumps(credential),
                              text=True,
                              check=True)
    def LoginUsingPywinauto_RunScriptInSubprocess(cls, credential=None):
        def main():
            # pylint: disable=redefined-outer-name,reimported,import-self
            import json
            import sys

            from koapy.backend.kiwoom_open_api_plus.core.KiwoomOpenApiPlusQAxWidgetMixin import (
                KiwoomOpenApiPlusQAxWidgetMixin, )

            credential = json.load(sys.stdin)
            KiwoomOpenApiPlusQAxWidgetMixin.LoginUsingPywinauto_Impl(
                credential)

        args = function_to_subprocess_args(main)
        return subprocess.run(args,
                              input=json.dumps(credential),
                              text=True,
                              check=True)
Esempio n. 4
0
    def show_account_window(self):
        # this function does pretty much the same job like the `__open_login_window()` function.
        # but the difference is that it will show up the account setting window after successful login,
        # so that we can (re-)enable the auto login functionality provided by the OpenAPI itself.
        #
        # this process will stay live until the account window is closed in the `OnEventConnect` event,
        # hopefully after successfully enabling the auto login functionality.
        #
        # note that the `control.KOA_Functions('ShowAccountWindow', '')` line is also blocking process.
        # so it will block until the account window is closed after enabling the auto login.

        def main():
            from koapy import (  # pylint: disable=redefined-outer-name
                KiwoomOpenApiPlusVersionUpdater, )

            KiwoomOpenApiPlusVersionUpdater.show_account_window_impl()

        cmd = function_to_subprocess_args(main)
        creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
        proc = subprocess.Popen(cmd, creationflags=creationflags)
        atexit.register(proc.kill)
        return proc
Esempio n. 5
0
    def open_login_window(self):
        # opening login window is a blocking process. (`app.exec_()` is the blocking process and will wait for `app.exit()`)
        # also it's hard to use both PySide2/PyQt5 and pywinauto at the same time in the same process due to compatibility issue.
        #
        # in order to avoid the issues mentioned above we are creating login window in a separate process.
        # and then will do login using pywinauto in another process using `__login_using_pywinauto()` function.
        #
        # this process will stay live until `OnEventConnect` event happens, hopefully a successful login.
        #
        # for more information about the compatibility issue between PySide2/PyQt5 and pywinauto, check the following link:
        #   https://github.com/pywinauto/pywinauto/issues/472

        def main():
            from koapy import (  # pylint: disable=redefined-outer-name
                KiwoomOpenApiPlusVersionUpdater, )

            KiwoomOpenApiPlusVersionUpdater.open_login_window_impl()

        cmd = function_to_subprocess_args(main)
        creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
        proc = subprocess.Popen(cmd, creationflags=creationflags)
        atexit.register(proc.kill)
        return proc