[PATCH 07/17] Rename image analysis plugin to image inspection plugin

Jonathan Maw jonathan.maw at codethink.co.uk
Thu Jan 24 18:45:12 GMT 2013


From: Jannis Pohlmann <jannis.pohlmann at codethink.co.uk>

---
 morphlib/plugins/image_analysis_plugin.py   | 112 ----------------------------
 morphlib/plugins/image_inspection_plugin.py | 112 ++++++++++++++++++++++++++++
 2 files changed, 112 insertions(+), 112 deletions(-)
 delete mode 100644 morphlib/plugins/image_analysis_plugin.py
 create mode 100644 morphlib/plugins/image_inspection_plugin.py

diff --git a/morphlib/plugins/image_analysis_plugin.py b/morphlib/plugins/image_analysis_plugin.py
deleted file mode 100644
index 69e23de..0000000
--- a/morphlib/plugins/image_analysis_plugin.py
+++ /dev/null
@@ -1,112 +0,0 @@
-# Copyright (C) 2012  Codethink Limited
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-
-import cliapp
-import glob
-import json
-import os
-
-import morphlib
-
-from morphlib.mountableimage import MountableImage
-
-
-class ImageAnalysisPlugin(cliapp.Plugin):
-
-    def enable(self):
-        self.app.add_subcommand('run-in-system-image',
-                                self.run_in_image,
-                                arg_synopsis='IMAGE CMD')
-        self.app.add_subcommand('content-manifest',
-                                self.content_manifest,
-                                arg_synopsis='IMAGE')
-
-    def disable(self):
-        pass
-
-    def run_in_image(self, args):
-        '''Run a command inside a mounted system image.'''
-
-        if len(args) < 2:
-            raise cliapp.AppException('run-in-system-image requires '
-                                      'arguments: a system image filename '
-                                      'plus a shell command')
-
-        filename = args[0]
-        cmd = args[1:]
-
-        with MountableImage(self.app, filename) as mount_point:
-            output = self.app.runcmd(cmd, cwd=mount_point)
-            self.app.output.write(output)
-
-    def content_manifest(self, args):
-        '''Generate a content manifest for a system image.'''
-
-        if len(args) != 1:
-            raise cliapp.AppException('content-manifest requires a '
-                                      'system image')
-
-        with MountableImage(self.app, args[0]) as mount_point:
-            metadir = os.path.join(mount_point, 'factory', 'baserock')
-            artifacts = []
-            for basename in glob.glob(os.path.join(metadir, '*.meta')):
-                metafile = os.path.join(metadir, basename)
-                metadata = json.load(open(metafile))
-
-                artifacts.append({
-                    'cache-key': metadata['cache-key'],
-                    'name': metadata['artifact-name'],
-                    'kind': metadata['kind'],
-                    'sha1': metadata['sha1'],
-                    'original_ref': metadata['original_ref'],
-                    'repo': metadata['repo'],
-                    'morphology': metadata['morphology']
-                })
-
-            fmt = self._generate_output_format(artifacts)
-
-            self._print_artifacts(fmt, artifacts, 'system')
-            self._print_artifacts(fmt, artifacts, 'stratum')
-            self._print_artifacts(fmt, artifacts, 'chunk')
-
-    def _generate_output_format(self, artifacts):
-        colwidths = {}
-        for artifact in artifacts:
-            for key, value in artifact.iteritems():
-                colwidths[key] = max(colwidths.get(key, 0), len(value))
-
-        colwidths['first'] = sum([colwidths['cache-key'],
-                                  colwidths['kind'],
-                                  colwidths['name']])
-
-        return '%%-%is\t%%-%is\t%%-%is\t%%-%is\t%%-%is\n' % (
-                colwidths['first'],
-                colwidths['repo'],
-                colwidths['sha1'],
-                colwidths['original_ref'],
-                colwidths['morphology'])
-
-    def _print_artifacts(self, fmt, artifacts, kind):
-        for artifact in sorted(artifacts, key=lambda x: x['name']):
-            if artifact['kind'] == kind:
-                self.app.output.write(fmt % (
-                    '%s.%s.%s' % (artifact['cache-key'],
-                                  artifact['kind'],
-                                  artifact['name']),
-                    artifact['repo'],
-                    artifact['sha1'],
-                    artifact['original_ref'],
-                    artifact['morphology']))
diff --git a/morphlib/plugins/image_inspection_plugin.py b/morphlib/plugins/image_inspection_plugin.py
new file mode 100644
index 0000000..9d6241a
--- /dev/null
+++ b/morphlib/plugins/image_inspection_plugin.py
@@ -0,0 +1,112 @@
+# Copyright (C) 2012  Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+import cliapp
+import glob
+import json
+import os
+
+import morphlib
+
+from morphlib.mountableimage import MountableImage
+
+
+class ImageInspectionPlugin(cliapp.Plugin):
+
+    def enable(self):
+        self.app.add_subcommand('run-in-system-image',
+                                self.run_in_image,
+                                arg_synopsis='IMAGE CMD')
+        self.app.add_subcommand('manifest',
+                                self.manifest,
+                                arg_synopsis='IMAGE')
+
+    def disable(self):
+        pass
+
+    def run_in_image(self, args):
+        '''Run a command inside a mounted system image.'''
+
+        if len(args) < 2:
+            raise cliapp.AppException('run-in-system-image requires '
+                                      'arguments: a system image filename '
+                                      'plus a shell command')
+
+        filename = args[0]
+        cmd = args[1:]
+
+        with MountableImage(self.app, filename) as mount_point:
+            output = self.app.runcmd(cmd, cwd=mount_point)
+            self.app.output.write(output)
+
+    def manifest(self, args):
+        '''Generate a content manifest for a system image.'''
+
+        if len(args) != 1:
+            raise cliapp.AppException('manifest requires a '
+                                      'system image')
+
+        with MountableImage(self.app, args[0]) as mount_point:
+            metadir = os.path.join(mount_point, 'factory', 'baserock')
+            artifacts = []
+            for basename in glob.glob(os.path.join(metadir, '*.meta')):
+                metafile = os.path.join(metadir, basename)
+                metadata = json.load(open(metafile))
+
+                artifacts.append({
+                    'cache-key': metadata['cache-key'],
+                    'name': metadata['artifact-name'],
+                    'kind': metadata['kind'],
+                    'sha1': metadata['sha1'],
+                    'original_ref': metadata['original_ref'],
+                    'repo': metadata['repo'],
+                    'morphology': metadata['morphology']
+                })
+
+            fmt = self._generate_output_format(artifacts)
+
+            self._print_artifacts(fmt, artifacts, 'system')
+            self._print_artifacts(fmt, artifacts, 'stratum')
+            self._print_artifacts(fmt, artifacts, 'chunk')
+
+    def _generate_output_format(self, artifacts):
+        colwidths = {}
+        for artifact in artifacts:
+            for key, value in artifact.iteritems():
+                colwidths[key] = max(colwidths.get(key, 0), len(value))
+
+        colwidths['first'] = sum([colwidths['cache-key'],
+                                  colwidths['kind'],
+                                  colwidths['name']])
+
+        return '%%-%is\t%%-%is\t%%-%is\t%%-%is\t%%-%is\n' % (
+                colwidths['first'],
+                colwidths['repo'],
+                colwidths['sha1'],
+                colwidths['original_ref'],
+                colwidths['morphology'])
+
+    def _print_artifacts(self, fmt, artifacts, kind):
+        for artifact in sorted(artifacts, key=lambda x: x['name']):
+            if artifact['kind'] == kind:
+                self.app.output.write(fmt % (
+                    '%s.%s.%s' % (artifact['cache-key'],
+                                  artifact['kind'],
+                                  artifact['name']),
+                    artifact['repo'],
+                    artifact['sha1'],
+                    artifact['original_ref'],
+                    artifact['morphology']))
-- 
1.7.11.7





More information about the baserock-dev mailing list