1 patch for repository davidsarah@dev.allmydata.org:/home/darcs/tahoe/trunk:

Thu Dec 30 04:19:09 GMT Standard Time 2010  david-sarah@jacaranda.org
  * Move responsibility for calculating the estimated total/used/available space on a grid as used by SFTP to client.py. refs #1285

New patches:

[Move responsibility for calculating the estimated total/used/available space on a grid as used by SFTP to client.py. refs #1285
david-sarah@jacaranda.org**20101230041909
 Ignore-this: 96ef30774bfc678f9890333b046f9f90
] {
hunk ./src/allmydata/client.py 476
         d.addCallback(lambda res: None)
         return d
 
+    def get_grid_stats(self):
+        # Make up some values; see ticket #1285.
+        used_KiB = available_KiB = 314159265
+
+        total_KiB = used_KiB + available_KiB
+        used_percent = 0
+        if total_KiB > 0:
+            used_percent = used_KiB * 100 // total_KiB
+        return { 'total_KiB': total_KiB, 'used_KiB': used_KiB, 'available_KiB': available_KiB,
+                 'used_percent': used_percent, 'fake': True}
+
 
     # these four methods are the primitives for creating filenodes and
     # dirnodes. The first takes a URI and produces a filenode or (new-style)
hunk ./src/allmydata/frontends/sftpd.py 1759
 
         if extensionName == 'statvfs@openssh.com' or extensionName == 'fstatvfs@openssh.com':
             # f_bsize and f_frsize should be the same to avoid a bug in 'df'
+            stats = self._get_grid_stats()
             return defer.succeed(struct.pack('>11Q',
hunk ./src/allmydata/frontends/sftpd.py 1761
-                1024,         # uint64  f_bsize     /* file system block size */
-                1024,         # uint64  f_frsize    /* fundamental fs block size */
-                628318530,    # uint64  f_blocks    /* number of blocks (unit f_frsize) */
-                314159265,    # uint64  f_bfree     /* free blocks in file system */
-                314159265,    # uint64  f_bavail    /* free blocks for non-root */
-                200000000,    # uint64  f_files     /* total file inodes */
-                100000000,    # uint64  f_ffree     /* free file inodes */
-                100000000,    # uint64  f_favail    /* free file inodes for non-root */
-                0x1AF5,       # uint64  f_fsid      /* file system id */
-                2,            # uint64  f_flag      /* bit mask = ST_NOSUID; not ST_RDONLY */
-                65535,        # uint64  f_namemax   /* maximum filename length */
+                1024,                   # uint64  f_bsize     /* file system block size */
+                1024,                   # uint64  f_frsize    /* fundamental fs block size */
+                stats['total_KiB'],     # uint64  f_blocks    /* number of blocks (unit f_frsize) */
+                stats['available_KiB'], # uint64  f_bfree     /* free blocks in file system */
+                stats['available_KiB'], # uint64  f_bavail    /* free blocks for non-root */
+                200000000,              # uint64  f_files     /* total file inodes */
+                100000000,              # uint64  f_ffree     /* free file inodes */
+                100000000,              # uint64  f_favail    /* free file inodes for non-root */
+                0x1AF5,                 # uint64  f_fsid      /* file system id */
+                2,                      # uint64  f_flag      /* bit mask = ST_NOSUID; not ST_RDONLY */
+                65535,                  # uint64  f_namemax   /* maximum filename length */
                 ))
 
         def _unsupported(): raise SFTPError(FX_OP_UNSUPPORTED, "unsupported %r request <data of length %r>" %
hunk ./src/allmydata/frontends/sftpd.py 1840
         d.addCallback(_got_root)
         return d
 
+    def _get_grid_stats(self):
+        return self._client.get_grid_stats()
+
 
 class FakeTransport:
     implements(ITransport)
hunk ./src/allmydata/frontends/sftpd.py 1863
     def __init__(self, userHandler):
         PrefixingLogMixin.__init__(self, facility="tahoe.sftp")
         if noisy: self.log(".__init__(%r)" % (userHandler), level=NOISY)
+        self._userHandler = userHandler
 
     def getPty(self, terminal, windowSize, attrs):
         self.log(".getPty(%r, %r, %r)" % (terminal, windowSize, attrs), level=OPERATIONAL)
hunk ./src/allmydata/frontends/sftpd.py 1885
 
         d = defer.succeed(None)
         if cmd == "df -P -k /":
+            stats = self._userHandler._get_grid_stats()
             d.addCallback(lambda ign: protocol.write(
hunk ./src/allmydata/frontends/sftpd.py 1887
-                          "Filesystem         1024-blocks      Used Available Capacity Mounted on\n"
-                          "tahoe                628318530 314159265 314159265      50% /\n"))
+                          "Filesystem         1024-blocks        Used   Available Capacity Mounted on\n"
+                          "tahoe              %11d %11d %11d      %3d /\n"
+                          % (stats['total_KiB'], stats['used_KiB'], stats['available_KiB'], stats['used_percent'])))
             d.addCallback(lambda ign: protocol.processEnded(Reason(ProcessDone(None))))
         else:
             d.addCallback(lambda ign: protocol.processEnded(Reason(ProcessTerminated(exitCode=1))))
hunk ./src/allmydata/interfaces.py 2132
                  DirectoryNode.
         """
 
+    def get_grid_stats():
+        """Get estimates of the total, used, and available space on this grid.
+        These estimates use an expansion factor based on the current encoding
+        settings, so may be inaccurate if the settings have changed. They only
+        take into account servers currently connected to this client.
+        @return: a dict with at least the following fields:
+                 total_KiB:     estimated total space on the grid, in KiB
+                 used_KiB:      estimated used space on the grid, in KiB
+                 available_KiB: estimated available space on the grid, in KiB
+                 used_percent:  used space as a percentage (rounded)
+                 fake:          True if the values are just made up.
+        """
+
 class INodeMaker(Interface):
     """The NodeMaker is used to create IFilesystemNode instances. It can
     accept a filecap/dircap string and return the node right away. It can
}

Context:

[docs/webapi.rst: typos.
david-sarah@jacaranda.org**20101230034422
 Ignore-this: d1f5166d72cc711f7e0d9981eac9105e
] 
[docs/webapi.rst: capitalization, formatting of section on URL character encoding, and a correction about Internet Explorer.
david-sarah@jacaranda.org**20101230034049
 Ignore-this: b3b9819d2fb264b4cdc5c8afd4e8c48d
] 
[docs: corrections and clarifications.
david-sarah@jacaranda.org**20101227051056
 Ignore-this: e33202858c7644c58f3f924b164294b6
] 
[docs: more formatting cleanups and corrections. Spell webapi and wapi as web-API.
david-sarah@jacaranda.org**20101227050533
 Ignore-this: 18b23cbfb780df585d8a722a1ec63e94
] 
[docs/debian.rst: bring description of building dependencies from source up-to-date, and change hostname from allmydata.com to tahoe-lafs.org.
david-sarah@jacaranda.org**20101212222912
 Ignore-this: f38462afc88b4475195610385a28391c
] 
[docs/architecture.rst: correct rst syntax.
david-sarah@jacaranda.org**20101212202003
 Ignore-this: 3fbe12feb28bec6f1c63aedbc79aad21
] 
[docs/architecture.rst: formatting.
david-sarah@jacaranda.org**20101212201719
 Ignore-this: 305fa5dfc2939355eaf6d0d2161eb1ff
] 
[docs: linkification, wording improvements.
david-sarah@jacaranda.org**20101212201234
 Ignore-this: 4e67287f527a8bc728cfbd93255d2aae
] 
[docs: formatting.
david-sarah@jacaranda.org**20101212201115
 Ignore-this: 2e0ed394ac7726651d3a4f2c4b0d3798
] 
[docs/configuration.rst: more formatting tweaks; which -> that.
david-sarah@jacaranda.org**20101212195522
 Ignore-this: a7becb7021854ca5a90edd892b36fdd7
] 
[docs/configuration.rst: more changes to formatting.
david-sarah@jacaranda.org**20101212194511
 Ignore-this: 491aac33e5f5268d224359f1447d10be
] 
[docs/configuration.rst: changes to formatting (mainly putting commands and filenames in monospace).
david-sarah@jacaranda.org**20101212181828
 Ignore-this: 8a1480e2d5f43bee678476424615b50f
] 
[scripts/backupdb.py: more accurate comment about path field.
david-sarah@jacaranda.org**20101212170320
 Ignore-this: 50e47a2228a85207bbcd188a78a0d4e6
] 
[scripts/cli.py: fix missing 'put' in usage example for 'tahoe put'.
david-sarah@jacaranda.org**20101212170207
 Ignore-this: 2cbadf066fff611fc03d3c0ff97ce6ec
] 
[docs/frontends/CLI.rst: changes to formatting (mainly putting commands and filenames in monospace), and to command syntax to reflect that DIRCAP/... is accepted. Clarify the syntax of 'tahoe put' and other minor corrections. Tahoe -> Tahoe-LAFS.
david-sarah@jacaranda.org**20101212165800
 Ignore-this: a123ef6b564aa8624d1e79c97068ea12
] 
[docs/frontends/CLI.rst: Unicode arguments to 'tahoe' work on Windows as of v1.7.1.
david-sarah@jacaranda.org**20101212063740
 Ignore-this: 3977a99dfa86ac33a44171deaf43aaab
] 
[docs/known_issues.rst: fix title and linkify another URL. refs #1225
david-sarah@jacaranda.org**20101212062817
 Ignore-this: cc91287f7fb51c23440b3d2fe79c449c
] 
[docs/known_issues.rst: fix an external link. refs #1225
david-sarah@jacaranda.org**20101212062435
 Ignore-this: b8cbf12f353131756c358965c48060ec
] 
[Fix a link from uri.rst to dirnodes.rst. refs #1225
david-sarah@jacaranda.org**20101212054502
 Ignore-this: af6205299f5c9a33229cab259c00f9d5
] 
[Fix a link from webapi.rst to FTP-and-SFTP.rst. refs #1225
david-sarah@jacaranda.org**20101212053435
 Ignore-this: 2b9f88678c3447ea860d6b61e8799858
] 
[More specific hyperlink to architecture.rst from helper.rst. refs #1225
david-sarah@jacaranda.org**20101212052607
 Ignore-this: 50424c768fca481252fabf58424852dc
] 
[Update hyperlinks between docs, and linkify some external references. refs #1225
david-sarah@jacaranda.org**20101212051459
 Ignore-this: cd43a4c3d3de1f832abfa88d5fc4ace1
] 
[docs/specifications/dirnodes.rst: fix references to mutable.rst. refs #1225
david-sarah@jacaranda.org**20101212012720
 Ignore-this: 6819b4b4e06e947ee48b365e840db37d
] 
[docs/specifications/mutable.rst: correct the magic string for v1 mutable containers. refs #1225
david-sarah@jacaranda.org**20101212011400
 Ignore-this: 99a5fcdd40cef83dbb08f323f6cdaaca
] 
[Move .txt files in docs/frontends and docs/specifications to .rst. refs #1225
david-sarah@jacaranda.org**20101212010251
 Ignore-this: 8796d35d928370f7dc6ad2dafdc1c0fe
] 
[Convert docs/frontends and docs/specifications to reStructuredText format (not including file moves).
david-sarah@jacaranda.org**20101212004632
 Ignore-this: e3ceb2d832d73875abe48624ddbb5622
] 
[scripts/cli.py: remove the disclaimer in the help for 'tahoe cp' that it does not handle non-ASCII filenames well. (At least, we intend to handle them.)
david-sarah@jacaranda.org**20101130002145
 Ignore-this: 94c003efaa20b9eb4a83503d79844ca
] 
[relnotes.txt: fifth -> sixth labor-of-love release
zooko@zooko.com**20101129045647
 Ignore-this: 21c245015268b38916e3a138d256c09d
] 
[Makefile: BB_BRANCH is set to the empty string for trunk, not the string 'trunk'.
david-sarah@jacaranda.org**20101128233512
 Ignore-this: 5a7ef8eb10475636d21b91e25b56c369
] 
[relnotes.txt: eleventh -> twelfth release.
david-sarah@jacaranda.org**20101128223321
 Ignore-this: 1e26410156a665271c1170803dea2c0d
] 
[relnotes.tst: point to known_issues.rst, not known_issues.txt.
david-sarah@jacaranda.org**20101128222918
 Ignore-this: 60194eb4544cac446fe4f60b3e34b887
] 
[quickstart.html: fix link to point to allmydata-tahoe-1.8.1.zip.
david-sarah@jacaranda.org**20101128221728
 Ignore-this: 7b3ee86f8256aa12f5d862f689f3ee29
] 
[TAG allmydata-tahoe-1.8.1
david-sarah@jacaranda.org**20101128212336
 Ignore-this: 9c18bdeaef4822f590d2a0d879e00621
] 
Patch bundle hash:
ebd185dcb1abb4aae3bd6612481d033cb03c38a4
