diff --git a/bin/wmagent-couchapp-init b/bin/wmagent-couchapp-init index 7317588f3b..7184738462 100755 --- a/bin/wmagent-couchapp-init +++ b/bin/wmagent-couchapp-init @@ -6,6 +6,7 @@ wmagent-couchapp-init from __future__ import print_function, division from future import standard_library + standard_library.install_aliases() import argparse @@ -16,9 +17,7 @@ import tempfile import urllib from urllib.parse import urlsplit - from couchapp.commands import push as couchapppush -from couchapp.config import Config from WMCore.Configuration import loadConfigurationFile from WMCore.Lexicon import splitCouchServiceURL @@ -45,14 +44,20 @@ def installCouchApp(couchUrl, couchDBName, couchAppName, basePath=None): Install the given couch app on the given server in the given database. If the database already exists it will be deleted. """ + # set of options required by the couchapp push command + # from collections import namedtuple + # couchOpts = namedtuple("opts", ["export", "output", "force", "no_atomic"]) + # for attribute in ["export", "output", "force", "no_atomic"]: + # setattr(couchOpts, attribute, False) + ### AMR debugging workqueue couchapps, remove it later ### + #couchOpts.export = True + #couchOpts.output = "/data/WorkQueue.json" + ########################################################## if not basePath: basePath = couchAppRoot(couchAppName) print("Installing %s into %s" % (couchAppName, urllib.unquote_plus(couchDBName))) - couchappConfig = Config() - - couchapppush(couchappConfig, "%s/%s" % (basePath, couchAppName), - "%s/%s" % (couchUrl, couchDBName)) + couchapppush("%s/%s" % (basePath, couchAppName), "%s/%s" % (couchUrl, couchDBName)) return diff --git a/src/python/WMQuality/TestInitCouchApp.py b/src/python/WMQuality/TestInitCouchApp.py index f04103d04a..ce3ce190ce 100644 --- a/src/python/WMQuality/TestInitCouchApp.py +++ b/src/python/WMQuality/TestInitCouchApp.py @@ -13,17 +13,18 @@ from builtins import object from future import standard_library + standard_library.install_aliases() import os import urllib.parse from couchapp.commands import push as couchapppush -from couchapp.config import Config from WMCore.Database.CMSCouch import CouchServer from WMQuality.TestInit import TestInit + class CouchAppTestHarness(object): """ Test Harness for installing a couch database instance with several couchapps @@ -31,7 +32,8 @@ class CouchAppTestHarness(object): """ - def __init__(self, dbName, couchUrl = None): + + def __init__(self, dbName, couchUrl=None): self.couchUrl = os.environ.get("COUCHURL", couchUrl) self.dbName = dbName if self.couchUrl == None: @@ -40,13 +42,11 @@ def __init__(self, dbName, couchUrl = None): if self.couchUrl.endswith('/'): raise RuntimeError("COUCHURL env var shouldn't end with /") self.couchServer = CouchServer(self.couchUrl) - self.couchappConfig = Config() - def create(self, dropExistingDb=True): """create couch db instance""" - #import pdb - #pdb.set_trace() + # import pdb + # pdb.set_trace() if self.dbName in self.couchServer.listDatabases(): if not dropExistingDb: return @@ -62,8 +62,8 @@ def pushCouchapps(self, *couchappdirs): """ push a list of couchapps to the database """ - for couchappdir in couchappdirs: - couchapppush(self.couchappConfig, couchappdir, "%s/%s" % (self.couchUrl, urllib.parse.quote_plus(self.dbName))) + for couchappdir in couchappdirs: + couchapppush(couchappdir, "%s/%s" % (self.couchUrl, urllib.parse.quote_plus(self.dbName))) class TestInitCouchApp(TestInit): @@ -104,8 +104,7 @@ def setupCouch(self, dbName, *couchapps): self.couch.create(dropExistingDb=self.dropExistingDb) # just create the db is couchapps are not specified if len(couchapps) > 0: - self.couch.pushCouchapps(*[os.path.join(self.couchAppRoot(couchapp), couchapp) for couchapp in couchapps ]) - + self.couch.pushCouchapps(*[os.path.join(self.couchAppRoot(couchapp), couchapp) for couchapp in couchapps]) couchUrl = property(lambda x: x.couch.couchUrl) couchDbName = property(lambda x: x.couch.dbName) diff --git a/test/data/WMStats/generator.py b/test/data/WMStats/generator.py index cf7048a776..ade9c9d379 100644 --- a/test/data/WMStats/generator.py +++ b/test/data/WMStats/generator.py @@ -6,7 +6,6 @@ from argparse import ArgumentParser from couchapp.commands import push as couchapppush -from couchapp.config import Config from WMCore.Database.CMSCouch import CouchServer from WMCore.Lexicon import splitCouchServiceURL @@ -39,11 +38,7 @@ def installCouchApp(couchUrl, couchDBName, couchAppName, basePath=None): basePath = couchAppRoot() print("Installing %s into %s" % (couchAppName, couchDBName)) - couchServer = CouchServer(couchUrl) - couchappConfig = Config() - - couchapppush(couchappConfig, "%s/%s" % (basePath, couchAppName), - "%s/%s" % (couchUrl, couchDBName)) + couchapppush("%s/%s" % (basePath, couchAppName), "%s/%s" % (couchUrl, couchDBName)) return