Roundup Tracker - Issues

Issue 1995623

classification
XMLRPC binary uploads
Type: Severity: normal
Components: None Versions:
process
Status: closed fixed
:
: : richard
Priority: normal :

Created on 2008-06-17 00:12 by anonymous, last changed 2008-08-18 06:21 by richard.

Messages
msg2570 Author: [hidden] (anonymous) Date: 2008-06-17 00:12
 Hi there,

I recently had the need to create new issues with binary file attachments via the roundup-xmlrpc-server interface.  Unfortunately, things didn't go quite as smoothly as I was hoping.

Here's the core of the client code I am using after some tinkering:

----
import xmlrpclib

fh=open("mybinaryfile")
file_num = roundup_server.create('file', "name=mybinaryfile", xmlrpclib.Binary("content="+fh.read()))
issue_num = roundup_server.create('issue', "title=New ticket", 'files='+str(file_num))

----

The problem I encountered back from the remote call was:

xmlrpclib.Fault: <Fault 1: "exceptions.AttributeError:Binary instance has no attribute 'find'">

My band-aid attempt at fixing xmlrpc.py by casting the arg data to a string is appended at the end.  After this, I was happy to see that the file was created and still looked like a binary file.  However, although it was the same size, it turned out to have subtly different contents.

It turns out that if a binary file contains a 0D hex value, this is converted to 0A in the resulting file (presumably by fixNewlines converting \r to \n)?

For example:

Original binary:
< 0000910 6f24 0805 0027 0000 0012 000d 02b2 0000
---
Uploaded binary:
> 0000910 6f24 0805 0027 0000 0012 000a 02b2 0000

Perhaps there's a way I can flag to rawToHyperdb that this data is binary and shouldn't be fixed for newlines?  Or, maybe there's a much easier way entirely.

Best regards,

Chris Horsley

---------

--- ~/roundup-1.4.4/roundup/xmlrpc.py 2008-06-05 10:10:39.000000000 +0900
+++ /usr/lib/python2.4/site-packages/roundup/xmlrpc.py  2008-06-06 19:12:10.000000000 +0900
@@ -82,9 +82,9 @@

         props = {}         for arg in args:
-            if arg.find('=') == -1:
+            if str(arg).find('=') == -1:
                 raise UsageError, 'argument "%s" not propname=value'%arg
-            l = arg.split('=')
+            l = str(arg).split('=')
             if len(l) < 2:
                 raise UsageError, 'argument "%s" not propname=value'%arg
             key, value = l[0], '='.join(l[1:])
msg2571 Author: [hidden] (richard) Date: 2008-08-18 06:21
"content" properties will accept binary data now. That's as good as it's going to get with the current XML-RPC API.
History
Date User Action Args
2008-06-17 00:12:28anonymouscreate