Changeset 10:b0048ba6f3ca in xplra for misc
- Timestamp:
- 01/04/13 16:36:30 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- misc
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
misc/client.py
r9 r10 175 175 print >> sys.stderr, "Error code:", result 176 176 177 def do_ reg_multiget(self, args):178 """Handle the ' reg_multiget' command"""177 def do_multiget(self, args): 178 """Handle the 'multiget' command""" 179 179 words = self._splitArgs(args) 180 180 specs = [] … … 190 190 return False 191 191 192 self._writeU8(0x03) 193 self._writeU32(len(specs)) 194 for (name, type, length, offset) in specs: 195 self._writeString(name) 196 self._writeU8(self._types[type]) 197 if length is not None: 198 self._writeS32(length) 199 self._writeS32(offset) 200 self._flush() 201 202 result = self._readU8() 203 if result==0: 204 for (_, type, _, _) in specs: 205 value = self._readValue(type) 206 print value 207 elif result==0x02: 208 index = self._readU32() 209 print >> sys.stderr, "Invalid dataref at #%d" % (index,) 210 else: 211 print >> sys.stderr, "Error code:", result 212 213 def do_multiset(self, args): 214 """Handle the 'multiset' command""" 215 words = self._splitArgs(args) 216 specs = [] 217 values = [] 218 while words: 219 result = self._parseGetSpec(words) 220 if result is None: 221 return False 222 else: 223 words = result[1] 224 if not words: 225 print >> sys.stderr, "Missing argument" 226 return False 227 specs.append(result[0]) 228 values.append(words[0]) 229 words = words[1:] 230 231 if not specs: 232 return False 233 234 self._writeU8(0x04) 235 self._writeU32(len(specs)) 236 for ((name, type, length, offset), value) in zip(specs, values): 237 self._writeString(name) 238 self._writeU8(self._types[type]) 239 if length is not None: 240 self._writeS32(length) 241 self._writeS32(offset) 242 self._writeValue(type, value, length) 243 self._flush() 244 245 result = self._readU8() 246 if result==0x02: 247 index = self._readU32() 248 print >> sys.stderr, "Invalid dataref at #%d" % (index,) 249 elif result!=0: 250 print >> sys.stderr, "Error code:", result 251 252 def do_reg_multiget(self, args): 253 """Handle the 'reg_multiget' command""" 254 words = self._splitArgs(args) 255 specs = [] 256 while words: 257 result = self._parseGetSpec(words) 258 if result is None: 259 return False 260 else: 261 specs.append(result[0]) 262 words = result[1] 263 264 if not specs: 265 return False 266 192 267 self._writeU8(0x11) 193 268 self._writeU32(len(specs)) 194 269 for (name, type, length, offset) in specs: 195 print name, type196 270 self._writeString(name) 197 271 self._writeU8(self._types[type]) … … 275 349 self._writeU32(len(specs)) 276 350 for (name, type, length, offset) in specs: 277 print name, type278 351 self._writeString(name) 279 352 self._writeU8(self._types[type])
Note:
See TracChangeset
for help on using the changeset viewer.