Blob Blame Raw
From 93b8fe10cec88aa7051a9eb8f7041b7be0edf661 Mon Sep 17 00:00:00 2001
From: Chenxiong Qi <cqi@redhat.com>
Date: Wed, 24 May 2017 13:41:26 +0800
Subject: [PATCH 2/2] Make osbs support optional

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
---
 pyrpkg/__init__.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py
index bdd7f70..3a1d544 100644
--- a/pyrpkg/__init__.py
+++ b/pyrpkg/__init__.py
@@ -27,11 +27,6 @@ import sys
 import tempfile
 import koji.ssl.SSLCommon
 
-try:
-    from osbs.api import OSBS
-    from osbs.conf import Configuration
-except ImportError:
-    pass
 from six.moves import configparser
 from six.moves import urllib
 
@@ -2491,6 +2486,15 @@ class Commands(object):
 
     def osbs_build(self, config_file, config_section, target_override=False,
                    yum_repourls=[], nowait=False):
+        # Because docker image should be built via Koji not in OSBS directly,
+        # it is not necessary to make osbs as a hard dependency
+        try:
+            from osbs.api import OSBS
+            from osbs.conf import Configuration
+        except ImportError:
+            raise rpkgError('Before building docker image in OSBS directly, '
+                            'please install python-osbs-client in advance.')
+
         self.check_repo()
         os_conf = Configuration(conf_file=config_file, conf_section=config_section)
         build_conf = Configuration(conf_file=config_file, conf_section=config_section)
-- 
2.7.5