Add pylint configuration and lint python scripts accordingly

Python files were not linted so far. Since in the following changes
tests for the container images and helm charts will be added, which will
use python, a linter would be helpful to keep the code quality high.

This change adds a pylint configuration file (.pylintrc) to the project
configuring pylint. The default configuration is changed in the folowing
ways:

- Use 2-space indentations
- Do not enforce doc-strings

The python scripts used in the gerrit-init container did not fully
follow PEP8-rules and were adapted according to the output of pylint.

Change-Id: I495ebc6b9cf47e63e40cf1b19dad6fbbbd3bc260
diff --git a/.pylintrc b/.pylintrc
new file mode 100644
index 0000000..7ee00aa
--- /dev/null
+++ b/.pylintrc
@@ -0,0 +1,6 @@
+[MESSAGES CONTROL]
+disable=C0111
+
+[FORMAT]
+indent-string='  '
+indent-after-paren=2
diff --git a/container-images/gerrit-init/tools/gerrit_init.py b/container-images/gerrit-init/tools/gerrit_init.py
index 96d2114..c280683 100755
--- a/container-images/gerrit-init/tools/gerrit_init.py
+++ b/container-images/gerrit-init/tools/gerrit_init.py
@@ -24,8 +24,8 @@
 from validate_db import select_db
 
 def ensure_database_connection(gerrit_site_path):
-  db = select_db(gerrit_site_path)
-  db.wait_for_db_server()
+  database = select_db(gerrit_site_path)
+  database.wait_for_db_server()
 
 def determine_is_slave(gerrit_site_path):
   gerrit_config_path = os.path.join(gerrit_site_path, "etc/gerrit.config")
@@ -58,9 +58,10 @@
 
   if init_process.returncode > 0:
     print("An error occured, when initializing Gerrit. Exit code: ",
-      init_process.returncode)
+          init_process.returncode)
     sys.exit(1)
 
+# pylint: disable=C0103
 if __name__ == "__main__":
   parser = argparse.ArgumentParser()
   parser.add_argument(
diff --git a/container-images/gerrit-init/tools/git_config_parser.py b/container-images/gerrit-init/tools/git_config_parser.py
index dc35619..05076f2 100644
--- a/container-images/gerrit-init/tools/git_config_parser.py
+++ b/container-images/gerrit-init/tools/git_config_parser.py
@@ -46,7 +46,7 @@
     Returns boolean value of given key in the configuration file. If the key
     appears multiple times, the last value is returned.
     """
-    if not type(default) == bool:
+    if not isinstance(default, bool):
       raise TypeError("Default has to be a boolean.")
 
     try:
diff --git a/container-images/gerrit-init/tools/validate_db.py b/container-images/gerrit-init/tools/validate_db.py
index 99077f9..184a4f6 100755
--- a/container-images/gerrit-init/tools/validate_db.py
+++ b/container-images/gerrit-init/tools/validate_db.py
@@ -14,14 +14,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from abc import ABC, abstractmethod
-from sqlalchemy import create_engine
-
 import argparse
 import os.path
 import sys
 import time
 
+from abc import ABC, abstractmethod
+from sqlalchemy import create_engine
+from sqlalchemy.exc import SQLAlchemyError
+
 from git_config_parser import GitConfigParser
 
 class AbstractGerritDB(ABC):
@@ -34,21 +35,18 @@
     """
     Read all required configuration values.
     """
-    pass
 
   @abstractmethod
   def _create_db_url(self):
     """
     Create a URL with which the database can be reached.
     """
-    pass
 
   @abstractmethod
   def wait_for_db_server(self):
     """
     Wait until a connection with the database server is achieved.
     """
-    pass
 
   @abstractmethod
   def wait_for_db(self):
@@ -56,7 +54,6 @@
     Check whether a database with the name configured for the ReviewDB
     exists on the database server and wait for its creation.
     """
-    pass
 
   @abstractmethod
   def wait_for_schema(self):
@@ -64,19 +61,19 @@
     Check whether the schema of the ReviewDBwas created and wait for its
     creation.
     """
-    pass
 
 
 class H2GerritDB(AbstractGerritDB):
 
   def __init__(self, config, secure_config, site):
     super().__init__(config, secure_config)
-    self.url = self._create_db_url(site)
+    self.site = site
+    self.url = self._create_db_url()
 
   def _read_config(self, config, secure_config):
     self.name = config.get("database.database", default="ReviewDB")
 
-  def _create_db_url(self, site):
+  def _create_db_url(self):
     suffix = '.h2.db'
     if os.path.isabs(self.name):
       if self.name.endswith(suffix):
@@ -84,7 +81,7 @@
       else:
         return self.name + suffix
     else:
-      return os.path.join(site, "db", self.name) + suffix
+      return os.path.join(self.site, "db", self.name) + suffix
 
   def wait_for_db_server(self):
     # Not required. H2 is an embedded database.
@@ -112,6 +109,9 @@
     self.tables = ['changes', 'patch_sets']
     self.server_url, self.reviewdb_url = self._create_db_url()
 
+    self.engine = None
+    self.connection = None
+
   def _read_config(self, config, secure_config):
     self.host = config.get("database.hostname", default="localhost")
     self.port = config.get("database.port", default="3306")
@@ -134,11 +134,11 @@
 
   def wait_for_db_server(self):
     print("%s: Waiting for database server connection..." % time.ctime())
-    while not hasattr(self, 'connection') or self.connection.closed:
+    while not self.connection or self.connection.closed:
       try:
         self._connect_to_db(self.server_url)
         continue
-      except:
+      except SQLAlchemyError:
         print("%s: Still waiting..." % time.ctime(), flush=True)
         time.sleep(3)
     self.connection.close()
@@ -147,11 +147,11 @@
   def wait_for_db(self):
     print("%s: Waiting for database to be available..." % time.ctime())
     self.connection.close()
-    while not hasattr(self, 'connection') or self.connection.closed:
+    while not self.connection or self.connection.closed:
       try:
         self._connect_to_db(self.reviewdb_url)
         continue
-      except:
+      except SQLAlchemyError:
         print("%s: Still waiting..." % time.ctime(), flush=True)
         time.sleep(3)
     self.connection.close()
@@ -161,10 +161,8 @@
     print("%s: Waiting for database schema to be created..." % time.ctime())
     for table in self.tables:
       while not self.engine.dialect.has_table(self.engine, table):
-        print("%s: Still waiting for table %s..." % (
-            time.ctime(),
-            table),
-          flush=True)
+        print("%s: Still waiting for table %s..." % (time.ctime(), table),
+              flush=True)
         time.sleep(3)
     print("%s: Schema appears to have been created!" % time.ctime())
 
@@ -194,6 +192,7 @@
   gerrit_db.wait_for_db()
   gerrit_db.wait_for_schema()
 
+# pylint: disable=C0103
 if __name__ == "__main__":
   parser = argparse.ArgumentParser()
   parser.add_argument(