[protobuf] Re: Issue 226 in protobuf: Python API doesn't support reading/writing delimited messages

2014-10-30 Thread protobuf


Comment #9 on issue 226 by vladimir...@gmail.com: Python API doesn't  
support reading/writing delimited messages

https://code.google.com/p/protobuf/issues/detail?id=226

Here's a workaround - assuming you want to do this because you are writing  
protobuf messages to sockets. The delimited write simply writes the message  
length as a varint32 before writing the message itself:


(apologies for unidiomatic code - bit of a python noob)

from google.protobuf.internal.decoder import _DecodeVarint32
from google.protobuf.internal.encoder import _EncodeVarint

def write_message_delimited(socket, msg):
hdr = []
_EncodeVarint(hdr.append, len(msg))
socket.sendall(.join(hdr))
socket.sendall(msg.SerializeToString())

def read_message_delimited(socket):
# int length is at most 4 bytes long
hdr_bytes = self.socket.recv(4)
(msg_length, hdr_length) = _DecodeVarint32(hdr_bytes, 0)

rsp_buffer = io.BytesIO()
if hdr_length  4:
  rsp_buffer.write(hdr_bytes[hdr_length:])

# read the remaining message bytes
msg_length = msg_length - (4 - hdr_length)
while msg_length  0:
rsp_bytes = self.socket.recv(min(8096, msg_length))
rsp_buffer.write(rsp_bytes)
msg_length = msg_length - len(rsp_bytes)

return MyMessage.ParseFromString(rsp_buffer.getvalue())

--
You received this message because this project is configured to send all  
issue notifications to this address.

You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups Protocol 
Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Re: Issue 226 in protobuf: Python API doesn't support reading/writing delimited messages

2014-10-30 Thread protobuf


Comment #10 on issue 226 by vladimir...@gmail.com: Python API doesn't  
support reading/writing delimited messages

https://code.google.com/p/protobuf/issues/detail?id=226

Here's a workaround - assuming you want to do this because you are writing  
protobuf messages to sockets. The delimited write simply writes the message  
length as a varint32 before writing the message itself:


(apologies for unidiomatic code - bit of a python noob)

from google.protobuf.internal.decoder import _DecodeVarint32
from google.protobuf.internal.encoder import _EncodeVarint

def write_message_delimited(socket, msg):
hdr = []
_EncodeVarint(hdr.append, len(msg))
socket.sendall(.join(hdr))
socket.sendall(msg.SerializeToString())

def read_message_delimited(socket):
# int length is at most 4 bytes long
hdr_bytes = socket.recv(4)
(msg_length, hdr_length) = _DecodeVarint32(hdr_bytes, 0)

rsp_buffer = io.BytesIO()
if hdr_length  4:
  rsp_buffer.write(hdr_bytes[hdr_length:])

# read the remaining message bytes
msg_length = msg_length - (4 - hdr_length)
while msg_length  0:
rsp_bytes = socket.recv(min(8096, msg_length))
rsp_buffer.write(rsp_bytes)
msg_length = msg_length - len(rsp_bytes)

return MyMessage.ParseFromString(rsp_buffer.getvalue())

--
You received this message because this project is configured to send all  
issue notifications to this address.

You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups Protocol 
Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Re: Issue 324 in protobuf: Feature: Add a new primitive type for a DateTime format

2014-10-30 Thread protobuf


Comment #8 on issue 324 by wouter.b...@gmail.com: Feature: Add a new  
primitive type for a DateTime format

https://code.google.com/p/protobuf/issues/detail?id=324

Temporenc (http://temporenc.org) is a comprehensive binary encoding format  
for dates and times that tries to solve the problem discussed in this  
issue. It is designed to be embedded into protobufs (or other embedding  
formats).


--
You received this message because this project is configured to send all  
issue notifications to this address.

You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups Protocol 
Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Runtime Dependency (or Portable Protobuf)

2014-10-30 Thread Jiwoong Lee
I have a need to minimize the dependency on OS environment. 

What I am given is 
(1) pretty standard Linux OS name and version
(2) The fact that it has Python 2.7
(3) I do not have super user permission on that machine.

What I want to do is to provide a single tar ball of directory, 
which still enables  the user run python script that encode/decode PB, with 
C++ extension supported parser.

In a sense, I want to avoid making the user to do configure/make/make 
install/python setup.py ..
How can I achieve this?

Thanks,
Jiwoong



-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Parse a .proto file

2014-10-30 Thread Pradeep Gollakota
Hi Protobuf gurus,

I'm trying to parse a .proto file in Java to use with DynamicMessages. Is 
this possible or does it have to be compiled to a descriptor set file 
first before this can be done?

I have a use case where I need to parse messages without having the 
corresponding precompiled classes in Java. So the DynamicMessage seems to 
be the correct fit, but I'm not sure how I can generate the DescriptorSet 
from the .proto definition.

Thanks in advance,
Pradeep

-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Re: [protobuf] Parse a .proto file

2014-10-30 Thread Oliver Jowett
On 30 October 2014 02:53, Pradeep Gollakota pradeep...@gmail.com wrote:

 I have a use case where I need to parse messages without having the
 corresponding precompiled classes in Java. So the DynamicMessage seems to be
 the correct fit, but I'm not sure how I can generate the DescriptorSet from
 the .proto definition.

protoc --descriptor_set_out=FILE ?

Oliver

-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Protobuf-2.6.1 make install failure on Centos 6.5

2014-10-30 Thread Jiwoong Lee
Centos 6.5 x86_64
make, make check all fine. But make install causes error. I tried without 
--prefix option too. I tried without sudo too. Nothing helped.

 make clean;./configure --prefix=/usr;make clean; make; make check; sudo 
make install
...

Testsuite summary for Protocol Buffers 2.6.1

# TOTAL: 5
# PASS:  5
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0

make[4]: Leaving directory 
`/net/spindles/jiwoong/ws/GoogleProtobuf/protobuf-2.6.1/src'
make[3]: Leaving directory 
`/net/spindles/jiwoong/ws/GoogleProtobuf/protobuf-2.6.1/src'
make[2]: Leaving directory 
`/net/spindles/jiwoong/ws/GoogleProtobuf/protobuf-2.6.1/src'
make[1]: Leaving directory 
`/net/spindles/jiwoong/ws/GoogleProtobuf/protobuf-2.6.1/src'
Making install in .
/bin/sh: line 20: cd: .: Not a directory
make: *** [install-recursive] Error 1


~\ cat /etc/issue
*CentOS release 6.5 (Final)*
Kernel \r on an \m

~\ cat /proc/version
*Linux version 2.6.32-431.11.2.el6.x86_64 
(mockbu...@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 
4.4.7-4) (GCC) ) #1 SMP Tue Mar 25 19:59:55 UTC 2014*



-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Python google_test error

2014-10-30 Thread Jiwoong Lee
Experts: 

Can you plz tell what might cause the issue and how to workaround? I use 
Python 2.6.6 on Centos 6.5

python\ python setup.py google_test
running google_test
running egg_info
writing requirements to protobuf.egg-info/requires.txt
writing protobuf.egg-info/PKG-INFO
writing namespace_packages to protobuf.egg-info/namespace_packages.txt
writing top-level names to protobuf.egg-info/top_level.txt
writing dependency_links to protobuf.egg-info/dependency_links.txt
reading manifest file 'protobuf.egg-info/SOURCES.txt'
writing manifest file 'protobuf.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File setup.py, line 200, in module
Protocol Buffers are Google's data interchange format.,
  File /usr/lib64/python2.6/distutils/core.py, line 152, in setup
dist.run_commands()
  File /usr/lib64/python2.6/distutils/dist.py, line 975, in run_commands
self.run_command(cmd)
  File /usr/lib64/python2.6/distutils/dist.py, line 995, in run_command
cmd_obj.run()
  File /usr/lib/python2.6/site-packages/setuptools/command/test.py, line 
137, in run
self.with_project_on_sys_path(self.run_tests)
  File /usr/lib/python2.6/site-packages/setuptools/command/test.py, line 
117, in with_project_on_sys_path
func()
  File 
/tmp/GoogleProtobuf/protobuf-2.6.1/python/google_apputils-0.4.1-py2.6.egg/google/apputils/setup_command.py,
 
line 157, in run_tests
ok = self._RunTestModule(file_path)
  File 
/tmp/GoogleProtobuf/protobuf-2.6.1/python/google_apputils-0.4.1-py2.6.egg/google/apputils/setup_command.py,
 
line 123, in _RunTestModule
module = imp.load_module(module_name, *import_tuple)
  File google/protobuf/internal/message_test.py, line 52, in module
from google.apputils import basetest
  File 
/tmp/GoogleProtobuf/protobuf-2.6.1/python/google_apputils-0.4.1-py2.6.egg/google/apputils/basetest.py,
 
line 117, in module
_MonkeyPatchTestResultForUnexpectedPasses()
  File 
/tmp/GoogleProtobuf/protobuf-2.6.1/python/google_apputils-0.4.1-py2.6.egg/google/apputils/basetest.py,
 
line 108, in _MonkeyPatchTestResultForUnexpectedPasses
test_result = unittest.result.TestResult()
*AttributeError: 'module' object has no attribute 'result'*
python\

-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.