]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
web: status: add 'started' timestamps to all operations
authorBrian Warner <warner@allmydata.com>
Wed, 5 Mar 2008 01:50:44 +0000 (18:50 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 5 Mar 2008 01:50:44 +0000 (18:50 -0700)
src/allmydata/download.py
src/allmydata/interfaces.py
src/allmydata/mutable.py
src/allmydata/upload.py
src/allmydata/web/download-status.xhtml
src/allmydata/web/publish-status.xhtml
src/allmydata/web/retrieve-status.xhtml
src/allmydata/web/status.xhtml
src/allmydata/web/upload-status.xhtml
src/allmydata/webish.py

index 53b268e71d8e452bd0c50f911e5fec521f2503ab..66c399c5e1df7baa31c98ded99fb67e0e843fb56 100644 (file)
@@ -364,7 +364,10 @@ class DownloadStatus:
         self.active = True
         self.results = None
         self.counter = self.statusid_counter.next()
+        self.started = time.time()
 
+    def get_started(self):
+        return self.started
     def get_storage_index(self):
         return self.storage_index
     def get_size(self):
index b9ff96f4da8543262fe8e6cd38592a86c022f2b5..91757856f5725648009421b1c49758d6e9067053 100644 (file)
@@ -1453,6 +1453,9 @@ class IClientStatus(Interface):
         started downloads."""
 
 class IUploadStatus(Interface):
+    def get_started():
+        """Return a timestamp (float with seconds since epoch) indicating
+        when the operation was started."""
     def get_storage_index():
         """Return a string with the (binary) storage index in use on this
         upload. Returns None if the storage index has not yet been
@@ -1489,6 +1492,9 @@ class IUploadStatus(Interface):
         page can generate a suitable hyperlink."""
 
 class IDownloadStatus(Interface):
+    def get_started():
+        """Return a timestamp (float with seconds since epoch) indicating
+        when the operation was started."""
     def get_storage_index():
         """Return a string with the (binary) storage index in use on this
         download. This may be None if there is no storage index (i.e. LIT
index 925a286a64051daf013bfab684e77cbdbee94fc1..f983d3b7a636701c061d3efaa7dee1eb66ae7278 100644 (file)
@@ -211,7 +211,10 @@ class RetrieveStatus:
         self.status = "Not started"
         self.progress = 0.0
         self.counter = self.statusid_counter.next()
+        self.started = time.time()
 
+    def get_started(self):
+        return self.started
     def get_storage_index(self):
         return self.storage_index
     def using_helper(self):
@@ -783,7 +786,10 @@ class PublishStatus:
         self.status = "Not started"
         self.progress = 0.0
         self.counter = self.statusid_counter.next()
+        self.started = time.time()
 
+    def get_started(self):
+        return self.started
     def get_storage_index(self):
         return self.storage_index
     def using_helper(self):
index c3dd29dfa3e3440837cb75356cc2515b7cac4cfc..015a74a5f3485f9124ce51c92e1944365a6eb284 100644 (file)
@@ -575,7 +575,10 @@ class UploadStatus:
         self.active = True
         self.results = None
         self.counter = self.statusid_counter.next()
+        self.started = time.time()
 
+    def get_started(self):
+        return self.started
     def get_storage_index(self):
         return self.storage_index
     def get_size(self):
index 5e563acfdd1ebf78689609113a51268aea6d8978..5a3d47e2ad5cb4b302a802e98876a51e7c2c0ba8 100644 (file)
@@ -11,6 +11,7 @@
 <h1>File Download Status</h1>
 
 <ul>
+  <li>Started: <span n:render="started"/></li>
   <li>Storage Index: <span n:render="si"/></li>
   <li>Helper?: <span n:render="helper"/></li>
   <li>Total Size: <span n:render="total_size"/></li>
index 657bde3c5599b3dd2a92a3f06c37870808be5c40..f6b862c33230470d2a68ef7149fbfee66d1e2c75 100644 (file)
@@ -11,6 +11,7 @@
 <h1>Mutable File Publish Status</h1>
 
 <ul>
+  <li>Started: <span n:render="started"/></li>
   <li>Storage Index: <span n:render="si"/></li>
   <li>Helper?: <span n:render="helper"/></li>
   <li>Current Size: <span n:render="current_size"/></li>
index 1d2bb554cba94ee0d60b47a314bcdd067e6a7411..422cdcd87d8e390e6ad3cbf699aa8803965f8860 100644 (file)
@@ -11,6 +11,7 @@
 <h1>Mutable File Retrieve Status</h1>
 
 <ul>
+  <li>Started: <span n:render="started"/></li>
   <li>Storage Index: <span n:render="si"/></li>
   <li>Helper?: <span n:render="helper"/></li>
   <li>Current Size: <span n:render="current_size"/></li>
index f0a24247a2a2683f330ccb6ac4bbffd097f9513c..4c478b97d50c6b039b1708c5381209a756166d24 100644 (file)
@@ -36,6 +36,7 @@
 <h2>Recent Operations:</h2>
 <table n:render="sequence" n:data="recent_operations" border="1">
   <tr n:pattern="header">
+    <td>Started</td>
     <td>Type</td>
     <td>Storage Index</td>
     <td>Helper?</td>
@@ -44,6 +45,7 @@
     <td>Status</td>
   </tr>
   <tr n:pattern="item" n:render="row">
+    <td><n:slot name="started"/></td>
     <td><n:slot name="type"/></td>
     <td><n:slot name="si"/></td>
     <td><n:slot name="helper"/></td>
index 1d8c7e0fd79e0f871b896808a18eaa00c7bc2b85..90e676ff19a8d309afb2382381c5762fcd3fc4d4 100644 (file)
@@ -11,6 +11,7 @@
 <h1>File Upload Status</h1>
 
 <ul>
+  <li>Started: <span n:render="started"/></li>
   <li>Storage Index: <span n:render="si"/></li>
   <li>Helper?: <span n:render="helper"/></li>
   <li>Total Size: <span n:render="total_size"/></li>
index bdbce4438a0cc3bac0fd706a9156e6c7c52cd1d0..bae3d7d13462e7fe27b4918f2c7d8b5c5a591bfa 100644 (file)
@@ -1638,6 +1638,12 @@ class UploadStatusPage(UploadResultsRendererMixin, rend.Page):
         d.addCallback(_got_results)
         return d
 
+    def render_started(self, ctx, data):
+        TIME_FORMAT = "%H:%M:%S %d-%b-%Y"
+        started_s = time.strftime(TIME_FORMAT,
+                                  time.localtime(data.get_started()))
+        return started_s
+
     def render_si(self, ctx, data):
         si_s = base32.b2a_or_none(data.get_storage_index())
         if si_s is None:
@@ -1841,6 +1847,12 @@ class DownloadStatusPage(DownloadResultsRendererMixin, rend.Page):
         d.addCallback(_got_results)
         return d
 
+    def render_started(self, ctx, data):
+        TIME_FORMAT = "%H:%M:%S %d-%b-%Y"
+        started_s = time.strftime(TIME_FORMAT,
+                                  time.localtime(data.get_started()))
+        return started_s
+
     def render_si(self, ctx, data):
         si_s = base32.b2a_or_none(data.get_storage_index())
         if si_s is None:
@@ -1868,6 +1880,12 @@ class DownloadStatusPage(DownloadResultsRendererMixin, rend.Page):
 class RetrieveStatusPage(rend.Page):
     docFactory = getxmlfile("retrieve-status.xhtml")
 
+    def render_started(self, ctx, data):
+        TIME_FORMAT = "%H:%M:%S %d-%b-%Y"
+        started_s = time.strftime(TIME_FORMAT,
+                                  time.localtime(data.get_started()))
+        return started_s
+
     def render_si(self, ctx, data):
         si_s = base32.b2a_or_none(data.get_storage_index())
         if si_s is None:
@@ -1895,6 +1913,12 @@ class RetrieveStatusPage(rend.Page):
 class PublishStatusPage(rend.Page):
     docFactory = getxmlfile("publish-status.xhtml")
 
+    def render_started(self, ctx, data):
+        TIME_FORMAT = "%H:%M:%S %d-%b-%Y"
+        started_s = time.strftime(TIME_FORMAT,
+                                  time.localtime(data.get_started()))
+        return started_s
+
     def render_si(self, ctx, data):
         si_s = base32.b2a_or_none(data.get_storage_index())
         if si_s is None:
@@ -1936,10 +1960,18 @@ class Status(rend.Page):
                             IClient(ctx).list_recent_publish() +
                             IClient(ctx).list_recent_retrieve())
                   if not o.get_active()]
+        recent.sort(lambda a,b: cmp(a.get_started(), b.get_started()))
+        recent.reverse()
         return recent
 
     def render_row(self, ctx, data):
         s = data
+
+        TIME_FORMAT = "%H:%M:%S %d-%b-%Y"
+        started_s = time.strftime(TIME_FORMAT,
+                                  time.localtime(s.get_started()))
+        ctx.fillSlots("started", started_s)
+
         si_s = base32.b2a_or_none(s.get_storage_index())
         if si_s is None:
             si_s = "(None)"