[Checkins] SVN: zopyx.smartprintng.server/trunk/ fixes and refactoring
Andreas Jung
andreas at andreas-jung.com
Mon Jul 6 01:58:22 EDT 2009
Log message for revision 101600:
fixes and refactoring
Changed:
U zopyx.smartprintng.server/trunk/setup.py
U zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/__init__.py
U zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/base.py
A zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/header.txt
D zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/twisted.py
A zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/twisted_srv.py
-=-
Modified: zopyx.smartprintng.server/trunk/setup.py
===================================================================
--- zopyx.smartprintng.server/trunk/setup.py 2009-07-06 05:48:17 UTC (rev 101599)
+++ zopyx.smartprintng.server/trunk/setup.py 2009-07-06 05:58:22 UTC (rev 101600)
@@ -30,6 +30,6 @@
# -*- Extra requirements: -*-
],
entry_points=dict(
- console_scripts=['smartprintng_server_twisted=zopyx.smartprintng.server.twisted:main']
+ console_scripts=['smartprintng_server_twisted=zopyx.smartprintng.server.twisted_srv:main']
)
)
Modified: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/__init__.py
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/__init__.py 2009-07-06 05:48:17 UTC (rev 101599)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/__init__.py 2009-07-06 05:58:22 UTC (rev 101600)
@@ -0,0 +1,4 @@
+##########################################################################
+# zopyx.smartprintng.server
+# (C) 2008, 2009, ZOPYX Ltd & Co. KG, Tuebingen, Germany
+##########################################################################
Modified: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/base.py
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/base.py 2009-07-06 05:48:17 UTC (rev 101599)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/base.py 2009-07-06 05:58:22 UTC (rev 101600)
@@ -1,3 +1,8 @@
+##########################################################################
+# zopyx.smartprintng.server
+# (C) 2008, 2009, ZOPYX Ltd & Co. KG, Tuebingen, Germany
+##########################################################################
+
import base64
import glob
import os
@@ -8,7 +13,7 @@
import uuid
import zipfile
from zopyx.convert2.convert import Converter
-from zopyx.convert2.logger import LOG
+from logger import LOG
temp_directory = os.path.join(tempfile.gettempdir(),
'zopyx.smartprintng.server')
@@ -19,8 +24,7 @@
class ServerCore(object):
""" SmartPrintNG Server Core Implementation """
-
- def _convertZIP(zip_archive, converter_name='pdf-prince'):
+ def convertZIP(self, zip_archive, converter_name='pdf-prince'):
""" Process html-file + images within a ZIP archive """
now = datetime.now().strftime('%Y%m%d%Z%H%M%S')
@@ -47,8 +51,8 @@
if len(html_files) > 1:
raise RuntimeError('Archive contains more than one html file')
html_filename = html_files[0]
- result = self.convert(html_filename,
- converter_name=converter_name)
+ result = self._convert(html_filename,
+ converter_name=converter_name)
basename, ext = os.path.splitext(os.path.basename(result))
# Generate result ZIP archive with base64-encoded result
@@ -61,7 +65,7 @@
LOG.debug('Request end (%3.2lf seconds)' % (time.time() -ts))
return encoded_result
- def convert(self, html_filename, converter_name='pdf-prince'):
+ def _convert(self, html_filename, converter_name='pdf-prince'):
""" Process a single HTML file """
return Converter(html_filename)(converter_name)
Added: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/header.txt
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/header.txt (rev 0)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/header.txt 2009-07-06 05:58:22 UTC (rev 101600)
@@ -0,0 +1,4 @@
+##########################################################################
+# zopyx.smartprintng.server
+# (C) 2008, 2009, ZOPYX Ltd & Co. KG, Tuebingen, Germany
+##########################################################################
Deleted: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/twisted.py
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/twisted.py 2009-07-06 05:48:17 UTC (rev 101599)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/twisted.py 2009-07-06 05:58:22 UTC (rev 101600)
@@ -1,34 +0,0 @@
-from twisted.web import xmlrpc, server
-
-from base import ServerCore
-from logger import LOG
-
-class Server(xmlrpc.XMLRPC, ServerCore):
- """ SmartPrintNG Server (based on Twisted)"""
-
- def xmlrpc_convertZIP(self, zip_archive, converter_name='pdf-prince'):
- """ Process html-file + images within a ZIP archive """
-
- try:
- return self.convertZIP(zip_archive, converter_name)
- except Exception, e:
- msg = 'Conversion failed (%s)' % e
- LOG.error(msg, exc_info=True)
- return xmlrpc.Fault(123, msg)
-
-def main():
- from twisted.internet import reactor
- from optparse import OptionParser
-
- parser = OptionParser()
- parser.add_option("-p", "--port", dest="port", type="int",
- help="port", default=7080)
-
- (options, args) = parser.parse_args()
- LOG.debug('Started SmartPrintNG XMLRPC server(port %d)' % options.port)
- r = Server()
- reactor.listenTCP(options.port, server.Site(r))
- reactor.run()
-
-if __name__ == '__main__':
- main()
Copied: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/twisted_srv.py (from rev 101599, zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/twisted.py)
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/twisted_srv.py (rev 0)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/twisted_srv.py 2009-07-06 05:58:22 UTC (rev 101600)
@@ -0,0 +1,38 @@
+##########################################################################
+# zopyx.smartprintng.server
+# (C) 2008, 2009, ZOPYX Ltd & Co. KG, Tuebingen, Germany
+##########################################################################
+
+from twisted.web import xmlrpc, server
+from base import ServerCore
+from logger import LOG
+
+class Server(xmlrpc.XMLRPC, ServerCore):
+ """ SmartPrintNG Server (based on Twisted)"""
+
+ def xmlrpc_convertZIP(self, zip_archive, converter_name='pdf-prince'):
+ """ Process html-file + images within a ZIP archive """
+
+ try:
+ return self.convertZIP(zip_archive, converter_name)
+ except Exception, e:
+ msg = 'Conversion failed (%s)' % e
+ LOG.error(msg, exc_info=True)
+ return xmlrpc.Fault(123, msg)
+
+def main():
+ from twisted.internet import reactor
+ from optparse import OptionParser
+
+ parser = OptionParser()
+ parser.add_option("-p", "--port", dest="port", type="int",
+ help="port", default=7080)
+
+ (options, args) = parser.parse_args()
+ LOG.debug('Started SmartPrintNG XMLRPC server(port %d)' % options.port)
+ r = Server()
+ reactor.listenTCP(options.port, server.Site(r))
+ reactor.run()
+
+if __name__ == '__main__':
+ main()
More information about the Checkins
mailing list