Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

dream-alpha / enigma2-plugin-extensions-testcockpit   deb

Repository URL to install this package:

Version: 4.0.6 

/ usr / lib / enigma2 / python / Plugins / Extensions / TestCockpit / TestCockpit.py

#!/usr/bin/python
# coding=utf-8
#
# Copyright (C) 2018-2025 by dream-alpha
#
# In case of reuse of this source code please do not remove this copyright.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For more information on the GNU General Public License see:
# <http://www.gnu.org/licenses/>.


import Test1  # noqa: F401, pylint: disable=W0611
import Test2  # noqa: F401, pylint: disable=W0611
import Test3  # noqa: F401, pylint: disable=W0611
import Test4  # noqa: F401, pylint: disable=W0611
import Test5  # noqa: F401, pylint: disable=W0611
import Test6  # noqa: F401, pylint: disable=W0611
import Test7  # noqa: F401, pylint: disable=W0611
import Test8  # noqa: F401, pylint: disable=W0611
import Test9  # noqa: F401, pylint: disable=W0611
import Test10  # noqa: F401, pylint: disable=W0611
import Test11  # noqa: F401, pylint: disable=W0611
import Test12  # noqa: F401, pylint: disable=W0611
import Test13  # noqa: F401, pylint: disable=W0611
import Test14  # noqa: F401, pylint: disable=W0611
import Test15  # noqa: F401, pylint: disable=W0611
# import Test16  # noqa: F401, pylint: disable=W0611
from Plugins.SystemPlugins.CacheCockpit.FileManager import FileManager
from Screens.Screen import Screen
from Screens.MessageBox import MessageBox
from Components.Button import Button
from Components.Sources.List import List
from Components.ActionMap import ActionMap
from Components.config import config
from .Debug import logger
from .__init__ import _
from .ConfigScreen import ConfigScreen
from .SkinUtils import getSkinName
from .CockpitContextMenu import CockpitContextMenu


class TestCockpit(Screen):

	def __init__(self, session):
		logger.info("...")
		Screen.__init__(self, session)
		self.skinName = getSkinName("TestCockpit")

		self["actions"] = ActionMap(
			["OkCancelActions", "ColorActions", "MenuActions"],
			{
				"menu":		self.openContextMenu,
				"cancel":	self.exit,
				"red":		self.exit,
				"green":	self.green,
				"ok":		self.ok
			},
			prio=-1
		)

		self.setTitle(_("TestCockpit"))
		self["key_green"] = Button(_("Run all"))
		self["key_red"] = Button(_("Exit"))
		self["key_yellow"] = Button()
		self["key_blue"] = Button()

		self.list = []
		self.list.append(("Test 1: CacheCockpit: Load cache"))
		self.list.append(("Test 2: CacheCockpit: Delete file(s)"))
		self.list.append(("Test 3: CacheCockpit: Copy file(s) to same bookmark"))
		self.list.append(("Test 4: CacheCockpit: Copy file(s) to different bookmark"))
		self.list.append(("Test 5: CacheCockpit: Move file(s) to same bookmark"))
		self.list.append(("Test 6: CacheCockpit: Move/restore file(s) to/from trashcan"))
		self.list.append(("Test 7: CacheCockpit: Move/restore link(s) to/from trashcan"))
		self.list.append(("Test 8: CacheCockpit: Move file(s) to different bookmark"))
		self.list.append(("Test 9: CacheCockpit: PurgeTrashcan"))
		self.list.append(("Test 10: CacheCockpit: Archive"))
		self.list.append(("Test 11: CacheCockpit: Abort large file move"))
		self.list.append(("Test 12: CoverCockpit: Download covers"))
		self.list.append(("Test 13: CacheCockpit: Cache integrity: files => cache"))
		self.list.append(("Test 14: CacheCockpit: Cache integrity: cache => files"))
		self.list.append(("Test 15: CacheCockpit: Cache integrity: meta files"))
		# self.list.append(("Test 16: CacheCockpit: File Ops: Partial copy"))
		self["list"] = List(self.list)

		self.file_manager = FileManager.getInstance("MVC")
		self.run_all = False
		self.success = True
		self.index = 1

		self.onShow.append(self.onDialogShow)

	def onDialogShow(self):
		logger.info("...")

	def onSelectionChanged(self):
		logger.info("...")

	def ok(self):
		self.index = self["list"].getIndex() + 1
		self.success = True
		self.file_manager.onDatabaseLoaded(self.runTest)

	def runTest(self):
		logger.info("self.runTest%d()", self.index)
		self["list"].setIndex(self.index - 1)
		exec("Test%d.Test(self.session).start(%d, self.runTestCallback)" % (self.index, self.index))

	def runTestCallback(self, index, success):
		logger.info("self.index: %s, success: %s", self.index, success)
		if index != self.index:
			logger.error("index mismatch: index: %s, self.index: %s", index, self.index)
		else:
			self.success = self.success and success
			if not self.run_all or self.index >= len(self.list) or not self.success:
				logger.debug("stopping...")
				self.run_all = False
				msg = _("completed successfully.") if self.success else _("failed.")
				self.session.open(MessageBox, _("Test(s) ") + msg, MessageBox.TYPE_INFO)
			else:
				self.index += 1
				self.runTest()

	def openContextMenu(self):
		self.session.open(
			CockpitContextMenu,
			self,
		)

	def openConfigScreen(self):
		logger.info("...")
		self.session.openWithCallback(self.openConfigScreenCallback, ConfigScreen, config.plugins.testcockpit)

	def openConfigScreenCallback(self, _result=None):
		logger.info("...")

	def exit(self):
		logger.info("...")
		self.close()

	def green(self):
		if not self.run_all:
			self.index = self["list"].getIndex() + 1
			self.success = True
			self.run_all = True
			self.file_manager.onDatabaseLoaded(self.runTest)