[Checkins] SVN: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/cli fixes
Andreas Jung
andreas at andreas-jung.com
Sun Jul 5 08:35:35 EDT 2009
Log message for revision 101577:
fixes
Changed:
U zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/cli.py
U zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/client_demo/zip_client.py
-=-
Modified: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/cli.py
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/cli.py 2009-07-05 12:25:44 UTC (rev 101576)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/cli.py 2009-07-05 12:35:35 UTC (rev 101577)
@@ -1,13 +1,17 @@
import os
import glob
import re
+import shutil
import zipfile
import time
import base64
import tempfile
+import uuid
from zopyx.convert2.convert import Converter
from twisted.web import xmlrpc, server
+tempdir = tempfile.mkdtemp(prefix='zopyx.smartprintng.server')
+
class Server(xmlrpc.XMLRPC):
""" SmartPrintNG Server """
@@ -17,7 +21,7 @@
data = file(filename,"rb").read()
return len(self.rxcountpages.findall(data))
- def xmlrpc_convertZIP(self, zip_archive, spool=0, converter_name='pdf-prince'):
+ def xmlrpc_convertZIP(self, zip_archive, converter_name='pdf-prince'):
""" Process html-file + images within a ZIP archive """
# store zip archive first
@@ -39,7 +43,6 @@
html_filename = html_files[0]
result = self.convert(html_filename,
- spool=spool,
converter_name=converter_name)
# Generate result ZIP archive with base64-encoded result
@@ -51,7 +54,7 @@
shutil.rmtree(tempdir)
return encoded_result
- def convert(self, html_filename, spool=0, converter_name='pdf-prince'):
+ def convert(self, html_filename, converter_name='pdf-prince'):
""" Process a single HTML file """
start_time = time.time()
@@ -59,26 +62,9 @@
output_filename = c(converter_name)
file_size = os.stat(output_filename)[6]
duration = time.time() - start_time
- self.context.addJob(input_filename=html_filename,
- output_filename=output_filename,
- output_size=file_size,
- duration=duration,
- pages=self._countPages(output_filename),
- converter_name=converter_name)
- if spool:
- id = uuid.uuid1()
- if not os.path.exists(self.context.spool_directory):
- os.makedirs(self.context.spool_directory)
- new_filename = os.path.join(self.context.spool_directory,
- '%s.pdf' % id)
- os.rename(output_filename, new_filename)
- return grok.url(self.request, self.context) + \
- '/download?id=%s' % id
- else:
- return output_filename
+ return output_filename
-
if __name__ == '__main__':
from twisted.internet import reactor
r = Server()
Modified: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/client_demo/zip_client.py
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/client_demo/zip_client.py 2009-07-05 12:25:44 UTC (rev 101576)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/client_demo/zip_client.py 2009-07-05 12:35:35 UTC (rev 101577)
@@ -7,7 +7,8 @@
server = xmlrpclib.Server('http://localhost:7080/')
# send the ZIP archive base64 encoded
-zip_data = server.convertZIP(base64.encodestring(file('test.zip', 'rb').read()))
+zip_data = server.convertZIP(base64.encodestring(file('test.zip', 'rb').read()),
+ 'pdf-prince')
# and receive the result PDF as base64 encoded ZIP archive
zip_temp = tempfile.mktemp()
More information about the Checkins
mailing list