Bugzilla – Attachment 100184 Details for
Bug 63230
Calc: Date decreased by 1 depending on Timezone
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Script to look for similar bug.
tztest.py (text/x-python), 7.08 KB, created by
Isamu Mogi
on 2014-05-31 02:13:29 UTC
(
hide
)
Description:
Script to look for similar bug.
Filename:
MIME Type:
Creator:
Isamu Mogi
Created:
2014-05-31 02:13:29 UTC
Size:
7.08 KB
patch
obsolete
>import atexit >import datetime >import os >import re >import signal >import sys >from os import path >from pprint import pprint >from subprocess import Popen >from time import sleep > >import uno >import unohelper >from com.sun.star.beans import PropertyValue >from com.sun.star.connection import NoConnectException > >officePath = sys.argv[1] if len(sys.argv) > 1 else "soffice" >startYear = int(sys.argv[2]) if len(sys.argv) > 2 else 1850 >endYear = int(sys.argv[3]) if len(sys.argv) > 3 else 2050 > >def timezones(): > if os.name == 'nt': > return [None] > try: > with open(path.join(path.dirname(path.realpath(__file__)), "tz.txt")) as f: > return [line for line in [line.strip() for line in f.read().splitlines()] if line] > except IOError: # FileNotFoundError: > None > try: > import pytz > return pytz.common_timezones > except ImportError: > print("'import pytz' failed") > return [ > "Africa/Johannesburg", > "Europe/Berlin", > "Pacific/Fiji", > ] > >startDate = datetime.date(startYear, 1, 1) >endDate = datetime.date(endYear, 1, 1) > >pipeCount = 1 >first = True >for tz in timezones(): > pipeName = "pythonpipe_%d_%d" % (os.getpid(), pipeCount) > pipeCount += 1 > acceptArg = "-accept=pipe,name=%s;urp;StarOffice.ServiceManager" % pipeName > url = "uno:pipe,name=%s;urp;StarOffice.ComponentContext" % pipeName > process = None > desktop = None > document = None > processEnv = os.environ.copy() > if tz: > print("Checking: " + tz) > processEnv["TZ"] = tz > #processEnv["SAL_LOG"] = "+INFO.i18npool" > try: > process = Popen([officePath, acceptArg, "-nologo", "-nodefault", "-norestore", "-nofirststartwizard"], env=processEnv) > ctx = None > for i in range(10): > print("Connectiong...") > try: > localctx = uno.getComponentContext() > resolver = localctx.getServiceManager().createInstanceWithContext( > "com.sun.star.bridge.UnoUrlResolver", localctx) > ctx = resolver.resolve(url) > except NoConnectException: > sleep(i * 2 + 1) > if ctx: > break > if process.poll(): > raise Exception("Process exited") > if not ctx: > raise Exception("Connection failure") > > if first: > first = False > configurationProvider = ctx.ServiceManager.createInstanceWithContext('com.sun.star.configuration.ConfigurationProvider', ctx) > nodepath = PropertyValue() > nodepath.Name = 'nodepath' > nodepath.Value = '/org.openoffice.Setup/Product' > product = configurationProvider.createInstanceWithArguments('com.sun.star.configuration.ConfigurationAccess', (nodepath,)) > print("%s %s (%s)" % (product.getByName('ooName'), product.getByName('ooSetupVersionAboutBox'), product.getByName('ooVendor'))) > > desktop = ctx.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop", ctx) > > loadArg = PropertyValue() > loadArg.Name = "Hidden" > loadArg.Value = True > #document = desktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, (loadArg,)); > document = desktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, ()); > > frame = document.CurrentController.Frame > dispatchHelper = ctx.getServiceManager().createInstance('com.sun.star.frame.DispatchHelper') > > sys.stdout.flush() > numErrors = 0 > cell = document.CurrentController.ActiveSheet.getCellByPosition(0, 0) > > goToCellArg = PropertyValue() > goToCellArg.Name = "ToPoint" > goToCellArg.Value = "$A$1" > dispatchHelper.executeDispatch(frame, ".uno:GoToCell", "", 0, (goToCellArg,)) > > > format = "YYYY.MM.DD" # defferent from an input > charLocale = document.getPropertyValue("CharLocale") > numberFormats = document.getNumberFormats() > numberFormatId = numberFormats.queryKey(format, charLocale, True) > if numberFormatId == -1: > numberFormatId = numberFormats.addNew(format, charLocale) > numberFormatValueArg = PropertyValue() > numberFormatValueArg.Name = "NumberFormatValue" > numberFormatValueArg.Value = numberFormatId > dispatchHelper.executeDispatch(frame, ".uno:NumberFormatValue", "", 0, (numberFormatValueArg,)) > > for i in range((endDate - startDate).days + 1): > cell.String = "" > #dummyValue = 2593224 > #cell.Value = dummyValue > #delta = i if i % 2 == 0 else i + 20 > delta = i > date = startDate + datetime.timedelta(days = delta) > dateInputString = "%04d-%02d-%02d" % (date.year, date.month, date.day) # old strftime requires year >= 1900 > dateString = "%04d.%02d.%02d" % (date.year, date.month, date.day) # old strftime requires year >= 1900 > dateValue = (date - datetime.date(1899, 12, 30)).days > for retry in range(5): > enterStringArg = PropertyValue() > enterStringArg.Name = "StringName" > enterStringArg.Value = dateInputString > enterStringResultEvent = dispatchHelper.executeDispatch(frame, ".uno:EnterString", "", 0, (enterStringArg,)) > if retry > 0: > sleep(retry) > cellString = cell.String > cellValue = cell.Value > #if cellValue != prevDateValue or cellString != prevDateString: > if cellString: > break > print("Oops! cell.String is not updated. Waiting several seconds") > print("DispatchResultEvent Result=%s, dump=%s" % (enterStringResultEvent.Result, enterStringResultEvent)) > sleep(10) > cellString = cell.String > cellValue = cell.Value > if cellString: > break > print("Oops! cell.String is still not updated. Retry!") > > if dateString != cellString or dateValue != cellValue: > numErrors += 1 > if numErrors > 100: > break > print('"%s", "%s", "%s", "%d", "%f"' % (tz, dateString, cellString, dateValue, cellValue)) > finally: > if document: > try: > document.dispose() > except Exception: # __main__.DisposeException > None > if desktop: > try: > desktop.terminate() > except Exception: # __main__.DisposeException > None > if process: > try: > if not process.poll(): > try: > process.send_signal(signal.SIGINT) > sleep(3) > except ValueError: # Windows > None > while not process.poll(): > print("terminating...") > process.terminate() > sleep(3) > if not process.poll(): > process.kill() > sleep(3) > except OSError: # ProcessLookupError > None
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 63230
:
79051
|
79052
|
99582
| 100184