Ejemplo n.º 1
0
    def upgrade(cls):
        config_object = Config()
        config = config_object.get_config()

        Setup.run(config)
        CLI.colored_print("KoBoToolbox has been upgraded", CLI.COLOR_SUCCESS)

        # update itself
        git_command = ["git", "pull", "origin", "master"]
        CLI.run_command(git_command)
        CLI.colored_print("KoBoInstall has been upgraded", CLI.COLOR_SUCCESS)
Ejemplo n.º 2
0
    def run(cls, version=None, cron=False, update_self=True):
        # Validate kobo-docker already exists and is valid
        Setup.validate_already_run()

        if version is None:
            git_commit_version_command = [
                'git',
                'rev-parse',
                '--abbrev-ref',
                'HEAD',
            ]
            version = CLI.run_command(git_commit_version_command).strip()

        if update_self:
            # Update kobo-install first
            Setup.update_koboinstall(version)
            CLI.colored_print('kobo-install has been updated',
                              CLI.COLOR_SUCCESS)

            # Reload this script to use `version`.
            # NB:`argv[0]` does not automatically get set to the executable
            # path as it usually would, so we have to do it manually--hence the
            # double `sys.executable`
            sys.argv.append(cls.NO_UPDATE_SELF_OPTION)
            os.execl(sys.executable, sys.executable, *sys.argv)

        # Update kobo-docker
        Setup.update_kobodocker()
        CLI.colored_print('kobo-docker has been updated', CLI.COLOR_SUCCESS)
        Setup.post_update(cron)
Ejemplo n.º 3
0
    def update(cls):
        config_object = Config()
        config = config_object.get_config()

        Setup.update_kobodocker(config)
        CLI.colored_print("KoBoToolbox has been updated", CLI.COLOR_SUCCESS)

        # update itself
        git_command = ['git', 'pull', 'origin', Config.KOBO_INSTALL_BRANCH]
        CLI.run_command(git_command)
        CLI.colored_print("KoBoInstall has been updated", CLI.COLOR_SUCCESS)

        CLI.colored_print(
            "╔═════════════════════════════════════════════════════╗",
            CLI.COLOR_WARNING)
        CLI.colored_print(
            "║ After an update, it's strongly recommended to run   ║",
            CLI.COLOR_WARNING)
        CLI.colored_print(
            "║ `./run.py --setup` to regenerate environment files. ║",
            CLI.COLOR_WARNING)
        CLI.colored_print(
            "╚═════════════════════════════════════════════════════╝",
            CLI.COLOR_WARNING)

        CLI.colored_print("Do you want to proceed?", CLI.COLOR_SUCCESS)
        CLI.colored_print("\t1) Yes")
        CLI.colored_print("\t2) No")
        response = CLI.get_response([Config.TRUE, Config.FALSE], Config.TRUE)
        if response == Config.TRUE:
            current_config = config_object.build()
            Template.render(config_object)
            config_object.init_letsencrypt()
            Setup.update_hosts(current_config)

            CLI.colored_print("Do you want to (re)start containers?",
                              CLI.COLOR_SUCCESS)
            CLI.colored_print("\t1) Yes")
            CLI.colored_print("\t2) No")
            response = CLI.get_response([Config.TRUE, Config.FALSE],
                                        Config.TRUE)
            if response == Config.TRUE:
                Command.start()
class CalculatorTest(unittest.TestCase):
    """Test Scenario for Calculator"""

    setup = Setup()
    calcsession = None
    calc = None
    action = None
    app = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"

    def setUp(self):

        self.calcsession = self.setup.setUp(self.app)
        self.calc = Calc(self.calcsession)
        self.action = Action(self.calcsession)

    def tearDown(self):
        self.setup.tearDown()

    def test_addition(self):
        """Addition test"""

        print("Adding Test")
        self.calc.button("One").click()
        self.calc.button("Nine").click()
        self.calc.button("Plus").click()
        self.calc.button("Three").click()
        self.calc.button("Equals").click()

        self.assertEqual(self.calc.get_display_result(), "22")

    def test_subtraction(self):
        """Subtraction test"""

        print("Subtraction Test")
        self.calc.button("One").click()
        # first click not performed, no idea why
        self.calc.button("One").click()
        self.calc.button("Nine").click()
        self.calc.button("Minus").click()
        self.calc.button("Three").click()
        self.calc.button("Equals").click()

        self.assertEqual(self.calc.get_display_result(), "16")

    def test_move_calc(self):
        """Moving test"""

        print("Moving Test")
        self.action.click_and_hold(self.calc.app_hold()).move_by_offset(
            50, 50).perform()
        self.action.click_and_hold(self.calc.app_hold()).move_by_offset(
            -50, -50).perform()
        # not working ...
        self.action.context_click(self.calc.app_hold()).perform()
        time.sleep(2)
Ejemplo n.º 5
0
def run(force_setup=False):

    if sys.version_info[0] == 2:
        CLI.colored_print("╔═══════════════════════════════════════════════════════════════╗", CLI.COLOR_ERROR)
        CLI.colored_print("║ DEPRECATION: Python 2.7 has reached the end of its life on    ║", CLI.COLOR_ERROR)
        CLI.colored_print("║ January 1st, 2020. Please upgrade your Python as Python 2.7   ║", CLI.COLOR_ERROR)
        CLI.colored_print("║ is not maintained anymore.                                    ║", CLI.COLOR_ERROR)
        CLI.colored_print("║ A future version of KoBoInstall will drop support for it.     ║", CLI.COLOR_ERROR)
        CLI.colored_print("╚═══════════════════════════════════════════════════════════════╝", CLI.COLOR_ERROR)

    if not platform.system() in ["Linux", "Darwin"]:
        CLI.colored_print("Not compatible with this OS", CLI.COLOR_ERROR)
    else:
        config = Config()
        current_config = config.get_config()
        if config.first_time:
            force_setup = True

        if force_setup:
            current_config = config.build()
            Setup.clone_kobodocker(config)
            Template.render(config)
            config.init_letsencrypt()
            Setup.update_hosts(current_config)
        else:
            if config.auto_detect_network():
                Template.render(config)
                Setup.update_hosts(current_config)

        Command.start()
Ejemplo n.º 6
0
def run(force_setup=False):

    if sys.version_info[0] == 2:
        message = (
            'DEPRECATION: Python 2.7 has reached the end of its life on '
            'January 1st, 2020. Please upgrade your Python as Python 2.7 is '
            'not maintained anymore.\n\n'
            'A future version of KoBoInstall will drop support for it.')
        CLI.framed_print(message)

    if not platform.system() in ['Linux', 'Darwin']:
        CLI.colored_print('Not compatible with this OS', CLI.COLOR_ERROR)
    else:
        config = Config()
        dict_ = config.get_dict()
        if config.first_time:
            force_setup = True

        if force_setup:
            dict_ = config.build()
            Setup.clone_kobodocker(config)
            Template.render(config)
            config.init_letsencrypt()
            Setup.update_hosts(dict_)
        else:
            if config.auto_detect_network():
                Template.render(config)
                Setup.update_hosts(dict_)

        Command.start()
Ejemplo n.º 7
0
    def run(cls, version='stable', cron=False, update_self=True):
        # Validate kobo-docker already exists and is valid
        Setup.validate_already_run()

        if update_self:
            # Update kobo-install first
            Setup.update_koboinstall(version)
            CLI.colored_print("KoBoInstall has been updated",
                              CLI.COLOR_SUCCESS)

            # Reload this script to use `version`.
            # NB:`argv[0]` does not automatically get set to the executable
            # path as it usually would, so we have to do it manually--hence the
            # double `sys.executable`
            sys.argv.append(cls.NO_UPDATE_SELF_OPTION)
            os.execl(sys.executable, sys.executable, *sys.argv)

        # Update kobo-docker
        Setup.update_kobodocker()
        CLI.colored_print("KoBoToolbox has been updated", CLI.COLOR_SUCCESS)
        Setup.post_update(cron)
Ejemplo n.º 8
0
class NotepadTest(unittest.TestCase):
    """Test Scenario for Notepad"""

    setup = Setup()
    notepad_session = None
    notepad = None
    action = None
    app = "c:\\windows\\system32\\notepad.exe"

    def setUp(self):
        self.notepad_session = self.setup.setUp(self.app)
        self.notepad = Note(self.notepad_session)
        self.action = Action(self.notepad_session)

    def tearDown(self):
        self.setup.tearDown()

    def test_01(self):
        print("Test Case 01")
        input_text = "Windriver is awesome?"
        self.notepad.text_area().send_keys(input_text)
        text_area = self.notepad.text_area()
        self.assertEqual(text_area.text, input_text)

        self.notepad.text_area().send_keys(Keys.ALT, Keys.F4)
        self.notepad.exit_dialog("Cancel").click()
        self.notepad.text_area().send_keys(Keys.ALT, Keys.F4)
        self.notepad.exit_dialog("Don't Save").click()

    def test_02(self):
        print("Test Case 02")
        self.notepad.menu("File").click()
        time.sleep(3)

    def test_03(self):
        print("Test Case 03")
        self.notepad.window("Minimize").click()
        time.sleep(3)
Ejemplo n.º 9
0
def run(force_setup=False):

    if not platform.system() in ["Linux", "Darwin"]:
        CLI.colored_print("Not compatible with this OS", CLI.COLOR_ERROR)
    else:
        config = Config()
        current_config = config.get_config()
        if not current_config:
            force_setup = True

        if force_setup:
            current_config = config.build()
            Setup.run(current_config)
            Template.render(config)
            Setup.update_hosts(current_config)
        else:
            if config.auto_detect_network():
                Template.render(config)
                Setup.update_hosts(current_config)

        Command.start()
Ejemplo n.º 10
0
def run(force_setup=False):

    if not platform.system() in ['Linux', 'Darwin']:
        CLI.colored_print('Not compatible with this OS', CLI.COLOR_ERROR)
    else:
        config = Config()
        dict_ = config.get_dict()
        if config.first_time:
            force_setup = True

        if force_setup:
            dict_ = config.build()
            Setup.clone_kobodocker(config)
            Template.render(config)
            Setup.update_hosts(dict_)
        else:
            if config.auto_detect_network():
                Template.render(config)
                Setup.update_hosts(dict_)

        config.validate_passwords()
        Command.start(force_setup=force_setup)
Ejemplo n.º 11
0
    def upgrade(cls):
        config_object = Config()
        config = config_object.get_config()

        Setup.run(config)
        CLI.colored_print("KoBoToolbox has been upgraded", CLI.COLOR_SUCCESS)