[gnome-hwtest-simulator] Remove need to be run from GNOME Continuous build directory



commit 233da24a9406b7972f85526c2a8c55d54b3b0403
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Thu Jun 26 16:14:23 2014 -0400

    Remove need to be run from GNOME Continuous build directory
    
    Instead of looking for files relative to the cwd, use a gnome-continuous-home
    key to find the GNOME Continous builddir. (Defaults to ~/gnome/continuous)

 data/org.gnome.HWTestSimulator.gschema.xml |    7 ++++++
 src/machine.js                             |   14 ++++++------
 src/main.js                                |   33 +++++++++++++++++++++++++--
 src/spice.js                               |   11 ++++++---
 4 files changed, 51 insertions(+), 14 deletions(-)
---
diff --git a/data/org.gnome.HWTestSimulator.gschema.xml b/data/org.gnome.HWTestSimulator.gschema.xml
index 62a480b..c18d4b9 100644
--- a/data/org.gnome.HWTestSimulator.gschema.xml
+++ b/data/org.gnome.HWTestSimulator.gschema.xml
@@ -10,5 +10,12 @@
         should be the path to a serial port, for example "/dev/ttyUSB0".
       </description>
     </key>
+    <key name="gnome-continuous-home" type="s">
+      <default>"~/gnome/continuous"</default>
+      <summary>Build directory for gnome-continuous </summary>
+      <description>
+        Build directory for gnome-continuous.
+      </description>
+    </key>
   </schema>
 </schemalist>
diff --git a/src/machine.js b/src/machine.js
index f9fb391..d4a1a99 100644
--- a/src/machine.js
+++ b/src/machine.js
@@ -156,11 +156,11 @@ const TargetMachine = new Lang.Class({
         let drives = [];
         if (bootType == BOOT_NETWORK || bootType == BOOT_IMAGE)
             drives.push({
-                file: 'images/local/gnome-continuous-x86_64-minimal.qcow2',
+                file: 
application.getHomeFile('images/local/gnome-continuous-x86_64-hwtest.qcow2').get_path(),
                 readonly: true
             });
         drives.push({
-            file: 'target.image',
+            file: application.getHomeFile('target.image').get_path(),
         });
 
         this.parent('hwtest-target', application,
@@ -184,14 +184,14 @@ const ControllerMachine = new Lang.Class({
         let drives = [];
         if (bootType == BOOT_NETWORK || bootType == BOOT_IMAGE)
             drives.push({
-                file: 'images/local/gnome-continuous-x86_64-minimal.qcow2',
+                file: 
application.getHomeFile('images/local/gnome-continuous-x86_64-hwtest.qcow2').get_path(),
                 readonly: true
             });
         drives.push({
-            file: 'controller.image',
+            file: application.getHomeFile('controller.image').get_path(),
         });
         drives.push({
-            file: 'srv-gnome-hwtest.image',
+            file: application.getHomeFile('srv-gnome-hwtest.image').get_path(),
         });
 
         let params = { spicePort: 3501,
@@ -217,11 +217,11 @@ const ControllerMachine = new Lang.Class({
             }
         }
 
-        let integrationDir = Gio.File.new_for_path('overrides/gnome-ostree-integration');
+        let integrationDir = application.getHomeFile('overrides/gnome-hwtest');
         if (integrationDir.query_exists(null)) {
             params.virtfs = [
                 {
-                    mountTag: 'gnome-ostree-integration',
+                    mountTag: 'gnome-hwtest',
                     path: integrationDir.get_path()
                 }
             ];
diff --git a/src/main.js b/src/main.js
index bdadd61..e4baf8d 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,3 +1,4 @@
+const Format = imports.format;
 const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
@@ -19,11 +20,20 @@ const Application = new Lang.Class({
 
         Gtk.Settings.get_default().set_property('gtk-application-prefer-dark-theme', true);
 
+        let settings = new Gio.Settings({ schema: 'org.gnome.HWTestSimulator' });
+        let gnomeContinuousHome = settings.get_string("gnome-continuous-home");
+        gnomeContinuousHome = gnomeContinuousHome.replace(/^~(?=\/|$)/, GLib.get_home_dir());
+        this.gnomeContinuousHome = Gio.File.new_for_path(gnomeContinuousHome);
+
         this.mainWindow = null;
         this.targetProxy = null;
         this.exitRequested = false;
     },
 
+    getHomeFile: function(relative) {
+        return this.gnomeContinuousHome.get_child(relative);
+    },
+
     requestExit: function() {
         this.exitRequested = true;
         if (this.controllerProxy.machine)
@@ -34,6 +44,21 @@ const Application = new Lang.Class({
     },
 
     vfunc_activate: function() {
+        if (!this.gnomeContinuousHome.query_exists(null) ||
+            !this.getHomeFile('manifest.json').query_exists(null)) {
+            let dialog = new Gtk.MessageDialog({
+                message_type: Gtk.MessageType.ERROR,
+                text: "GNOME Continuous build directory messing",
+                secondary_text: Format.vprintf("'%s' does not seem to be a GNOME Continuous build directory. 
See https://wiki.gnome.org/Projects/HardwareTesting/Tasks/HackingEnvironment";,
+                                               [this.gnomeContinuousHome.get_path()]),
+                buttons: Gtk.ButtonsType.OK
+            });
+            dialog.application = this;
+            dialog.show_all();
+            dialog.connect('response',
+                           function() { dialog.destroy() });
+        }
+
         if (this.mainWindow == null) {
             this.networkManager = new Network.NetworkManager();
 
@@ -67,7 +92,7 @@ const Application = new Lang.Class({
             button.connect('toggled', this._onSerialToggled.bind(this, true));
             this.serialBox.pack_start(button, true, true, 0);
 
-            this.mainView = new Spice.MainView();
+            this.mainView = new Spice.MainView(this);
             this.mainView.connect('display-changed', this._onDisplayChanged.bind(this));
             this.mainView.connect('show-serial-changed', this._onShowSerialChanged.bind(this));
             hbox.pack_start(this.mainView, true, true, 0);
@@ -107,7 +132,8 @@ const Application = new Lang.Class({
     },
 
     vfunc_shutdown: function() {
-        this._httpd.send_signal(15, null); /* SIGTERM */
+        if (this._httpd)
+            this._httpd.send_signal(15, null); /* SIGTERM */
         this.parent();
     },
 
@@ -144,7 +170,8 @@ const Application = new Lang.Class({
     },
 
     _startHttpd: function() {
-        this._httpd = Gio.Subprocess.new(['ostree', 'trivial-httpd', '--port-file=-', '.'],
+        this._httpd = Gio.Subprocess.new(['ostree', 'trivial-httpd', '--port-file=-',
+                                          this.gnomeContinuousHome.get_path()],
                                         Gio.SubprocessFlags.STDOUT_PIPE);
         let datastream = Gio.DataInputStream.new(this._httpd.get_stdout_pipe());
         datastream.read_line_async(GLib.PRIORITY_DEFAULT, null, function(datastream, result) {
diff --git a/src/spice.js b/src/spice.js
index 3944063..2bbca19 100644
--- a/src/spice.js
+++ b/src/spice.js
@@ -447,9 +447,10 @@ const MachineWidget = new Lang.Class({
     },
 
     _onSaveTerminalContents: function() {
-        output = Gio.File.new_for_path(this.proxy.name + '-serial.txt').replace(null, false,
-                                                                                Gio.FileCreateFlags.NONE,
-                                                                                null);
+        outputFile = this.mainView.application.getHomeFile(this.proxy.name + '-serial.txt');
+        output = outputFile.replace(null, false,
+                                    Gio.FileCreateFlags.NONE,
+                                    null);
         this.term.write_contents (output, Vte.TerminalWriteFlags.DEFAULT,
                                   null);
         output.close(null);
@@ -467,9 +468,11 @@ const MainView = new Lang.Class({
         'show-serial-changed': {}
     },
 
-    _init: function() {
+    _init: function(application) {
         this.parent();
 
+        this.application = application;
+
         this.consoleHolder = new StraightJacket();
         this.consoleHolder.show();
         this.add_named(this.consoleHolder, 'console');


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