openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rab...@apache.org
Subject [incubator-openwhisk] branch master updated: Makes db tools python2 and python3 compatible (#3483)
Date Mon, 11 Jun 2018 15:29:21 GMT
This is an automated email from the ASF dual-hosted git repository.

rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new 9445d61  Makes db tools python2 and python3 compatible (#3483)
9445d61 is described below

commit 9445d6100f6e3aa4a00e489ca98f99a3f4a207f5
Author: Tzu-Chiao Yeh <su3g4284zo6y7@gmail.com>
AuthorDate: Mon Jun 11 23:29:17 2018 +0800

    Makes db tools python2 and python3 compatible (#3483)
    
    The map in python2 and python3 is not compatible on subscription.
    Therefore, this caused an error subscription throwed from couchdb.client in python3.
    
    Signed-off-by: tz70s <su3g4284zo6y7@gmail.com>
---
 tools/db/cleanUpActivations.py        |  2 +-
 tools/db/deleteLogsFromActivations.py |  2 +-
 tools/db/replicateDbs.py              | 12 ++++++------
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/tools/db/cleanUpActivations.py b/tools/db/cleanUpActivations.py
index d6c0cf3..a51f73e 100755
--- a/tools/db/cleanUpActivations.py
+++ b/tools/db/cleanUpActivations.py
@@ -39,7 +39,7 @@ def deleteOldActivations(args):
     while True:
         activationIds = db.view("activations/byDate", limit=args.docsPerRequest, start_key=0,
end_key=endkey)
         if activationIds:
-            documentsToDelete = map(lambda entry: couchdb.client.Document(_id=entry.value[0],
_rev=entry.value[1], _deleted=True), activationIds)
+            documentsToDelete = [couchdb.client.Document(_id=entry.value[0], _rev=entry.value[1],
_deleted=True) for entry in activationIds]
             db.update(documentsToDelete)
         else:
             return
diff --git a/tools/db/deleteLogsFromActivations.py b/tools/db/deleteLogsFromActivations.py
index ac2b424..7fa0973 100755
--- a/tools/db/deleteLogsFromActivations.py
+++ b/tools/db/deleteLogsFromActivations.py
@@ -44,7 +44,7 @@ def deleteLogsFromOldActivations(args):
     while True:
         activations = db.view("logCleanup/byDateWithLogs", limit=args.docsPerRequest, start_key=0,
end_key=endkey, include_docs=True)
         if activations:
-            activationsWithoutLogs = map(removeLogFromActivation, activations)
+            activationsWithoutLogs = [removeLogFromActivation(activation) for activation
in activations]
             db.update(activationsWithoutLogs)
         else:
             return
diff --git a/tools/db/replicateDbs.py b/tools/db/replicateDbs.py
index ae4a4e1..7de83a2 100755
--- a/tools/db/replicateDbs.py
+++ b/tools/db/replicateDbs.py
@@ -43,7 +43,7 @@ def replicateDatabases(args):
     targetDb = couchdb.client.Server(args.targetDbUrl)
 
     excludedDatabases = args.exclude.split(",")
-    excludedBaseNames = filter(lambda x: x != "", args.excludeBaseName.split(","))
+    excludedBaseNames = [x for x in args.excludeBaseName.split(",") if x != ""]
 
     # Create _replicator DB if it does not exist yet.
     if "_replicator" not in sourceDb:
@@ -59,12 +59,12 @@ def replicateDatabases(args):
         # is the databaseName is in the list of excluded database
         isNameExcluded = dbNameWithoutPrefix in excludedDatabases
         # if one of the basenames matches, the database is excluded
-        isBaseNameExcluded = functools.reduce(lambda x, y: x or y, map(lambda en: dbNameWithoutPrefix.startswith(en),
excludedBaseNames), False)
+        isBaseNameExcluded = functools.reduce(lambda x, y: x or y, [dbNameWithoutPrefix.startswith(en)
for en in excludedBaseNames], False)
         return isNameExcluded or isBaseNameExcluded
 
     # Create backup of all databases with given prefix
     print("----- Create backups -----")
-    for db in filter(lambda dbName: dbName.startswith(args.dbPrefix) and not isExcluded(dbName),
sourceDb):
+    for db in [dbName for dbName in sourceDb if dbName.startswith(args.dbPrefix) and not
isExcluded(dbName)]:
         backupDb = backupPrefix + db if not args.continuous else 'continuous_' + db
         replicateDesignDocument = {
             "_id": backupDb,
@@ -92,14 +92,14 @@ def replicateDatabases(args):
 
     # Delete all documents in the _replicator-database of old backups to avoid that they
continue after they are deprecated
     print("----- Delete backup-documents older than %d seconds -----" % args.expires)
-    for doc in filter(lambda doc: isBackupDb(doc.id) and isExpired(extractTimestamp(doc.id)),
replicator.view('_all_docs', include_docs=True)):
+    for doc in [doc for doc in replicator.view('_all_docs', include_docs=True) if isBackupDb(doc.id)
and isExpired(extractTimestamp(doc.id))]:
         print("deleting backup document: %s" % doc.id)
         # Get again the latest version of the document to delete the right revision and avoid
Conflicts
         retry(lambda: replicator.delete(replicator[doc.id]), 5)
 
     # Delete all backup-databases, that are older than specified
     print("----- Delete backups older than %d seconds -----" % args.expires)
-    for db in filter(lambda db: isBackupDb(db) and isExpired(extractTimestamp(db)), targetDb):
+    for db in [db for db in targetDb if isBackupDb(db) and isExpired(extractTimestamp(db))]:
         print("deleting backup: %s" % db)
         targetDb.delete(db)
 
@@ -112,7 +112,7 @@ def replayDatabases(args):
     if "_replicator" not in sourceDb:
         sourceDb.create("_replicator")
 
-    for db in filter(lambda dbName: dbName.startswith(args.dbPrefix), sourceDb):
+    for db in [dbName for dbName in sourceDb if dbName.startswith(args.dbPrefix)]:
         plainDbName = db.replace(args.dbPrefix, "")
         (identifier, _) = sourceDb["_replicator"].save({
             "source": args.sourceDbUrl + "/" + db,

-- 
To stop receiving notification emails like this one, please contact
rabbah@apache.org.

Mime
View raw message