为zip文件创建字节数组

时间:2017-06-19 20:41:34

标签: python python-2.7 rpc xml-rpc confluence

我正在尝试使用RPC importSpace对象将zip文件导入Confluence,但它一直出错.Atlassian有以下文档可供您使用:

public boolean importSpace(String token,byte [] importData)

我创建了一个小的Pyhton脚本,循环通过保存zip文件名的文件:

#!/usr/bin/python
import xmlrpclib
import time
import urllib
confluence2site = "https://confluence"
server = xmlrpclib.ServerProxy(confluence2site + '/rpc/xmlrpc')
username = ''
password = ''
token = server.confluence2.login(username, password)
loginString = "?os_username=" + username + "&os_password=" + password
filelist = ""
start = True

with open('exportedspaces.txt') as f:
    for file in f:
        try:
            print file
            f = open(os.curdir+ "\\zips\\" + file, 'rb')
            fileHandle = f.read()
            f.close()
            server.confluence2.importSpace(token, xmlrpclib.Binary(fileHandle)) 
        except:
            print file + " failed to restore"
            failureList.append(file)

哪里出错了?

0 个答案:

没有答案