Exemple #1
0
def run():
    os.chdir(workspace().directory)
    plugin_dependencies = workspace().config().dependencies.plugins
    copy_dependencies(plugin_dependencies, 'https://api.wordpress.org/plugins/info/1.0/{}.json', 'plugins')

    theme_dependencies = workspace().config().dependencies.themes
    copy_dependencies(theme_dependencies, 'https://api.wordpress.org/themes/info/1.1/?action=theme_information&request[slug]={}&request[fields][versions]=true', 'themes')
Exemple #2
0
def run():
    prototype_name = environment().prototype_name
    print("Adding prototype %s" % prototype_name)

    prototype_template_path = environment().prototype_template_path
    if not prototype_template_path:
        raise Exception("No prototype template path provided")

    logger.debug(
        "Reading prototype template from {}".format(prototype_template_path))
    prototype_template = TemplateFolder(prototype_template_path)
    prototype_path = workspace().prototype_path(prototype_name)
    prototype_template.copy_to(prototype_path)

    prototype_data_path = os.path.join(prototype_template_path,
                                       'gunilla-prototype.json')
    if not os.path.exists(prototype_data_path):
        raise Exception(
            "%s does not contain a valid prototype template, missing 'gunilla-prototype.json'"
            % prototype_template_path)

    os.remove(os.path.join(prototype_path, 'gunilla-prototype.json'))

    with open(prototype_data_path, 'r') as f:
        prototype_data = json.load(f)
        prototype = Prototype(prototype_data)
        workspace().add_prototype(prototype_name, prototype)
Exemple #3
0
def run_builder(root_path):
    if not os.path.exists(root_path) or not os.path.isdir(root_path):
        raise ActionException(
            "Provided path does not exist or is not a folder ({})".format(
                root_path))

    prototypes_path = os.path.join(root_path, 'prototypes')
    themes_path = os.path.join(root_path, 'themes')
    prototype_names = os.listdir(prototypes_path)
    for prototype_name in prototype_names:
        prototype_path = os.path.join(prototypes_path, prototype_name)
        if not os.path.isdir(prototype_path):
            continue

        gunilla_config = workspace().config()
        prototype_config = gunilla_config.prototypes[prototype_name]
        prototype_root_path = os.path.join(prototypes_path, prototype_name)
        os.chdir(prototype_root_path)

        build_cmd = prototype_config.build_cmd
        if build_cmd:
            print("Building prototype {}".format(prototype_name))
            subprocess.call(build_cmd, shell=True)

        print("Building theme {}".format(prototype_name))
        prototype_path = os.path.join(prototype_root_path,
                                      prototype_config.path)
        theme_path = os.path.join(themes_path, prototype_name)
        config = ThemeBuilderConfig(prototype_path, theme_path)

        builder = ThemeBuilder(config)
        builder.build()
Exemple #4
0
 def deregister(self):
     temp_file = self.temp_file()
     with open(temp_file, 'w') as f:
         with open(self.host_file) as host_file:
             for line in host_file:
                 if not workspace().config().project_name in line:
                     f.write(line)
     shutil.move(temp_file, self.host_file)
Exemple #5
0
def run():
    if not workspace().is_configured():
        raise ActionException("Project was not already set up")

    infrastructure().clear()

    if environment().clear_volumes:
        infrastructure().clear_volumes()
Exemple #6
0
 def host_registered(self):
     with open(self.host_file) as f:
         line = f.readline()
         while line:
             if workspace().config().project_name in line:
                 return True
             line = f.readline()
     return False
Exemple #7
0
def print_howto():
    print("Connect to WP via:")
    print("- http://{}/".format(infrastructure().get_wordpress_container_ip()))
    print("- http://{}/ (you need first to run 'register_host')".format(
        workspace().config().project_name))
    print("")
    print(
        "Note: If it is the first time you start the project, you might have to wait a few minutes before WP is actually available."
    )
Exemple #8
0
 def register(self, ip_address):
     if not ip_address:
         raise ActionException("No IP address detected")
     temp_file = self.temp_file()
     with open(temp_file, 'w') as f:
         with open(self.host_file) as host_file:
             for line in host_file:
                 f.write(line)
         f.write('{}\t{}\n'.format(ip_address,
                                   workspace().config().project_name))
     shutil.move(temp_file, self.host_file)
Exemple #9
0
def run():
    workspace_directory = workspace().directory
    if not os.path.exists(workspace_directory):
        logger.debug(
            "Creating workspace directory {}".format(workspace_directory))
        os.makedirs(workspace_directory)

    if not os.path.exists(workspace().config_file_path()):
        workspace().init_config_file()

    try:
        workspace().init()
    except WorkspaceException as e:
        raise ActionException(e)
Exemple #10
0
def run():
    run_builder(workspace().directory)
Exemple #11
0
 def __init__(self):
     self.config = workspace().config()
     self.client = DockerClient()
Exemple #12
0
def run():
    os.chdir(workspace().directory)
    Install().run()
Exemple #13
0
 def _validate(self):
     if not self.host_registered():
         raise ActionException("Host '{}' was not registered".format(
             workspace().config().project_name))