summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python-smartpm/smart-yaml-error.patch
blob: e16c5c12aa1c51954f4f4c9654007443ade8b423 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Print a more friendly error if YAML output is requested without PyYAML

Upstream-Status: Pending

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>

diff --git a/smart/commands/channel.py b/smart/commands/channel.py
index 63fbb35..108f3f1 100644
--- a/smart/commands/channel.py
+++ b/smart/commands/channel.py
@@ -339,7 +339,10 @@ def main(ctrl, opts):
                     print
 
     if opts.yaml is not None:
-        import yaml
+        try:
+            import yaml
+        except ImportError:
+            raise Error, _("Please install PyYAML in order to use this function")
         yamlchannels = {}
         for alias in (opts.yaml or sysconf.get("channels", ())):
             channel = sysconf.get(("channels", alias))
diff --git a/smart/commands/config.py b/smart/commands/config.py
index 4fe4366..aa1db78 100644
--- a/smart/commands/config.py
+++ b/smart/commands/config.py
@@ -137,7 +137,10 @@ def main(ctrl, opts):
             pprint.pprint(sysconf.get((), hard=True))
 
     if opts.yaml is not None:
-        import yaml
+        try:
+            import yaml
+        except ImportError:
+            raise Error, _("Please install PyYAML in order to use this function")
         if opts.yaml:
             marker = object()
             for opt in opts.yaml:
diff --git a/smart/commands/flag.py b/smart/commands/flag.py
index ed18999..8b90496 100644
--- a/smart/commands/flag.py
+++ b/smart/commands/flag.py
@@ -138,7 +138,10 @@ def main(ctrl, opts):
             print
 
     if opts.yaml is not None:
-        import yaml
+        try:
+            import yaml
+        except ImportError:
+            raise Error, _("Please install PyYAML in order to use this function")
         yamlflags = {}
         for flag in opts.yaml or pkgconf.getFlagNames():
             flag = flag.strip()
diff --git a/smart/commands/mirror.py b/smart/commands/mirror.py
index ca50a95..f7b019d 100644
--- a/smart/commands/mirror.py
+++ b/smart/commands/mirror.py
@@ -218,7 +218,10 @@ def main(ctrl, opts):
             print
 
     if opts.yaml:
-        import yaml
+        try:
+            import yaml
+        except ImportError:
+            raise Error, _("Please install PyYAML in order to use this function")
         yamlmirrors = {}
         mirrors = sysconf.get("mirrors", ())
         for origin in mirrors:
diff --git a/smart/commands/priority.py b/smart/commands/priority.py
index d850d29..441ea32 100644
--- a/smart/commands/priority.py
+++ b/smart/commands/priority.py
@@ -117,7 +117,10 @@ def main(ctrl, opts):
         print
 
     elif opts.yaml:
-        import yaml
+        try:
+            import yaml
+        except ImportError:
+            raise Error, _("Please install PyYAML in order to use this function")
         yamlpriorities = {}
         priorities = sysconf.get("package-priorities", {})
         for name in opts.args or priorities:
OpenPOWER on IntegriCloud