Esempio n. 1
0
    def create_user_package(self, name, metainfo, path=None):
        """
        Create a new package in the user space and register it
        Return the created package
        :param path : the directory where to create the package
        """

        if name in self.pkgs:
            return self.pkgs[name]

        # Create directory
        if not path:
            path = get_userpkg_dir()
        path = os.path.join(path, name)

        if not isdir(path):
            os.mkdir(path)

        if not os.path.exists(os.path.join(path, "__wralea__.py")):
            # Create new Package and its wralea
            p = UserPackage(name, metainfo, path)
            p.write()

        # Register package
        self.load_directory(path)
        self.write_config()

        p = self.pkgs.get(name)
        return p
Esempio n. 2
0
    def __init__(self, pkgs, name="", parent=None, metainfo=None):
        """
        @param pkgs : list of existing package name
        @param name : defaut name
        @param parent :
        @metainfo : default metainfo
        """

        qt.QtGui.QDialog.__init__(self, parent)
        ui_newpackage.Ui_NewPackageDialog.__init__(self)
        self.setupUi(self)

        self.pkgs = pkgs
        self.connect(self.pathButton, qt.QtCore.SIGNAL("clicked()"),
                     self.path_clicked)

        #self.pathEdit.setText(get_userpkg_dir())
        if (metainfo): self.set_data(name, "", metainfo)

        self.pathEdit.setText(get_userpkg_dir())
Esempio n. 3
0
    def __init__(self, pkgs, name="", parent=None, metainfo=None):
        """
        @param pkgs : list of existing package name
        @param name : defaut name
        @param parent :
        @metainfo : default metainfo
        """

        qt.QtGui.QDialog.__init__(self, parent)
        ui_newpackage.Ui_NewPackageDialog.__init__(self)
        self.setupUi(self)

        self.pkgs = pkgs
        self.connect(self.pathButton, qt.QtCore.SIGNAL("clicked()"), self.path_clicked)

        # self.pathEdit.setText(get_userpkg_dir())
        if metainfo:
            self.set_data(name, "", metainfo)

        self.pathEdit.setText(get_userpkg_dir())
Esempio n. 4
0
    def set_sys_wralea_path(self):
        """ Define the default wralea search path

        For that, we look for "wralea" entry points
        and deprecated_wralea entry point
        if a package is declared as deprecated_wralea,
        the module is not load
        """

        if self.sys_wralea_path:
            return

        self.sys_wralea_path = set()
        self.deprecated_pkg = set()

        if DEBUG:
            res = {}
        # Use setuptools entry_point
        for epoint in iter_entry_points("wralea"):
            # Get Deprecated packages
            if self.verbose:
                pmanLogger.debug(epoint.name + " " + epoint.module_name)
            if(epoint.module_name == "deprecated"):
                self.deprecated_pkg.add(epoint.name.lower())
                continue

            # base = epoint.dist.location
            # m = epoint.module_name.split('.')
            # p = os.path.join(base, *m)

            # Be careful, this lines will import __init__.py and all its predecessor
            # to find the path.
            if DEBUG:
                print(epoint.module_name)
                t1 = clock()

            try:
                m = importlib.import_module(epoint.module_name)
                #m = __import__(epoint.module_name, fromlist=epoint.module_name)
            except ImportError as e:
                logger.error("Cannot load %s : %s" % (epoint.module_name, e))
                # self.log.add("Cannot load %s : %s"%(epoint.module_name, e))
                continue

            if DEBUG:
                print((epoint.module_name))
                tn = clock() - t1
                res[tn] = epoint.module_name


            l = list(m.__path__)
            for p in l:
                p = os.path.abspath(p)
                logger.info("Wralea entry point: %s (%s) " % (epoint.module_name, p))
                # self.log.add("Wralea entry point: %s (%s) "%(epoint.module_name, p))
                self.add_wralea_path(p, self.sys_wralea_path)

        # Search the path based on the old method (by hand).
        # Search in openalea namespace
#        if(self.include_namespace):
#            l = list(openalea.__path__)
#            for p in l :
#                self.add_wralea_path(p, self.sys_wralea_path)

        if SEARCH_OUTSIDE_ENTRY_POINTS:
            self.add_wralea_path(os.path.dirname(__file__), self.sys_wralea_path)
            self.add_wralea_path(get_userpkg_dir(), self.sys_wralea_path)

        if DEBUG:
            return res