Пример #1
0
 def do_run_testserver(self, statement: cmd2.Statement):
     """
     Start Django dev server with the test project
     """
     # Start the "[tool.poetry.scripts]" script via subprocess
     # This works good with django dev server reloads
     verbose_check_call('run_testserver', *statement.arg_list, cwd=PACKAGE_ROOT)
Пример #2
0
 def do_poetry(self, statement: cmd2.Statement):
     """
     Call poetry and pass all given arguments to it.
     """
     verbose_check_call('poetry',
                        *statement.arg_list,
                        cwd=self.config.base_path,
                        exit_on_error=True)
Пример #3
0
 def do_pytest(self, statement: cmd2.Statement):
     """
     Run dev-shell tests via pytest
     """
     verbose_check_call('pytest',
                        *statement.arg_list,
                        cwd=self.config.base_path,
                        exit_on_error=True)
Пример #4
0
    def do_publish(self, statement: cmd2.Statement):
        # don't publish if test fails:
        verbose_check_call('pytest', '-x')

        poetry_publish(
            package_root=PACKAGE_ROOT,
            version=py_rcon_shell.__version__,
        )
Пример #5
0
def run_linters(cwd=None):
    """
    Run code formatters and linter
    """
    verbose_check_call('darker',
                       '--diff',
                       '--check',
                       cwd=cwd,
                       exit_on_error=True)
    verbose_check_call('flake8', cwd=cwd, exit_on_error=True)
Пример #6
0
 def do_linting(self, statement: cmd2.Statement):
     """
     Linting: Check code style with darker and flake8
     """
     verbose_check_call('darker',
                        '--diff',
                        '--check',
                        cwd=self.config.base_path)
     verbose_check_call('flake8',
                        cwd=self.config.base_path,
                        exit_on_error=True)
Пример #7
0
    def do_publish(self, statement: cmd2.Statement):
        """
        Publish "dev-shell" to PyPi
        """
        # don't publish if test fails:
        verbose_check_call('pytest', '-x')

        poetry_publish(
            package_root=PACKAGE_ROOT,
            version=django_yunohost_integration.__version__,
        )
Пример #8
0
 def do_update(self, statement: cmd2.Statement):
     """
     Call "poetry update" to update all dependencies in .venv
     """
     verbose_check_call('poetry',
                        'update',
                        *statement.arg_list,
                        cwd=self.config.base_path,
                        exit_on_error=True)
     script_name = Path(sys.argv[0]).name
     print(bright_green(f'\n\nPlease restart "{script_name}" !\n'))
     sys.exit(0)  # Stop cmd
Пример #9
0
 def do_update_test_snapshots(self, statement: cmd2.Statement):
     """
     Update all test snapshot files by run tests with RAISE_SNAPSHOT_ERRORS=0
     """
     verbose_check_call(
         'pytest',
         *statement.arg_list,
         cwd=self.config.base_path,
         exit_on_error=True,
         extra_env={
             # https://github.com/boxine/bx_py_utils#notes-about-snapshot
             'RAISE_SNAPSHOT_ERRORS': '0'
         }
     )
Пример #10
0
    def do_publish(self, statement: cmd2.Statement):
        """
        Publish "dev-shell" to PyPi
        """
        # don't publish if README is not up-to-date:
        assert_rst_readme(package_root=PACKAGE_ROOT, filename='README.creole')

        # don't publish if code style wrong:
        run_linters()

        # don't publish if test fails:
        verbose_check_call('pytest', '-x')

        poetry_publish(
            package_root=PACKAGE_ROOT,
            version=inventory.__version__,
            creole_readme=True  # don't publish if README.rst is not up-to-date
        )
Пример #11
0
    def do_publish(self, statement: cmd2.Statement):
        """
        Publish "dev-shell" to PyPi
        """
        # Maybe a project that use dev-shell doesn't use poetry-publish, too!
        # So import it here to make this dependency "optional"
        from poetry_publish.publish import poetry_publish  # noqa

        # Don't publish if test failed or code linting wrong:
        verbose_check_call(
            'pytest',
            '-x',
            cwd=self.config.base_path,
            exit_on_error=True,
        )
        run_linters(cwd=self.config.base_path)

        poetry_publish(
            package_root=self.config.base_path,
            version=self.config.version,
        )
Пример #12
0
 def do_list_venv_packages(self, statement: cmd2.Statement):
     """
     Just call "pip freeze" to list all installed venv packages
     """
     verbose_check_call('pip', 'freeze', cwd=self.config.base_path)
Пример #13
0
def run_fix_code_style(cwd=None):
    verbose_check_call('darker', cwd=cwd)