Skip to content

Commit

Permalink
Merge pull request #1818 from UlrichB22/create_inst
Browse files Browse the repository at this point in the history
remove subprocess call from create_instance
  • Loading branch information
RogerHaase authored Dec 7, 2024
2 parents 577cece + 86977b2 commit b421b53
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/moin/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def _Help():


cli.add_command(create_instance.cli_CreateInstance)
cli.add_command(create_instance.cli_BuildInstance)

cli.add_command(index.cli_IndexCreate)
cli.add_command(index.IndexBuild)
Expand Down
16 changes: 7 additions & 9 deletions src/moin/cli/maint/create_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import os
import shutil
import subprocess
import click

from flask.cli import FlaskGroup
Expand Down Expand Up @@ -66,10 +65,14 @@ def CreateInstance(full, **kwargs):
"""
Create wikiconfig and wiki instance directories and copy required files.
"""
path = kwargs.get("path", None)
if full and path:
logging.error("The parameter full and path are mutually exclusive.")
return False
logging.debug("Instance creation started.")
config_path = os.path.dirname(config.__file__)
contrib_path = os.path.dirname(contrib.__file__)
path = kwargs.get("path", None)

if not path:
path = os.getcwd()
if os.path.exists(path):
Expand All @@ -93,19 +96,14 @@ def CreateInstance(full, **kwargs):
logging.info("Instance creation finished.")

if full:
if path != os.getcwd():
os.chdir(path)
subprocess.call("moin build-instance", shell=True)
build_instance()


@cli.command("build-instance", hidden=True)
def cli_BuildInstance():
def build_instance():
"""
Create and build index, load help data and welcome page.
This command is hidden in help. For internal use in "create-instance --full" only!
"""
logging.info("Build Instance started.")
logging.debug("CWD: %s", os.getcwd())
if index.IndexCreate():
modify_item.LoadHelp(namespace="help-en", path_to_help=None)
modify_item.LoadHelp(namespace="help-common", path_to_help=None)
Expand Down

0 comments on commit b421b53

Please sign in to comment.