ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject incubator-ponymail git commit: Simplify config by using fallback option
Date Mon, 31 Oct 2016 22:23:53 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/master 059c79204 -> d60c77fd8


Simplify config by using fallback option

Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/d60c77fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/d60c77fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/d60c77fd

Branch: refs/heads/master
Commit: d60c77fd81d2cd0cccd1e188eccaf558c6f1fe45
Parents: 059c792
Author: Sebb <sebb@apache.org>
Authored: Mon Oct 31 22:23:44 2016 +0000
Committer: Sebb <sebb@apache.org>
Committed: Mon Oct 31 22:23:44 2016 +0000

----------------------------------------------------------------------
 tools/archiver.py | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/d60c77fd/tools/archiver.py
----------------------------------------------------------------------
diff --git a/tools/archiver.py b/tools/archiver.py
index 2102523..0d820a2 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -132,23 +132,15 @@ class Archiver(object):
     def __init__(self, parseHTML=False):
         """ Just initialize ES. """
         global config, auth
-        ssl = False
-        self.cropout = None
         self.html = parseHTML
         if parseHTML:
            import html2text
            self.html2text = html2text.html2text
         self.dbname = config.get("elasticsearch", "dbname")
-        self.consistency = 'quorum'
-        if config.has_option("elasticsearch", "ssl") and config.get("elasticsearch", "ssl").lower()
== 'true':
-            ssl = True
-        if config.has_option("elasticsearch", "write") and config.get("elasticsearch", "write")
!= "":
-            self.consistency = config.get('elasticsearch', 'write')
-        if config.has_option("debug", "cropout") and config.get("debug", "cropout") != "":
-            self.cropout = config.get("debug", "cropout")
-        uri = ""
-        if config.has_option("elasticsearch", "uri") and config.get("elasticsearch", "uri")
!= "":
-            uri = config.get("elasticsearch", "uri")
+        ssl = config.get("elasticsearch", "ssl", fallback="false").lower() == 'true'
+        self.consistency = config.get('elasticsearch', 'write', fallback='quorum')
+        self.cropout = config.get("debug", "cropout", fallback=None)
+        uri = config.get("elasticsearch", "uri", fallback="")
         dbs = [
             {
                 'host': config.get("elasticsearch", "hostname"),
@@ -158,11 +150,11 @@ class Archiver(object):
                 'http_auth': auth
             }]
         # Backup ES?
-        if config.has_option("elasticsearch", "backup") and config.get("elasticsearch", "backup")
!= "":
-            backup = config.get("elasticsearch", "backup")
+        backup = config.get("elasticsearch", "backup", fallback="")
+        if backup != "":
             dbs.append(
                 {
-                'host': config.get("elasticsearch", "backup"),
+                'host': backup,
                 'port': int(config.get("elasticsearch", "port")),
                 'use_ssl': ssl,
                 'url_prefix': uri,


Mime
View raw message