Adjust cloud configuration INI files

* Rename my_config.ini to cloud_config.ini.
* Move a copy into coral-cloudiot, so coral-enviro isn't required.
* Set default ini file in case a path isn't provided.
* Disable CloudIoT if no config file is found.
* Run autopep8 on both coral projects.

Change-Id: Ic29696a04597fcc84f2f2956d07775bd7e0aa1ce
diff --git a/python/coral-cloudiot/MANIFEST.in b/python/coral-cloudiot/MANIFEST.in
new file mode 100644
index 0000000..08e184f
--- /dev/null
+++ b/python/coral-cloudiot/MANIFEST.in
@@ -0,0 +1 @@
+include coral/cloudiot/cloud_config.ini
diff --git a/python/coral-cloudiot/coral/cloudiot/__init__.py b/python/coral-cloudiot/coral/cloudiot/__init__.py
index e229742..1df472c 100644
--- a/python/coral-cloudiot/coral/cloudiot/__init__.py
+++ b/python/coral-cloudiot/coral/cloudiot/__init__.py
@@ -11,4 +11,3 @@
 # 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.
-
diff --git a/python/coral-enviro/coral/enviro/my_config.ini b/python/coral-cloudiot/coral/cloudiot/cloud_config.ini
similarity index 100%
copy from python/coral-enviro/coral/enviro/my_config.ini
copy to python/coral-cloudiot/coral/cloudiot/cloud_config.ini
diff --git a/python/coral-cloudiot/coral/cloudiot/core.py b/python/coral-cloudiot/coral/cloudiot/core.py
index 46f76dd..ef8f50c 100644
--- a/python/coral-cloudiot/coral/cloudiot/core.py
+++ b/python/coral-cloudiot/coral/cloudiot/core.py
@@ -30,6 +30,7 @@
 
 logger = logging.getLogger(__name__)
 
+DEFAULT_CONFIG_LOCATION = os.path.join(os.path.dirname(__file__), 'cloud_config.ini')
 
 class CloudIot:
     """
@@ -39,7 +40,8 @@
     You must configure a connection by specifying a Clout IoT configuration file (.ini). Then
     you can use :meth:`publish_message` to send an arbitrary message to your cloud project.
     """
-    def __init__(self, config_file, config_section='DEFAULT'):
+
+    def __init__(self, config_file=DEFAULT_CONFIG_LOCATION, config_section='DEFAULT'):
         """
         Args:
             config_file (str): Path to your Cloud IoT configuration file (.ini).
@@ -47,7 +49,11 @@
                 can be read. By default, it reads from the "[DEFAULT]" section.
         """
         self._config = configparser.ConfigParser()
-        self._config.read(config_file)
+        if not self._config.read(config_file):
+            logger.warn('No valid config provided (reading %s).\nCloud IoT is disabled.' % config_file)
+            self._enabled = False
+            return
+
 
         if not self._config.getboolean(config_section, 'Enabled'):
             logger.warn('Cloud IoT is disabled per configuration.')
diff --git a/python/coral-cloudiot/coral/cloudiot/ecc608.py b/python/coral-cloudiot/coral/cloudiot/ecc608.py
index 67cb9d4..9346428 100644
--- a/python/coral-cloudiot/coral/cloudiot/ecc608.py
+++ b/python/coral-cloudiot/coral/cloudiot/ecc608.py
@@ -26,9 +26,11 @@
 
 logger = logging.getLogger(__name__)
 
+
 def _split_equal_parts(line, n):
     return [line[i:i+n] for i in range(0, len(line), n)]
 
+
 def _ascii_hex_string(a, l=16):
     """
     Format a bytearray object into a formatted ascii hex string
@@ -43,7 +45,8 @@
     public_key_der = bytearray.fromhex(
         '3059301306072A8648CE3D020106082A8648CE3D03010703420004') + raw_pub_key
     public_key_b64 = base64.b64encode(public_key_der).decode('ascii')
-    public_key_pem = '-----BEGIN PUBLIC KEY-----\n%s\n-----END PUBLIC KEY-----' % '\n'.join(_split_equal_parts(public_key_b64, 64))
+    public_key_pem = '-----BEGIN PUBLIC KEY-----\n%s\n-----END PUBLIC KEY-----' % '\n'.join(
+        _split_equal_parts(public_key_b64, 64))
     return public_key_pem
 
 
diff --git a/python/coral-enviro/MANIFEST.in b/python/coral-enviro/MANIFEST.in
index 4ff6b05..ddb24c6 100644
--- a/python/coral-enviro/MANIFEST.in
+++ b/python/coral-enviro/MANIFEST.in
@@ -1 +1 @@
-include coral/enviro/my_config.ini
+include coral/enviro/cloud_config.ini
diff --git a/python/coral-enviro/coral/enviro/board.py b/python/coral-enviro/coral/enviro/board.py
index abf71ba..7f73245 100644
--- a/python/coral-enviro/coral/enviro/board.py
+++ b/python/coral-enviro/coral/enviro/board.py
@@ -52,6 +52,7 @@
     """
     An interface for all input and output modules on the Environmental Sensor Board.
     """
+
     def __init__(self):
         # Obtain the full sysfs path of the IIO devices.
         self._hdc2010 = _get_path('hdc20x0')
diff --git a/python/coral-enviro/coral/enviro/my_config.ini b/python/coral-enviro/coral/enviro/cloud_config.ini
similarity index 100%
rename from python/coral-enviro/coral/enviro/my_config.ini
rename to python/coral-enviro/coral/enviro/cloud_config.ini
diff --git a/python/coral-enviro/coral/enviro/enviro_demo.py b/python/coral-enviro/coral/enviro/enviro_demo.py
index 75bfcda..9b9e7d9 100644
--- a/python/coral-enviro/coral/enviro/enviro_demo.py
+++ b/python/coral-enviro/coral/enviro/enviro_demo.py
@@ -20,6 +20,9 @@
 
 import argparse
 import itertools
+import os
+
+DEFAULT_CONFIG_LOCATION = os.path.join(os.path.dirname(__file__), 'cloud_config.ini')
 
 
 def update_display(display, msg):
@@ -40,7 +43,7 @@
     parser.add_argument('--upload_delay', help='Cloud upload delay (seconds)',
                         type=int, default=300)
     parser.add_argument(
-        '--cloud_config', help='Cloud IoT config file', default='my_config.ini')
+        '--cloud_config', help='Cloud IoT config file', default=DEFAULT_CONFIG_LOCATION)
     args = parser.parse_args()
 
     # Create instances of EnviroKit and Cloud IoT.