[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[myserver-commit] [3021] myserver-get:
From: |
Daniele Perrone |
Subject: |
[myserver-commit] [3021] myserver-get: |
Date: |
Tue, 03 Mar 2009 13:21:15 +0000 |
Revision: 3021
http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3021
Author: dperrone
Date: 2009-03-03 13:21:12 +0000 (Tue, 03 Mar 2009)
Log Message:
-----------
myserver-get:
- refactoring install command code
- added source command
- added source-auto command (compile sources after download them)
Modified Paths:
--------------
trunk/misc/myserver-get/myserver-get.py
trunk/misc/myserver-get/myserverGetLib/config.py
trunk/misc/myserver-get/myserverGetLib/general.py
trunk/misc/myserver-get/myserverGetLib/local.py
trunk/misc/myserver-get/myserverGetLib/remote.py
trunk/misc/myserver-get/myserverGetLib/remoteGenericUrl.py
Modified: trunk/misc/myserver-get/myserver-get.py
===================================================================
--- trunk/misc/myserver-get/myserver-get.py 2009-03-03 13:01:10 UTC (rev
3020)
+++ trunk/misc/myserver-get/myserver-get.py 2009-03-03 13:21:12 UTC (rev
3021)
@@ -5,13 +5,13 @@
def usage(arg):
- print "usage: myserver-get update "
+ print "usage: myserver-get [update|search|install|source|source-auto]
[-v|--verbose|-h|--help] "
def main(argv):
myserverGet = MyServerGet()
command = ""
- commands = {"":usage, "update":myserverGet.update,
"search":myserverGet.search,"install":myserverGet.install}
+ commands = {"":usage, "update":myserverGet.update,
"search":myserverGet.search,"install":myserverGet.install,"source":myserverGet.source,"source-auto":myserverGet.sourceAuto}
import os
@@ -39,7 +39,7 @@
arguments = []
for arg in args:
- if arg in ("update","search","install"):
+ if arg in ("update","search","install","source","source-auto"):
command = arg
else:
arguments.append(arg)
Modified: trunk/misc/myserver-get/myserverGetLib/config.py
===================================================================
--- trunk/misc/myserver-get/myserverGetLib/config.py 2009-03-03 13:01:10 UTC
(rev 3020)
+++ trunk/misc/myserver-get/myserverGetLib/config.py 2009-03-03 13:21:12 UTC
(rev 3021)
@@ -13,10 +13,9 @@
MYSERVER_VERSION = "0.9"
+MSHEADERS = "/home/dany/srcprojects/myserver/myserver"
+
verbose = False
arch = ""
-class ConfigLoader:
- def __init__(self, configFile):
- self.__configFile = configFile
\ No newline at end of file
Modified: trunk/misc/myserver-get/myserverGetLib/general.py
===================================================================
--- trunk/misc/myserver-get/myserverGetLib/general.py 2009-03-03 13:01:10 UTC
(rev 3020)
+++ trunk/misc/myserver-get/myserverGetLib/general.py 2009-03-03 13:21:12 UTC
(rev 3021)
@@ -17,6 +17,7 @@
self.__repManager.addSupportedRepository("http",remoteGenericUrl.RepositoryGenericUrl)
self.__repManager.addSupportedRepository("ftp",remoteGenericUrl.RepositoryGenericUrl)
self.__list = []
+ self.__dbManager = local.DatabaseManager()
self.loadRepositoryList()
self.__versionRegex =
re.compile(r'^([1-2]?[1-9]?[0-9])?(.[1-2]?[0-9]?[0-9])?(.[1-2]?[0-9]?[0-9])?(.[1-2]?[0-9]?[0-9])?$')
@@ -28,11 +29,13 @@
result = numbers[i] << 8*(4-i)
return result
+
def loadRepositoryList(self):
list = xml.dom.minidom.parse(self.__rep)
repXmlList = list.getElementsByTagName("REPOSITORY")
self.__list =
[local.ListManager(repXml.firstChild.data,self.__listDir) for repXml in
repXmlList]
+
def update(self, arg):
for list in self.__list:
rep = self.__repManager.getRepository(list.repository)
@@ -49,6 +52,7 @@
results.append(plugin)
return results
+
def search(self,arg):
arg = " ".join(arg)
if config.verbose:
@@ -57,6 +61,7 @@
results = [plugin["name"][0]["value"] + " - " +
plugin["description"][0]["value"] for plugin in self.__search(arg)]
console.writeln("\n".join(results))
+
def __find(self,arg):
for list in self.__list:
plugins = list.getPluginsList()
@@ -65,6 +70,7 @@
return (plugin,list)
return [None, None]
+
def __recursiveDependencesChecker(self,pluginRoot):
result = []
errors = []
@@ -85,6 +91,7 @@
errors.extend(er)
return (result,errors)
+
def install(self,args):
for arg in args:
(plugin,list) = self.__find(arg)
@@ -107,6 +114,7 @@
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())
@@ -120,6 +128,9 @@
downloadErrors = []
for (plugin,list) in toInstall:
+ if self.__dbManager.isPluginInstalled(plugin):
+ 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):
@@ -130,6 +141,9 @@
return None
for (plugin,list) in toInstall:
+ if self.__dbManager.isPluginInstalled(plugin):
+ 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..")
@@ -141,4 +155,58 @@
return None
import os
os.remove(filename)
- console.writeln("plugin %s installed." %
(plugin["name"][0]["value"]))
\ No newline at end of file
+ console.writeln("plugin %s installed.\n" %
(plugin["name"][0]["value"]))
+
+ def source(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
+ import tempfile
+ dir = "./"
+ rep = self.__repManager.getRepository(list.repository)
+ rep = rep(list.repository)
+ if not rep.getPluginSource(list,plugin,dir):
+ console.writeln ("Errors retriving the source package:
%s-%s-src.tar.gz" % (plugin["name"][0]["value"],plugin["version"][0]["value"]))
+ return None
+
+ filename = dir + "/%s-%s-src.tar.gz" %
(plugin["name"][0]["value"],plugin["version"][0]["value"])
+
+
+ import tarfile
+ console.writeln("Exctracting source package..")
+ try:
+ tarf = tarfile.open(filename.encode("ascii"),"r|gz")
+ tarf.extractall (dir)
+ except Exception:
+ console.writeln("Error while exctracting source package!")
+ return None
+
+ console.writeln("%s source installed." %
(plugin["name"][0]["value"]))
+
+ def sourceAuto(self,args):
+ self.source(args)
+ import os
+ rootpath = os.path.abspath("./")
+ for arg in args:
+ import subprocess
+
+ path = os.path.join(rootpath,arg)
+ os.chdir(path)
+ try:
+ os.mkdir("bin")
+ except Exception:
+ pass
+ print os.path.abspath("./")
+ retcode = subprocess.call(["scons",
"plugin="+arg,"command=build", "msheaders="+ config.MSHEADERS])
+ if retcode==0:
+ import shutil
+ os.chdir(rootpath)
+
shutil.copytree(os.path.join(arg,"bin",arg),os.path.join(config.MYSERVER_PLUGIN_DIR,arg))
+ console.writeln("\n plugin %s installed." % (arg))
+ console.writeln("WARNING! no dependeces checked!")
+ continue
+
+ console.writeln("Error while compiling the source package. check
scons error message.")
+
\ No newline at end of file
Modified: trunk/misc/myserver-get/myserverGetLib/local.py
===================================================================
--- trunk/misc/myserver-get/myserverGetLib/local.py 2009-03-03 13:01:10 UTC
(rev 3020)
+++ trunk/misc/myserver-get/myserverGetLib/local.py 2009-03-03 13:21:12 UTC
(rev 3021)
@@ -56,6 +56,7 @@
def finalize(self):
self.__manager.synchronizeListWithFileSystem()
+
class ListManager:
def __init__ (self,repository, listFilePath, listFile = None):
self.repository = repository
@@ -140,8 +141,18 @@
pluginsList = self.listDOM.getElementsByTagName("PLUGINS")
plugins = pluginsList[0]
return plugins.getAttribute("revision")
-
+class DatabaseManager:
+ def __init__ (self,path = config.MYSERVER_PLUGIN_DIR):
+ import os
+ self.pluginsDir = path
+ self.plugins = [f for f in os.listdir(self.pluginsDir) if not
os.path.isfile(os.path.join(self.pluginsDir, f))]
+
+ def isPluginInstalled(self,plugin):
+ return plugin["name"][0]["value"] in self.plugins
+
+
+
if __name__ == "__main__":
manager = ListManager("localhost.it",".","localhost.it-plugins.list")
plugin = manager.getPlugin("prova")
Modified: trunk/misc/myserver-get/myserverGetLib/remote.py
===================================================================
--- trunk/misc/myserver-get/myserverGetLib/remote.py 2009-03-03 13:01:10 UTC
(rev 3020)
+++ trunk/misc/myserver-get/myserverGetLib/remote.py 2009-03-03 13:21:12 UTC
(rev 3021)
@@ -11,6 +11,9 @@
def getPluginBinary(self,list,plugin):
pass
+ def getPluginSource(self,list,source,dir):
+ pass
+
class RepositoryManager:
def __init__(self):
self.__reps = {}
Modified: trunk/misc/myserver-get/myserverGetLib/remoteGenericUrl.py
===================================================================
--- trunk/misc/myserver-get/myserverGetLib/remoteGenericUrl.py 2009-03-03
13:01:10 UTC (rev 3020)
+++ trunk/misc/myserver-get/myserverGetLib/remoteGenericUrl.py 2009-03-03
13:21:12 UTC (rev 3021)
@@ -17,6 +17,7 @@
def synchronizeListWithRepository(self, list):
+ Repository.synchronizeListWithRepository(self,list)
console.write("update: "+ list.repository + '\n')
console.write("loading ")
localRevision = int(list.getRevision())
@@ -47,14 +48,26 @@
list.synchronizeListWithFileSystem()
console.write("DONE.\n")
- def getPluginBinary(self,list,plugin):
- url ="%s/pub/%s-%s-%s.tar.gz" %
(list.repository,plugin["name"][0]["value"],plugin["version"][0]["value"],config.arch)
- filename = config.MYSERVER_PLUGIN_DIR + "/%s-%s-%s.tar.gz" %
(plugin["name"][0]["value"],plugin["version"][0]["value"],config.arch)
- console.writeln("Downloading %s-%s-%s.tar.gz..." %
(plugin["name"][0]["value"],plugin["version"][0]["value"],config.arch))
+ def __getRemoteFile(self, url,filename):
+ import os
+ (filepath, file) = os.path.split(filename)
+ console.writeln("Downloading %s..\n" % (file))
try:
urllib.urlretrieve(url, filename)
except Exception:
console.writeln("Error while retriving remote file!")
return False
return True
+
+ def getPluginBinary(self,list,plugin):
+ Repository.getPluginBinary(self,list,plugin)
+ url ="%s/pub/%s-%s-%s.tar.gz" %
(list.repository,plugin["name"][0]["value"],plugin["version"][0]["value"],config.arch)
+ filename = config.MYSERVER_PLUGIN_DIR + "/%s-%s-%s.tar.gz" %
(plugin["name"][0]["value"],plugin["version"][0]["value"],config.arch)
+ return self.__getRemoteFile(url, filename)
+
+ def getPluginSource(self,list,plugin, dir):
+ Repository.getPluginSource(self,list,plugin,dir)
+ url ="%s/src/%s-%s-src.tar.gz" %
(list.repository,plugin["name"][0]["value"],plugin["version"][0]["value"])
+ filename = dir + "/%s-%s-src.tar.gz" %
(plugin["name"][0]["value"],plugin["version"][0]["value"])
+ return self.__getRemoteFile(url, filename)
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [myserver-commit] [3021] myserver-get:,
Daniele Perrone <=