当前位置: 首页>>代码示例>>Python>>正文


Python jarray.zeros方法代码示例

本文整理汇总了Python中jarray.zeros方法的典型用法代码示例。如果您正苦于以下问题:Python jarray.zeros方法的具体用法?Python jarray.zeros怎么用?Python jarray.zeros使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jarray的用法示例。


在下文中一共展示了jarray.zeros方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_inflate_data

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def _get_inflate_data(inflater, max_length=0):
    buf = jarray.zeros(1024, 'b')
    s = StringIO()
    total = 0
    while not inflater.finished():
        try:
            if max_length:
                l = inflater.inflate(buf, 0, min(1024, max_length - total))
            else:
                l = inflater.inflate(buf)
        except DataFormatException, e:
            raise error(str(e))

        if l == 0:
            break

        total += l
        s.write(String(buf, 0, 0, l))
        if max_length and total == max_length:
            break 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:22,代码来源:zlib.py

示例2: _do_receive_net

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def _do_receive_net(self, return_source_address, num_bytes, flags):
        byte_array = jarray.zeros(num_bytes, 'b')
        packet = java.net.DatagramPacket(byte_array, num_bytes)
        self.jsocket.receive(packet)
        bytes_rcvd = packet.getLength()
        if bytes_rcvd < num_bytes:
            byte_array = byte_array[:bytes_rcvd]
        return_data = byte_array.tostring()
        if return_source_address:
            host = None
            if packet.getAddress():
                host = packet.getAddress().getHostAddress()
            port = packet.getPort()
            return return_data, (host, port)
        else:
            return return_data 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:18,代码来源:socket.py

示例3: recv

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def recv(self, n):
        try:
            if not self.sock_impl: raise error(errno.ENOTCONN, 'Socket is not connected')
            if self.sock_impl.jchannel.isConnectionPending():
                self.sock_impl.jchannel.finishConnect()
            data = jarray.zeros(n, 'b')
            m = self.sock_impl.read(data)
            if m == -1:#indicates EOF has been reached, so we just return the empty string
                return ""
            elif m <= 0:
                if self.mode == MODE_NONBLOCKING:
                    raise would_block_error()
                return ""
            if m < n:
                data = data[:m]
            return data.tostring()
        except java.lang.Exception, jlx:
            raise _map_exception(jlx) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:20,代码来源:socket.py

示例4: generateSecretKey

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def generateSecretKey(self, keyLength):
        bytes = jarray.zeros(keyLength, "b")
        secureRandom = SecureRandom()
        secureRandom.nextBytes(bytes)

        return bytes

    # HOTP methods 
开发者ID:GluuFederation,项目名称:community-edition-setup,代码行数:10,代码来源:casa-external_otp.py

示例5: generateSecretKey

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def generateSecretKey(self, keyLength):
        bytes = jarray.zeros(keyLength, "b")
        secureRandom = SecureRandom()
        secureRandom.nextBytes(bytes)
        
        return bytes
    
    # HOTP methods 
开发者ID:GluuFederation,项目名称:community-edition-setup,代码行数:10,代码来源:OtpExternalAuthenticator.py

示例6: getRGBData

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def getRGBData(self):
        "Return byte array of RGB data as string"
        try:
            if self._data is None:
                self._dataA = None
                if sys.platform[0:4] == 'java':
                    import jarray
                    from java.awt.image import PixelGrabber
                    width, height = self.getSize()
                    buffer = jarray.zeros(width*height, 'i')
                    pg = PixelGrabber(self._image, 0,0,width,height,buffer,0,width)
                    pg.grabPixels()
                    # there must be a way to do this with a cast not a byte-level loop,
                    # I just haven't found it yet...
                    pixels = []
                    a = pixels.append
                    for i in range(len(buffer)):
                        rgb = buffer[i]
                        a(chr((rgb>>16)&0xff))
                        a(chr((rgb>>8)&0xff))
                        a(chr(rgb&0xff))
                    self._data = ''.join(pixels)
                    self.mode = 'RGB'
                else:
                    im = self._image
                    mode = self.mode = im.mode
                    if mode=='RGBA':
                        if Image.VERSION.startswith('1.1.7'): im.load()
                        self._dataA = ImageReader(im.split()[3])
                        im = im.convert('RGB')
                        self.mode = 'RGB'
                    elif mode not in ('L','RGB','CMYK'):
                        im = im.convert('RGB')
                        self.mode = 'RGB'
                    self._data = im.tostring()
            return self._data
        except:
            annotateException('\nidentity=%s'%self.identity()) 
开发者ID:gltn,项目名称:stdm,代码行数:40,代码来源:utils.py

示例7: createByteArrayZeros

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def createByteArrayZeros(howMany):
        return jarray.zeros(howMany, 'h') #use short instead of bytes, cause bytes are signed 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:4,代码来源:compat.py

示例8: stringToJavaByteArray

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def stringToJavaByteArray(s):
        bytes = jarray.zeros(len(s), 'b')
        for count, c in enumerate(s):
            x = ord(c)
            if x >= 128: x -= 256
            bytes[count] = x
        return bytes 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:9,代码来源:compat.py

示例9: _get_deflate_data

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def _get_deflate_data(deflater):
    buf = jarray.zeros(1024, 'b')
    s = StringIO()
    while not deflater.finished():
        l = deflater.deflate(buf)

        if l == 0:
            break
        s.write(String(buf, 0, 0, l))
    s.seek(0)
    return s.read() 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:13,代码来源:zlib.py

示例10: _do_receive_nio

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def _do_receive_nio(self, return_source_address, num_bytes, flags):
        byte_array = jarray.zeros(num_bytes, 'b')
        byte_buf = java.nio.ByteBuffer.wrap(byte_array)
        source_address = self.jchannel.receive(byte_buf)
        if source_address is None and not self.jchannel.isBlocking():
            raise would_block_error()
        byte_buf.flip() ; bytes_read = byte_buf.remaining()
        if bytes_read < num_bytes:
            byte_array = byte_array[:bytes_read]
        return_data = byte_array.tostring()
        if return_source_address:
            return return_data, (source_address.getAddress().getHostAddress(), source_address.getPort())
        else:
            return return_data 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:16,代码来源:socket.py

示例11: test_jarray

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def test_jarray(self): # until it is fully formally removed
        # While jarray is still being phased out, just flex the initializers.
        # The rest of the test for array will catch all the big problems.
        import jarray
        from java.lang import String
        jarray.array(range(5), 'i')
        jarray.array([String("a"), String("b"), String("c")], String)
        jarray.zeros(5, 'i')
        jarray.zeros(5, String) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:11,代码来源:test_array_jy.py

示例12: test_java_object_arrays

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def test_java_object_arrays(self):
        from array import zeros
        from java.lang import String
        from java.lang.reflect import Array
        from java.util import Arrays
        jStringArr = array(String, [String("a"), String("b"), String("c")])
        self.assert_(
            Arrays.equals(jStringArr.typecode, 'java.lang.String'),
               "String array typecode of wrong type, expected %s, found %s" %
               (jStringArr.typecode, str(String)))
        self.assertEqual(zeros(String, 5), Array.newInstance(String, 5))

        import java.lang.String # require for eval to work
        self.assertEqual(jStringArr, eval(str(jStringArr))) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:16,代码来源:test_array_jy.py

示例13: test_java_compat

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def test_java_compat(self):
        from array import zeros
        from java.awt import Color
        hsb = Color.RGBtoHSB(0,255,255, None)
        self.assertEqual(hsb, array('f', [0.5,1,1]),
                         "output hsb float array does not correspond to input rgb values")

        rgb = apply(Color.HSBtoRGB, tuple(hsb))
        self.assertEqual(rgb, -0xff0001,
                         "output rgb bytes don't match input hsb floats")
        hsb1 = zeros('f', 3)
        Color.RGBtoHSB(0, 255, 255, hsb1)
        self.assertEqual(hsb, hsb1, "hsb float arrays were not equal") 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:15,代码来源:test_array_jy.py

示例14: setUp

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def setUp(self):
        self.v = v = 2**53-1 # full mag bits of a double value
        self.v8 = v * 8      # fills up 7 bytes
        self.e = jarray.zeros(1,'i')
        iarr = java.lang.Object.getClass(self.e)
        sdv = java.lang.Class.getMethod(long, 'scaledDoubleValue', [iarr])
        import org.python.core.PyReflectedFunction as ReflFunc
        self.sdv = ReflFunc([sdv]) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:10,代码来源:test_jy_internals.py

示例15: _get_deflate_data

# 需要导入模块: import jarray [as 别名]
# 或者: from jarray import zeros [as 别名]
def _get_deflate_data(deflater, mode=Z_NO_FLUSH):
    buflen = 1024
    buf = jarray.zeros(buflen, 'b')
    s = StringIO()
    while not deflater.finished():
        l = deflater.deflate(buf, 0, buflen, _zlib_to_deflater.get(mode, Deflater.NO_FLUSH))
        if l == 0:
            break
        s.write(String(buf, 0, 0, l))
    s.seek(0)
    return s.read() 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:13,代码来源:zlib.py


注:本文中的jarray.zeros方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。