コード例 #1
0
ファイル: general.py プロジェクト: rupinder/GNU-MyServer-GSoC
 def remove(self,args):
     console.write ("the following plugins will be removed:\n %s\n do you want to continue?[Y|n] " % (", ".join(args)))
     resp = string.lower(console.readln())
         
     while not resp in  ("y\n","n\n","\n"):
         console.write ("the following plugins will be removed:\n %s\n do you want to continue?[Y|n] " % (", ".join(args)))
         resp = string.lower(console.readln())
     if resp == 'n\n':
         console.writeln ("Install aborted.")
         return None
     
     console.writeln ("")
     
     for arg in args:
         if not self.__dbManager.isPluginInstalled(arg):
             console.writeln("Plugin %s already not installed.\n" % (arg))
         elif self.__dbManager.removePlugin(arg):
             console.writeln("Plugin %s removed.\n" % (arg))
         else:
             console.writeln("Error while removing plugin %s.\n" % (arg))            
コード例 #2
0
    def remove(self, args):
        console.write(
            "the following plugins will be removed:\n %s\n do you want to continue?[Y|n] "
            % (", ".join(args)))
        resp = string.lower(console.readln())

        while not resp in ("y\n", "n\n", "\n"):
            console.write(
                "the following plugins will be removed:\n %s\n do you want to continue?[Y|n] "
                % (", ".join(args)))
            resp = string.lower(console.readln())
        if resp == 'n\n':
            console.writeln("Install aborted.")
            return None

        console.writeln("")

        for arg in args:
            if not self.__dbManager.isPluginInstalled(arg):
                console.writeln("Plugin %s already not installed.\n" % (arg))
            elif self.__dbManager.removePlugin(arg):
                console.writeln("Plugin %s removed.\n" % (arg))
            else:
                console.writeln("Error while removing plugin %s.\n" % (arg))
コード例 #3
0
ファイル: general.py プロジェクト: rupinder/GNU-MyServer-GSoC
    def install(self,args):
        for arg in args:
            (plugin,list) = self.__find(arg)
            if plugin == None:
                console.writeln("No plugin with this name is present in the plugin database.")
                return None
            
            myserverVersion = self.__versionConverter(config.MYSERVER_VERSION)
            minversion = self.__versionConverter(plugin.getMyServerMinVersion())
            maxversion = self.__versionConverter(plugin.getMyServerMaxVersion())
            if myserverVersion < minversion or myserverVersion > maxversion:
                console.writeln("Plugin incompatible with GNU MyServer installed version.")
                return None
            
            
            toInstall = [(plugin,list)]
            (result,errors) = self.__recursiveDependencesChecker(plugin)
            if len(errors) != 0:
                for (plugin,msg) in errors:
                    console.writeln("Error while install %s: %s" % (plugin["name"][0]["value"],msg))
                return None
            toInstall.extend(result)

            
            console.write ("the following plugins will be installed:\n %s\n do you want to continue?[Y|n] " % (", ".join(plugin["name"][0]["value"] for (plugin,list) in toInstall)))
            resp = string.lower(console.readln())
            
            while not resp in  ("y\n","n\n","\n"):
                console.write ("the following plugins will be installed:\n %s\n do you want to continue?[Y|n] " % (", ".join(plugin["name"][0]["value"] for (plugin,list) in toInstall)))
                resp = string.lower(console.readln())
            if resp == 'n\n':
                console.writeln ("Install aborted.")
                return None
            
            downloadErrors = []
            for (plugin,list) in toInstall:
                if self.__dbManager.isPluginInstalled(plugin["name"][0]["value"]):
                    console.writeln ("plugin %s already installed." % (plugin["name"][0]["value"]))
                    continue
                rep = self.__repManager.getRepository(list.repository)
                rep = rep(list.repository)
                if not rep.getPluginBinary(list,plugin):
                    downloadErrors.append(plugin)
            
            if len(downloadErrors) != 0:
                console.writeln ("Errors retriving the follow plugins packages: %s" % (" ".join("%s-%s-%s.tar.gz" % (plugin["name"][0]["value"],plugin["version"][0]["value"],config.arch) for plugin in downloadErrors)))
                return None
                
            for (plugin,list) in toInstall:
                if self.__dbManager.isPluginInstalled(plugin["name"][0]["value"]):
                    continue
                
                filename = config.MYSERVER_PLUGIN_DIR + "/%s-%s-%s.tar.gz" % (plugin["name"][0]["value"],plugin["version"][0]["value"],config.arch)
                import tarfile
                console.writeln("Exctracting plugin package..")
                try:
                    tarf = tarfile.open(filename.encode("ascii"),"r|gz")
                    tarf.extractall (config.MYSERVER_PLUGIN_DIR)
                except Exception:
                    console.writeln("Error while exctracting plugin package!")
                    return None
                import os
                os.remove(filename)
                console.writeln("plugin %s installed.\n" % (plugin["name"][0]["value"]))
コード例 #4
0
    def install(self, args):
        for arg in args:
            (plugin, list) = self.__find(arg)
            if plugin == None:
                console.writeln(
                    "No plugin with this name is present in the plugin database."
                )
                return None

            myserverVersion = self.__versionConverter(config.MYSERVER_VERSION)
            minversion = self.__versionConverter(
                plugin.getMyServerMinVersion())
            maxversion = self.__versionConverter(
                plugin.getMyServerMaxVersion())
            if myserverVersion < minversion or myserverVersion > maxversion:
                console.writeln(
                    "Plugin incompatible with GNU MyServer installed version.")
                return None

            toInstall = [(plugin, list)]
            (result, errors) = self.__recursiveDependencesChecker(plugin)
            if len(errors) != 0:
                for (plugin, msg) in errors:
                    console.writeln("Error while install %s: %s" %
                                    (plugin["name"][0]["value"], msg))
                return None
            toInstall.extend(result)

            console.write(
                "the following plugins will be installed:\n %s\n do you want to continue?[Y|n] "
                % (", ".join(plugin["name"][0]["value"]
                             for (plugin, list) in toInstall)))
            resp = string.lower(console.readln())

            while not resp in ("y\n", "n\n", "\n"):
                console.write(
                    "the following plugins will be installed:\n %s\n do you want to continue?[Y|n] "
                    % (", ".join(plugin["name"][0]["value"]
                                 for (plugin, list) in toInstall)))
                resp = string.lower(console.readln())
            if resp == 'n\n':
                console.writeln("Install aborted.")
                return None

            downloadErrors = []
            for (plugin, list) in toInstall:
                if self.__dbManager.isPluginInstalled(
                        plugin["name"][0]["value"]):
                    console.writeln("plugin %s already installed." %
                                    (plugin["name"][0]["value"]))
                    continue
                rep = self.__repManager.getRepository(list.repository)
                rep = rep(list.repository)
                if not rep.getPluginBinary(list, plugin):
                    downloadErrors.append(plugin)

            if len(downloadErrors) != 0:
                console.writeln(
                    "Errors retriving the follow plugins packages: %s" %
                    (" ".join("%s-%s-%s.tar.gz" %
                              (plugin["name"][0]["value"],
                               plugin["version"][0]["value"], config.arch)
                              for plugin in downloadErrors)))
                return None

            for (plugin, list) in toInstall:
                if self.__dbManager.isPluginInstalled(
                        plugin["name"][0]["value"]):
                    continue

                filename = config.MYSERVER_PLUGIN_DIR + "/%s-%s-%s.tar.gz" % (
                    plugin["name"][0]["value"], plugin["version"][0]["value"],
                    config.arch)
                import tarfile
                console.writeln("Exctracting plugin package..")
                try:
                    tarf = tarfile.open(filename.encode("ascii"), "r|gz")
                    tarf.extractall(config.MYSERVER_PLUGIN_DIR)
                except Exception:
                    console.writeln("Error while exctracting plugin package!")
                    return None
                import os
                os.remove(filename)
                console.writeln("plugin %s installed.\n" %
                                (plugin["name"][0]["value"]))