You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by bo...@apache.org on 2007/09/28 07:20:35 UTC
svn commit: r580222 - in /gump/trunk/python/gump: actor/mvnrepoproxy/
actor/mvnrepoproxy/__init__.py actor/mvnrepoproxy/proxycontrol.py
core/config.py core/runner/runner.py
Author: bodewig
Date: Thu Sep 27 22:20:34 2007
New Revision: 580222
URL: http://svn.apache.org/viewvc?rev=580222&view=rev
Log:
start/stop the mvn repository proxy
Added:
gump/trunk/python/gump/actor/mvnrepoproxy/
gump/trunk/python/gump/actor/mvnrepoproxy/__init__.py
gump/trunk/python/gump/actor/mvnrepoproxy/proxycontrol.py
Modified:
gump/trunk/python/gump/core/config.py
gump/trunk/python/gump/core/runner/runner.py
Added: gump/trunk/python/gump/actor/mvnrepoproxy/__init__.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/actor/mvnrepoproxy/__init__.py?rev=580222&view=auto
==============================================================================
--- gump/trunk/python/gump/actor/mvnrepoproxy/__init__.py (added)
+++ gump/trunk/python/gump/actor/mvnrepoproxy/__init__.py Thu Sep 27 22:20:34 2007
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+#!/usr/bin/env python
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+# tell Python what modules make up the gump.actor.mvnrepoproxy package
+__all__ = ["proxycontrol"]
+
Added: gump/trunk/python/gump/actor/mvnrepoproxy/proxycontrol.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/actor/mvnrepoproxy/proxycontrol.py?rev=580222&view=auto
==============================================================================
--- gump/trunk/python/gump/actor/mvnrepoproxy/proxycontrol.py (added)
+++ gump/trunk/python/gump/actor/mvnrepoproxy/proxycontrol.py Thu Sep 27 22:20:34 2007
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+import os
+import os.path
+import sys
+import urllib
+
+from gump import log
+from gump.core.run.gumprun import *
+
+class MvnRepositoryProxyController(gump.core.run.actor.AbstractRunActor):
+ """
+ Starts/Stops the proxy, adds artifacts to it when a project has
+ been built, collects the results.
+ """
+
+ def __init__(self, run, javaCommand='java'):
+ gump.core.run.actor.AbstractRunActor.__init__(self, run)
+ self.proxyURL = "http://localhost:%s/" \
+ % (run.getWorkspace().mvnRepoProxyPort)
+ self.java = javaCommand
+
+ def processOtherEvent(self, event):
+ if isinstance(event, InitializeRunEvent):
+ self.spawnProxy()
+ elif isinstance(event, FinalizeRunEvent):
+ self.saveLogAndStop()
+
+ def spawnProxy(self):
+ log.info('Starting mvn repository proxy')
+ try:
+ proxyJar = os.path.join(os.environ.get('MVN_PROXY_HOME'),
+ 'repoproxy.jar')
+ log.info('Running: %s -jar %s %s'
+ % (self.java, proxyJar, self.workspace.mvnRepoProxyPort))
+ # TODO emulate spawnlp on non-Unix platforms
+ os.spawnlp(os.P_NOWAIT, self.java, self.java, '-jar', proxyJar,
+ self.workspace.mvnRepoProxyPort)
+ except:
+ log.error('--- Failed to start proxy', exc_info=1)
+
+ def saveLogAndStop(self):
+ proxyLogFileName = 'proxyLog.html'
+
+ log.info('Storing proxyLog to xdocs-work ...')
+ try:
+ proxyLogRequest = urllib.urlopen(self.proxyURL + proxyLogFileName)
+ proxyLogContent = proxyLogRequest.read()
+ proxyLogRequest.close()
+ # TODO xdocs-Documenter is hard-coded here
+ proxyLogFile = open(os.path.join(os.path.join(self.workspace.getBaseDirectory(),
+ 'xdocs-work'),
+ proxyLogFileName), 'w')
+ proxyLogFile.write(proxyLogContent)
+ proxyLogFile.close();
+ except:
+ log.error('--- Failed to store ' + proxyLogFileName, exc_info=1)
+
+ log.info('Stopping mvn repository proxy')
+ try:
+ urllib.urlopen(self.proxyURL + 'stop', urllib.urlencode({}))
+ except:
+ log.error('--- Failed to stop proxy', exc_info=1)
Modified: gump/trunk/python/gump/core/config.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/config.py?rev=580222&r1=580221&r2=580222&view=diff
==============================================================================
--- gump/trunk/python/gump/core/config.py (original)
+++ gump/trunk/python/gump/core/config.py Thu Sep 27 22:20:34 2007
@@ -104,7 +104,7 @@
signature="\r\n--\r\nApache Gump\nhttp://gump.apache.org/ " \
+ '[Instance: ' + gumpfullhost + "]\n"
- mvnRepoProxyPort = 8192
+ mvnRepoProxyPort = '8192'
# Information for portability
if not os.name == 'dos' and not os.name == 'nt':
Modified: gump/trunk/python/gump/core/runner/runner.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/runner/runner.py?rev=580222&r1=580221&r2=580222&view=diff
==============================================================================
--- gump/trunk/python/gump/core/runner/runner.py (original)
+++ gump/trunk/python/gump/core/runner/runner.py Thu Sep 27 22:20:34 2007
@@ -36,6 +36,7 @@
from gump.actor.results.resulter import Resulter
from gump.actor.syndication.syndicator import Syndicator
from gump.actor.mvnrepository.local import LocalMvnRepositoryCleaner
+from gump.actor.mvnrepoproxy.proxycontrol import MvnRepositoryProxyController
class GumpRunner(RunSpecific):
"""
@@ -212,6 +213,13 @@
if self.run.getOptions().isPublish():
self.run.registerActor(RepositoryPublisher(self.run))
+ # Handle mvn repository proxy
+ if not self.run.getEnvironment().noMvnRepoProxy:
+ self.run.registerActor(MvnRepositoryProxyController(self.run))
+
+ # Clear local mvn repository
+ self.run.registerActor(LocalMvnRepositoryCleaner(self.run))
+
# Synchonize
if xdocs:
self.run.registerActor(Synchronizer(self.run,documenter))
@@ -224,8 +232,6 @@
% (self.run.getOptions().isNotify(), \
self.run.getWorkspace().isNotify() ) )
- self.run.registerActor(LocalMvnRepositoryCleaner(self.run))
-
# See what we have...
self.run.logActors()