Skip to content

Commit

Permalink
update robocomp for using python3.12 and python3.10 and change QT6 an…
Browse files Browse the repository at this point in the history
…d Pyside6
  • Loading branch information
alfiTH committed Jun 25, 2024
1 parent d03888c commit 6311dd0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
20 changes: 15 additions & 5 deletions cli/robocompdsl/robocompdsl/templates/common/plugin_collection.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import inspect
import os
import pkgutil
import importlib
import importlib.util
import sys

from robocompdsl.templates.common.templatedict import TemplateDict

Expand All @@ -15,6 +16,15 @@ def __init__(self):
self.classes = {}
self.description = 'UNKNOWN'

def load_module_from_path(self, module_name, path):
spec = importlib.util.spec_from_file_location(module_name, path)
if spec is None:
raise ImportError(f"Cannot find module {module_name} at {path}")
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
spec.loader.exec_module(module)
return module

def load_functions(self):
for root, dirs, files in os.walk(self.abs_path + "/functions"):
for file in files:
Expand All @@ -24,12 +34,12 @@ def load_functions(self):
if relative_path not in self.classes:
try:
module_name = self.__class__.__name__+"_"+relative_path.replace('/','_').split('.')[0]
module = importlib.machinery.SourceFileLoader(module_name,
os.path.join(root, file)).load_module()
module = self.load_module_from_path(module_name, os.path.join(root, file))
except AssertionError as e:
pass
print(f"ERROR AssertionError: {e}")
except ValueError as e:
pass
print(f"ERROR ValueError: {e}")

for _, the_class in inspect.getmembers(module, lambda x: inspect.isclass(x) and issubclass(x, TemplateDict) and x.__name__!="TemplateDict"):
# print(f"Loading plugin: {relative_path}")
self.classes[relative_path] = the_class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# along with RoboComp. If not, see <http://www.gnu.org/licenses/>.

import sys, Ice, os
from PySide2 import QtWidgets, QtCore
from PySide6 import QtWidgets, QtCore

ROBOCOMP = ''
try:
Expand Down Expand Up @@ -47,7 +47,7 @@ def __init__(self, mprx):
${publishes_proxies}
${gui_setup}

self.mutex = QtCore.QMutex(QtCore.QMutex.Recursive)
self.mutex = QtCore.QMutex()
self.Period = 30
self.timer = QtCore.QTimer(self)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
# along with RoboComp. If not, see <http://www.gnu.org/licenses/>.
#

from PySide2.QtCore import QTimer
from PySide2.QtWidgets import QApplication
from PySide6.QtCore import QTimer
from PySide6.QtWidgets import QApplication
from rich.console import Console
from genericworker import *
import interfaces as ifaces
Expand Down

0 comments on commit 6311dd0

Please sign in to comment.