From 842ba173e44b3ca5ab4bdfb0715e592990ecda7d Mon Sep 17 00:00:00 2001 From: root Date: Fri, 20 Dec 2024 14:44:05 +0100 Subject: [PATCH] 0.3.20 --- .gitignore | 50 ++ .pylintrc | 548 ++++++++++++++++++ CONTROL/control | 5 + CONTROL/postinst | 16 + CONTROL/postrm | 9 + CONTROL/preinst | 5 + Components/Makefile.am | 2 + Components/Task.py | 469 +++++++++++++++ Makefile.am | 1 + README.md | 18 + docs/index.html | 15 + docs/jobcockpit.sh | 8 + po/JobCockpit.pot | 35 ++ po/Makefile.am | 61 ++ po/de.po | 35 ++ setup.cfg | 9 + src/Debug.py | 53 ++ src/JobCockpit.png | Bin 0 -> 9590 bytes src/JobCockpit.py | 121 ++++ src/JobSupervisor.py | 82 +++ src/Makefile.am | 4 + src/PluginUtils.py | 39 ++ src/SkinUtils.py | 96 +++ src/Version.py | 26 + src/__init__.py | 45 ++ src/keymap.xml | 27 + src/locale/de/LC_MESSAGES/JobCockpit.mo | Bin 0 -> 746 bytes src/plugin.py | 69 +++ src/skin/Default-FHD/Makefile.am | 2 + src/skin/Default-FHD/colors.xmlinc | 15 + src/skin/Default-FHD/skin.xml | 16 + src/skin/Default-HD/Makefile.am | 2 + src/skin/Default-HD/colors.xmlinc | 15 + src/skin/Default-HD/skin.xml | 16 + src/skin/Default-WQHD/Makefile.am | 2 + src/skin/Default-WQHD/colors.xmlinc | 34 ++ .../Default-WQHD/screen_JobCockpit.xmlinc | 6 + src/skin/Default-WQHD/skin.xml | 20 + src/skin/Makefile.am | 1 + src/skin/Other-WQHD/Makefile.am | 2 + src/skin/Other-WQHD/colors.xmlinc | 23 + src/skin/Other-WQHD/skin.xml | 16 + src/skin/Shadow-FHD/Makefile.am | 2 + src/skin/Shadow-FHD/colors.xmlinc | 34 ++ src/skin/Shadow-FHD/screen_JobCockpit.xmlinc | 6 + src/skin/Shadow-FHD/skin.xml | 20 + src/skin/screen_JobCockpit.xmlinc | 11 + src/skin/screenpart_1Button_icon.xmlinc | 1 + src/skin/screenpart_1Button_source_2x.xmlinc | 1 + src/skin/screenpart_4Buttons_icon.xmlinc | 4 + src/skin/screenpart_4Buttons_source_2x.xmlinc | 5 + src/skin/screenpart_Background.xmlinc | 3 + src/skin/screenpart_JobCockpitList.xmlinc | 13 + src/skin/screenpart_TitleOnly.xmlinc | 1 + src/skin/skin_src.xml | 4 + 55 files changed, 2123 insertions(+) create mode 100644 .gitignore create mode 100644 .pylintrc create mode 100644 CONTROL/control create mode 100755 CONTROL/postinst create mode 100755 CONTROL/postrm create mode 100755 CONTROL/preinst create mode 100644 Components/Makefile.am create mode 100644 Components/Task.py create mode 100644 Makefile.am create mode 100755 README.md create mode 100644 docs/index.html create mode 100755 docs/jobcockpit.sh create mode 100644 po/JobCockpit.pot create mode 100644 po/Makefile.am create mode 100644 po/de.po create mode 100644 setup.cfg create mode 100644 src/Debug.py create mode 100644 src/JobCockpit.png create mode 100644 src/JobCockpit.py create mode 100644 src/JobSupervisor.py create mode 100644 src/Makefile.am create mode 100644 src/PluginUtils.py create mode 100644 src/SkinUtils.py create mode 100644 src/Version.py create mode 100644 src/__init__.py create mode 100644 src/keymap.xml create mode 100644 src/locale/de/LC_MESSAGES/JobCockpit.mo create mode 100644 src/plugin.py create mode 100644 src/skin/Default-FHD/Makefile.am create mode 100644 src/skin/Default-FHD/colors.xmlinc create mode 100644 src/skin/Default-FHD/skin.xml create mode 100644 src/skin/Default-HD/Makefile.am create mode 100644 src/skin/Default-HD/colors.xmlinc create mode 100644 src/skin/Default-HD/skin.xml create mode 100644 src/skin/Default-WQHD/Makefile.am create mode 100644 src/skin/Default-WQHD/colors.xmlinc create mode 100755 src/skin/Default-WQHD/screen_JobCockpit.xmlinc create mode 100644 src/skin/Default-WQHD/skin.xml create mode 100644 src/skin/Makefile.am create mode 100644 src/skin/Other-WQHD/Makefile.am create mode 100644 src/skin/Other-WQHD/colors.xmlinc create mode 100644 src/skin/Other-WQHD/skin.xml create mode 100644 src/skin/Shadow-FHD/Makefile.am create mode 100644 src/skin/Shadow-FHD/colors.xmlinc create mode 100755 src/skin/Shadow-FHD/screen_JobCockpit.xmlinc create mode 100644 src/skin/Shadow-FHD/skin.xml create mode 100755 src/skin/screen_JobCockpit.xmlinc create mode 100644 src/skin/screenpart_1Button_icon.xmlinc create mode 100644 src/skin/screenpart_1Button_source_2x.xmlinc create mode 100644 src/skin/screenpart_4Buttons_icon.xmlinc create mode 100644 src/skin/screenpart_4Buttons_source_2x.xmlinc create mode 100644 src/skin/screenpart_Background.xmlinc create mode 100755 src/skin/screenpart_JobCockpitList.xmlinc create mode 100644 src/skin/screenpart_TitleOnly.xmlinc create mode 100755 src/skin/skin_src.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b24d71e --- /dev/null +++ b/.gitignore @@ -0,0 +1,50 @@ +# These are some examples of commonly ignored file patterns. +# You should customize this list as applicable to your project. +# Learn more about .gitignore: +# https://www.atlassian.com/git/tutorials/saving-changes/gitignore + +# Node artifact files +node_modules/ +dist/ + +# Compiled Java class files +*.class + +# Compiled Python bytecode +*.py[cod] + +# Log files +*.log + +# Package files +*.jar + +# Maven +target/ +dist/ + +# JetBrains IDE +.idea/ + +# Unit test reports +TEST*.xml + +# Generated by MacOS +.DS_Store + +# Generated by Windows +Thumbs.db + +# Applications +*.app +*.exe +*.war + +# Large media files +*.mp4 +*.tiff +*.avi +*.flv +*.mov +*.wmv + diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..db4a6ec --- /dev/null +++ b/.pylintrc @@ -0,0 +1,548 @@ +[MASTER] + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code +extension-pkg-whitelist= + +# Add files or directories to the blacklist. They should be base names, not +# paths. +ignore=CVS + +# Add files or directories matching the regex patterns to the blacklist. The +# regex matches against base names, not paths. +ignore-patterns= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Use multiple processes to speed up Pylint. +jobs=1 + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + +# Pickle collected data for later comparisons. +persistent=yes + +# Specify a configuration file. +#rcfile= + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages +suggestion-mode=yes + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED +confidence= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once).You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use"--disable=all --enable=classes +# --disable=W" +disable=print-statement, + parameter-unpacking, + unpacking-in-except, + old-raise-syntax, + backtick, + long-suffix, + old-ne-operator, + old-octal-literal, + import-star-module-level, + non-ascii-bytes-literal, + raw-checker-failed, + bad-inline-option, + locally-disabled, + locally-enabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + apply-builtin, + basestring-builtin, + buffer-builtin, + cmp-builtin, + coerce-builtin, + execfile-builtin, + file-builtin, + long-builtin, + raw_input-builtin, + reduce-builtin, + standarderror-builtin, + unicode-builtin, + xrange-builtin, + coerce-method, + delslice-method, + getslice-method, + setslice-method, + no-absolute-import, + old-division, + dict-iter-method, + dict-view-method, + next-method-called, + metaclass-assignment, + indexing-exception, + raising-string, + reload-builtin, + oct-method, + hex-method, + nonzero-method, + cmp-method, + input-builtin, + round-builtin, + intern-builtin, + unichr-builtin, + map-builtin-not-iterating, + zip-builtin-not-iterating, + range-builtin-not-iterating, + filter-builtin-not-iterating, + using-cmp-argument, + eq-without-hash, + div-method, + idiv-method, + rdiv-method, + exception-message-attribute, + invalid-str-codec, + sys-max-int, + bad-python3-import, + deprecated-string-function, + deprecated-str-translate-call, + deprecated-itertools-function, + deprecated-types-field, + next-method-defined, + dict-items-not-iterating, + dict-keys-not-iterating, + dict-values-not-iterating, + + R0201, R0205, R1725, + C0103, C0114, C0326, C0330, C0411, + W0122, W0123, W0201, W0311, W0312, W0603, W0703, W1505, + E0401, E0611, E1101 + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable=c-extension-no-member + + +[REPORTS] + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details +msg-template='{msg_id}:{line:3d},{column}: {obj}: {msg}' + +# Set the output format. Available formats are text, parseable, colorized, json +# and msvs (visual studio).You can also give a reporter class, eg +# mypackage.mymodule.MyReporterClass. +output-format=text + +# Tells whether to display a full report or only the messages +reports=no + +# Activate the evaluation score. +score=yes + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=10 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=optparse.Values,sys.exit + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes +max-spelling-suggestions=4 + +# Spelling dictionary name. Available dictionaries: none. To make it working +# install python-enchant package. +spelling-dict= + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to indicated private dictionary in +# --spelling-private-dict-file option instead of raising a message. +spelling-store-unknown-words=no + + +[SIMILARITIES] + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + +# Minimum lines number of a similarity. +min-similarity-lines=50 + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + + +[FORMAT] + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Maximum number of characters on a single line. +max-line-length=300 + +# Maximum number of lines in a module +max-module-lines=1000 + +# List of optional constructs for which whitespace checking is disabled. `dict- +# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. +# `trailing-comma` allows a space between comma and closing bracket: (a, ). +# `empty-line` allows space-only lines. +no-space-check=trailing-comma, + dict-separator + +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + + +[LOGGING] + +# Logging modules to check that the string format arguments are in logging +# function parameter format +logging-modules=logging + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expectedly +# not used). +#dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ +dummy-variables-rgx=(_+[a-zA-Z0-9_]*?$)|dummy + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis. It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + + +[BASIC] + +# Naming style matching correct argument names +argument-naming-style=snake_case + +# Regular expression matching correct argument names. Overrides argument- +# naming-style +#argument-rgx= + +# Naming style matching correct attribute names +attr-naming-style=snake_case + +# Regular expression matching correct attribute names. Overrides attr-naming- +# style +#attr-rgx= + +# Bad variable names which should always be refused, separated by a comma +bad-names=foo, + bar, + baz, + toto, + tutu, + tata + +# Naming style matching correct class attribute names +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style +#class-attribute-rgx= + +# Naming style matching correct class names +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming-style +#class-rgx= + +# Naming style matching correct constant names +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=1000 + +# Naming style matching correct function names +function-naming-style=camelCase + +# Regular expression matching correct function names. Overrides function- +# naming-style +#function-rgx= + +# Good variable names which should always be accepted, separated by a comma +good-names=i, + j, + k, + ex, + Run, + _ + +# Include a hint for the correct naming format with invalid-name +include-naming-hint=no + +# Naming style matching correct inline iteration names +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style +#inlinevar-rgx= + +# Naming style matching correct method names +method-naming-style=camelCase + +# Regular expression matching correct method names. Overrides method-naming- +# style +#method-rgx= + +# Naming style matching correct module names +module-naming-style=any + +# Regular expression matching correct module names. Overrides module-naming- +# style +#module-rgx= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +property-classes=abc.abstractproperty + +# Naming style matching correct variable names +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style +#variable-rgx= + + +[IMPORTS] + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=regsub, + TERMIOS, + Bastion, + rexec + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled) +import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled) +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + + +[DESIGN] + +# Maximum number of arguments for function / method +max-args=100 + +# Maximum number of attributes for a class (see R0902). +max-attributes=100 + +# Maximum number of boolean expressions in a if statement +max-bool-expr=100 + +# Maximum number of branch for function / method body +max-branches=100 + +# Maximum number of locals for function / method body +max-locals=100 + +# Maximum number of parents for a class (see R0901). +max-parents=100 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=100 + +# Maximum number of return / yield for function / method body +max-returns=100 + +# Maximum number of statements in function / method body +max-statements=200 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=0 + + +[CLASSES] + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict, + _fields, + _replace, + _source, + _make + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception" +overgeneral-exceptions=Exception diff --git a/CONTROL/control b/CONTROL/control new file mode 100644 index 0000000..437fc06 --- /dev/null +++ b/CONTROL/control @@ -0,0 +1,5 @@ +Description: JobCockpit +Maintainer: dream-alpha +Package: enigma2-plugin-systemplugins-jobcockpit +Version: 0.3.20 +Architecture: all diff --git a/CONTROL/postinst b/CONTROL/postinst new file mode 100755 index 0000000..7add5f6 --- /dev/null +++ b/CONTROL/postinst @@ -0,0 +1,16 @@ +#!/bin/sh +if [ ! -f /usr/lib/enigma2/python/Components/Task.py.org ]; then + cp /usr/lib/enigma2/python/Components/Task.py /usr/lib/enigma2/python/Components/Task.py.org +fi +cp /usr/lib/enigma2/python/Plugins/SystemPlugins/JobCockpit/Components/Task.py /usr/lib/enigma2/python/Components/Task.py + +echo "***********************************" +echo "* JobCockpit *" +echo "* by *" +echo "* dream-alpha *" +echo "***********************************" +echo "" +echo "Plugin installed successfully." +echo "Please restart DreamOS now!" +echo "" +exit 0 diff --git a/CONTROL/postrm b/CONTROL/postrm new file mode 100755 index 0000000..39e1389 --- /dev/null +++ b/CONTROL/postrm @@ -0,0 +1,9 @@ +#!/bin/sh +if [ "$1" = "remove" ]; then + rm -rf /usr/lib/enigma2/python/Plugins/SystemPlugins/JobCockpit > /dev/null 2>&1 + cp /usr/lib/enigma2/python/Components/Task.py.org /usr/lib/enigma2/python/Components/Task.py + echo "JobCockpit plugin removed successfully." +else + find /usr/lib/enigma2/python/Plugins/SystemPlugins/JobCockpit -type f -name "*.pyo" -exec rm -f {} \; > /dev/null 2>&1 +fi +exit 0 diff --git a/CONTROL/preinst b/CONTROL/preinst new file mode 100755 index 0000000..9194113 --- /dev/null +++ b/CONTROL/preinst @@ -0,0 +1,5 @@ +#!/bin/sh +if [ ! -f /usr/lib/enigma2/python/Components/Task.py.org ]; then + mv /usr/lib/enigma2/python/Components/Task.py /usr/lib/enigma2/python/Components/Task.py.org +fi +exit 0 diff --git a/Components/Makefile.am b/Components/Makefile.am new file mode 100644 index 0000000..721302f --- /dev/null +++ b/Components/Makefile.am @@ -0,0 +1,2 @@ +installdir = $(libdir)/enigma2/python/Plugins/SystemPlugins/JobCockpit/Components +install_PYTHON = *.py diff --git a/Components/Task.py b/Components/Task.py new file mode 100644 index 0000000..25a94d2 --- /dev/null +++ b/Components/Task.py @@ -0,0 +1,469 @@ +import os +from enigma import eConsoleAppContainer +from Tools.CList import CList +from Tools import Notifications + + +Notifications.notificationQueue.registerDomain("JobManager", _("Job Manager"), Notifications.ICON_DEFAULT) # pylint: disable=E0602 + + +class Job(object): + NOT_STARTED, IN_PROGRESS, FINISHED, FAILED = range(4) + + def __init__(self, name): + self.tasks = [] + self.resident_tasks = [] + self.workspace = "/tmp" + self.current_task = 0 + self.callback = None + self.name = name + self.finished = False + self.end = 100 + self.__progress = 0 + self.weightScale = 1 + self.afterEvent = None + self.state_changed = CList() + self.status = self.NOT_STARTED + + # description is a dict + def fromDescription(self, description): + pass + + def createDescription(self): + return None + + def getProgress(self): + # if self.current_task == len(self.tasks): + # return self.end + # t = self.tasks[self.current_task] + # jobprogress = t.weighting * t.progress / float(t.end) + sum([task.weighting for task in self.tasks[:self.current_task]]) + jobprogress = sum([task.weighting * task.progress / float(task.end) for task in self.tasks]) + progress = int(jobprogress * self.weightScale) + print("JOB: getProgress: progress: %s" % progress) + return int(jobprogress * self.weightScale) + + progress = property(getProgress) + + def getStatustext(self): + return {self.NOT_STARTED: _("Waiting"), self.IN_PROGRESS: _("In Progress"), self.FINISHED: _("Finished"), self.FAILED: _("Failed")}[self.status] # pylint: disable=E0602 + + def task_progress_changed_CB(self): + self.state_changed() + + def addTask(self, task): + print("JOB: addTask: %s" % task) + task.job = self + task.task_progress_changed = self.task_progress_changed_CB + self.tasks.append(task) + + def start(self, callback): + print("JOB: start: %s" % callback) + assert self.callback is None + self.callback = callback + self.restart() + + def restart(self): + print("JOB: restart") + self.status = self.IN_PROGRESS + self.state_changed() + self.runNext() + sumTaskWeightings = sum([t.weighting for t in self.tasks]) or 1 + self.weightScale = self.end / float(sumTaskWeightings) + + def runNext(self): + print("JOB: runNext: current_task: %s, tasks: %s" % (self.current_task, self.tasks)) + if self.current_task == len(self.tasks): + if len(self.resident_tasks) == 0: + self.status = self.FINISHED + self.state_changed() + self.callback(self, None, []) + self.callback = None + else: + print("JOB: still waiting for %d resident task(s) %s to finish" % (len(self.resident_tasks), str(self.resident_tasks))) + else: + print("JOB: current_task: %s" % self.current_task) + print("JOB: tasks: %s" % self.tasks) + self.tasks[self.current_task].run(self.taskCallback) + self.state_changed() + + def taskCallback(self, task, res, stay_resident=False): + print("JOB: taskCallback: task: %s, res: %s, stay_residents: %s" % (task, res, stay_resident)) + cb_idx = self.tasks.index(task) + if stay_resident: + if cb_idx not in self.resident_tasks: + self.resident_tasks.append(self.current_task) + print("JOB: task going resident:", task) + else: + print("JOB: task keeps staying resident:", task) + return + if len(res) > 0: + print("JOB: >>> Error:", res) + self.status = self.FAILED + self.state_changed() + self.callback(self, task, res) + if cb_idx != self.current_task: + if cb_idx in self.resident_tasks: + print("JOB: resident task finished:", task) + self.resident_tasks.remove(cb_idx) + if res == []: + self.state_changed() + self.current_task += 1 + self.runNext() + + def retry(self): + assert self.status == self.FAILED + self.restart() + + def abort(self, *args): + print("JOB: abort") + if self.current_task < len(self.tasks): + self.tasks[self.current_task].abort(*args) + for i in self.resident_tasks: + self.tasks[i].abort(*args) + + def cancel(self, *args): + print("JOB: cancel") + self.abort(*args) + + def remove(self, callback): + print("JOB: remove: callback: %s" % callback) + if self.status == self.IN_PROGRESS: + self.abort() + else: + callback(self, None, []) + + +class Task(object): + def __init__(self, job, name): + self.name = name + self.immediate_preconditions = [] + self.global_preconditions = [] + self.postconditions = [] + self.returncode = None + self.initial_input = None + self.job = None + self.end = 100 + self.weighting = 100 + self.__progress = 0 + self.cmd = None + self.cwd = "/tmp" + self.args = [] + self.cmdline = None + self.task_progress_changed = None + self.output_line = "" + job.addTask(self) + self.container = None + + def setCommandline(self, cmd, args): + self.cmd = cmd + self.args = args + + def setTool(self, tool): + self.cmd = tool + self.args = [tool] + self.global_preconditions.append(ToolExistsPrecondition()) + self.postconditions.append(ReturncodePostcondition()) + + def setCmdline(self, cmdline): + self.cmdline = cmdline + + def checkPreconditions(self, immediate=False): + not_met = [] + if immediate: + preconditions = self.immediate_preconditions + else: + preconditions = self.global_preconditions + for precondition in preconditions: + if not precondition.check(self): + not_met.append(precondition) + return not_met + + def run(self, callback): + failed_preconditions = self.checkPreconditions(True) + self.checkPreconditions(False) + if len(failed_preconditions) > 0: + callback(self, failed_preconditions) + return + self.prepare() + + self.callback = callback + self.container = eConsoleAppContainer() + self.appClosed_conn = self.container.appClosed.connect(self.processFinished) + self.stdoutAvail_conn = self.container.stdoutAvail.connect(self.processStdout) + self.stderrAvail_conn = self.container.stderrAvail.connect(self.processStderr) + + if self.cwd is not None: + self.container.setCWD(self.cwd) + + if not self.cmd and self.cmdline: + print("TASK: execute:", self.container.execute(self.cmdline), self.cmdline) + else: + assert self.cmd is not None + assert len(self.args) >= 1 + print("TASK: execute:", self.container.execute(self.cmd, *self.args), ' '.join(self.args)) + if self.initial_input: + self.writeInput(self.initial_input) + + def prepare(self): + pass + + def cleanup(self, failed): + pass + + def processStdout(self, data): + self.processOutput(data) + + def processStderr(self, data): + self.processOutput(data) + + def processOutput(self, data): + self.output_line += data + while True: + i = self.output_line.find('\n') + if i == -1: + break + self.processOutputLine(self.output_line[:i + 1]) + self.output_line = self.output_line[i + 1:] + + def processOutputLine(self, line): + pass + + def processFinished(self, returncode): + self.returncode = returncode + self.finish() + + def abort(self): + if self.container: + self.container.kill() + self.finish(aborted=True) + + def finish(self, aborted=False): + self.afterRun() + not_met = [] + if aborted: + not_met.append(AbortedPostcondition()) + else: + for postcondition in self.postconditions: + if not postcondition.check(self): + not_met.append(postcondition) + self.cleanup(not_met) + self.callback(self, not_met) + + def afterRun(self): + pass + + def writeInput(self, ainput): + self.container.write(ainput) + + def getProgress(self): + print("TASK: getProgress: __progress: %s" % self.__progress) + return self.__progress + + def setProgress(self, progress): + print("TASK: setProgress: progress: %s" % progress) + if progress > self.end: + progress = self.end + if progress < 0: + progress = 0 + self.__progress = progress + if self.task_progress_changed: + self.task_progress_changed() # pylint: disable=E1102 + print("TASK: setProgress: __progress: %s" % self.__progress) + + progress = property(getProgress, setProgress) + + +# The jobmanager will execute multiple jobs, each after another. +# later, it will also support suspending jobs (and continuing them after reboot etc) +# It also supports a notification when some error occured, and possibly a retry. + + +class JobManager: + def __init__(self, domain="JobManager"): + self.active_jobs = [] + self.successfull_jobs = [] + self.failed_jobs = [] + self.job_classes = [] + self.in_background = False + self.active_job = None + self.domain = domain + + def AddJob(self, job): + self.active_jobs.append(job) + self.kick() + + def AbortJob(self, job, *args): + if job.status == Job.IN_PROGRESS: + job.abort(*args) + + def RemoveJob(self, job): + if job.status == Job.NOT_STARTED: + if job in self.active_jobs: + self.active_jobs.remove(job) + elif job.status == Job.FINISHED: + if job in self.successfull_jobs: + self.successfull_jobs.remove(job) + elif job.status == Job.FAILED: + if job in self.failed_jobs: + self.failed_jobs.remove(job) + + def CleanupJobs(self): + self.successfull_jobs = [] + self.failed_jobs = [] + + def kick(self): + if self.active_job is None: + if len(self.active_jobs) > 0: + self.active_job = self.active_jobs.pop(0) + self.active_job.start(self.jobDone) + + def jobDone(self, job, task, problems): + print("JOBMGR: job", job, "completed with", problems, "in", task) + if self.in_background: + from Screens.TaskView import JobView # pylint: disable=C0415 + self.in_background = False + Notifications.AddNotification(JobView, self.active_job, domain=self.domain) + if problems: + from Screens.MessageBox import MessageBox # pylint: disable=C0415 + if problems[0].RECOVERABLE: + Notifications.AddNotificationWithCallback(self.errorCB, MessageBox, _("Error: %s\nRetry?") % (problems[0].getErrorMessage(task)), domain=self.domain) # pylint: disable=E0602 + else: + Notifications.AddNotification(MessageBox, _("Error") + (': %s') % (problems[0].getErrorMessage(task)), type=MessageBox.TYPE_ERROR, domain=self.domain) # pylint: disable=E0602 + self.errorCB(False) + if hasattr(self.active_job, "keep") and self.active_job.keep: + self.failed_jobs.append(self.active_job) + return + if hasattr(self.active_job, "keep") and self.active_job.keep: + self.successfull_jobs.append(self.active_job) + + self.active_job = None + self.kick() + + def errorCB(self, answer): + if answer: + print("JOBMGR: retrying job") + self.active_job.retry() + else: + print("JOBMGR: not retrying job.") + self.failed_jobs.append(self.active_job) + self.active_job = None + self.kick() + + def getPendingJobs(self): + jobs = [] + if self.active_job: + jobs.append(self.active_job) + jobs += self.active_jobs + return jobs + + def getSuccessfullJobs(self): + return self.successfull_jobs + + def getFailedJobs(self): + return self.failed_jobs + + +# some examples: +# class PartitionExistsPostcondition: +# def __init__(self, device): +# self.device = device +# +# def check(self, task): +# import os +# return os.access(self.device + "part1", os.F_OK) +# +# class CreatePartitionTask(Task): +# def __init__(self, device): +# Task.__init__(self, _("Create Partition")) +# self.device = device +# self.setTool("/sbin/sfdisk") +# self.args += ["-f", self.device + "disc"] +# self.initial_input = "0,\n;\n;\n;\ny\n" +# self.postconditions.append(PartitionExistsPostcondition(self.device)) +# +# class CreateFilesystemTask(Task): +# def __init__(self, device, partition = 1, largefile = True): +# Task.__init__(self, _("Create Filesystem")) +# self.setTool("/sbin/mkfs.ext") +# if largefile: +# self.args += ["-T", "largefile"] +# self.args.append("-m0") +# self.args.append(device + "part%d" % partition) +# +# class FilesystemMountTask(Task): +# def __init__(self, device, partition = 1, filesystem = "ext3"): +# Task.__init__(self, _("Mounting Filesystem")) +# self.setTool("/bin/mount") +# if filesystem is not None: +# self.args += ["-t", filesystem] +# self.args.append(device + "part%d" % partition) + + +class Condition: + RECOVERABLE = False + + def getErrorMessage(self, task): + return _("An unknown error occured!") + " (%s @ task %s)" % (self.__class__.__name__, task.__class__.__name__) # pylint: disable=E0602 + + +class DiskspacePrecondition(Condition): + def __init__(self, diskspace_required): + self.diskspace_required = diskspace_required + self.diskspace_available = 0 + + def check(self, task): + try: + s = os.statvfs(task.job.workspace) + self.diskspace_available = s.f_bsize * s.f_bavail + return self.diskspace_available >= self.diskspace_required + except OSError: + return False + + def getErrorMessage(self, task): + return _("Not enough diskspace. Please free up some diskspace and try again. (%d MB required, %d MB available)") % (self.diskspace_required / 1024 / 1024, self.diskspace_available / 1024 / 1024) # pylint: disable=E0602 + + +class ToolExistsPrecondition(Condition): + def check(self, task): + if task.cmd[0] == '/': + self.realpath = task.cmd + print("[Task.py][ToolExistsPrecondition] WARNING: usage of absolute paths for tasks should be avoided!") + return os.access(self.realpath, os.X_OK) + self.realpath = task.cmd + path = os.environ.get('PATH', '').split(os.pathsep) + path.append(task.cwd + '/') + absolutes = filter(lambda file: os.access(file, os.X_OK), map(lambda directory, file=task.cmd: os.path.join(directory, file), path)) + if len(absolutes) > 0: + self.realpath = task.cmd[0] + return True + return False + + def getErrorMessage(self, task): + return _("A required tool (%s) was not found.") % (self.realpath) # pylint: disable=E0602 + + +class AbortedPostcondition(Condition): + def getErrorMessage(self, task): + return "Cancelled upon user request" + + +class ReturncodePostcondition(Condition): + def check(self, task): + return task.returncode == 0 + + +# class HDDInitJob(Job): +# def __init__(self, device): +# Job.__init__(self, _("Initialize Harddisk")) +# self.device = device +# self.fromDescription(self.createDescription()) +# +# def fromDescription(self, description): +# self.device = description["device"] +# self.addTask(CreatePartitionTask(self.device)) +# self.addTask(CreateFilesystemTask(self.device)) +# self.addTask(FilesystemMountTask(self.device)) +# +# def createDescription(self): +# return {"device": self.device} + +job_manager = JobManager() diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..f56f3bc --- /dev/null +++ b/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = Components src po diff --git a/README.md b/README.md new file mode 100755 index 0000000..1373c97 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/92f5ff82cf014812a6383cc8fbac235e)](https://app.codacy.com/gh/dream-alpha/JobCockpit/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) +[![Gemfury](https://badge.fury.io/fp/gemfury.svg)](https://gemfury.com/f/partner) + +# JOBCockpit (JOC) +DreamOS plugin replacing standard job manager + +## Features +- Keeps jobs after completion. +- Adds functions to query successfully completed and failed jobs. +- Provides separate task managers by plugin... that allow parallel execution of jobs. + +## Languages +- n/a + +## Links +- Installation: https://dream-alpha.github.io/JobCockpit +- Support: https://github.com/dream-alpha/JobCockpit/discussions +- Package feed: https://gemfury.com/dream-alpha diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..1c551b4 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,15 @@ + + +

JobCockpit Installation

+ To install the JobCockpit plugin execute the following commands in a telnet console on your dreambox: + + The installation script will also install a feed source that enables a convenient upgrade to the latest version with the following commands or automatically as part of a DreamOS upgrade: + + + diff --git a/docs/jobcockpit.sh b/docs/jobcockpit.sh new file mode 100755 index 0000000..b52b8b5 --- /dev/null +++ b/docs/jobcockpit.sh @@ -0,0 +1,8 @@ +#!/bin/sh +rm -f /etc/apt/sources.list.d/cockpit.list +apt-get update +apt-get install -y apt-transport-https +echo deb [trusted=yes] https://apt.fury.io/dream-alpha ./ > /etc/apt/sources.list.d/cockpit.list +apt-get update +apt-get install -y enigma2-plugin-systemplugins-jobcockpit +systemctl restart enigma2 diff --git a/po/JobCockpit.pot b/po/JobCockpit.pot new file mode 100644 index 0000000..dfc967c --- /dev/null +++ b/po/JobCockpit.pot @@ -0,0 +1,35 @@ +msgid "" +msgstr "" +"Project-Id-Version: JobCockpit\n" +"POT-Creation-Date: 2024-09-07 17:56+0200\n" +"PO-Revision-Date: \n" +"Last-Translator: dream-alpha\n" +"Language-Team: \n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.5\n" +"X-Poedit-Basepath: ../src\n" +"X-Poedit-SearchPath-0: .\n" + +msgid "Job Management" +msgstr "" + +msgid "Abort current job" +msgstr "" + +msgid "Abort all jobs" +msgstr "" + +msgid "Abort all pending jobs" +msgstr "" + +msgid "Cleanup jobs" +msgstr "" + +msgid "Manage Jobs" +msgstr "" + +msgid "Jobs" +msgstr "" diff --git a/po/Makefile.am b/po/Makefile.am new file mode 100644 index 0000000..28156b5 --- /dev/null +++ b/po/Makefile.am @@ -0,0 +1,61 @@ +# +# to use this for the localisation of other plugins, +# just change the DOMAIN to the name of the Plugin. +# It is assumed, that the domain ist the same as +# the directory name of the plugin. +# + +DOMAIN = JobCockpit +installdir = $(libdir)/enigma2/python/Plugins/Extensions/$(DOMAIN) +#GETTEXT=./pygettext.py +GETTEXT=xgettext + +#MSGFMT = ./msgfmt.py +MSGFMT = msgfmt + +LANGS := de +LANGPO := $(foreach LANG, $(LANGS),$(LANG).po) +LANGMO := $(foreach LANG, $(LANGS),$(LANG).mo) + +default: $(DOMAIN).pot $(LANGPO) merge $(LANGMO) + for lang in $(LANGS); do \ + mkdir -p $$lang/LC_MESSAGES; \ + cp $$lang.mo $$lang/LC_MESSAGES/$(DOMAIN).mo; \ + cp $$lang.po $$lang/LC_MESSAGES/$$lang.po; \ + done + +merge: + for lang in $(LANGS); do \ + msgmerge --no-location -s -N -U $$lang.po $(DOMAIN).pot; \ + done + + +# the TRANSLATORS: allows putting translation comments before the to-be-translated line. +$(DOMAIN).pot: + $(GETTEXT) -L python --add-comments="TRANSLATORS:" -d $(DOMAIN) -s -o $(DOMAIN).pot ../*.py + + ../xml2po.py ../ >> $(DOMAIN).pot + + msguniq -o $(DOMAIN)uniq.pot $(DOMAIN).pot + + +.PHONY: $(DOMAIN).pot + + +%.mo: %.po + $(MSGFMT) -o $@ $< + +%.po: + msginit -l $@ -o $@ -i $(DOMAIN).pot --no-translator + +CLEANFILES = $(foreach LANG, $(LANGS),$(LANG).mo) + +clean-local: + $(RM) -r $(LANGS) + +install-data-am: default + for lang in $(LANGS); do \ + mkdir -p $(DESTDIR)$(installdir)/locale/$$lang/LC_MESSAGES; \ + cp $$lang.mo $(DESTDIR)$(installdir)/locale/$$lang/LC_MESSAGES/$(DOMAIN).mo; \ + cp $$lang.po $(DESTDIR)$(installdir)/locale/$$lang/LC_MESSAGES/$$lang.po; \ + done diff --git a/po/de.po b/po/de.po new file mode 100644 index 0000000..5dc23b5 --- /dev/null +++ b/po/de.po @@ -0,0 +1,35 @@ +msgid "" +msgstr "" +"Project-Id-Version: JobCockpit\n" +"POT-Creation-Date: 2024-09-07 17:56+0200\n" +"PO-Revision-Date: \n" +"Last-Translator: dream-alpha\n" +"Language-Team: \n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.5\n" +"X-Poedit-Basepath: ../src\n" +"X-Poedit-SearchPath-0: .\n" + +msgid "Job Management" +msgstr "Job Verwaltung" + +msgid "Abort current job" +msgstr "Ausgewählten Job abbrechen" + +msgid "Abort all jobs" +msgstr "Alle Jobs abbrechen" + +msgid "Abort all pending jobs" +msgstr "Alle wartenden Jobs abbrechen" + +msgid "Cleanup jobs" +msgstr "Jobs bereinigen" + +msgid "Manage Jobs" +msgstr "Jobs verwalten" + +msgid "Jobs" +msgstr "Jobs" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..968fd5c --- /dev/null +++ b/setup.cfg @@ -0,0 +1,9 @@ +[flake8] +ignore = W191, W503, E117, E203, E242, E501 + +[pycodestyle] +count = False +ignore = W191, W503, E117, E203, E242 + +max-line-length = 320 +statistics = True diff --git a/src/Debug.py b/src/Debug.py new file mode 100644 index 0000000..35bf1cf --- /dev/null +++ b/src/Debug.py @@ -0,0 +1,53 @@ +#!/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: +# . + + +import sys +import logging +from Components.config import config, ConfigSubsection, ConfigDirectory, ConfigSelection # noqa: F401, pylint: disable=W0611 +from .Version import ID, PLUGIN + + +logger = None +streamer = None +format_string = ID + ": " + "%(levelname)s: %(filename)s: %(funcName)s: %(message)s" +log_levels = {"ERROR": logging.ERROR, "INFO": logging.INFO, "DEBUG": logging.DEBUG} +plugin = PLUGIN.lower() +exec("config.plugins." + plugin + " = ConfigSubsection()") # noqa: F401, pylint: disable=W0122 +exec("config.plugins." + plugin + ".debug_log_level = ConfigSelection(default='INFO', choices=log_levels.keys())") # noqa: F401, pylint: disable=W0122 + + +def initLogging(): + global logger + global streamer + if not logger: + logger = logging.getLogger(ID) + formatter = logging.Formatter(format_string) + streamer = logging.StreamHandler(sys.stdout) + streamer.setFormatter(formatter) + logger.addHandler(streamer) + logger.propagate = False + setLogLevel(log_levels[eval("config.plugins." + plugin + ".debug_log_level").value]) + + +def setLogLevel(level): + logger.setLevel(level) + streamer.setLevel(level) + logger.info("level: %s", level) diff --git a/src/JobCockpit.png b/src/JobCockpit.png new file mode 100644 index 0000000000000000000000000000000000000000..2a2f8cc3a79dc0d6f29658f16e547723bc74ea68 GIT binary patch literal 9590 zcmaiabwE^K^EV(W-3kU5feodb_W3h?7+^()b4h+5GRnk2+be4AmI1I zV|E(qKP=8RA~f2{Z>Xj09l_MRY`kn7G@@wK!j5L(zXt<%A~crH&QK6LyPKOE zn;SQqy`u#?r=Xx9I|mm#7Z)qQ!Rq7zaW-~mg*eeZi1%Lj%yM{}v8*xB91ah|}NG2Nr_;fx^zo#=-ut?9Nu^{|oyAL?+ znD#$uA~bv)9PIz{BAx$E`-d$+e-u=@U#QjBevNv~jGj;?^SO7*Ap#i+c$^rs*q_%ovY(~umcqQ+@^SfDs z|5*Hgn;HAxda*zF-2W&h%>Ey$3;$vG7bgYA{q+oRejtjl|09e5H~$DkU9Dy)n zBFr6zfPnbH3NXrl7y|);@r%osCZ$IbIKg80FGN3O1O>_9)F?{hqs*buhoI5m(Oy_b zb7Mb`T>IsZtk=PpK|OcDe8xVmRZfH~gWC#nuyn{8ULvwtd4pq{+F2@%DQBatU~OgW zA$Yr^p;GX(&r{(&OI1B}#p`C`R2+3=C}$U)#LfVUDcAM!GFV>g#{d=E#@LrQeHrsO zVKQ<$d6Q)#UIv&c-da|lSx&#+?fv{)kzc3rMRiXzc3?b9PunZd#U4-IfH+6e)yv!3 zUA`ryi+r5Gouk3`0-rNd(Bn(A38gX^5OwLg{$SsJjO7gvtW z;s@5P7eQ8*ah_~6I~@=w^jX|+rU?@R`2rOxuj2$H7TJdjksww|0s(ua#!dD{D54J)lq zi>GPl-jU)jk?`qBkr||rB~aqqQ7rYQk5^2iR*-j*855$=6tk)~ypDsAsd->1;rCRS z{si>$uaF@KrAQ_S>O-EQUKo7lr=49x6z_hAIFnOTnR?MlZ=W-o$CH1 z8>h}I=a=vy!|*T%o60)^;a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7JR1TZemI%+S(*Q zGJe6!tC=|oAo|F8%weE*XFV_Jc=v81O9m~k{hMWX?L`l}Pv-cVCNm*Wtn#xrANhN+ z0EmAinZL;(82~?+{6EJFwv-eVO;)=U0olDAs{5ooUjBiYRm%LT=KHNjUg^M`B1C(wLDNP(b7H& z?vn8G5(WV8t8~%SiR}4BKY1Kv^Rcv%a^tRS|TLmP>#>amjA0JdY1J$=Yph^H2oDc zDz1DPq1cDW88qfVxtLX0h}L4bR5Ek=P4Mm8>s_dTCr`o=;GG1=)b?$+waI>PemaG$ z(nZ;cAg)p3cV19t~50F7b-d`v_Ok!Qik6(z(%je@aWO5;+dgM z0?f7>j%e7GM5OnrNb6%XaohOs}OJwF+;Ww97TYyf5{j-So-N^5F8nrDN~t_ z?|u4&LMzZt6+Ee6kc!!~@Zp=9O!C(yubTv#6=(S${5)!Ex)Kfw9($h@QlA9kMX7Ly zAWO4bPgwB+r#wK%2C3A;|23aiwJZ{Fs4z-wxNJLhIhCixgQr%DV1$H^aNd85D6gRN z!syvu=31zzm-uOA1D;USH)eR*%UI;!h;q;oxhKM{A3FP9tgun2L^=BT<`0bZk?>R_ z=b*Qvv=363Lr|mF)k?gmmii|1>{92k)Ywq;9@kV$l;Xy^N8sk|`ifr=a*&}s3CEz> wi^ry-gd)JjNugRe7dUa%mz_IhN_S$6b2B!d#RV51{w}2;qas}@`Og3U0NA(grvLx| literal 0 HcmV?d00001 diff --git a/src/JobCockpit.py b/src/JobCockpit.py new file mode 100644 index 0000000..a2e4022 --- /dev/null +++ b/src/JobCockpit.py @@ -0,0 +1,121 @@ +#!/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: +# . + + +from Screens.Screen import Screen +from Components.ActionMap import ActionMap +from Components.Sources.StaticText import StaticText +from Components.Sources.List import List +from Components.Task import Job +from enigma import eTimer +from .__init__ import _ +from .Debug import logger +from .JobSupervisor import JobSupervisor + + +class JobCockpit(Screen): + + def __init__(self, session, plugin_id=""): + logger.info("...") + self.plugin_id = plugin_id + self.job_supervisor = JobSupervisor.getInstance() + Screen.__init__(self, session) + self.skinName = "JobCockpit" + self.setTitle(_("Job Management")) + self['actions'] = ActionMap( + ['JOC_Actions'], + { + 'ok': self.exit, + 'cancel': self.exit, + 'red': self.execRed, + 'green': self.execGreen, + 'yellow': self.execYellow, + 'blue': self.execBlue + } + ) + self['key_red'] = StaticText(_('Abort current job')) + self['key_green'] = StaticText(_('Abort all jobs')) + self['key_yellow'] = StaticText(_('Abort all pending jobs')) + self['key_blue'] = StaticText(_('Cleanup jobs')) + self['list'] = List() + self.update_timer = eTimer() + self.update_timer_conn = self.update_timer.timeout.connect(self.updateList) + self.updateList() + + def updateList(self): + logger.info("...") + self.update_timer.stop() + index = self['list'].index + alist = [] + for plugin, job in self.job_supervisor.getPendingJobs(self.plugin_id, as_tuples=True): + alist.append((job.name, job.getStatustext(), job.getProgress(), "%d%%" % job.getProgress(), job, plugin)) + for plugin, job in self.job_supervisor.getFailedJobs(self.plugin_id, as_tuples=True): + alist.append((job.name, job.getStatustext(), job.getProgress(), "%d%%" % job.getProgress(), job, plugin)) + for plugin, job in self.job_supervisor.getSuccessfullJobs(self.plugin_id, as_tuples=True): + alist.append((job.name, job.getStatustext(), job.getProgress(), "%d%%" % job.getProgress(), job, plugin)) + self['list'].setList(alist) + self['list'].setIndex(index) + self.update_timer.startLongTimer(1) + + @staticmethod + def abortJob(job, plugin_id, force=True): + logger.info("force: %s", force) + if job.status == Job.IN_PROGRESS: + JobSupervisor.getInstance().getJobManager(plugin_id).AbortJob(job, force) + + def execYellow(self): + logger.info("...") + self.update_timer.stop() + for entry in self["list"].list: + _name, _status, _progress, _info, job, plugin_id = entry + if job.status == Job.NOT_STARTED: + self.job_supervisor.getJobManager(plugin_id).RemoveJob(job) + self.updateList() + + def execGreen(self): + logger.info("...") + self.update_timer.stop() + for entry in self["list"].list: + _name, _status, _progress, _info, job, plugin_id = entry + self.job_supervisor.getJobManager(plugin_id).AbortJob(job) + self.updateList() + + def execRed(self): + logger.info("...") + self.update_timer.stop() + entry = self["list"].getCurrent() + if entry: + _name, _status, _progress, _info, job, plugin_id = entry + if job.status == Job.IN_PROGRESS: + self.job_supervisor.getJobManager(plugin_id).AbortJob(job) + else: + self.job_supervisor.getJobManager(plugin_id).RemoveJob(job) + self.updateList() + + def execBlue(self): + logger.info("...") + self.update_timer.stop() + for job_manager in self.job_supervisor.job_managers.values(): + job_manager.CleanupJobs() + self.updateList() + + def exit(self): + self.update_timer.stop() + self.close() diff --git a/src/JobSupervisor.py b/src/JobSupervisor.py new file mode 100644 index 0000000..413a7b4 --- /dev/null +++ b/src/JobSupervisor.py @@ -0,0 +1,82 @@ +#!/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: +# . + + +from Components.Task import job_manager, JobManager +from .Debug import logger + + +instance = None + + +class JobSupervisor(): + + def __init__(self): + self.job_managers = {} + self.job_managers["DEFAULT"] = job_manager + + @staticmethod + def getInstance(): + global instance + if instance is None: + instance = JobSupervisor() + return instance + + def getJobManager(self, plugin_id): + logger.info("plugin_id: %s", plugin_id) + if plugin_id not in self.job_managers: + self.job_managers[plugin_id] = JobManager() + return self.job_managers[plugin_id] + + def createJobTuples(self, plugin_id, jobs, as_tuples): + job_tuples = [] + if as_tuples: + for job in jobs: + job_tuples.append((plugin_id, job)) + else: + job_tuples = jobs + return job_tuples + + def getJobManagers(self, plugin_id=""): + job_managers = {} + if plugin_id: + if self.job_managers.get(plugin_id, ""): + job_managers = {plugin_id: self.job_managers.get(plugin_id, "")} + else: + job_managers = self.job_managers + return job_managers + + def getPendingJobs(self, plugin_id="", as_tuples=False): + jobs = [] + for plugin, manager in self.getJobManagers(plugin_id).items(): + jobs += self.createJobTuples(plugin, manager.getPendingJobs(), as_tuples) + return jobs + + def getFailedJobs(self, plugin_id="", as_tuples=False): + jobs = [] + for plugin, manager in self.getJobManagers(plugin_id).items(): + jobs += self.createJobTuples(plugin, manager.getFailedJobs(), as_tuples) + return jobs + + def getSuccessfullJobs(self, plugin_id="", as_tuples=False): + jobs = [] + for plugin, manager in self.getJobManagers(plugin_id).items(): + jobs += self.createJobTuples(plugin, manager.getSuccessfullJobs(), as_tuples) + return jobs diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..e546386 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,4 @@ +installdir = $(libdir)/enigma2/python/Plugins/SystemPlugins/JobCockpit +SUBDIRS = skin +install_PYTHON = *.py +install_DATA = *.xml *.png diff --git a/src/PluginUtils.py b/src/PluginUtils.py new file mode 100644 index 0000000..88945f8 --- /dev/null +++ b/src/PluginUtils.py @@ -0,0 +1,39 @@ +#!/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: +# . + + +from Components.PluginComponent import plugins + + +WHERE_SEARCH = -99 +WHERE_TMDB_SEARCH = -98 +WHERE_TMDB_MOVIELIST = -97 +WHERE_MEDIATHEK_SEARCH = -96 +WHERE_TVMAGAZINE_SEARCH = -95 +WHERE_COVER_DOWNLOAD = -94 +WHERE_JOBCOCKPIT = -93 + + +def getPlugin(where): + plugin = None + plugins_list = plugins.getPlugins(where=where) + if len(plugins_list) > 0: + plugin = plugins_list[0] + return plugin diff --git a/src/SkinUtils.py b/src/SkinUtils.py new file mode 100644 index 0000000..4dfd914 --- /dev/null +++ b/src/SkinUtils.py @@ -0,0 +1,96 @@ +#!/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: +# . + + +import os +from enigma import getDesktop +from Components.config import config +from Tools.Directories import resolveFilename, SCOPE_PLUGINS +from skin import loadSkin, loadSingleSkinData, dom_skins +from .Debug import logger +from .Version import ID, PLUGIN + + +def getSkinName(skin_name): + return ID + skin_name + + +def getScalingFactor(): + return {"HD": 2.0 / 3.0, "FHD": 1, "WQHD": 4.0 / 3.0}[getResolution()] + + +def getResolution(): + height = getDesktop(0).size().height() + resolution = "SD" + if height > 576: + resolution = "HD" + if height > 720: + resolution = "FHD" + if height > 1080: + resolution = "WQHD" + return resolution + + +def getSkinPath(file_name): + logger.debug(">>> file_name: %s", file_name) + base_skin_dir = "/usr/share/enigma2" + sub_skin_dir = os.path.dirname(config.skin.primary_skin.value) + resolution = getResolution() + logger.debug("resolution: %s, sub_skin_dir: %s", resolution, sub_skin_dir) + if not sub_skin_dir: + sub_skin_dir = "Default-HD" + elif resolution == "FHD": + if sub_skin_dir in ["Shadow-FHD", "Zombi-Shadow-FHD"]: + sub_skin_dir = "Shadow-FHD" + else: + sub_skin_dir = "Default-FHD" + elif resolution == "WQHD": + if sub_skin_dir in ["Shadow-WQHD", "Default-WQHD"]: + sub_skin_dir = "Default-WQHD" + else: + sub_skin_dir = "Other-WQHD" + else: + sub_skin_dir = "Default-HD" + + dirs = [ + os.path.join(resolveFilename(SCOPE_PLUGINS), "Extensions", PLUGIN, "skin", sub_skin_dir), + os.path.join(resolveFilename(SCOPE_PLUGINS), "SystemPlugins", PLUGIN, "skin", sub_skin_dir), + os.path.join(resolveFilename(SCOPE_PLUGINS), "Extensions", PLUGIN, "skin"), + os.path.join(resolveFilename(SCOPE_PLUGINS), "SystemPlugins", PLUGIN, "skin"), + os.path.join(base_skin_dir, sub_skin_dir), + base_skin_dir + ] + logger.debug("dirs: %s", dirs) + + for adir in dirs: + skin_path = os.path.join(adir, file_name) + logger.debug("checking: skin_path: %s", skin_path) + if os.path.exists(skin_path): + break + skin_path = "" + logger.debug("skin_path: %s", skin_path) + return skin_path + + +def loadPluginSkin(skin_file): + logger.info("skin_path: %s", getSkinPath(skin_file)) + loadSkin(getSkinPath(skin_file), "") + path, dom_skin = dom_skins[-1:][0] + loadSingleSkinData(getDesktop(0), dom_skin, path) diff --git a/src/Version.py b/src/Version.py new file mode 100644 index 0000000..93507ff --- /dev/null +++ b/src/Version.py @@ -0,0 +1,26 @@ +#!/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: +# . + + +PLUGIN = "JobCockpit" +ID = "JOC" +VERSION = "0.3.20" +COPYRIGHT = "2018-2025 by dream-alpha" +LICENSE = "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." diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e9485a0 --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,45 @@ +#!/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: +# . + + +import os +import gettext +from Components.Language import language +from Tools.Directories import resolveFilename, SCOPE_PLUGINS +from .Version import PLUGIN +from .Debug import initLogging + + +def initLocale(): + os.environ["LANGUAGE"] = language.getLanguage()[:2] + locale = resolveFilename(SCOPE_PLUGINS, "Extensions/" + PLUGIN + "/locale") + if not os.path.exists(locale): + locale = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/" + PLUGIN + "/locale") + if os.path.exists(locale): + gettext.bindtextdomain(PLUGIN, locale) + + +def _(txt): + return gettext.dgettext(PLUGIN, txt) + + +initLogging() +initLocale() +language.addCallback(initLocale) diff --git a/src/keymap.xml b/src/keymap.xml new file mode 100644 index 0000000..734da18 --- /dev/null +++ b/src/keymap.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/locale/de/LC_MESSAGES/JobCockpit.mo b/src/locale/de/LC_MESSAGES/JobCockpit.mo new file mode 100644 index 0000000000000000000000000000000000000000..793195368c9840bb62a3a3f702f3eb5942607d49 GIT binary patch literal 746 zcmZWmOK#La5OpAYWKa+wu>qtOThxv-BqSKI2tz1i=&#zy-s&d)=`@-`32yq&?0=xvy03U%6-+&e1J8%j3 z37iN10B3=vrNLhTFGF7ihyH8e3`l^B(CsmJ;CJB5;1A$);LqSN|0_83|2WjYz-Wz5 z060dcfUskTlLJM^!J%g!+l8@SkWymL6fRoGj&;@Q`e?fBt!3>)DjF*$-FJii&=g`q znrhyMA3?fk&|-d`TC>Ncm%EjG&epX?XTcbo@^#nxc=|Y(W6R`W$a~~D6QgvrF4J2w z-4tt^*~ZQ5=_pN6D4*~_8wMQK#gE8&nOo9MkvBFI6$b4~Qe8tZb=_ktnIo5pe;QRB zPj)9ei*?qLG#(r6vA@jUc38pl8^78qYV~bVHe?<9JJ0g_a%)i+Ui*rz+|i{8KPwYk z1-|Ene88IRu+P+R)p~Iw*+6~}@-8{<$Tyitl2vERh4YljmdzBNOyS1Swo*L*iGqs4 za@nvRax=16wqpIC+q;@)Up_SoelU-8hT9MYTW)n*V^VN&BQsLI*L9F?{tyR45+#2D DKoZ2r literal 0 HcmV?d00001 diff --git a/src/plugin.py b/src/plugin.py new file mode 100644 index 0000000..2763bac --- /dev/null +++ b/src/plugin.py @@ -0,0 +1,69 @@ +#!/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: +# . + + +from Plugins.Plugin import PluginDescriptor +from .SkinUtils import loadPluginSkin +from .Debug import logger +from .Version import VERSION +from .JobCockpit import JobCockpit +from .PluginUtils import WHERE_JOBCOCKPIT +from . import _ +from .JobSupervisor import JobSupervisor + + +def main(session, plugin_id="", **__kwargs): + logger.info("plugin_id: %s", plugin_id) + session.open(JobCockpit, plugin_id) + + +def autoStart(reason, **kwargs): + if reason == 0: # startup + if "session" in kwargs: + logger.info("+++ Version: %s starts...", VERSION) + loadPluginSkin("skin.xml") + JobSupervisor.getInstance() + elif reason == 1: # shutdown + logger.info("--- shutdown") + + +def Plugins(**__kwargs): + return [ + PluginDescriptor( + where=[ + PluginDescriptor.WHERE_AUTOSTART, + PluginDescriptor.WHERE_SESSIONSTART + ], + fnc=autoStart + ), + PluginDescriptor( + name="JobCockpit", + where=PluginDescriptor.WHERE_PLUGINMENU, + icon="JobCockpit.png", + description=_("Manage Jobs"), + fnc=main + ), + PluginDescriptor( + name=_("Jobs"), + description=_("Manage Jobs"), + where=WHERE_JOBCOCKPIT, + fnc=main + ) + ] diff --git a/src/skin/Default-FHD/Makefile.am b/src/skin/Default-FHD/Makefile.am new file mode 100644 index 0000000..116b96d --- /dev/null +++ b/src/skin/Default-FHD/Makefile.am @@ -0,0 +1,2 @@ +installdir = $(libdir)/enigma2/python/Plugins/Extensions/JobCockpit/skin/Default-FHD +install_DATA = skin.xml diff --git a/src/skin/Default-FHD/colors.xmlinc b/src/skin/Default-FHD/colors.xmlinc new file mode 100644 index 0000000..239e7c9 --- /dev/null +++ b/src/skin/Default-FHD/colors.xmlinc @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/skin/Default-FHD/skin.xml b/src/skin/Default-FHD/skin.xml new file mode 100644 index 0000000..dc6688c --- /dev/null +++ b/src/skin/Default-FHD/skin.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + {"template": [ MultiContentEntryText(pos=(10,0),size=(1160,40),flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER,font=0, text=0), MultiContentEntryText(pos=(10,40),size=(200,40),flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER,font=0, text=1), MultiContentEntryProgress(pos=(250,50),size=(800,20),percent=-2, borderWidth=1), MultiContentEntryText(pos=(1060,40),size=(100,40),flags=RT_HALIGN_RIGHT|RT_VALIGN_CENTER,font=0, text=3), ], "fonts": [gFont("Regular",28)], "itemHeight": 80 } + + + diff --git a/src/skin/Default-HD/Makefile.am b/src/skin/Default-HD/Makefile.am new file mode 100644 index 0000000..acccbb4 --- /dev/null +++ b/src/skin/Default-HD/Makefile.am @@ -0,0 +1,2 @@ +installdir = $(libdir)/enigma2/python/Plugins/Extensions/JobCockpit/skin/Default-HD +install_DATA = skin.xml diff --git a/src/skin/Default-HD/colors.xmlinc b/src/skin/Default-HD/colors.xmlinc new file mode 100644 index 0000000..239e7c9 --- /dev/null +++ b/src/skin/Default-HD/colors.xmlinc @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/skin/Default-HD/skin.xml b/src/skin/Default-HD/skin.xml new file mode 100644 index 0000000..c749ee6 --- /dev/null +++ b/src/skin/Default-HD/skin.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + {"template":[MultiContentEntryText(pos=(7,0),size=(773,27),flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER,font=0,text=0),MultiContentEntryText(pos=(7,27),size=(133,27),flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER,font=0,text=1),MultiContentEntryProgress(pos=(167,33),size=(533,13),percent=-2,borderWidth=1),MultiContentEntryText(pos=(707,27),size=(67,27),flags=RT_HALIGN_RIGHT|RT_VALIGN_CENTER,font=0,text=3),],"fonts":[gFont("Regular",19)],"itemHeight":53} + + + diff --git a/src/skin/Default-WQHD/Makefile.am b/src/skin/Default-WQHD/Makefile.am new file mode 100644 index 0000000..137fb3d --- /dev/null +++ b/src/skin/Default-WQHD/Makefile.am @@ -0,0 +1,2 @@ +installdir = $(libdir)/enigma2/python/Plugins/Extensions/JobCockpit/skin/Default-WQHD +install_DATA = skin.xml diff --git a/src/skin/Default-WQHD/colors.xmlinc b/src/skin/Default-WQHD/colors.xmlinc new file mode 100644 index 0000000..23b5d66 --- /dev/null +++ b/src/skin/Default-WQHD/colors.xmlinc @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/skin/Default-WQHD/screen_JobCockpit.xmlinc b/src/skin/Default-WQHD/screen_JobCockpit.xmlinc new file mode 100755 index 0000000..6622f38 --- /dev/null +++ b/src/skin/Default-WQHD/screen_JobCockpit.xmlinc @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/skin/Default-WQHD/skin.xml b/src/skin/Default-WQHD/skin.xml new file mode 100644 index 0000000..8b4de64 --- /dev/null +++ b/src/skin/Default-WQHD/skin.xml @@ -0,0 +1,20 @@ + + + + + + + + + {"template":[MultiContentEntryText(pos=(13,0),size=(1547,53),flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER,font=0,text=0),MultiContentEntryText(pos=(13,53),size=(267,53),flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER,font=0,text=1),MultiContentEntryProgress(pos=(333,67),size=(1067,27),percent=-2,borderWidth=1),MultiContentEntryText(pos=(1413,53),size=(133,53),flags=RT_HALIGN_RIGHT|RT_VALIGN_CENTER,font=0,text=3),],"fonts":[gFont("Regular",37)],"itemHeight":107} + + + + + + + + + + + diff --git a/src/skin/Makefile.am b/src/skin/Makefile.am new file mode 100644 index 0000000..43f5e1c --- /dev/null +++ b/src/skin/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = Default-HD Default-FHD Default-WQHD Other-WQHD Shadow-FHD diff --git a/src/skin/Other-WQHD/Makefile.am b/src/skin/Other-WQHD/Makefile.am new file mode 100644 index 0000000..137fb3d --- /dev/null +++ b/src/skin/Other-WQHD/Makefile.am @@ -0,0 +1,2 @@ +installdir = $(libdir)/enigma2/python/Plugins/Extensions/JobCockpit/skin/Default-WQHD +install_DATA = skin.xml diff --git a/src/skin/Other-WQHD/colors.xmlinc b/src/skin/Other-WQHD/colors.xmlinc new file mode 100644 index 0000000..88b18fa --- /dev/null +++ b/src/skin/Other-WQHD/colors.xmlinc @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/skin/Other-WQHD/skin.xml b/src/skin/Other-WQHD/skin.xml new file mode 100644 index 0000000..38a6c0a --- /dev/null +++ b/src/skin/Other-WQHD/skin.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + {"template":[MultiContentEntryText(pos=(13,0),size=(1547,53),flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER,font=0,text=0),MultiContentEntryText(pos=(13,53),size=(267,53),flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER,font=0,text=1),MultiContentEntryProgress(pos=(333,67),size=(1067,27),percent=-2,borderWidth=1),MultiContentEntryText(pos=(1413,53),size=(133,53),flags=RT_HALIGN_RIGHT|RT_VALIGN_CENTER,font=0,text=3),],"fonts":[gFont("Regular",37)],"itemHeight":107} + + + diff --git a/src/skin/Shadow-FHD/Makefile.am b/src/skin/Shadow-FHD/Makefile.am new file mode 100644 index 0000000..c91f46e --- /dev/null +++ b/src/skin/Shadow-FHD/Makefile.am @@ -0,0 +1,2 @@ +installdir = $(libdir)/enigma2/python/Plugins/Extensions/JobCockpit/skin/Shadow-FHD +install_DATA = skin.xml diff --git a/src/skin/Shadow-FHD/colors.xmlinc b/src/skin/Shadow-FHD/colors.xmlinc new file mode 100644 index 0000000..218bc31 --- /dev/null +++ b/src/skin/Shadow-FHD/colors.xmlinc @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/skin/Shadow-FHD/screen_JobCockpit.xmlinc b/src/skin/Shadow-FHD/screen_JobCockpit.xmlinc new file mode 100755 index 0000000..a97e581 --- /dev/null +++ b/src/skin/Shadow-FHD/screen_JobCockpit.xmlinc @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/skin/Shadow-FHD/skin.xml b/src/skin/Shadow-FHD/skin.xml new file mode 100644 index 0000000..7f9cef2 --- /dev/null +++ b/src/skin/Shadow-FHD/skin.xml @@ -0,0 +1,20 @@ + + + + + + + + + {"template": [ MultiContentEntryText(pos=(10,0),size=(1160,40),flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER,font=0, text=0), MultiContentEntryText(pos=(10,40),size=(200,40),flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER,font=0, text=1), MultiContentEntryProgress(pos=(250,50),size=(800,20),percent=-2, borderWidth=1), MultiContentEntryText(pos=(1060,40),size=(100,40),flags=RT_HALIGN_RIGHT|RT_VALIGN_CENTER,font=0, text=3), ], "fonts": [gFont("Regular",28)], "itemHeight": 80 } + + + + + + + + + + + diff --git a/src/skin/screen_JobCockpit.xmlinc b/src/skin/screen_JobCockpit.xmlinc new file mode 100755 index 0000000..1c64d40 --- /dev/null +++ b/src/skin/screen_JobCockpit.xmlinc @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/skin/screenpart_1Button_icon.xmlinc b/src/skin/screenpart_1Button_icon.xmlinc new file mode 100644 index 0000000..7fdff5f --- /dev/null +++ b/src/skin/screenpart_1Button_icon.xmlinc @@ -0,0 +1 @@ + diff --git a/src/skin/screenpart_1Button_source_2x.xmlinc b/src/skin/screenpart_1Button_source_2x.xmlinc new file mode 100644 index 0000000..9ce9b2c --- /dev/null +++ b/src/skin/screenpart_1Button_source_2x.xmlinc @@ -0,0 +1 @@ + diff --git a/src/skin/screenpart_4Buttons_icon.xmlinc b/src/skin/screenpart_4Buttons_icon.xmlinc new file mode 100644 index 0000000..3494407 --- /dev/null +++ b/src/skin/screenpart_4Buttons_icon.xmlinc @@ -0,0 +1,4 @@ + + + + diff --git a/src/skin/screenpart_4Buttons_source_2x.xmlinc b/src/skin/screenpart_4Buttons_source_2x.xmlinc new file mode 100644 index 0000000..3fb5b29 --- /dev/null +++ b/src/skin/screenpart_4Buttons_source_2x.xmlinc @@ -0,0 +1,5 @@ + + + + + diff --git a/src/skin/screenpart_Background.xmlinc b/src/skin/screenpart_Background.xmlinc new file mode 100644 index 0000000..73bed6f --- /dev/null +++ b/src/skin/screenpart_Background.xmlinc @@ -0,0 +1,3 @@ + + + diff --git a/src/skin/screenpart_JobCockpitList.xmlinc b/src/skin/screenpart_JobCockpitList.xmlinc new file mode 100755 index 0000000..d1c7b96 --- /dev/null +++ b/src/skin/screenpart_JobCockpitList.xmlinc @@ -0,0 +1,13 @@ + + + {"template": [ + MultiContentEntryText(pos=(10,0),size=(eval($screen_width-40),40),flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER,font=0, text=0), + MultiContentEntryText(pos=(10,40),size=(200,40),flags=RT_HALIGN_LEFT|RT_VALIGN_CENTER,font=0, text=1), + MultiContentEntryProgress(pos=(250,50),size=(800,20),percent=-2, borderWidth=1), + MultiContentEntryText(pos=(1060,40),size=(100,40),flags=RT_HALIGN_RIGHT|RT_VALIGN_CENTER,font=0, text=3), + ], + "fonts": [gFont("Regular",28)], + "itemHeight": 80 + } + + diff --git a/src/skin/screenpart_TitleOnly.xmlinc b/src/skin/screenpart_TitleOnly.xmlinc new file mode 100644 index 0000000..8360b2d --- /dev/null +++ b/src/skin/screenpart_TitleOnly.xmlinc @@ -0,0 +1 @@ + diff --git a/src/skin/skin_src.xml b/src/skin/skin_src.xml new file mode 100755 index 0000000..c8f88e7 --- /dev/null +++ b/src/skin/skin_src.xml @@ -0,0 +1,4 @@ + + + +