[Solved] Python: asyncio module

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
buffercache
Posts: 2
Joined: Fri Jun 26, 2020 2:45 pm

[Solved] Python: asyncio module

Post by buffercache »

Hi !

I got issue with asyncio python module
got this error : <class 'AttributeError'>: module 'asyncio' has no attribute 'get_event_loop'

Is there somewhere the list of available modules and restrictions for openoffice python ?


The following code works using standard python

Code: Select all

import datetime
import time
#from pytz import timezone
import sys
import asyncio

event_loop = asyncio.get_event_loop()

def AddClock():
    COLUMN_A = 0
    FIRST_ROW = 7
    SHEET_NAME= "Horaire"
    
    #oDoc = XSCRIPTCONTEXT.getDocument()
    #oSheet = oDoc.Sheets.getByName(SHEET_NAME)
    #oCell = oSheet.getCellByPosition(COLUMN_A, FIRST_ROW)
    
    def keep_changing_time(loop,N):
        loop.call_at(N + 1, keep_changing_time, loop, N + 1)
        #timezone('US/Eastern')
        #oCell.setFormula(datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S EST"))
        print(datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S EST"))

    try:
        NOW = event_loop.time() // 1 + 1
        event_loop.call_at(NOW, keep_changing_time, event_loop, NOW)
        event_loop.run_forever()

    finally:
        event_loop.close()
Last edited by buffercache on Mon Jun 29, 2020 11:00 am, edited 1 time in total.
Open Office 4.1 on windows
Libre Office Version : 6.4.4.2 (x64)
Build ID : 3d775be2011f3886db32dfd395a6a6d1ca2630ff
Threads CPU : 8; OS : Windows 10.0 Build 18363; UI Render : par d??faut; VCL: win;
Locale??: fr-FR (fr_FR); Langue IHM : fr-FR
User avatar
MrProgrammer
Moderator
Posts: 4905
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Python : asyncio module

Post by MrProgrammer »

Hi, and welcome to the forum.
buffercache wrote:Is there somewhere the list of available modules and restrictions for openoffice python ?
buffercache signature wrote:Open Office 4.1
Libre Office Version : 6.4.4.
I do not use Python, however my web search found:
OpenOffice 4.1 uses Python 2.7.
LibreOffice 6.4 uses Python 3.7.
asyncio requires Python Version 3.4.

You may find other Python facilities which are common to the two Python versions that would allow your code to work with both suites. I do not know if it is practical to configure OpenOffice to use Python version 3. A search of the forum might answer that question for you.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
buffercache
Posts: 2
Joined: Fri Jun 26, 2020 2:45 pm

Re: Python : asyncio module

Post by buffercache »

Thanks for your reply
  • LibreOffice asyncio ( C:\Program Files\LibreOffice\program\python-core-3.7.7\lib\asyncio ) contains 4 files
  • Standard asyncio module contains 26 files ...
Seems to be a pruned version of asyncio for some reasons ....
Open Office 4.1 on windows
Libre Office Version : 6.4.4.2 (x64)
Build ID : 3d775be2011f3886db32dfd395a6a6d1ca2630ff
Threads CPU : 8; OS : Windows 10.0 Build 18363; UI Render : par d??faut; VCL: win;
Locale??: fr-FR (fr_FR); Langue IHM : fr-FR
Post Reply