You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@gump.apache.org by ru...@apache.org on 2003/04/26 23:43:43 UTC
cvs commit: jakarta-gump/python gumpview.py orphans.py ruper.py
rubys 2003/04/26 14:43:43
Modified: python gumpview.py orphans.py ruper.py
Log:
Fix all cr/lf problems, remove all tabs
Revision Changes Path
1.5 +153 -1 jakarta-gump/python/gumpview.py
Index: gumpview.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/gumpview.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- gumpview.py 26 Apr 2003 08:46:19 -0000 1.4
+++ gumpview.py 26 Apr 2003 21:43:43 -0000 1.5
@@ -1 +1,153 @@
-#!/usr/bin/python
"""
Graphic GUI to navigate a Gump workspace
"""
import sys
from xml.sax import parse
from xml.sax.handler import ContentHandler
# http://wxpython.org/
from wxPython.wx import *
from gumpcore import load,Module,Project,dependencies
from gen import xmlize
from gumpconf import *
class gumpview(wxApp):
# model
mySubs=None
items=None
build_sequence=None
# view
tree=None
list=None
data=None
# tree index
mItem={}
pItem={}
def OnInit(self):
# layout
frame = wxFrame(NULL, -1, "Gump Workspace Viewer")
split1 = wxSplitterWindow(frame,-1)
notebook = wxNotebook(split1, -1, style=wxCLIP_CHILDREN)
split2 = wxSplitterWindow(notebook,-1)
# panes
self.tree=wxTreeCtrl(split1,-1)
self.list=wxListCtrl(split2,-1,style=wxLC_REPORT|wxSUNKEN_BORDER)
self.dependencies=wxListCtrl(notebook,-1,style=wxLC_REPORT|wxSUNKEN_BORDER)
self.data=wxTextCtrl(split2,-1,style=wxTE_MULTILINE)
# attach the panes to the frame
split1.SplitVertically(self.tree, notebook)
notebook.AddPage(split2, 'referenced')
notebook.AddPage(self.dependencies, 'dependencies')
split2.SplitHorizontally(self.list, self.data)
self.SetTopWindow(frame)
frame.Show(true)
# resize
split1.SetMinimumPaneSize(20)
split2.SetMinimumPaneSize(20)
split1.SetSashPosition(300,true)
split2.SetSashPosition(200)
# wire up the events
EVT_TREE_SEL_CHANGED(self, self.tree.GetId(), self.selectTree)
EVT_LIST_ITEM_SELECTED(self, self.list.GetId(), self.selectItem)
EVT_LIST_ITEM_SELECTED(self, self.dependencies.GetId(), self.selectItem2)
return true
# list all modules and their projects
def load(self,files):
root = self.tree.AddRoot(files[0])
self.workspace = load(files[0])
names=Module.list.keys()
names.sort()
for name in names:
module=Module.list[name]
parent=self.mItem[name]=self.tree.AppendItem(root,name)
self.tree.SetPyData(parent,module)
for project in module.project:
self.pItem[project.name]=self.tree.AppendItem(parent,project.name)
self.tree.SetPyData(self.pItem[project.name],project)
self.tree.Expand(root)
# select a single feed and display titles from each item
def selectTree(self, event):
self.showProject(self.tree.GetPyData(event.GetItem()))
def showProject(self,project):
if not project or not isinstance(project,Project): return
# gather a list of projects which reference this project
self.items=[]
for parent in Project.list.values():
list=parent.depend+parent.option
if parent.ant: list+=parent.ant.depend
for depend in list:
if depend.project==project.name:
self.items.append(parent.name)
# display the list, sorted by name
self.list.DeleteAllItems()
if not self.list.GetColumn(0):
self.list.InsertColumn(0, 'Cross Reference')
self.items.sort()
for i in range(0,len(self.items)):
row=self.list.InsertStringItem(i,self.items[i])
self.list.SetItemData(row,i)
self.list.SetColumnWidth(0,wxLIST_AUTOSIZE_USEHEADER)
# display the project definition
import StringIO
data = StringIO.StringIO()
xmlize('project',project,data,)
self.data.Clear()
data.seek(0)
self.data.AppendText(data.read())
self.data.ShowPosition(0)
# gather a list of project dependencies unrolled to build
self.build_sequence = dependencies(project.name, project.depend)
# display the project dependencies
self.dependencies.DeleteAllItems()
if not self.dependencies.GetColumn(0):
self.dependencies.InsertColumn(0, 'Build sequence')
for i in range(0,len(self.build_sequence)):
row=self.dependencies.InsertStringItem(i,self.build_sequence[i].name)
self.dependencies.SetItemData(row,i)
self.list.SetColumnWidth(0,wxLIST_AUTOSIZE_USEHEADER)
# show the xml description for a single item
def selectItem(self, event):
project=Project.list[self.items[event.GetItem().GetData()]]
self.showProject(project)
# expand the associated module and select the project
self.tree.Expand(self.mItem[project.module])
self.tree.SelectItem(self.pItem[project.name])
# show the xml description for a single item
def selectItem2(self, event):
project=Project.list[self.build_sequence[event.GetItem().GetData()].name]
self.showProject(project)
# expand the associated module and select the project
self.tree.Expand(self.mItem[project.module])
self.tree.SelectItem(self.pItem[project.name])
if __name__ == '__main__':
app = gumpview(0)
app.load(sys.argv[1:] or [default.workspace])
app.MainLoop()
\ No newline at end of file
+#!/usr/bin/python
+"""
+ Graphic GUI to navigate a Gump workspace
+"""
+
+import sys
+from xml.sax import parse
+from xml.sax.handler import ContentHandler
+
+# http://wxpython.org/
+from wxPython.wx import *
+
+from gumpcore import load,Module,Project,dependencies
+from gen import xmlize
+from gumpconf import *
+
+class gumpview(wxApp):
+ # model
+ mySubs=None
+ items=None
+ build_sequence=None
+
+ # view
+ tree=None
+ list=None
+ data=None
+
+ # tree index
+ mItem={}
+ pItem={}
+
+ def OnInit(self):
+ # layout
+ frame = wxFrame(NULL, -1, "Gump Workspace Viewer")
+ split1 = wxSplitterWindow(frame,-1)
+ notebook = wxNotebook(split1, -1, style=wxCLIP_CHILDREN)
+ split2 = wxSplitterWindow(notebook,-1)
+
+ # panes
+ self.tree=wxTreeCtrl(split1,-1)
+ self.list=wxListCtrl(split2,-1,style=wxLC_REPORT|wxSUNKEN_BORDER)
+ self.dependencies=wxListCtrl(notebook,-1,style=wxLC_REPORT|wxSUNKEN_BORDER)
+ self.data=wxTextCtrl(split2,-1,style=wxTE_MULTILINE)
+
+ # attach the panes to the frame
+ split1.SplitVertically(self.tree, notebook)
+ notebook.AddPage(split2, 'referenced')
+ notebook.AddPage(self.dependencies, 'dependencies')
+ split2.SplitHorizontally(self.list, self.data)
+ self.SetTopWindow(frame)
+ frame.Show(true)
+
+ # resize
+ split1.SetMinimumPaneSize(20)
+ split2.SetMinimumPaneSize(20)
+ split1.SetSashPosition(300,true)
+ split2.SetSashPosition(200)
+
+ # wire up the events
+ EVT_TREE_SEL_CHANGED(self, self.tree.GetId(), self.selectTree)
+ EVT_LIST_ITEM_SELECTED(self, self.list.GetId(), self.selectItem)
+ EVT_LIST_ITEM_SELECTED(self, self.dependencies.GetId(), self.selectItem2)
+ return true
+
+ # list all modules and their projects
+ def load(self,files):
+ root = self.tree.AddRoot(files[0])
+ self.workspace = load(files[0])
+ names=Module.list.keys()
+ names.sort()
+ for name in names:
+ module=Module.list[name]
+ parent=self.mItem[name]=self.tree.AppendItem(root,name)
+ self.tree.SetPyData(parent,module)
+ for project in module.project:
+ self.pItem[project.name]=self.tree.AppendItem(parent,project.name)
+ self.tree.SetPyData(self.pItem[project.name],project)
+
+ self.tree.Expand(root)
+
+ # select a single feed and display titles from each item
+ def selectTree(self, event):
+ self.showProject(self.tree.GetPyData(event.GetItem()))
+
+ def showProject(self,project):
+ if not project or not isinstance(project,Project): return
+
+ # gather a list of projects which reference this project
+ self.items=[]
+ for parent in Project.list.values():
+ list=parent.depend+parent.option
+ if parent.ant: list+=parent.ant.depend
+ for depend in list:
+ if depend.project==project.name:
+ self.items.append(parent.name)
+
+ # display the list, sorted by name
+ self.list.DeleteAllItems()
+ if not self.list.GetColumn(0):
+ self.list.InsertColumn(0, 'Cross Reference')
+ self.items.sort()
+ for i in range(0,len(self.items)):
+ row=self.list.InsertStringItem(i,self.items[i])
+ self.list.SetItemData(row,i)
+
+ self.list.SetColumnWidth(0,wxLIST_AUTOSIZE_USEHEADER)
+
+ # display the project definition
+ import StringIO
+ data = StringIO.StringIO()
+ xmlize('project',project,data,)
+ self.data.Clear()
+ data.seek(0)
+ self.data.AppendText(data.read())
+ self.data.ShowPosition(0)
+
+ # gather a list of project dependencies unrolled to build
+ self.build_sequence = dependencies(project.name, project.depend)
+
+ # display the project dependencies
+ self.dependencies.DeleteAllItems()
+ if not self.dependencies.GetColumn(0):
+ self.dependencies.InsertColumn(0, 'Build sequence')
+
+ for i in range(0,len(self.build_sequence)):
+ row=self.dependencies.InsertStringItem(i,self.build_sequence[i].name)
+ self.dependencies.SetItemData(row,i)
+
+ self.list.SetColumnWidth(0,wxLIST_AUTOSIZE_USEHEADER)
+
+
+ # show the xml description for a single item
+ def selectItem(self, event):
+ project=Project.list[self.items[event.GetItem().GetData()]]
+ self.showProject(project)
+
+ # expand the associated module and select the project
+ self.tree.Expand(self.mItem[project.module])
+ self.tree.SelectItem(self.pItem[project.name])
+
+ # show the xml description for a single item
+ def selectItem2(self, event):
+ project=Project.list[self.build_sequence[event.GetItem().GetData()].name]
+ self.showProject(project)
+
+ # expand the associated module and select the project
+ self.tree.Expand(self.mItem[project.module])
+ self.tree.SelectItem(self.pItem[project.name])
+
+if __name__ == '__main__':
+ app = gumpview(0)
+ app.load(sys.argv[1:] or [default.workspace])
+ app.MainLoop()
1.6 +59 -1 jakarta-gump/python/orphans.py
Index: orphans.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/orphans.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- orphans.py 26 Apr 2003 08:46:19 -0000 1.5
+++ orphans.py 26 Apr 2003 21:43:43 -0000 1.6
@@ -1 +1,59 @@
-#!/usr/bin/python
"""
Look for obsolete installed packages, cvs checkouts, and build
directories.
"""
from xml.sax import parse
from xml.sax.handler import ContentHandler
from glob import glob
import os
class Workspace(ContentHandler):
cvsdir = None
pkgdir = None
logdir = None
basedir = None
jardir = ""
modules=[]
packages=[]
def startElement(self, name, attrs):
if name == 'workspace':
attrs=dict(attrs)
self.pkgdir = attrs['pkgdir']
self.cvsdir = attrs['cvsdir']
self.basedir = attrs['basedir']
if 'jardir' in attrs: self.jardir = attrs['jardir']
self.logdir = attrs['logdir']
if name == 'module':
attrs=dict(attrs)
self.modules.append(attrs['name'])
if name == 'project':
attrs=dict(attrs)
if 'home' in attrs and attrs['home'].find(self.pkgdir) ==0:
self.packages.append(attrs['home'].replace('\\','/'))
workspace=Workspace()
parse(open('work/merge.xml'),workspace)
# orphan packages
for dir in glob(workspace.pkgdir+'/*'):
if not dir.replace('\\','/') in workspace.packages:
if os.path.isdir(dir): print dir.replace('/',os.sep)
# orphan cvs checkouts
for dir in glob(workspace.cvsdir+'/*'):
if dir.endswith('Entries') or dir.endswith('Entries.log'): continue
if not dir[len(workspace.cvsdir)+1:] in workspace.modules:
if os.path.isdir(dir): print dir.replace('/',os.sep)
# orphan builds
for dir in glob(workspace.basedir+'/*'):
if not dir[len(workspace.basedir)+1:] in workspace.modules:
dir=dir.replace('/',os.sep)
if dir==workspace.basedir.replace('/',os.sep)+os.sep+"dist": continue
if dir==workspace.jardir.replace('/',os.sep): continue
if dir==workspace.logdir.replace('/',os.sep): continue
if dir==workspace.cvsdir.replace('/',os.sep): continue
if os.path.isdir(dir): print dir
\ No newline at end of file
+#!/usr/bin/python
+"""
+ Look for obsolete installed packages, cvs checkouts, and build
+ directories.
+"""
+
+from xml.sax import parse
+from xml.sax.handler import ContentHandler
+from glob import glob
+import os
+
+class Workspace(ContentHandler):
+ cvsdir = None
+ pkgdir = None
+ logdir = None
+ basedir = None
+ jardir = ""
+ modules=[]
+ packages=[]
+ def startElement(self, name, attrs):
+ if name == 'workspace':
+ attrs=dict(attrs)
+ self.pkgdir = attrs['pkgdir']
+ self.cvsdir = attrs['cvsdir']
+ self.basedir = attrs['basedir']
+ if 'jardir' in attrs: self.jardir = attrs['jardir']
+ self.logdir = attrs['logdir']
+ if name == 'module':
+ attrs=dict(attrs)
+ self.modules.append(attrs['name'])
+ if name == 'project':
+ attrs=dict(attrs)
+ if 'home' in attrs and attrs['home'].find(self.pkgdir) ==0:
+ self.packages.append(attrs['home'].replace('\\','/'))
+
+workspace=Workspace()
+parse(open('work/merge.xml'),workspace)
+
+# orphan packages
+for dir in glob(workspace.pkgdir+'/*'):
+ if not dir.replace('\\','/') in workspace.packages:
+ if os.path.isdir(dir): print dir.replace('/',os.sep)
+
+# orphan cvs checkouts
+for dir in glob(workspace.cvsdir+'/*'):
+ if dir.endswith('Entries') or dir.endswith('Entries.log'): continue
+ if not dir[len(workspace.cvsdir)+1:] in workspace.modules:
+ if os.path.isdir(dir): print dir.replace('/',os.sep)
+
+# orphan builds
+for dir in glob(workspace.basedir+'/*'):
+ if not dir[len(workspace.basedir)+1:] in workspace.modules:
+ dir=dir.replace('/',os.sep)
+ if dir==workspace.basedir.replace('/',os.sep)+os.sep+"dist": continue
+ if dir==workspace.jardir.replace('/',os.sep): continue
+ if dir==workspace.logdir.replace('/',os.sep): continue
+ if dir==workspace.cvsdir.replace('/',os.sep): continue
+ if os.path.isdir(dir): print dir
+
1.4 +65 -2 jakarta-gump/python/ruper.py
Index: ruper.py
===================================================================
RCS file: /home/cvs/jakarta-gump/python/ruper.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ruper.py 26 Apr 2003 08:46:19 -0000 1.3
+++ ruper.py 26 Apr 2003 21:43:43 -0000 1.4
@@ -1,2 +1,65 @@
-#!/usr/bin/python
"""
Resource updater for Gump
"""
import os, os.path, sys, urllib
from gumpconf import *
# output debug messages or not
debug = True #True
-# Repository
class RuperRepository(object):
def __init__(self,url,type):
self.url=url
self.type=type
def resolve(self, resource):
# FIXME (nicolaken)
# delegate the getting of a resource to an outside file
# named after the repository type
if self.type == 'maven':
# not necessarily Maven uses our resource.standardName()
if resource.type == 'jar':
resolvedUrl = '%s/%s/jars/%s-%s.jar' % (self.url,resource.name,resource.name,resource.version)
else:
raise Error, 'Unknown Resource Type; type: '+type
else:
raise Error, 'Unknown Repository; type: '+type
return resolvedUrl
def download(self, resource, destinationDir):
if not os.path.isdir(destinationDir):
raise IOError, 'This method needs a directory, instead it got:'+destinationDir
remoteurl = self.resolve(resource)
urllib.urlretrieve(remoteurl, '%s/%s' % (destinationDir,resource.standardName()))
# Resource
class RuperResource(object):
def __init__(self,name,version,type):
self.name=name
self.version=version
self.type=type
def standardName(self):
if self.type == 'jar':
return '%s-%s.jar' % (self.name,self.version)
else:
raise Error, 'Unknown Resource Type; type: '+type
if __name__=='__main__':
os.chdir(dir.base)
resource = RuperResource('log4j','1.3.4','jar')
print resource.standardName()
repository = RuperRepository('http://www.ibiblio.org/maven','maven')
print repository.resolve(resource)
repository.download(resource,dir.cache)
\ No newline at end of file
+#!/usr/bin/python
+"""
+ Resource updater for Gump
+"""
+
+import os, os.path, sys, urllib
+from gumpconf import *
+
+# output debug messages or not
+debug = True #True
+# Repository
+class RuperRepository(object):
+ def __init__(self,url,type):
+ self.url=url
+ self.type=type
+
+ def resolve(self, resource):
+ # FIXME (nicolaken)
+ # delegate the getting of a resource to an outside file
+ # named after the repository type
+ if self.type == 'maven':
+ # not necessarily Maven uses our resource.standardName()
+ if resource.type == 'jar':
+ resolvedUrl = '%s/%s/jars/%s-%s.jar' % (self.url,resource.name,resource.name,resource.version)
+ else:
+ raise Error, 'Unknown Resource Type; type: '+type
+ else:
+ raise Error, 'Unknown Repository; type: '+type
+
+ return resolvedUrl
+
+ def download(self, resource, destinationDir):
+ if not os.path.isdir(destinationDir):
+ raise IOError, 'This method needs a directory, instead it got:'+destinationDir
+
+ remoteurl = self.resolve(resource)
+ urllib.urlretrieve(remoteurl, '%s/%s' % (destinationDir,resource.standardName()))
+
+
+
+# Resource
+class RuperResource(object):
+ def __init__(self,name,version,type):
+ self.name=name
+ self.version=version
+ self.type=type
+
+ def standardName(self):
+ if self.type == 'jar':
+ return '%s-%s.jar' % (self.name,self.version)
+ else:
+ raise Error, 'Unknown Resource Type; type: '+type
+
+
+
+if __name__=='__main__':
+ os.chdir(dir.base)
+ resource = RuperResource('log4j','1.3.4','jar')
+ print resource.standardName()
+ repository = RuperRepository('http://www.ibiblio.org/maven','maven')
+ print repository.resolve(resource)
+ repository.download(resource,dir.cache)
+
+
+