You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by le...@apache.org on 2005/01/07 22:03:29 UTC
svn commit: r124575 - /gump/branches/Gump3/pygump/python/gump/model/__init__.py /gump/branches/Gump3/pygump/python/gump/plugins/instrumentation.py /gump/branches/Gump3/pygump/python/gump/plugins/updater.py /gump/branches/Gump3/pygump/python/header.txt
Author: leosimons
Date: Fri Jan 7 13:03:26 2005
New Revision: 124575
URL: http://svn.apache.org/viewcvs?view=rev&rev=124575
Log:
Whoops. Missed something in my last commit. Now really add the instrumentation. Also start on an updater plugin.
Added:
gump/branches/Gump3/pygump/python/gump/plugins/instrumentation.py
gump/branches/Gump3/pygump/python/gump/plugins/updater.py
Modified:
gump/branches/Gump3/pygump/python/gump/model/__init__.py
gump/branches/Gump3/pygump/python/header.txt
Modified: gump/branches/Gump3/pygump/python/gump/model/__init__.py
Url: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/model/__init__.py?view=diff&rev=124575&p1=gump/branches/Gump3/pygump/python/gump/model/__init__.py&r1=124574&p2=gump/branches/Gump3/pygump/python/gump/model/__init__.py&r2=124575
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/__init__.py Fri Jan 7 13:03:26 2005
@@ -117,6 +117,15 @@
self.method = method,
self.user = user,
self.password = password
+
+ def to_url(self):
+ url = method + ':'
+ if user:
+ url += user + '@'
+ url += hostname + ':' + path
+
+ return url
+
class SvnRepository(Repository):
"""Model a subversion repository.
Added: gump/branches/Gump3/pygump/python/gump/plugins/instrumentation.py
Url: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/instrumentation.py?view=auto&rev=124575
==============================================================================
--- (empty file)
+++ gump/branches/Gump3/pygump/python/gump/plugins/instrumentation.py Fri Jan 7 13:03:26 2005
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+
+# Copyright 2004-2005 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+__copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
+__license__ = "http://www.apache.org/licenses/LICENSE-2.0"
+
+import platform
+
+from gump.plugins import AbstractPlugin
+
+class TimerPlugin(AbstractPlugin):
+ """Set a date property on each model object as it is visited."""
+ def __init__(self, propertyname, format='%d %b %Y %H:%M:%S'):
+ self.format = format
+ self.propertyname = propertyname
+
+ def _do_visit(self, object):
+ setattr(object, self.propertyname, self.gettime())
+
+ def visit_workspace(self, workspace):
+ self._do_visit(workspace)
+
+ def visit_module(self, module):
+ self._do_visit(module)
+
+ def visit_project(self, project):
+ self._do_visit(project)
+
+ def gettime(self):
+ import time
+ return time.strftime(self.format, time.gmtime())
Added: gump/branches/Gump3/pygump/python/gump/plugins/updater.py
Url: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/updater.py?view=auto&rev=124575
==============================================================================
--- (empty file)
+++ gump/branches/Gump3/pygump/python/gump/plugins/updater.py Fri Jan 7 13:03:26 2005
@@ -0,0 +1,129 @@
+#!/usr/bin/env python
+#
+# Copyright 2005 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""This preprocessor handles checkouts and updates from cvs and svn."""
+
+__copyright__ = "Copyright (c) 2005 The Apache Software Foundation"
+__license__ = "http://www.apache.org/licenses/LICENSE-2.0"
+
+import os
+import commands
+
+from gump.plugin import AbstractPlugin
+from gump.model import CvsRepository, SvnRepository
+
+UPDATE_TYPE_CHECKOUT="checkout"
+UPDATE_TYPE_UPDATE="update"
+
+class ModuleUpdater(AbstractPlugin):
+ def __init__(self, workdir):
+ self.workdir = workdir
+
+ def visit_repository(self, repository):
+ repopath = self.get_repo_path()
+ if not os.path.exists(repopath):
+ os.mkdir(repopath)
+
+ def visit_module(self, module):
+ modulepath = self.get_module_path()
+ if not os.path.exists(modulepath):
+ os.mkdir(modulepath)
+
+ def get_repo_path(self, repository):
+ return os.path.join(self.workdir, repository.name)
+
+ def get_module_path(self, module):
+ return os.path.join(self.get_repo_path(), module.name)
+
+class CvsUpdater(ModuleUpdater):
+ def __init__(self, workdir):
+ ModuleUpdater.__init__(self, workdir)
+
+ def visit_repository(self, repository):
+ if isinstance(repository, CvsRepository):
+ ModuleUpdater.visit_repository(self, repository)
+
+ def visit_module(self, module):
+ if not isinstance(repository, CvsRepository): return
+
+ ModuleUpdater.visit_module(self, module)
+
+ modulepath = self.get_module_path()
+ current = os.path.curdir
+ os.chdir(modulepath)
+ cvsdir = os.path.join(modulepath, 'CVS')
+ if not os.path.exists(cvsdir):
+ self.checkout(module)
+ else:
+ self.update(module)
+ os.chdir(current)
+
+ def checkout(self, module, modulepath):
+ repository = module.repository.to_url()
+ cmd = 'cvs -d %s checkout -P %s .' % (repository, module.name)
+
+ (status, output) = commands.getstatusoutput(cmd)
+ module.update_log = output
+ module.update_exit_status = status
+ module.update_type = UPDATE_TYPE_CHECKOUT
+
+ def update(self, module, modulepath):
+ cmd = 'cvs up -Pd'
+
+ (status, output) = commands.getstatusoutput(cmd)
+ module.update_log = output
+ module.update_exit_status = status
+ module.update_type = UPDATE_TYPE_UPDATE
+
+class SvnUpdater(ModuleUpdater):
+ def __init__(self, workdir):
+ ModuleUpdater.__init__(self, workdir)
+
+ def visit_repository(self, repository):
+ if isinstance(repository, SvnRepository):
+ ModuleUpdater.visit_repository(self, repository)
+
+ def visit_module(self, module):
+ if not isinstance(repository, SvnRepository): return
+
+ ModuleUpdater.visit_module(self, module)
+
+ modulepath = self.get_module_path()
+ current = os.path.curdir
+ os.chdir(modulepath)
+ svndir = os.path.join(modulepath, '.svn')
+ if not os.path.exists(svndir):
+ self.checkout(module)
+ else:
+ self.update(module)
+ os.chdir(current)
+
+ def checkout(self, module, modulepath):
+ repository = module.repository.url + '/' + module.path
+ cmd = 'svn checkout %s .' % repository
+
+ (status, output) = commands.getstatusoutput(cmd)
+ module.update_log = output
+ module.update_exit_status = status
+ module.update_type = UPDATE_TYPE_CHECKOUT
+
+ def update(self, module, modulepath):
+ cmd = 'svn up'
+
+ (status, output) = commands.getstatusoutput(cmd)
+ module.update_log = output
+ module.update_exit_status = status
+ module.update_type = UPDATE_TYPE_UPDATE
Modified: gump/branches/Gump3/pygump/python/header.txt
Url: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/header.txt?view=diff&rev=124575&p1=gump/branches/Gump3/pygump/python/header.txt&r1=124574&p2=gump/branches/Gump3/pygump/python/header.txt&r2=124575
==============================================================================
--- gump/branches/Gump3/pygump/python/header.txt (original)
+++ gump/branches/Gump3/pygump/python/header.txt Fri Jan 7 13:03:26 2005
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004-2005 The Apache Software Foundation
+# Copyright 2005 The Apache Software Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,5 +14,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-__copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
+__copyright__ = "Copyright (c) 2005 The Apache Software Foundation"
__license__ = "http://www.apache.org/licenses/LICENSE-2.0"