Changeset 5e6201ae in trunk
- Timestamp:
- 2020-09-28T15:35:15Z (5 years ago)
- Branches:
- master
- Children:
- 587d9ef, cc7a3bc
- Parents:
- 4e7e847 (diff), d7b5230f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Itamar Turner-Trauring <itamar@…> (2020-09-28 15:35:15)
- git-committer:
- GitHub <noreply@…> (2020-09-28 15:35:15)
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/immutable/offloaded.py ¶
r4e7e847 r5e6201ae 204 204 assert interfaces.IUploadResults.providedBy(ur), ur 205 205 vcapstr = ur.get_verifycapstr() 206 precondition(isinstance(vcapstr, str), vcapstr)206 precondition(isinstance(vcapstr, bytes), vcapstr) 207 207 v = uri.from_string(vcapstr) 208 208 f_times = self._fetcher.get_times() … … 493 493 494 494 name = "helper" 495 VERSION = { "http://allmydata.org/tahoe/protocols/helper/v1" :495 VERSION = { b"http://allmydata.org/tahoe/protocols/helper/v1" : 496 496 { }, 497 "application-version": str(allmydata.__full_version__),497 b"application-version": allmydata.__full_version__.encode("utf-8"), 498 498 } 499 499 MAX_UPLOAD_STATUSES = 10 -
TabularUnified src/allmydata/immutable/upload.py ¶
r4e7e847 r5e6201ae 1817 1817 def _got_helper(self, helper): 1818 1818 self.log("got helper connection, getting versions") 1819 default = { "http://allmydata.org/tahoe/protocols/helper/v1" :1819 default = { b"http://allmydata.org/tahoe/protocols/helper/v1" : 1820 1820 { }, 1821 "application-version": b"unknown: no get_version()",1821 b"application-version": b"unknown: no get_version()", 1822 1822 } 1823 1823 d = add_version_to_remote_reference(helper, default) … … 1825 1825 1826 1826 def _got_versioned_helper(self, helper): 1827 needed = "http://allmydata.org/tahoe/protocols/helper/v1"1827 needed = b"http://allmydata.org/tahoe/protocols/helper/v1" 1828 1828 if needed not in helper.version: 1829 1829 raise InsufficientVersionError(needed, helper.version) -
TabularUnified src/allmydata/interfaces.py ¶
r4e7e847 r5e6201ae 3 3 4 4 Ported to Python 3. 5 6 Note that for RemoteInterfaces, the __remote_name__ needs to be a native string because of https://github.com/warner/foolscap/blob/43f4485a42c9c28e2c79d655b3a9e24d4e6360ca/src/foolscap/remoteinterface.py#L67 5 7 """ 6 8 from __future__ import absolute_import … … 9 11 from __future__ import unicode_literals 10 12 11 from future.utils import PY2 13 from future.utils import PY2, native_str 12 14 if PY2: 13 15 # Don't import object/str/dict/etc. types, so we don't break any … … 106 108 107 109 class RIStorageServer(RemoteInterface): 108 __remote_name__ = b"RIStorageServer.tahoe.allmydata.com"110 __remote_name__ = native_str("RIStorageServer.tahoe.allmydata.com") 109 111 110 112 def get_version(): … … 2837 2839 # debug stuff 2838 2840 2839 def upload_random_data_from_file(size=int, convergence= str):2841 def upload_random_data_from_file(size=int, convergence=bytes): 2840 2842 return str 2841 2843 2842 def download_to_tempfile_and_delete(uri= str):2844 def download_to_tempfile_and_delete(uri=bytes): 2843 2845 return None 2844 2846 … … 2847 2849 keys are 'VmPeak', 'VmSize', and 'VmData'. The values are integers, 2848 2850 measuring memory consupmtion in bytes.""" 2849 return DictOf( str, int)2851 return DictOf(bytes, int) 2850 2852 2851 2853 def speed_test(count=int, size=int, mutable=Any()): … … 2872 2874 2873 2875 2874 UploadResults = Any() #DictOf( str, str)2876 UploadResults = Any() #DictOf(bytes, bytes) 2875 2877 2876 2878 2877 2879 class RIEncryptedUploadable(RemoteInterface): 2878 __remote_name__ = b"RIEncryptedUploadable.tahoe.allmydata.com"2880 __remote_name__ = native_str("RIEncryptedUploadable.tahoe.allmydata.com") 2879 2881 2880 2882 def get_size(): … … 2885 2887 2886 2888 def read_encrypted(offset=Offset, length=ReadSize): 2887 return ListOf( str)2889 return ListOf(bytes) 2888 2890 2889 2891 def close(): … … 2892 2894 2893 2895 class RICHKUploadHelper(RemoteInterface): 2894 __remote_name__ = b"RIUploadHelper.tahoe.allmydata.com"2896 __remote_name__ = native_str("RIUploadHelper.tahoe.allmydata.com") 2895 2897 2896 2898 def get_version(): … … 2898 2900 Return a dictionary of version information. 2899 2901 """ 2900 return DictOf( str, Any())2902 return DictOf(bytes, Any()) 2901 2903 2902 2904 def upload(reader=RIEncryptedUploadable): … … 2905 2907 2906 2908 class RIHelper(RemoteInterface): 2907 __remote_name__ = b"RIHelper.tahoe.allmydata.com"2909 __remote_name__ = native_str("RIHelper.tahoe.allmydata.com") 2908 2910 2909 2911 def get_version(): … … 2911 2913 Return a dictionary of version information. 2912 2914 """ 2913 return DictOf( str, Any())2915 return DictOf(bytes, Any()) 2914 2916 2915 2917 def upload_chk(si=StorageIndex): … … 2932 2934 2933 2935 class RIStatsProvider(RemoteInterface): 2934 __remote_name__ = b"RIStatsProvider.tahoe.allmydata.com"2936 __remote_name__ = native_str("RIStatsProvider.tahoe.allmydata.com") 2935 2937 """ 2936 2938 Provides access to statistics and monitoring information. … … 2945 2947 internally) 2946 2948 """ 2947 return DictOf( str, DictOf(str, ChoiceOf(float, int, long, None)))2949 return DictOf(bytes, DictOf(bytes, ChoiceOf(float, int, long, None))) 2948 2950 2949 2951 2950 2952 class RIStatsGatherer(RemoteInterface): 2951 __remote_name__ = b"RIStatsGatherer.tahoe.allmydata.com"2953 __remote_name__ = native_str("RIStatsGatherer.tahoe.allmydata.com") 2952 2954 """ 2953 2955 Provides a monitoring service for centralised collection of stats 2954 2956 """ 2955 2957 2956 def provide(provider=RIStatsProvider, nickname= str):2958 def provide(provider=RIStatsProvider, nickname=bytes): 2957 2959 """ 2958 2960 @param provider: a stats collector instance that should be polled … … 2966 2968 def get_stats(): 2967 2969 """ 2968 returns a dictionary, with strkeys representing the names of stats2970 returns a dictionary, with bytes keys representing the names of stats 2969 2971 to be monitored, and numeric values. 2970 2972 """ -
TabularUnified src/allmydata/test/test_helper.py ¶
r4e7e847 r5e6201ae 1 from __future__ import absolute_import 2 from __future__ import division 3 from __future__ import print_function 4 from __future__ import unicode_literals 5 6 from future.utils import PY2 7 if PY2: 8 from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 9 1 10 import os 2 11 from twisted.internet import defer … … 19 28 MiB = 1024*1024 20 29 21 DATA = "I need help\n" * 100030 DATA = b"I need help\n" * 1000 22 31 23 32 class CHKUploadHelper_fake(offloaded.CHKUploadHelper): … … 34 43 "size": size, 35 44 } 36 ueb_hash = "fake"37 v = uri.CHKFileVerifierURI(self._storage_index, "x"*32,45 ueb_hash = b"fake" 46 v = uri.CHKFileVerifierURI(self._storage_index, b"x"*32, 38 47 needed_shares, total_shares, size) 39 48 _UR = upload.UploadResults … … 57 66 class Helper_fake_upload(offloaded.Helper): 58 67 def _make_chk_upload_helper(self, storage_index, lp): 59 si_s = s i_b2a(storage_index)68 si_s = str(si_b2a(storage_index), "utf-8") 60 69 incoming_file = os.path.join(self._chk_incoming, si_s) 61 70 encoding_file = os.path.join(self._chk_encoding, si_s) … … 70 79 def _check_chk(self, storage_index, lp): 71 80 res = upload.HelperUploadResults() 72 res.uri_extension_hash = hashutil.uri_extension_hash( "")81 res.uri_extension_hash = hashutil.uri_extension_hash(b"") 73 82 74 83 # we're pretending that the file they're trying to upload was already … … 128 137 EMPTY_CLIENT_CONFIG, 129 138 ) 130 self.s.secret_holder = client.SecretHolder( "lease secret","converge")139 self.s.secret_holder = client.SecretHolder(b"lease secret", b"converge") 131 140 self.s.startService() 132 141 … … 135 144 # we never actually use this for network traffic, so it can use a 136 145 # bogus host/port 137 t.setLocation( "bogus:1234")146 t.setLocation(b"bogus:1234") 138 147 139 148 def setUpHelper(self, basedir, helper_class=Helper_fake_upload): … … 163 172 assert u._helper 164 173 165 return upload_data(u, DATA, convergence= "some convergence string")174 return upload_data(u, DATA, convergence=b"some convergence string") 166 175 d.addCallback(_ready) 167 176 def _uploaded(results): 168 177 the_uri = results.get_uri() 169 assert "CHK" in the_uri178 assert b"CHK" in the_uri 170 179 d.addCallback(_uploaded) 171 180 … … 196 205 segsize = mathutil.next_multiple(segsize, k) 197 206 198 key = hashutil.convergence_hash(k, n, segsize, DATA, "test convergence string")207 key = hashutil.convergence_hash(k, n, segsize, DATA, b"test convergence string") 199 208 assert len(key) == 16 200 209 encryptor = aes.create_encryptor(key) 201 210 SI = hashutil.storage_index_hash(key) 202 SI_s = s i_b2a(SI)211 SI_s = str(si_b2a(SI), "utf-8") 203 212 encfile = os.path.join(self.basedir, "CHK_encoding", SI_s) 204 213 f = open(encfile, "wb") … … 213 222 def _ready(res): 214 223 assert u._helper 215 return upload_data(u, DATA, convergence= "test convergence string")224 return upload_data(u, DATA, convergence=b"test convergence string") 216 225 d.addCallback(_ready) 217 226 def _uploaded(results): 218 227 the_uri = results.get_uri() 219 assert "CHK" in the_uri228 assert b"CHK" in the_uri 220 229 d.addCallback(_uploaded) 221 230 … … 240 249 assert u._helper 241 250 242 return upload_data(u, DATA, convergence= "some convergence string")251 return upload_data(u, DATA, convergence=b"some convergence string") 243 252 d.addCallback(_ready) 244 253 def _uploaded(results): 245 254 the_uri = results.get_uri() 246 assert "CHK" in the_uri255 assert b"CHK" in the_uri 247 256 d.addCallback(_uploaded) 248 257 -
TabularUnified src/allmydata/util/_python3.py ¶
r4e7e847 r5e6201ae 94 94 "allmydata.test.test_hashtree", 95 95 "allmydata.test.test_hashutil", 96 "allmydata.test.test_helper", 96 97 "allmydata.test.test_humanreadable", 97 98 "allmydata.test.test_immutable",
Note: See TracChangeset
for help on using the changeset viewer.