Changeset 7f8bbcc in trunk
- Timestamp:
- 2011-11-20T23:24:26Z (14 years ago)
- Branches:
- master
- Children:
- d887782
- Parents:
- 7989fe2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified docs/frontends/drop-upload.rst ¶
r7989fe2 r7f8bbcc 21 21 should not keep important data in the upload directory, and should not rely 22 22 on all changes to files in the local directory to result in successful uploads. 23 There might be incompatible changes to how the feature is configured in24 future versions. There is even the possibility that it may be abandoned, for23 There might be (and have been) incompatible changes to how the feature is 24 configured. There is even the possibility that it may be abandoned, for 25 25 example if unsolveable reliability issues are found. 26 26 … … 43 43 ``enabled = (boolean, optional)`` 44 44 45 If this is ``True``, drop-upload will be enabled (provided that the 46 ``upload.dircap`` and ``local.directory`` fields are also set). The 47 default value is ``False``. 48 49 ``upload.dircap = (directory writecap)`` 50 51 This is a writecap pointing to an existing mutable directory to be used 52 as the target of uploads. It will start with ``URI:DIR2:``, and cannot 53 include an alias or path. 45 If this is ``True``, drop-upload will be enabled. The default value is 46 ``False``. 54 47 55 48 ``local.directory = (UTF-8 path)`` … … 59 52 in UTF-8 regardless of the system's filesystem encoding. Relative paths 60 53 will be interpreted starting from the node's base directory. 54 55 In addition, the file ``private/drop_upload_dircap`` must contain a 56 writecap pointing to an existing mutable directory to be used as the target 57 of uploads. It will start with ``URI:DIR2:``, and cannot include an alias 58 or path. 61 59 62 60 After setting the above fields and starting or restarting the gateway, -
TabularUnified src/allmydata/client.py ¶
r7989fe2 r7f8bbcc 27 27 from allmydata.nodemaker import NodeMaker 28 28 from allmydata.blacklist import Blacklist 29 from allmydata.node import OldConfigOptionError 29 30 30 31 … … 440 441 def init_drop_uploader(self): 441 442 if self.get_config("drop_upload", "enabled", False, boolean=True): 442 upload_dircap = self.get_config("drop_upload", "upload.dircap", None) 443 local_dir_utf8 = self.get_config("drop_upload", "local.directory", None) 444 445 if upload_dircap and local_dir_utf8: 446 try: 447 from allmydata.frontends import drop_upload 448 s = drop_upload.DropUploader(self, upload_dircap, local_dir_utf8) 449 s.setServiceParent(self) 450 s.startService() 451 except Exception, e: 452 self.log("couldn't start drop-uploader: %r", args=(e,)) 453 else: 454 self.log("couldn't start drop-uploader: upload.dircap or local.directory not specified") 443 if self.get_config("drop_upload", "upload.dircap", None): 444 raise OldConfigOptionError("The [drop_upload]upload.dircap option is no longer supported; please " 445 "put the cap in a 'private/drop_upload_dircap' file, and delete this option.") 446 447 upload_dircap = self.get_or_create_private_config("drop_upload_dircap") 448 local_dir_utf8 = self.get_config("drop_upload", "local.directory") 449 450 try: 451 from allmydata.frontends import drop_upload 452 s = drop_upload.DropUploader(self, upload_dircap, local_dir_utf8) 453 s.setServiceParent(self) 454 s.startService() 455 except Exception, e: 456 self.log("couldn't start drop-uploader: %r", args=(e,)) 455 457 456 458 def _check_hotline(self, hotline_file): -
TabularUnified src/allmydata/node.py ¶
r7989fe2 r7f8bbcc 52 52 "See docs/historical/configuration.rst." 53 53 % "\n".join([quote_output(fname) for fname in self.args[0]])) 54 55 class OldConfigOptionError(Exception): 56 pass 54 57 55 58 … … 202 205 open(privname, "w").write(value.strip()) 203 206 204 def get_or_create_private_config(self, name, default ):207 def get_or_create_private_config(self, name, default=_None): 205 208 """Try to get the (string) contents of a private config file (which 206 209 is a config file that resides within the subdirectory named … … 208 211 stripped from the data. 209 212 210 If the file does not exist, try to create it using default, and 211 then return the value that was written. If 'default' is a string, 212 use it as a default value. If not, treat it as a 0-argument callable 213 which is expected to return a string. 213 If the file does not exist, and default is not given, report an error. 214 If the file does not exist and a default is specified, try to create 215 it using that default, and then return the value that was written. 216 If 'default' is a string, use it as a default value. If not, treat it 217 as a zero-argument callable that is expected to return a string. 214 218 """ 215 219 privname = os.path.join(self.basedir, "private", name) … … 217 221 value = fileutil.read(privname) 218 222 except EnvironmentError: 223 if os.path.exists(privname): 224 raise 225 if default is _None: 226 raise MissingConfigEntry("The required configuration file %s is missing." 227 % (quote_output(privname),)) 219 228 if isinstance(default, basestring): 220 229 value = default -
TabularUnified src/allmydata/scripts/create_node.py ¶
r7989fe2 r7f8bbcc 156 156 c.write("# Shall this node automatically upload files created or modified in a local directory?\n") 157 157 c.write("enabled = false\n") 158 c.write("# T his must be a mutable directory writecap.\n")159 c.write("upload.dircap =\n")158 c.write("# To specify the target of uploads, a mutable directory writecap URI must be placed\n" 159 "# in 'private/drop_upload_dircap'.\n") 160 160 c.write("local.directory = ~/drop_upload\n") 161 161 c.write("\n") -
TabularUnified src/allmydata/test/test_client.py ¶
r7989fe2 r7f8bbcc 4 4 5 5 import allmydata 6 from allmydata.node import OldConfigError 6 from allmydata.node import OldConfigError, OldConfigOptionError, MissingConfigEntry 7 7 from allmydata import client 8 8 from allmydata.storage_client import StorageFarmBroker … … 192 192 "enabled = false\n" + 193 193 "[drop_upload]\n" + 194 "enabled = true\n" + 195 "upload.dircap = " + upload_dircap + "\n" + 196 "local.directory = " + local_dir_utf8 + "\n") 194 "enabled = true\n") 197 195 198 196 basedir1 = "test_client.Basic.test_create_drop_uploader1" 199 197 os.mkdir(basedir1) 198 fileutil.write(os.path.join(basedir1, "tahoe.cfg"), 199 config + "local.directory = " + local_dir_utf8 + "\n") 200 self.failUnlessRaises(MissingConfigEntry, client.Client, basedir1) 201 200 202 fileutil.write(os.path.join(basedir1, "tahoe.cfg"), config) 203 fileutil.write(os.path.join(basedir1, "private", "drop_upload_dircap"), "URI:DIR2:blah") 204 self.failUnlessRaises(MissingConfigEntry, client.Client, basedir1) 205 206 fileutil.write(os.path.join(basedir1, "tahoe.cfg"), 207 config + "upload.dircap = " + upload_dircap + "\n") 208 self.failUnlessRaises(OldConfigOptionError, client.Client, basedir1) 209 210 fileutil.write(os.path.join(basedir1, "tahoe.cfg"), 211 config + "local.directory = " + local_dir_utf8 + "\n") 201 212 c1 = client.Client(basedir1) 202 213 uploader = c1.getServiceNamed('drop-upload') … … 214 225 basedir2 = "test_client.Basic.test_create_drop_uploader2" 215 226 os.mkdir(basedir2) 227 os.mkdir(os.path.join(basedir2, "private")) 216 228 fileutil.write(os.path.join(basedir2, "tahoe.cfg"), 217 229 BASECONFIG + 218 230 "[drop_upload]\n" + 219 "enabled = true\n") 231 "enabled = true\n" + 232 "local.directory = " + local_dir_utf8 + "\n") 233 fileutil.write(os.path.join(basedir2, "private", "drop_upload_dircap"), "URI:DIR2:blah") 220 234 c2 = client.Client(basedir2) 221 235 self.failUnlessRaises(KeyError, c2.getServiceNamed, 'drop-upload') 222 self.failIf([True for arg in mock_log_msg.call_args_list if "Boom" in repr(arg)],223 mock_log_msg.call_args_list)224 self.failUnless([True for arg in mock_log_msg.call_args_list if "upload.dircap or local.directory not specified" in repr(arg)],225 mock_log_msg.call_args_list)226 227 basedir3 = "test_client.Basic.test_create_drop_uploader3"228 os.mkdir(basedir3)229 fileutil.write(os.path.join(basedir3, "tahoe.cfg"), config)230 client.Client(basedir3)231 236 self.failUnless([True for arg in mock_log_msg.call_args_list if "Boom" in repr(arg)], 232 237 mock_log_msg.call_args_list)
Note: See TracChangeset
for help on using the changeset viewer.