OSDN Git Service

test: Fix opp-client not printing progress
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 10 Apr 2013 11:33:57 +0000 (14:33 +0300)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 17 Apr 2013 10:43:45 +0000 (13:43 +0300)
This avoid KeyError expection and fixes print usage.

test/opp-client

index 3078d49..878c263 100755 (executable)
@@ -49,23 +49,25 @@ class OppClient:
                        print("Transfer created: %s" % path)
 
        def error(self, err):
-               print err
+               print(err)
                mainloop.quit()
 
        def properties_changed(self, interface, properties, invalidated, path):
                if path != self.transfer_path:
                        return
 
-               if properties['Status'] == 'complete' or \
-                               properties['Status'] == 'error':
+               if "Status" in properties and \
+                               (properties["Status"] == "complete" or \
+                               properties["Status"] == "error"):
                        if self.verbose:
-                               print("Transfer %s" % properties['Status'])
+                               print("Transfer %s" % properties["Status"])
                        mainloop.quit()
                        return
 
-               if properties["Transferred"] == None:
+               if "Transferred" not in properties:
                        return
 
+               value = properties["Transferred"]
                speed = (value - self.transferred) / 1000
                print("Transfer progress %d/%d at %d kBps" % (value,
                                                        self.transfer_size,