[Checkins] SVN: zopyx.smartprintng.client/trunk/zopyx/smartprintng/client/ cleanup
Andreas Jung
andreas at andreas-jung.com
Wed Jul 8 07:01:15 EDT 2009
Log message for revision 101731:
cleanup
Changed:
A zopyx.smartprintng.client/trunk/zopyx/smartprintng/client/header.txt
U zopyx.smartprintng.client/trunk/zopyx/smartprintng/client/zip_client.py
-=-
Added: zopyx.smartprintng.client/trunk/zopyx/smartprintng/client/header.txt
===================================================================
--- zopyx.smartprintng.client/trunk/zopyx/smartprintng/client/header.txt (rev 0)
+++ zopyx.smartprintng.client/trunk/zopyx/smartprintng/client/header.txt 2009-07-08 11:01:15 UTC (rev 101731)
@@ -0,0 +1,5 @@
+##########################################################################
+# zopyx.smartprintng.client - client library for the SmartPrintNG server
+# (C) 2009, ZOPYX Ltd & Co. KG, Tuebingen, Germany
+##########################################################################
+
Modified: zopyx.smartprintng.client/trunk/zopyx/smartprintng/client/zip_client.py
===================================================================
--- zopyx.smartprintng.client/trunk/zopyx/smartprintng/client/zip_client.py 2009-07-08 10:55:42 UTC (rev 101730)
+++ zopyx.smartprintng.client/trunk/zopyx/smartprintng/client/zip_client.py 2009-07-08 11:01:15 UTC (rev 101731)
@@ -1,3 +1,8 @@
+##########################################################################
+# zopyx.smartprintng.client - client library for the SmartPrintNG server
+# (C) 2009, ZOPYX Ltd & Co. KG, Tuebingen, Germany
+##########################################################################
+
import os
import sys
import base64
@@ -6,9 +11,9 @@
import tempfile
import zipfile
-# XMLRPC server instance
-
def convertZIP(dirname, converter_name='pdf-prince', host='localhost', port=6543):
+ """ XMLRPC client to SmartPrintNG server """
+ cwd = os.getcwd()
os.chdir(dirname)
server = xmlrpclib.ServerProxy('http://%s:%d/convertZIP' % (host, port))
zip_filename = tempfile.mktemp()
@@ -22,20 +27,22 @@
# send the ZIP archive base64 encoded
zip_data = server.convertZIP(base64.encodestring(file(zip_filename, 'rb').read()),
- converter_name)
+ converter_name)
# and receive the result PDF as base64 encoded ZIP archive
zip_temp = tempfile.mktemp()
file(zip_temp, 'wb').write(base64.decodestring(zip_data))
ZF = zipfile.ZipFile(zip_temp, 'r')
names = ZF.namelist()
- output_filename = names[0]
- file(output_filename, 'wb').write(ZF.read(output_filename))
+ output_filename = os.path.abspath(names[0])
+ file(output_filename, 'wb').write(ZF.read(names[0]))
ZF.close()
os.unlink(zip_filename)
os.unlink(zip_temp)
+ os.chdir(cwd)
return output_filename
if __name__ == '__main__':
+ # usage: convertZIP <dirname>
print convertZIP(sys.argv[1])
More information about the Checkins
mailing list