Merge lp://qastaging/~verterok/ubuntuone-client/keep-uploading-clean into lp://qastaging/ubuntuone-client

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: Rick McBride
Approved revision: 8
Merged at revision: not available
Proposed branch: lp://qastaging/~verterok/ubuntuone-client/keep-uploading-clean
Merge into: lp://qastaging/ubuntuone-client
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~verterok/ubuntuone-client/keep-uploading-clean
Reviewer Review Type Date Requested Status
Rick McBride (community) Approve
dobey (community) Approve
Review via email: mp+6529@code.qastaging.launchpad.net

Commit message

[r=dobey, r=rmcbride] Clean ups in current_uploads

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

 This branch fix:
  1) DBus current_uploads method to only return the uploads that already have a real node_id
  2) fix Action Queue in order to cleanup the uploads with markers from the uploading list once the marker is mapped to a real node_id
  3) a typo in the u1sdtool manpage

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Rick McBride (rmcbride) wrote :

I like it

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/u1sdtool'
2--- bin/u1sdtool 2009-05-12 13:36:05 +0000
3+++ bin/u1sdtool 2009-05-13 15:33:22 +0000
4@@ -23,6 +23,7 @@
5 import dbus
6 import os
7 import sys
8+import warnings
9
10 from canonical.ubuntuone.storage.syncdaemon.tools import SyncDaemonTool
11 from dbus.mainloop.glib import DBusGMainLoop
12@@ -58,6 +59,9 @@
13 metavar="PATH", help=" request a refresh of PATH")
14 parser.add_option("", "--info", dest="path_info",
15 metavar="PATH", help=" request the metadata of PATH")
16+ parser.add_option("", "--current-transfers", dest="current_transfers",
17+ action="store_true",
18+ help=" show the current uploads and downloads")
19
20 (options, args) = parser.parse_args(argv)
21
22@@ -127,6 +131,29 @@
23 for k, v in result.items():
24 print " %s: %s " % (k, v)
25 d.addCallback(show_info)
26+ elif options.current_transfers:
27+ d = sync_daemon_tool.get_current_uploads()
28+ def show_uploads(uploads):
29+ if uploads:
30+ print "Current uploads:"
31+ else:
32+ print "Current uploads: 0"
33+ for upload in uploads:
34+ print " path: %s" % upload['path']
35+ print " deflated size: %s" % upload['deflated_size']
36+ print " bytes written: %s" % upload['n_bytes_written']
37+ def show_downloads(downloads):
38+ if downloads:
39+ print "Current downloads:"
40+ else:
41+ print "Current downloads: 0"
42+ for download in downloads:
43+ print " path: %s" % download['path']
44+ print " deflated size: %s" % download['deflated_size']
45+ print " bytes read: %s" % download['n_bytes_read']
46+ d.addCallback(show_uploads)
47+ d.addCallback(lambda _: sync_daemon_tool.get_current_downloads())
48+ d.addCallback(show_downloads)
49 else:
50 parser.print_help()
51 sys.exit(0)
52@@ -146,4 +173,6 @@
53
54
55 if __name__ == '__main__':
56+ # disable the dbus warnings
57+ warnings.filterwarnings('ignore', module='dbus')
58 main(sys.argv)
59
60=== modified file 'canonical/ubuntuone/storage/syncdaemon/action_queue.py'
61--- canonical/ubuntuone/storage/syncdaemon/action_queue.py 2009-05-12 13:36:05 +0000
62+++ canonical/ubuntuone/storage/syncdaemon/action_queue.py 2009-05-13 13:38:20 +0000
63@@ -1389,7 +1389,12 @@
64 """
65 Called when all the markers are realized.
66 """
67+ # update action_queue.uploading with the real node_id
68+ uploading = self.action_queue.uploading.pop((self.share_id,
69+ self.node_id))
70 self.node_id = node_id
71+ self.action_queue.uploading[self.share_id, node_id] = uploading
72+
73
74 def _run(self):
75 """
76
77=== modified file 'canonical/ubuntuone/storage/syncdaemon/dbus_interface.py'
78--- canonical/ubuntuone/storage/syncdaemon/dbus_interface.py 2009-05-12 13:36:05 +0000
79+++ canonical/ubuntuone/storage/syncdaemon/dbus_interface.py 2009-05-13 13:38:20 +0000
80@@ -19,6 +19,7 @@
81 import dbus.service
82
83 from canonical.ubuntuone.storage.syncdaemon.event_queue import EVENTS
84+from canonical.ubuntuone.storage.syncdaemon.interfaces import IMarker
85 import logging
86
87 DBUS_IFACE_NAME = 'com.ubuntuone.SyncDaemon'
88@@ -104,8 +105,11 @@
89 """ return a list of files with a upload in progress """
90 current_uploads = []
91 for upload in self.action_queue.uploading:
92- path = self.fs_manager.get_abspath(upload[0],
93- self.fs_manager.get_by_node_id(*upload).path)
94+ share_id, node_id = upload
95+ if IMarker.providedBy(node_id):
96+ continue
97+ path = self.fs_manager.get_by_node_id(share_id, node_id).path
98+ path = self.fs_manager.get_abspath(share_id, path)
99 info = self.action_queue.uploading[upload]
100 entry = {'path':path,
101 'share_id':upload[0],
102
103=== modified file 'docs/man/u1sdtool.1'
104--- docs/man/u1sdtool.1 2009-05-12 13:36:05 +0000
105+++ docs/man/u1sdtool.1 2009-05-13 15:33:22 +0000
106@@ -31,6 +31,9 @@
107 .br
108 .B u1sdtool
109 \-\-info=PATH
110+.br
111+.B u1sdtool
112+\-\-current-transfers
113
114 .SH DESCRIPTION
115 u1sdtool is a command line command line utility for controlling
116@@ -43,7 +46,7 @@
117 .SH OPTIONS
118 .TP
119 \fB\-\-wait\fR
120-Wait until SyncDaemon reachs nirvana
121+Wait until SyncDaemon reaches nirvana (no more events, uploads and/or downloads)
122 .TP
123 \fB\-\-accept-share\fR=\fISHARE_ID\fR
124 accept the share with the specified id
125@@ -102,6 +105,9 @@
126 .I PATH
127 A path of a directory or file managed by ubuntuone-syncdaemon
128 .RE
129+.TP
130+\fB\-\-current-transfers\fR
131+Show the current uploads and downloads
132 .SH AUTHOR
133 This manual page was written by Guillermo Gonzalez <guillermo.gonzalez@canonical.com>.
134
135
136=== modified file 'tests/syncdaemon/test_dbus.py'
137--- tests/syncdaemon/test_dbus.py 2009-05-12 17:34:36 +0000
138+++ tests/syncdaemon/test_dbus.py 2009-05-13 13:38:20 +0000
139@@ -203,6 +203,22 @@
140 error_handler=self.error_handler)
141 return d
142
143+ def test_current_uploads_with_marker(self):
144+ """ Test Status.current_uploads with fake data in the AQ """
145+ self.action_q.uploading[('', MDMarker('a_marker_uuid'))] = dict(
146+ deflated_size=100, n_bytes_written=10)
147+ client = DBusClient(self.bus, '/status', DBUS_IFACE_STATUS_NAME)
148+ d = defer.Deferred()
149+
150+ def uploads_handler(result):
151+ """ reply handler """
152+ self.assertEquals(0, len(result))
153+ d.callback(True)
154+
155+ client.call_method('current_uploads', reply_handler=uploads_handler,
156+ error_handler=self.error_handler)
157+ return d
158+
159 def test_two_current_downloads(self):
160 """ Test Status.current_downloads with fake data in the AQ """
161 share_path = os.path.join(self.shares_dir, 'share')

Subscribers

People subscribed via source and target branches