Changeset 6:8dd4ca9966d0 in xplra for misc
- Timestamp:
- 01/03/13 19:09:46 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- misc
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
misc/client.py
-
Property exe
set to
*
r3 r6 1 1 #!/usr/bin/env python 2 2 3 import sys 3 4 import cmd 4 5 import struct … … 42 43 self.use_rawinput = True 43 44 self.intro = "\nX-Plane Remote Access plugin command prompt\n" 44 self.prompt = "XPLRA> "45 self.prompt = "XPLRA> " 45 46 46 47 self.daemon = True … … 50 51 if line=="EOF": 51 52 print 52 return self.do_quit("")53 return True 53 54 else: 54 55 return super(CLI, self).default(line) … … 58 59 words = args.split() 59 60 if len(words)<2: 60 print >> sys.stderr, " missing parameters"61 print >> sys.stderr, "Missing parameters" 61 62 return False 62 63 … … 65 66 type = words[1] 66 67 if type not in self._types: 67 print >> sys.stderr, " invalid type"68 print >> sys.stderr, "Invalid type" 68 69 return False 69 70 70 71 length = None 71 if len(words)>2: 72 offset = None 73 if len(words)>3: 72 74 length = int(words[2]) 75 offset = int(words[3]) 73 76 74 77 self._writeU8(0x01) … … 77 80 if length is not None: 78 81 self._writeS32(length) 82 self._writeS32(offset) 79 83 self._flush() 80 84 81 85 result = self._readU8() 82 print "result:", result83 86 if result==0: 87 value = None 84 88 if type=="i": 85 89 value = self._readS32() … … 92 96 if length>0: 93 97 value = [self._readFloat() for i in range(0, length)] 94 else:95 value = None96 98 elif type=="ia": 97 99 length = self._readS32() 98 100 if length>0: 99 101 value = [self._readS32() for i in range(0, length)] 100 else:101 value = None102 102 elif type=="ba": 103 103 length = self._readS32() … … 108 108 if b==0: break 109 109 value += chr(b) 110 else: 111 value = None 110 #value = bytes 112 111 113 print "value:", value, len(value) 112 print value 113 else: 114 print "Result code:", result 114 115 115 116 def _writeU8(self, x): -
Property exe
set to
Note:
See TracChangeset
for help on using the changeset viewer.