当前位置: 首页 > 工具软件 > Plone > 使用案例 >

小试Plone-5.1.6下用collective.celery支持collective.documentviewer 5.0.4的异步转换,效果仍不理想

翟展
2023-12-01

---------------------------------------------------------------------------------------------------------------------------

首先抛出结论:异步转换效果仍不理想, 两年前collective.documentviewer 5.0.1就有的两个毛病还是没解决

收获也有:

一是保存了可用的pin组件versions组合,

二是试了一下用flower查看celery信息,至少可以知道有哪几个文件异步转换失败

---------------------------------------------------------------------------------------------------------------------------

续上一篇:小试debian-7.11.0-amd64+Plone5.1.2全文检索和预览中文WORD中文PDF

https://blog.csdn.net/sinat_20985355/article/details/81517010

#####################################################################
#其他值得探索的功能及需求
#一、异步支持
#上传一个文件时,转换预览很慢,collective.documentviewer同时支持plone.app.async和
#collective.celery进行异步转换,上传时可以迅速返回,实际转换在后台运行,还可以查看进度,
#但是网上的文章都是Plone4的,只找到一篇Plone5使用collective.celery的文章。
#https://www.codesyntax.com/en/blog/collective-documentviewer-with-redis-backed-celery-tasks-on-plone-4-and-5
#文章中两个指向https://gist.github.com的链接,不能直接打开,但网页的确存在,原因~!@#¥%&*()+
#####################################################################

写上一篇博文时在Plone-5.1.2下对collective.documentviewer 5.0.1异步转换的尝试效果并不理想,所以没写进正文

一是同时上传的多个文件异步转换有的成功有的不成功,但是对不成功的文件单独转换:点开单个文件->“操作”->“文档管理系统转换”又可以转换成功

二是本应支持查看转换进度的“admin”->“网站设置”->“Document Viewer Async Tasks”直接无效,导致到底有哪几个没转换成功还必须一个个点开检查。

而Plone-4.3.18下用app.plone.async异步转换collective.documentviewer 4.0.14,则完全没有上面两个毛病。

由于这个功能涉及的方面太多,根本搞不清楚是redis-server的问题还是collective.celery或collective.documentviewer的问题,当时还试图不用redis-server,改用celery[sqlalchemy]或celery[librabbitmq],结果网上一篇文章都找不到,只好打消了这个念头。

其实在pypi.org中可以看到collective.celery和collective.documentviewer的作者是同一个人vangheem,我印象中曾经看到过此人在文章中承认collective.celery有一个和异步转换部分失效相关的issue还没有解决,和我当时记下的出错提示相符,但这篇文章网址当时没记下来,出错提示也没记下来。

---------------------------------------------------------------------------------------------------------------------------

快两年了,现在Plone-5.2版本都出来了,Plone开始进入Python3、Zope4的时代了

当前最新的5.1(old-stable)版本是Plone-5.1.6了。

我心想,再尝试的时间窗口基本上到了,技术继续迭代下去,最新组件将全面支持Plone-5.2,逐渐会抛弃Plone-5.1,再想pin住那么多组件的versions,只会越来越困难了。这次尝试不用最新版本,采用Plone-5.1.6+collective.documentviewer 5.0.4的组合。

一方面Plone-5.1.6使用的还是Zope 2.13,而Plone-5.2已经是Zope4时代了

目前网上找到的唯一能解决中文ID问题的组件https://github.com/wichert/experimental.utf8id要求Zope 2.13.20 or later。

(我在Plone-4.3.18中经过尝试,可以用https://github.com/wichert/experimental.utf8id    加上

https://pypi.org/project/c2.patch.filenamenormalizer    的组合解决中文ID问题)

另一方面collective.documentviewer最新6.0.0 (2020-05-12)版本都已经不用docsplit了

Changelog
6.0.0 (2020-05-12)
...
...
Replaced docsplit. Instead call the various packages directly. See pull request #79. [alphaomega325]

我在Plone-4.3.18 中已经依赖docsplit切割出的文本,实现了目录列表时截取每条前几十个汉字文本,搜索结果时取出每条中关键字前后文(其中关键字用不同背景颜色高亮突出显示)分别列示在每个条目下方的功能。本次尝试的重点是异步转换,就不再引入新特性新版本了,免得节外生枝。

---------------------------------------------------------------------------------------------------------------------------

上一篇博文提到的,只找到一篇Plone5使用collective.celery的文章。
https://www.codesyntax.com/en/blog/collective-documentviewer-with-redis-backed-celery-tasks-on-plone-4-and-5

其中在Plone5使用collective.celery的链接https://gist.github.com/erral/4f5c6a64c12d626a9f7b7f18d98ab1e0内容如下:

#https://gist.github.com/erral/4f5c6a64c12d626a9f7b7f18d98ab1e0
[buildout]
projectname = plone5

extensions =
    mr.developer

show-picked-versions = true

parts +=
    instance
    zeo
    omelette
    zopepy
    scripts
    supervisor

# Change the number here to change the version of Plone being used
extends =
    https://dist.plone.org/release/5.0-latest/versions.cfg


versions = versions

# Add additional egg download sources here. dist.plone.org contains archives
# of Plone packages.
find-links =
    https://dist.plone.org/release/5.0-latest
    https://dist.plone.org/thirdparty

# Add additional eggs needed for your project here
eggs =
    pdbpp
    celery[redis]
    collective.celery
    collective.documentviewer

# Add here which products' zcml files will be loaded
zcml =

[versions]
# Solution for your setuptools problems
# https://community.plone.org/t/not-using-bootstrap-py-as-default/620
setuptools =
zc.buildout =

# Supervisor versions
supervisor = 3.3.1
collective.recipe.supervisor = 0.20
superlance = 0.14
meld3 = 1.0.2

fancycompleter = 0.7
pdbpp = 0.8.3
pyrepl = 0.8.4

# Required by:
# pdbpp==0.8.3
wmctrl = 0.3


collective.documentviewer = 5.0.0
# Required by:
# collective.documentviewer==5.0.0
repoze.catalog = 0.8.3



# celery
collective.celery = 1.0.6
redis = 2.10.5
amqp = 1.4.9
anyjson = 0.3.3
billiard = 3.3.0.20
celery = 3.1.18
elasticsearch = 2.3.0
kombu = 3.0.37

# Port configuration
[ports]
instance = 8080
zeo = 8090

[instance]
recipe = plone.recipe.zope2instance
user = admin:admin
http-address = ${ports:instance}
debug-mode = on
verbose-security = on
blob-storage = ${buildout:directory}/var/blobstorage

shared-blob = on
zeo-client = True
zeo-address = ${ports:zeo}

# Do not add eggs here
# for consistence-sake, please add them in the eggs
# option for buildout part. Only Zope and Plone eggs
# must be listed here. Thank you.
eggs =
    Zope2
    Plone
    ${buildout:eggs}


environment-vars =
   # Add here the languages of this site
    zope_i18n_compile_mo_files true
    TZ Europe/Madrid
    PYTHON_EGG_CACHE = ${buildout:directory}/var/.python-eggs
    CELERY_BROKER_URL redis://localhost:6379/0
    CELERY_RESULT_BACKEND redis://localhost:6379/1

# Do not add zcml here
# for consistence-sake, please add them in the zcml
# option for buildout part. Thank you.
zcml =
    ${buildout:zcml}

products =
    ${buildout:directory}/products

[zeo]
recipe = plone.recipe.zeoserver
zeo-address = ${ports:zeo}

[supervisor]
recipe = collective.recipe.supervisor
http-socket = unix
file = ${buildout:directory}/var/supervisord.sock
plugins = superlance
programs =
   10 zeo${buildout:projectname} (autorestart=true) ${buildout:directory}/bin/zeo [fg] true
   20 zope${buildout:projectname}${instance:http-address} (autorestart=true) ${buildout:directory}/bin/instance [console] true
   30 celery${buildout:projectname} (autorestart=true) ${buildout:directory}/bin/pcelery [worker ${instance:location}/etc/zope.conf]

eventlisteners =
   Memmon${buildout:projectname}${instance:http-address} TICK_60 ${buildout:bin-directory}/memmon [-p zope${buildout:projectname}${instance:http-address}=700MB -m support@server.com]
   MailMe${buildout:projectname}${instance:http-address} PROCESS_STATE_EXITED ${buildout:bin-directory}/crashmail [-p zope${buildout:projectname}${instance:http-address} -m support@server.com]


[omelette]
recipe = collective.recipe.omelette
eggs = ${instance:eggs}
products = ${instance:products}


[zopepy]
recipe = zc.recipe.egg
eggs = ${instance:eggs}
interpreter = zopepy
scripts = zopepy

[scripts]
recipe = zc.recipe.egg
eggs = ${instance:eggs}
scripts = pcelery

# Add here your develop eggs
# you can activate them using bin/develop
# for documentation about using git or svn urls, check
# http://pypi.python.org/pypi/mr.developer
[sources]

---------------------------------------------------------------------------------------------------------------------------

测试开始,与上一篇博文重复部分就不写了,只记录不一样的部分,操作系统还是debian-7.11.0-amd64

---------------------------------------------------------------------------------------------------------------------------

一、安装redis-server

apt-get -y --force-yes install redis-server

二、install.sh安装后改/opt/plone/zeocluster/buildout.cfg,在buildout.cfg同一目录中patch -p0 <buildout516.cfg.diff

--- buildout.cfg	2020-06-18 11:27:44.000000000 +0800
+++ buildout.cfg.ok	2020-06-23 20:48:45.098156470 +0800
@@ -43,6 +43,7 @@
 extends =
     base.cfg
     versions.cfg
+    tika.cfg
 #    http://dist.plone.org/release/5.1.6/versions.cfg
 
 # If you change your Plone version, you'll also need to update
@@ -76,6 +77,16 @@
 eggs =
     Plone
     Pillow
+    ftw.tika
+    collective.documentviewer
+#    experimental.utf8id
+    celery[redis]
+    collective.celery
+    flower
+environment-vars = 
+    CELERY_BROKER_URL redis://localhost:6379/0
+    CELERY_RESULT_BACKEND redis://localhost:6379/1
+
 
 ############################################
 # ZCML Slugs
@@ -84,6 +95,10 @@
 # use them. This is increasingly rare.
 zcml =
 #    plone.reload
+    ftw.tika
+    ftw.tika-meta
+#    experimental.utf8id
+#    experimental.utf8id-overrides
 
 ############################################
 # Development Eggs
@@ -97,6 +112,9 @@
 #
 # Provide the *paths* to the eggs you are developing here:
 develop =
+#    src/experimental.utf8id
+
+
 #    src/my.package
 
 ############################################
@@ -154,6 +172,9 @@
     unifiedinstaller
     precompiler
     setpermissions
+    tika-server-download
+    tika-server
+    scripts
 
 ############################################
 # Major Parts
@@ -172,12 +193,38 @@
 recipe = plone.recipe.zope2instance
 zeo-address = ${zeoserver:zeo-address}
 http-address = 8080
+zcml-additional += ${tika:zcml}
+eggs +=
+#    experimental.utf8id
+    ftw.tika
+zcml =
+#    experimental.utf8id
+#    experimental.utf8id-overrides
+    ftw.tika
+    ftw.tika-meta
 
 [client2]
 <= client_base
 recipe = plone.recipe.zope2instance
 zeo-address = ${zeoserver:zeo-address}
 http-address = 8081
+zcml-additional += ${tika:zcml}
+eggs +=
+#    experimental.utf8id
+    ftw.tika
+zcml =
+#    experimental.utf8id
+#    experimental.utf8id-overrides
+    ftw.tika
+    ftw.tika-meta
+
+[scripts]
+recipe = zc.recipe.egg
+eggs = ${buildout:eggs}
+    flower
+scripts = pcelery
+    flower
+
 
 ############################################
 # Versions Specification
@@ -196,7 +243,316 @@
 setuptools =
 zc.buildout =
 Pillow = 6.1.0
-
+#--not in zopepy--#
 buildout.sanitycheck = 1.0.2
+#--not in zopepy--#
 collective.recipe.backup = 4.1.0
+#--not in zopepy--#
 plone.recipe.unifiedinstaller = 4.3.2
+
+collective.documentviewer = 5.0.4
+zipp = 0.5.2
+amqp = 2.5.2
+billiard = 3.6.3.0
+celery = 4.4.2
+chardet = 3.0.4
+collective.celery = 1.1.4
+#--not in zopepy--#
+collective.recipe.scriptgen = 0.2
+configparser = 5.0.0
+ftw.tika = 2.10.0
+#--not in zopepy--#
+hexagonit.recipe.download = 1.7.1
+idna = 2.8
+importlib-metadata = 1.6.0
+kombu = 4.6.8
+#--not in zopepy--#
+plone.recipe.command = 1.1
+#--not in zopepy--#
+plone.recipe.precompiler = 0.6
+#redis = 3.5.2
+redis = 3.2.0
+
+# Required by:
+# importlib-metadata==1.6.0
+contextlib2 = 0.6.0.post1
+
+# Required by:
+# importlib-metadata==1.6.0
+pathlib2 = 2.3.5
+
+# Required by:
+# collective.documentviewer==5.0.4
+repoze.catalog = 0.9.0
+
+# Required by:
+# pathlib2==2.3.5
+scandir = 1.10.0
+
+# flower
+backports-abc = 0.5
+flower = 0.9.4
+tornado = 5.1.1
+
+# Required by:
+# tornado==5.1.1
+singledispatch = 3.4.0.3
+
+#--in zopepy--#
+Plone = 5.1.6
+pytz = 2017.3
+humanize = 0.5.1
+futures = 3.1.1
+plone.api = 1.10.0
+vine = 1.3.0
+plone.app.contenttypes = 1.4.16
+collective.monkeypatcher = 1.2
+plone.app.z3cform = 3.0.10
+zope.browserresource = 4.1.0
+Products.CMFPlone = 5.1.6
+Products.PortalTransforms = 3.1.7
+Products.GenericSetup = 1.8.10
+ZODB3 = 3.11.0
+zope.schema = 4.5.0
+zope.interface = 4.4.3
+zope.component = 4.4.1
+requests = 2.22.0
+plone.app.upgrade = 2.0.28
+plone.app.iterate = 3.3.12
+plone.app.dexterity = 2.6.3
+plone.app.caching = 1.2.23
+archetypes.multilingual = 3.0.7
+Products.CMFPlacefulWorkflow = 1.7.6
+Products.Archetypes = 1.15.8
+Products.ATContentTypes = 2.3.9
+zope.globalrequest = 1.2
+six = 1.10.0
+plone.uuid = 1.0.5
+plone.app.uuid = 1.2
+plone.app.linkintegrity = 3.3.11
+decorator = 4.1.2
+Products.statusmessages = 5.0.4
+zope.deprecation = 4.3.0
+plone.namedfile = 4.2.7
+plone.dexterity = 2.6.2
+plone.app.versioningbehavior = 1.3.8
+plone.app.relationfield = 1.4.3
+plone.app.querystring = 1.4.11
+plone.app.lockingbehavior = 1.0.6
+plone.app.event = 3.2.4
+plone.app.contentmenu = 2.3.0
+zope.traversing = 4.1.0
+zope.i18nmessageid = 4.1.0
+zope.i18n = 4.2.0
+zope.browserpage = 4.1.0
+z3c.formwidget.query = 0.17
+z3c.form = 3.6
+plone.z3cform = 0.9.2
+plone.protect = 3.1.4
+plone.app.widgets = 2.4.1
+plone.app.textfield = 1.2.11
+Zope2 = 2.13.29
+Products.CMFCore = 2.2.13
+Acquisition = 4.4.2
+zope.index = 3.6.4
+zope.publisher = 4.3.2
+zope.location = 3.9.1
+zope.contenttype = 4.2.0
+zope.configuration = 3.7.4
+zope.tales = 3.5.3
+zope.tal = 3.5.2
+zope.structuredtext = 3.5.1
+zope.site = 3.9.2
+zope.pagetemplate = 4.2.1
+zope.event = 3.5.2
+zope.dottedname = 4.2
+zope.deferredimport = 3.5.3
+zope.container = 3.11.2
+zope.cachedescriptors = 3.5.1
+zope.app.locales = 3.7.5
+z3c.autoinclude = 0.3.9
+transaction = 2.1.2
+slimit = 0.8.1
+pyScss = 1.3.5
+plonetheme.barceloneta = 2.1.4
+plone.theme = 3.0.6
+plone.subrequest = 1.8.6
+plone.session = 3.7.3
+plone.schema = 1.2.0
+plone.registry = 1.1.5
+plone.portlets = 2.3.1
+plone.portlet.static = 3.1.3
+plone.portlet.collection = 3.3.2
+plone.outputfilters = 3.0.5
+plone.memoize = 2.0.1
+plone.locking = 2.2.3
+plone.intelligenttext = 3.0.0
+plone.indexer = 1.0.6
+plone.i18n = 3.0.8
+plone.contentrules = 2.0.9
+plone.browserlayer = 2.2.2
+plone.batching = 1.1.5
+plone.app.workflow = 3.0
+plone.app.vocabularies = 4.0.7
+plone.app.viewletmanager = 2.0.12
+plone.app.users = 2.4.3
+plone.app.theming = 2.0.5
+plone.app.registry = 1.7.5
+plone.app.redirector = 1.3.7
+plone.app.portlets = 4.3.4
+plone.app.locales = 5.1.18
+plone.app.layout = 2.8.4
+plone.app.multilingual = 5.2.3
+plone.app.i18n = 3.0.5
+plone.app.folder = 1.2.6
+plone.app.discussion = 3.0.8
+plone.app.customerize = 1.3.10
+plone.app.controlpanel = 3.0.4
+plone.app.contentrules = 4.0.19
+plone.app.contentlisting = 1.3.3
+plone.app.content = 3.5.6
+mockup = 2.7.8
+five.pt = 2.2.5
+five.localsitemanager = 2.0.6
+five.customerize = 1.1
+borg.localrole = 3.1.6
+Products.contentmigration = 2.1.19
+Products.ResourceRegistries = 3.0.7
+Products.PluginRegistry = 1.4.1
+Products.PluggableAuthService = 1.11.2
+Products.PlonePAS = 5.1.1
+Products.PlacelessTranslationService = 2.0.7
+Products.MimetypesRegistry = 2.1.5
+Products.ExternalEditor = 1.1.3
+Products.ExtendedPathIndex = 3.4.2
+Products.DCWorkflow = 2.2.5
+Products.CMFUid = 2.2.2
+Products.CMFQuickInstallerTool = 3.0.16
+Products.CMFFormController = 3.1.5
+Products.CMFEditions = 3.2.2
+Products.CMFDynamicViewFTI = 5.0.0
+Products.CMFDiffTool = 3.3.0
+ExtensionClass = 4.3.0
+DateTime = 4.2
+AccessControl = 3.0.14
+Markdown = 2.6.9
+BTrees = 4.4.1
+persistent = 4.2.4.2
+ZODB = 5.3.0
+ZEO = 5.1.1
+urllib3 = 1.22
+certifi = 2017.11.5
+zope.ramcache = 2.2.0
+Products.ZCatalog = 3.0.3
+zope.viewlet = 3.7.2
+zope.lifecycleevent = 3.6.2
+zope.annotation = 3.5.0
+plone.supermodel = 1.4.0
+plone.schemaeditor = 2.1.0
+plone.rfc822 = 1.1.4
+plone.formwidget.namedfile = 2.0.9
+plone.behavior = 1.3.0
+plone.autoform = 1.8.1
+lxml = 4.2.1
+z3c.zcmlhook = 1.0b1
+python-dateutil = 2.7.3
+plone.caching = 1.2.1
+plone.cachepurging = 1.0.16
+zope.datetime = 3.4.1
+plone.folder = 2.0.2
+Products.validation = 2.1.1
+Products.ZSQLMethods = 2.13.5
+plone.app.imaging = 2.0.7
+plone.app.collection = 1.2.7
+plone.app.blob = 1.7.4
+ZConfig = 3.1.0
+plone.app.intid = 1.1.3
+zope.security = 4.1.1
+zope.copy = 3.5.0
+plone.scale = 3.0.3
+piexif = 1.0.13
+zope.size = 3.4.1
+zope.filerepresentation = 3.6.1
+zope.browser = 2.1.0
+plone.synchronize = 1.0.3
+plone.alterego = 1.1.3
+zope.intid = 3.7.2
+z3c.relationfield = 0.9.0
+five.intid = 1.1.2
+zope.contentprovider = 3.7.2
+plone.formwidget.recurrence = 2.1.3
+plone.event = 1.4.0
+icalendar = 4.0.3
+Products.DateRecurringIndex = 2.1
+zope.browsermenu = 4.2
+zope.proxy = 4.3.0
+repoze.xmliter = 0.6
+plone.transformchain = 2.0.1
+plone.keyring = 3.1.1
+five.globalrequest = 1.0
+ZServer = 3.0
+Record = 2.13.0
+Products.ZCTextIndex = 2.13.5
+Products.TemporaryFolder = 3.0
+Products.StandardCacheManagers = 2.13.1
+Products.Sessions = 3.0
+Products.PythonScripts = 2.13.2
+Products.MIMETools = 2.13.0
+Products.MailHost = 2.13.2
+Products.ExternalMethod = 2.13.1
+Products.BTreeFolder2 = 2.14.0
+initgroups = 4.0
+zope.testing = 3.9.7
+zope.testbrowser = 3.11.1
+zope.sequencesort = 3.4.0
+zope.sendmail = 3.7.5
+zope.ptresource = 3.9.0
+zope.processlifetime = 1.0
+zope.exceptions = 3.6.2
+zLOG = 3.0
+zExceptions = 2.13.0
+zdaemon = 4.2.0
+tempstorage = 4.0.1
+docutils = 0.14
+ZopeUndo = 4.3
+RestrictedPython = 3.6.0
+Products.OFSP = 2.13.2
+Persistence = 2.13.2
+MultiMapping = 3.1
+Missing = 3.2
+DocumentTemplate = 2.13.4
+zope.app.publication = 3.12.0
+zope.broken = 3.6.0
+ply = 3.4
+pathlib = 1.0.1
+enum34 = 1.1.6
+jsonschema = 2.6.0
+Unidecode = 0.4.1
+zope.componentvocabulary = 1.0.1
+roman = 1.4.0
+plone.resourceeditor = 2.1.3
+plone.resource = 2.0.2
+diazo = 1.3.0
+feedparser = 5.2.1
+plone.stringinterp = 1.3.1
+simplejson = 3.12.0
+Chameleon = 2.25
+z3c.pt = 3.0.0a1
+sourcecodegen = 0.6.14
+python-gettext = 3.0
+Products.ZopeVersionControl = 1.1.4
+zodbpickle = 0.7.0
+zc.lockfile = 1.2.1
+trollius = 2.1.post2
+z3c.caching = 2.0a1
+archetypes.schemaextender = 2.1.8
+zope.keyreference = 3.6.4
+zc.relation = 1.0
+z3c.objpath = 1.1
+future = 0.16.0
+mechanize = 0.2.5
+zope.error = 3.7.4
+zope.authentication = 3.7.1
+functools32 = 3.2.3.post2
+cssselect = 1.0.1
+zope.untrustedpython = 4.0.0

三、改/opt/plone/zeocluster/base.cfg,在base.cfg同一目录中patch -p0 <base516.cfg.diff

--- base.cfg	2020-06-18 11:27:52.000000000 +0800
+++ base.cfg.ok	2020-06-18 11:28:07.000000000 +0800
@@ -12,6 +12,10 @@
 eggs-directory=../buildout-cache/eggs
 download-cache=../buildout-cache/downloads
 
+# specify PyPI index
+index = http://mirrors.163.com/pypi/simple/
+#index = https://pypi.python.org/simple/
+
 # Don't download new things unless needed to satisfy dependencies.
 # Override this on the command line with the "-n" flag.
 newest = false

四、我试过了,collective.documentviewer 5.0.4不改convert.py在debian-7.11.0-amd64下仍然出错。避免走弯路,先改好。

改/opt/plone/buildout-cache/eggs/collective.documentviewer-5.0.4-py2.7.egg/collective/documentviewer/convert.py,在convert.py同一目录中patch -p0 <convert504.py.diff,完成后删除或改名同一目录中的convert.pyc和convert.pyo,这次没改出错信息编码出错的部分,哈哈

--- convert.py	2020-06-18 12:23:01.000000000 +0800
+++ convert.py.ok	2020-06-18 13:14:54.000000000 +0800
@@ -219,7 +219,7 @@
         # docsplit images pdf.pdf --size 700x,300x,50x
         # --format gif --output
         cmd = [
-            self.binary, "images", filepath,
+            '/usr/bin/sudo', self.binary, "images", filepath,
             '--language', lang,
             '--size', ','.join([str(s[1]) + 'x' for s in sizes]),
             '--format', format,
@@ -246,7 +246,7 @@
         output_dir = os.path.join(output_dir, TEXT_REL_PATHNAME)
         ocr = not ocr and 'no-' or ''
         cmd = [
-            self.binary, "text", filepath,
+            '/usr/bin/sudo', self.binary, "text", filepath,
             '--language', lang,
             '--%socr' % ocr,
             '--pages', 'all',
@@ -260,7 +260,7 @@
         self._run_command(cmd)
 
     def get_num_pages(self, filepath):
-        cmd = [self.binary, "length", filepath]
+        cmd = ['/usr/bin/sudo', self.binary, "length", filepath]
         return int(self._run_command(cmd).strip())
 
     def convert_to_pdf(self, filepath, filename, output_dir):
@@ -270,7 +270,7 @@
         shutil.move(filepath, inputfilepath)
         orig_files = set(os.listdir(output_dir))
         cmd = [
-            self.binary, 'pdf', inputfilepath,
+            '/usr/bin/sudo', self.binary, 'pdf', inputfilepath,
             '--output', output_dir]
         self._run_command(cmd)
 
@@ -283,9 +283,11 @@
         # In Nixos, the folder is called 'libreofficedev'
         libreOfficePathNixos = os.path.join(output_dir, 'libreofficedev')
         if os.path.exists(libreOfficePath):
-            shutil.rmtree(libreOfficePath)
+            #shutil.rmtree(libreOfficePath)
+            os.system('/usr/bin/sudo /bin/rm -fr %s' % (libreOfficePath,))
         elif os.path.exists(libreOfficePathNixos):
-            shutil.rmtree(libreOfficePathNixos)
+            #shutil.rmtree(libreOfficePathNixos)
+            os.system('/usr/bin/sudo /bin/rm -fr %s' % (libreOfficePathNixos,))
 
         # move the file to the right location now
         files = set(os.listdir(output_dir))
@@ -486,13 +488,15 @@
             files[filename] = saveFileToBlob(dump_pdf_path)
 
             settings.blob_files = files
-            shutil.rmtree(storage_dir)
+            #shutil.rmtree(storage_dir)
+            os.system('/usr/bin/sudo /bin/rm -fr %s' % (storage_dir,))
 
             # check for old storage to remove... Just in case.
             old_storage_dir = os.path.join(gsettings.storage_location,
                                            context.UID())
             if os.path.exists(old_storage_dir):
-                shutil.rmtree(old_storage_dir)
+                #shutil.rmtree(old_storage_dir)
+                os.system('/usr/bin/sudo /bin/rm -fr %s' % (old_storage_dir,))
         else:
             # if settings used to be blob, delete file data
             if settings.storage_type == 'Blob' and settings.blob_files:

五、其他参照上一篇博文,不能漏掉任何部分,buildout完成后要开四个终端并su为root权限(标准的做法是引入supervisor来启动各组件,原型测试就不学该怎么写buildout.cfg启动supervisor了)。前三个都滚屏显示,第四个会回到命令提示符下

分别在桌面开四个终端,都su为root权限
root@mydebian204:/opt/plone/zeocluster# bin/pcelery worker parts/client2/etc/zope.conf
root@mydebian204:/opt/plone/zeocluster# bin/flower --address=0.0.0.0 --port=5555 --broker redis://127.0.0.1:6379
root@mydebian204:/opt/plone/zeocluster# bin/tika-server
root@mydebian204:/opt/plone/zeocluster# bin/plonectl start

管理员登录建一个站点:http://10.16.97.204:8080/Plone,安装组件ftw.tika,collective.documentviewer组件,配置collective.documentviewer组件加入按文件类型自动布局"Word Document"。选某个目录,点“内容”-“上传”,从磁盘目录中拖动一批文件到上传区域-点"上传“按钮,在客户端浏览器打开http://10.16.97.204:5555可以见到flower的界面,点task可以看到当前进度。测试中出现State没有变成“SUCCESS”就说明没有异步转换成功。记下文件名,还可以单独转换,点开单个文件->“操作”->“文档管理系统转换”一般都可以转换成功。有时传三个文件就有一个没转换,传更多时又可能全部转换成功,就这么不着调儿

六、原型测试结束,我决定还是继续用Plone-4.3.18了,不折腾Plone5了

---------------------------------------------------------------------------------------------------------------------------

记下文件名时会发现文件名都是ASCII码和数字构成,而不是中文文件名。

我在Plone-4.3.18中经过尝试,可以用https://github.com/wichert/experimental.utf8id    加上

https://pypi.org/project/c2.patch.filenamenormalizer    的组合解决中文ID问题

本文中buildout.cfg中也加入了experimental.utf8id的内容,但是全部注释掉了

中文ID在Plone-5.1下有兴趣的读者可以试一下,

方法就是下载experimental.utf8id-master.zip,解压到/opt/plone/zeocluster/src,更名为experimental.utf8id,取消buildout.cfg所有experimental.utf8id前的注释符,再运行buildout

警告一下:批量上传就开始和中文ID就有冲突了,其他肯定还会有很多issue,要想实用肯定要修改experimental.utf8id组件以外的代码

(而Plone-4.3.18中用wildcard.foldercontents批量上传支持中文ID完全没有问题)

 类似资料: