Merge lp:~kaihengfeng/ubiquity/fix-usd-scaling into lp:ubiquity

Proposed by Kai-Heng Feng
Status: Merged
Approved by: Mathieu Trudel-Lapierre
Approved revision: 6453
Merged at revision: 6459
Proposed branch: lp:~kaihengfeng/ubiquity/fix-usd-scaling
Merge into: lp:ubiquity
Diff against target: 33 lines (+19/-0)
1 file modified
bin/ubiquity-dm (+19/-0)
To merge this branch: bzr merge lp:~kaihengfeng/ubiquity/fix-usd-scaling
Reviewer Review Type Date Requested Status
Iain Lane Disapprove
Mathieu Trudel-Lapierre Approve
Review via email: mp+298284@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Looks generally fine; have you built this locally and tested it on a live image?

review: Needs Information
Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

Yes. It depends on the dbus-monitor output format, but I think it won't change anytime soon.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Looks fine this way; thanks!

review: Approve
Revision history for this message
Iain Lane (laney) wrote :

IMHO calling out to an external program like this is bad form in terms of efficiency and using the right tools for the job (the regex in particular has a bad smell).

There are APIs to talk to DBus directly which you can use from python. I recommend using GDBus via g-i. Something like---

  from gi.repository import Gio
  loop = Glib.MainLoop()
  connection = Gio.bus_get (Gio.BusType.SESSION, None, on_got_bus, loop)
  loop.run()

  # on_got_bus
  connection.signal_subscribe (sender, interface, "PluginActivated", object_path, None, Gio.DBusSignalFlags.NONE, on_xsettings_active, loop)
  # add a timeout for safety
  # start u-s-d

  # on_xsettings_active
  # check the signal parameter
  loop.quit()

review: Disapprove
Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

Yea I think your solution is better. I didn't know that Glib.MainLoop.run() will block until quit() is called, so I came up with current solution.

I'll update one accordingly.

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

It can't receive signals even if it does use connection.signal_subscribe()... Does it require something more than Glib.MainLoop()?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubiquity-dm'
2--- bin/ubiquity-dm 2016-06-13 10:47:25 +0000
3+++ bin/ubiquity-dm 2016-06-24 09:05:30 +0000
4@@ -461,10 +461,29 @@
5 preexec_fn=self.drop_privileges))
6
7 elif osextras.find_on_path(usd):
8+ # Wait until xsettings plugin is activated
9+ import re
10+ regexp = re.compile(
11+ r'signal.*SettingsDaemon.*PluginActivated')
12+
13+ dbus_monitor = subprocess.Popen(
14+ '/usr/bin/dbus-monitor', stdin=null,
15+ stdout=subprocess.PIPE, stderr=subprocess.PIPE,
16+ universal_newlines=True,
17+ preexec_fn=self.drop_privileges)
18+
19 extras.append(subprocess.Popen(
20 [usd], stdin=null, stdout=logfile, stderr=logfile,
21 preexec_fn=self.drop_privileges))
22
23+ while True:
24+ line = dbus_monitor.stdout.readline()
25+ if regexp.match(line) is not None:
26+ nextline = dbus_monitor.stdout.readline()
27+ if 'xsettings' in nextline:
28+ dbus_monitor.terminate()
29+ break
30+
31 elif osextras.find_on_path(gsd):
32 extras.append(subprocess.Popen(
33 [gsd], stdin=null, stdout=logfile, stderr=logfile,

Subscribers

People subscribed via source and target branches

to status/vote changes: