# -*- coding: UTF-8 -*- import ldtp import os import time import json import sys class ubiquityfinaltest: """docstring for ubiquityfinaltest""" def __init__(self,language): self.context = {} self.appname = "" self.language = language self.__change_language_context(self.language) def enable_accesiblity(self): os.system("gsettings set org.gnome.desktop.interface toolkit-accessibility true") def __change_language_context(self,language): try: f = open(os.path.join(os.path.dirname(__file__),'context',language),'r') except Exception as e: f = open("/tmp/log","w") f.write(" ".join(dir(e))) f.write(e.strerror) f.close() raise e self.context = json.load(f) self.appname = self.context['appname'] f.close() def wait_app(self,timeout=2400): count = 0 seconds = 5 while True: list_apps = ldtp.getwindowlist() if self.appname in list_apps: return True else: if count > timeout: return False count += seconds time.sleep(seconds) def test_reboot(self,language): self.enable_accesiblity() time.sleep(2) if self.wait_app(): ldtp.click(self.appname,self.context['btnreboot'])