#!/usr/bin/env python # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- # # Version: MPL 1.1 / GPLv3+ / LGPLv3+ # # The contents of this file are subject to the Mozilla Public License Version # 1.1 (the "License"); you may not use this file except in compliance with # the License or as specified alternatively below. You may obtain a copy of # the License at http://www.mozilla.org/MPL/ # # Software distributed under the License is distributed on an "AS IS" basis, # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License # for the specific language governing rights and limitations under the # License. # # Major Contributor(s): # Copyright (C) 2012 Red Hat, Inc., Michael Stahl <mstahl@redhat.com> # (initial developer) # # All Rights Reserved. # # For minor contributions see the git repository. # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 3 or later (the "GPLv3+"), or # the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), # in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable # instead of those above.
# Simple script to load a bunch of documents and export them as Flat ODF # # Personally I run it like this: # ~/lo/master-suse/instdir/program/python ~/lo/master-suse/bin/benchmark-document-loading --soffice=path:/home/tml/lo/master-suse/instdir/program/soffice --outdir=file://$PWD/out --userdir=file:///tmp/test $PWD/docs #
import argparse import datetime import os import subprocess import sys import threading import time import urllib
try:
from urllib.parse import quote
except ImportError:
from urllib import quote import uuid
try: import pyuno import uno import unohelper
except ImportError:
print("pyuno not found: try to set PYTHONPATH and URE_BOOTSTRAP variables")
print("PYTHONPATH=/installation/opt/program")
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
try:
from com.sun.star.document import XDocumentEventListener
from com.sun.star.io import XOutputStream
except ImportError:
print("UNO API class not found: try to set URE_BOOTSTRAP variable")
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
def partition(list, pred):
left = []
right = [] for e in list: if pred(e):
left.append(e) else:
right.append(e)
return (left, right)
def filelist(directory, suffix): if not directory:
raise Exception("filelist: empty directory") if directory[-1] != "/":
directory += "/"
files = [directory + f for f in os.listdir(directory)] # print(files)
return [f for f in files if os.path.isfile(f) and os.path.splitext(f)[1] == suffix]
def getFiles(dirs, suffix): # print( dirs )
files = [] for d in dirs:
files += filelist(d, suffix)
return files
def runConnectionTests(connection, invoker, tests):
try:
connection.setUp() for test in tests:
invoker(connection, test)
finally:
pass #connection.tearDown()
def write_state_report(files_list, start_time, report_filename, description):
with open(report_filename, "w") as fh:
fh.write("%s:\n" % description)
fh.write("Starttime: %s\n" % start_time.isoformat()) for f in files_list:
fh.write("%s\n" % f)
def writeReport(state, startTime):
write_state_report(state.goodFiles, startTime, "goodFiles.log", "Files which loaded perfectly")
write_state_report(state.badDisposedFiles, startTime, "badDisposedFiles.log", "Files which crashed with DisposedException")
write_state_report(state.badPropertyFiles, startTime, "badPropertyFiles.log", "Files which crashed with UnknownPropertyException")
write_state_report(state.timeoutFiles, startTime, "timeoutFiles.log", "Files which timed out")
def runHandleFileTests(opts):
startTime = datetime.datetime.now()
connection = PersistentConnection(opts)
global outdir
outdir = os.path.join(opts.outdir, startTime.strftime('%Y%m%d.%H%M%S'))
try:
tests = []
state = State() # print("before map") for component, validExtension in validFileExtensions.items():
files = [] for suffix in validExtension:
files.extend(getFiles(opts.dirs, suffix))
files.sort()
tests.extend( (HandleFileTest(file, state, component) for file in files) )
runConnectionTests(connection, simpleInvoke, tests)
finally:
connection.kill()
writeReport(state, startTime)
def parseArgs(argv):
epilog = "'location' is a pathname, not a URL. 'outdir' and 'userdir' are URLs.\n" \ "The 'directory' parameters should be full absolute pathnames, not URLs."
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
epilog=epilog)
parser.add_argument('--soffice', metavar='method:location', required=True,
help="specify soffice instance to connect to\n" "supported methods: 'path', 'connect'")
parser.add_argument('--outdir', metavar='URL', required=True,
help="specify the output directory for flat ODF exports")
parser.add_argument('--userdir', metavar='URL',
help="specify user installation directory for 'path' method")
parser.add_argument('--valgrind', action='store_true',
help="pass --valgrind to soffice for 'path' method")
parser.add_argument('dirs', metavar='directory', nargs='+')
args = parser.parse_args(argv[1:])
return args
if __name__ == "__main__":
opts = parseArgs(sys.argv)
runHandleFileTests(opts)
# vim:set shiftwidth=4 softtabstop=4 expandtab:
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet am 2026-06-06)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.