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 / Test11.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 os
from Plugins.SystemPlugins.CacheCockpit.FileManager import FileManager
from Plugins.SystemPlugins.MountCockpit.MountCockpit import MountCockpit
from .Debug import logger
from .FileManagerUtils import FILE_OP_DELETE, FILE_OP_MOVE
from .DelayTimer import DelayTimer
from .FileChecks import FileChecks


class Test(FileChecks):

	def __init__(self, _session):
		logger.info("...")
		FileChecks.__init__(self)
		self.file_manager = FileManager.getInstance("MVC")
		self.home_dir = MountCockpit.getInstance().getHomeDir("MVC")
		mounted_bookmarks = MountCockpit.getInstance().getMountedBookmarks("MVC")
		self.source = ""
		self.destination = ""
		if len(mounted_bookmarks) >= 2:
			self.source = mounted_bookmarks[0]
			self.destination = mounted_bookmarks[1]

	def start(self, index, callback):
		logger.info("...")
		self.index = index
		self.callback = callback
		if self.source and self.destination:
			self.file_manager.execFileOp(FILE_OP_DELETE, self.destination + "/bigfile.ts", None, self.prepareTest)
		else:
			logger.error("only one bookmark available, skipping test...")
			self.callback(self.index, True)

	def prepareTest(self, *__):
		logger.info("...")
		os.system("dd if=/dev/null of=" + self.source + "/bigfile.ts seek=1MB")
		self.file_manager.clearDatabase()
		self.file_manager.onDatabaseLoaded(self.databaseLoaded)
		self.file_manager.loadDatabase()

	def databaseLoaded(self):
		logger.info("...")
		self.file_manager.execFileOp(FILE_OP_MOVE, self.source + "/bigfile.ts", self.destination, self.cancelCallback)
		DelayTimer(2000, self.file_manager.cancelJobs)

	def cancelCallback(self, file_op, path, target_dir, error):
		logger.info("file_op: %s, path: %s, target_dir: %s, error: %s", file_op, path, target_dir, error)
		self.success = error == 2
		self.success = self.success and self.doesExist(self.source + "/bigfile.ts")
		self.success = self.success and self.doesNotExist(self.destination + "/bigfile.ts")
		self.callback(self.index, self.success)