[gnome-boxes/gnome-3-4] Move exec* helpers to where they belong: Util module



commit 232933caefc8dcbc5eb51b9b1d97a70961b3c2a8
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue May 22 05:50:18 2012 +0300

    Move exec* helpers to where they belong: Util module
    
    https://bugzilla.gnome.org/show_bug.cgi?id=676320

 src/unattended-installer.vala |   43 -------------------------------------
 src/util.vala                 |   47 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 46 insertions(+), 44 deletions(-)
---
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 4aa1962..73dde76 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -3,7 +3,6 @@
 using GVirConfig;
 
 public errordomain UnattendedInstallerError {
-    COMMAND_FAILED,
     SETUP_INCOMPLETE
 }
 
@@ -246,33 +245,6 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
 
     protected virtual async void prepare_direct_boot (Cancellable? cancellable) throws GLib.Error {}
 
-    protected async void exec (string[] argv, Cancellable? cancellable) throws GLib.Error {
-        SourceFunc continuation = exec.callback;
-        GLib.Error error = null;
-        var context = MainContext.get_thread_default ();
-
-        g_io_scheduler_push_job ((job) => {
-            try {
-                exec_sync (argv);
-            } catch (GLib.Error err) {
-                error = err;
-            }
-
-            var source = new IdleSource ();
-            source.set_callback (() => {
-                continuation ();
-
-                return false;
-            });
-            source.attach (context);
-
-            return false;
-        });
-
-        yield;
-
-        if (error != null)
-            throw error;
     }
 
     private async void create_disk_image (Cancellable? cancellable) throws GLib.Error {
@@ -343,21 +315,6 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
         return true;
     }
 
-    private void exec_sync (string[] argv) throws GLib.Error {
-        int exit_status = -1;
-
-        Process.spawn_sync (null,
-                            argv,
-                            null,
-                            SpawnFlags.SEARCH_PATH,
-                            null,
-                            null,
-                            null,
-                            out exit_status);
-        if (exit_status != 0)
-            throw new UnattendedInstallerError.COMMAND_FAILED ("Failed to execute: %s", string.joinv (" ", argv));
-    }
-
     private async void fetch_user_avatar (Gtk.Image avatar) {
         if (accounts == null)
             return;
diff --git a/src/util.vala b/src/util.vala
index 89d8757..6b53f32 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -4,7 +4,8 @@ using Config;
 using Xml;
 
 public errordomain Boxes.Error {
-    INVALID
+    INVALID,
+    COMMAND_FAILED
 }
 
 namespace Boxes {
@@ -457,4 +458,48 @@ namespace Boxes {
         if (e != null)
             throw e;
     }
+
+    public async void exec (string[] argv, Cancellable? cancellable) throws GLib.Error {
+        SourceFunc continuation = exec.callback;
+        GLib.Error error = null;
+        var context = MainContext.get_thread_default ();
+
+        g_io_scheduler_push_job ((job) => {
+            try {
+                exec_sync (argv);
+            } catch (GLib.Error err) {
+                error = err;
+            }
+
+            var source = new IdleSource ();
+            source.set_callback (() => {
+                continuation ();
+
+                return false;
+            });
+            source.attach (context);
+
+            return false;
+        });
+
+        yield;
+
+        if (error != null)
+            throw error;
+    }
+
+    public void exec_sync (string[] argv) throws GLib.Error {
+        int exit_status = -1;
+
+        Process.spawn_sync (null,
+                            argv,
+                            null,
+                            SpawnFlags.SEARCH_PATH,
+                            null,
+                            null,
+                            null,
+                            out exit_status);
+        if (exit_status != 0)
+            throw new Boxes.Error.COMMAND_FAILED ("Failed to execute: %s", string.joinv (" ", argv));
+    }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]