コード例 #1
0
ファイル: apps.py プロジェクト: brosner/suitcaseproject
def generate_depends(global_config, package_config):
    """Generates the app dependencies automagically"""
    
    apps_path = package_config["path"].replace("apps","assets/apps")
    
    package_config["depends"] = merge_and_de_dupe(package_config["depends"])

    if os.path.isdir(apps_path):
        package_config["depends"] = merge_and_de_dupe(
            package_config["depends"],
            Debian.make_package_name(
                global_config["base_path"], 
                apps_path, 
                global_config.get("prefix"),
                global_config.get("package_name_filters")
            ) 
        )

    app_template_path = package_config["path"].replace(
        "apps", "templates/root/apps"
    )
    
    if os.path.isdir(app_template_path):
        
        package_config["depends"] = merge_and_de_dupe( 
            package_config["depends"],
            Debian.make_package_name(
                global_config["base_path"], 
                app_template_path, 
                global_config.get("prefix"),
                global_config.get("package_name_filters")
            ) 
        )
    
    return package_config
コード例 #2
0
ファイル: debian.py プロジェクト: brosner/suitcaseproject
    def make_package_conf_files(self):
        """Write out the control file and the configfiles for the deb package"""

        if DEBUG:
            import pprint

            pprint.pprint(self.package_config)

        # Write the control file
        control_dir = "%s/DEBIAN" % self.package_config["working_dir"]

        if not os.path.exists(control_dir):
            os.mkdir(control_dir)

        control_file = open("%s/control" % control_dir, "w")

        control_template = self.global_config.get(
            "control_template", os.path.join(os.path.dirname(__file__), "../templates/debian/control_minimum.template")
        )

        if not os.path.exists(control_template):
            raise SuitcasePackagingError("Missing control template file: %s" % os.path.abspath(control_template))

        template = open("%s" % control_template).read()

        self.package_config["maintainer"] = self.package_config.get("maintainer", self.global_config.get("maintainer"))
        self.package_config["description"] = self.package_config.get(
            "description", "%s package" % (self.package_config["package"])
        )

        # deal with depends - make a deduped, comma separated list, without
        # the package itself in
        depends = merge_and_de_dupe(self.package_config.get("depends", []))

        if self.package_config["package"] in depends:
            depends.remove(self.package_config["package"])

        if depends is None:
            depends = []

        self.package_config["depends"] = ", ".join(depends)
        if not self.package_config["depends"]:
            template = template.replace("Depends: %(depends)s\n", "")

        try:
            control_file.write(template % self.package_config)
        except KeyError, error:
            raise SuitcasePackagingError("%s missing from config" % error)
コード例 #3
0
ファイル: configs.py プロジェクト: brosner/suitcaseproject
def generate_depends(global_config, package_config):
    """Generates the config dependencies automagically"""

    # now export the root as whatever is in export_base_path_as
    if global_config.get("export_base_path_as"):
        
        relative_import(
            global_config["base_path"],
            global_config["export_base_path_as"]
        )
    
        # now load the config.settings file 
        config_path = package_config["path"]

        if config_path.endswith("/"):
            config_path = config_path[:-1]

        # make the config module name
        config_module = "configs.%s.settings" % config_path.split("/")[-1]

        if global_config.get("prefix"):
            config_module = "%s.%s" % (global_config["prefix"], config_module)

        package_config["depends"] = merge_and_de_dupe(
            package_config["depends"]
        )

        try:
            config_settings = dynamic_import(config_module)
            for app in config_settings.INSTALLED_APPS:
                if "django.contrib.admin" in app:
                    
                    migration_package = Debian.make_package_name(
                        global_config["base_path"],
                        os.path.join(global_config["base_path"],"migrations"), 
                        global_config.get("prefix"),
                        global_config.get("package_name_filters")
                    )
                    
                    # work out migration package
                    migration_config = {
                        "path":os.path.join(global_config["base_path"],"migrations")
                    }
                    
                    migration_version = Debian(global_config).get_package_version(
                        migration_config
                    )
                    
                    package_config["depends"] = merge_and_de_dupe(
                        package_config["depends"],
                        "%s (>=%s)" % (
                            migration_package,
                            migration_version
                        )
                    )

                elif not app.startswith("django"):
                    app_package = Debian.normalise_package_name(
                        app,
                        global_config.get("package_name_filters")
                    )
                    
                    package_config["depends"] = merge_and_de_dupe(
                        package_config["depends"],app_package
                    )
        except:
            display_warning('Suitcase Warning: No settings file found for config package %s' % package_config["package"])

    if package_config.get("target_hosts"):
        
        for host in package_config["target_hosts"]:
            asset_path = os.path.join(
                global_config["base_path"],
                "assets",
                "domains",
                host
            )
            
            if os.path.exists(asset_path):
                
                package_config["depends"] = merge_and_de_dupe(
                    package_config["depends"],
                    Debian.make_package_name(
                        global_config["base_path"],
                        asset_path, 
                        global_config.get("prefix"),
                        global_config.get("package_name_filters")
                    )
                )

            template_path = os.path.join(
                global_config["base_path"], 
                "templates", 
                "root",
                "domains",
                host
            )
            
            if os.path.exists(template_path):
                package_config["depends"] = merge_and_de_dupe(
                    package_config["depends"],
                    Debian.make_package_name(
                        global_config["base_path"],
                        template_path, 
                        global_config.get("prefix"),
                        global_config.get("package_name_filters")
                    )
                )

    return package_config
コード例 #4
0
ファイル: tests.py プロジェクト: brosner/suitcaseproject
 def test_list_merge_and_de_dupe2(self):
     """testing merging + deduping lists 2"""
     list1 = 1
     list2 = [2, 2, 3, 4]
     new_list = merge_and_de_dupe(list1, list2)
     self.assert_equal(new_list, [1, 2, 3, 4])