def generateData(self, data): # Each byte in the block is expanded to ten bits. Each bit is # represented as one low frequency cycle or two high frequency cycles. bytes = len(data) bits = bytes * 10 # Include samples for 1 channel samples = bits * self.SAMPLES_PER_BIT buf = ShortBuffer.allocate(samples) j = 0 i = 0 while i < bytes: j = self.writeTone(buf, j, self.low_tone) b = Byte(data[i]).intValue() k = 0 while k < 8: if b & 1 == 0: j = self.writeTone(buf, j, self.low_tone) else: j = self.writeTone(buf, j, self.high_tone) b = b >> 1 k += 1 j = self.writeTone(buf, j, self.high_tone) i += 1 return buf
def getunZippedContent(content): zipper = ChecksumZipper() zippedArray = content.split(',') zippedList = [] for zippedByte in zippedArray: zippedList.append(Byte.parseByte(zippedByte)) unzipBytes = zipper.unzip(zippedList) buffer = str(String(unzipBytes)) return buffer
def __init__(self): head = 'Byte,Double,Float,Integer,Long,Short'.split(',') self.data = [[ Byte(Byte.MIN_VALUE), Double(Double.MIN_VALUE), Float(Float.MIN_VALUE), Integer(Integer.MIN_VALUE), Long(Long.MIN_VALUE), Short(Short.MIN_VALUE) ], [ Byte(Byte.MAX_VALUE), Double(Double.MAX_VALUE), Float(Float.MAX_VALUE), Integer(Integer.MAX_VALUE), Long(Long.MAX_VALUE), Short(Short.MAX_VALUE) ]] DefaultTableModel.__init__(self, self.data, head)
def sendsmpp(self, data): # Add control of keys da = data['destinationAddress'] oa = data['originatingAddress'] userData = data['userData'] originatingAddress = GSMAddress(oa) destinationAddress = GSMAddress(da) myProtocol = SMPPProtocol() protocolIdentifier = Byte('7') serviceCenterTimeStamp = Date() replyPathIndication = False udhIndication = True dataCodingScheme = Byte('0') isBinaryUserData = True myDeliver = myProtocol.createDeliver( destinationAddress, originatingAddress, protocolIdentifier, serviceCenterTimeStamp, userData, replyPathIndication, udhIndication, dataCodingScheme, isBinaryUserData) resp = {} resp['errorCode'] = 200 resp['responseText'] = myDeliver.toInterpretedString() logger.debug('>>>> %s' % (resp['responseText'])) try: self.__class__.cv_send.acquire() smsc = SMSCDriver.getSmscDriver() if smsc: smsc.send(myDeliver) else: raise SyntaxError('SMSCDriver has not been started !!') self.__class__.cv_send.release() except Exception, ex: errMsg = "Unable to send data, reason: %s" % (ex) logger.error(errMsg) resp['errorCode'] = 500 resp['responseText'] = errMsg
def controller(id): from java.lang import Byte bb = Byte(id) return eng.controllerManager.getControllerById(bb)
def test_int_coercion(self): c = Coercions() self.assertEquals("5", c.takeInt(5)) self.assertEquals("15", c.takeInteger(15)) self.assertEquals("150", c.takeNumber(150)) self.assertEquals("take with byte arg: 10", Coercions.take(Byte(10)))
for _v, _id in zip([foo, subfoo, subfoo2, n], ['foo', 'subfoo', 'subfoo2', 'n']): d[_v] = _id from java.lang import Long, Integer, Short, Character, Byte, Boolean, Double, Float, String from java.math import BigInteger values = [ 0, 0L, 0.0, 'c', "string", (), o, c, foo, subfoo, subfoo2, n, Object, Class, Foo, SubFoo, C, SubFoo2, N, Integer, Long(0), Integer(0), Short(0), Character('c'), Byte(0), Boolean(0), Double(0), Float(0), String("js"), BigInteger("0") ] def pp(v): inst = d.get(v, None) if inst is not None: return inst if hasattr(v, '__name__'): return v.__name__ if isinstance(v, (String, Number, Character, Boolean)):