Merge lp:~mikemc/ubuntuone-client/log-monitor into lp:ubuntuone-client

Proposed by Mike McCracken
Status: Merged
Approved by: Roberto Alsina
Approved revision: 1297
Merged at revision: 1296
Proposed branch: lp:~mikemc/ubuntuone-client/log-monitor
Merge into: lp:ubuntuone-client
Diff against target: 52 lines (+13/-3)
1 file modified
ubuntuone/platform/filesystem_notifications/monitor/__init__.py (+13/-3)
To merge this branch: bzr merge lp:~mikemc/ubuntuone-client/log-monitor
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Review via email: mp+121507@code.launchpad.net

Commit message

- Log to syncdaemon log which monitor implementation is used. (LP: #1042336)

Description of the change

- Log to syncdaemon log which monitor implementation is used. (LP: #1042336)

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntuone/platform/filesystem_notifications/monitor/__init__.py'
--- ubuntuone/platform/filesystem_notifications/monitor/__init__.py 2012-08-01 14:25:58 +0000
+++ ubuntuone/platform/filesystem_notifications/monitor/__init__.py 2012-08-27 21:57:20 +0000
@@ -32,6 +32,8 @@
3232
33from twisted.internet import defer33from twisted.internet import defer
3434
35from ubuntuone.syncdaemon.logger import root_logger as logger
36
35DEFAULT_MONITOR = 'default'37DEFAULT_MONITOR = 'default'
3638
3739
@@ -70,6 +72,7 @@
70 DEFAULT_MONITOR: linux.FilesystemMonitor,72 DEFAULT_MONITOR: linux.FilesystemMonitor,
71 }73 }
7274
75
73# mantain old API76# mantain old API
74FilesystemMonitor = FILEMONITOR_IDS[DEFAULT_MONITOR]77FilesystemMonitor = FILEMONITOR_IDS[DEFAULT_MONITOR]
7578
@@ -77,21 +80,28 @@
77@defer.inlineCallbacks80@defer.inlineCallbacks
78def get_filemonitor_class(monitor_id=None):81def get_filemonitor_class(monitor_id=None):
79 """Return the class to be used."""82 """Return the class to be used."""
83 logger.debug('File monitor ids for platform "%s" are "%s"', sys.platform,
84 FILEMONITOR_IDS)
85
80 if monitor_id is None:86 if monitor_id is None:
81 # use default87 logger.debug('monitor_id is None, using default.')
82 monitor_id = 'default'88 monitor_id = 'default'
8389
84 if monitor_id not in FILEMONITOR_IDS:90 if monitor_id not in FILEMONITOR_IDS:
85 raise NoAvailableMonitorError(91 msg = 'No available monitor with id %r could be found.'
86 'No available monitor with id "%s"could be found.' % monitor_id)92 raise NoAvailableMonitorError(msg % monitor_id)
8793
88 # retrieve the correct class and assert it can be used94 # retrieve the correct class and assert it can be used
89 cls = FILEMONITOR_IDS[monitor_id]95 cls = FILEMONITOR_IDS[monitor_id]
96 logger.debug('Checking availability of monitor class %ns', cls)
90 is_available = yield cls.is_available_monitor()97 is_available = yield cls.is_available_monitor()
9198
92 if is_available:99 if is_available:
100 logger.debug('Monitor is available, returning monitor with id "%s"',
101 monitor_id)
93 defer.returnValue(cls)102 defer.returnValue(cls)
94 elif not is_available and monitor_id != DEFAULT_MONITOR:103 elif not is_available and monitor_id != DEFAULT_MONITOR:
104 logger.debug('Monitor is NOT available, returning default monitor.')
95 cls = yield get_filemonitor_class(DEFAULT_MONITOR)105 cls = yield get_filemonitor_class(DEFAULT_MONITOR)
96 defer.returnValue(cls)106 defer.returnValue(cls)
97 else:107 else:

Subscribers

People subscribed via source and target branches