mirror of
				https://github.com/gutosie/neoboot.git
				synced 2025-10-31 19:35:48 +01:00 
			
		
		
		
	Add files via upload
This commit is contained in:
		
							
								
								
									
										1057
									
								
								NeoBoot/files/Harddisk.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1057
									
								
								NeoBoot/files/Harddisk.py
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								NeoBoot/files/Harddisk.pyo
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								NeoBoot/files/Harddisk.pyo
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										522
									
								
								NeoBoot/files/Task.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										522
									
								
								NeoBoot/files/Task.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,522 @@ | |||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  |  | ||||||
|  | from Tools.CList import CList | ||||||
|  |  | ||||||
|  | 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 | ||||||
|  |         self.onSuccess = None | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |     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] ]) | ||||||
|  |         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] | ||||||
|  |  | ||||||
|  |     def task_progress_changed_CB(self): | ||||||
|  |         self.state_changed() | ||||||
|  |  | ||||||
|  |     def addTask(self, task): | ||||||
|  |         task.job = self | ||||||
|  |         task.task_progress_changed = self.task_progress_changed_CB | ||||||
|  |         self.tasks.append(task) | ||||||
|  |  | ||||||
|  |     def start(self, callback): | ||||||
|  |         self.callback = callback | ||||||
|  |         self.restart() | ||||||
|  |  | ||||||
|  |     def restart(self): | ||||||
|  |         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): | ||||||
|  |         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 ("still waiting for %d resident task(s) %s to finish") % (len(self.resident_tasks), str(self.resident_tasks)) | ||||||
|  |         else: | ||||||
|  |             self.tasks[self.current_task].run(self.taskCallback) | ||||||
|  |             self.state_changed() | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |     def taskCallback(self, task, res, stay_resident = False): | ||||||
|  |         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 ("task going resident:"), task | ||||||
|  |             else: | ||||||
|  |                 print ("task keeps staying resident:"), task | ||||||
|  |                 return | ||||||
|  |         if len(res): | ||||||
|  |             print (">>> 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 ("resident task finished:"), task | ||||||
|  |                 self.resident_tasks.remove(cb_idx) | ||||||
|  |         if res == []: | ||||||
|  |             self.state_changed() | ||||||
|  |             self.current_task += 1 | ||||||
|  |             self.runNext() | ||||||
|  |  | ||||||
|  |     def retry(self): | ||||||
|  |         self.restart() | ||||||
|  |  | ||||||
|  |     def abort(self): | ||||||
|  |         if self.current_task < len(self.tasks): | ||||||
|  |             self.tasks[self.current_task].abort() | ||||||
|  |         for i in self.resident_tasks: | ||||||
|  |             self.tasks[i].abort() | ||||||
|  |  | ||||||
|  |     def cancel(self): | ||||||
|  |         self.abort() | ||||||
|  |  | ||||||
|  |     def __str__(self): | ||||||
|  |         return 'Components.Task.Job name=%s #tasks=%s' % (self.name, len(self.tasks)) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 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 | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |     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): | ||||||
|  |         if self.cmd is None and self.cmdline is None: | ||||||
|  |             self.finish() | ||||||
|  |             return | ||||||
|  |         else: | ||||||
|  |             from enigma import eConsoleAppContainer | ||||||
|  |             self.container = eConsoleAppContainer() | ||||||
|  |             self.container.appClosed.append(self.processFinished) | ||||||
|  |             self.container.stdoutAvail.append(self.processStdout) | ||||||
|  |             self.container.stderrAvail.append(self.processStderr) | ||||||
|  |             if self.cwd is not None: | ||||||
|  |                 self.container.setCWD(self.cwd) | ||||||
|  |             if not self.cmd and self.cmdline: | ||||||
|  |                 print ("execute:"), self.container.execute(self.cmdline), self.cmdline | ||||||
|  |             else: | ||||||
|  |                 print ("execute:"), self.container.execute(self.cmd, *self.args), ' '.join(self.args) | ||||||
|  |             if self.initial_input: | ||||||
|  |                 self.writeInput(self.initial_input) | ||||||
|  |             return | ||||||
|  |             return | ||||||
|  |  | ||||||
|  |     def run(self, callback): | ||||||
|  |         failed_preconditions = self.checkPreconditions(True) + self.checkPreconditions(False) | ||||||
|  |         if failed_preconditions: | ||||||
|  |             print ("[Task] preconditions failed") | ||||||
|  |             callback(self, failed_preconditions) | ||||||
|  |             return | ||||||
|  |         self.callback = callback | ||||||
|  |         try: | ||||||
|  |             self.prepare() | ||||||
|  |             self._run() | ||||||
|  |         except Exception as ex: | ||||||
|  |             print ("[Task] exception:"), ex | ||||||
|  |             self.postconditions = [FailedPostcondition(ex)] | ||||||
|  |             self.finish() | ||||||
|  |  | ||||||
|  |     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): | ||||||
|  |         print ("[Task %s]") % self.name, line[:-1] | ||||||
|  |  | ||||||
|  |     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, input): | ||||||
|  |         self.container.write(input) | ||||||
|  |  | ||||||
|  |     def getProgress(self): | ||||||
|  |         return self.__progress | ||||||
|  |  | ||||||
|  |     def setProgress(self, 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() | ||||||
|  |  | ||||||
|  |     progress = property(getProgress, setProgress) | ||||||
|  |  | ||||||
|  |     def __str__(self): | ||||||
|  |         return 'Components.Task.Task name=%s' % self.name | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class LoggingTask(Task): | ||||||
|  |  | ||||||
|  |     def __init__(self, job, name): | ||||||
|  |         Task.__init__(self, job, name) | ||||||
|  |         self.log = [] | ||||||
|  |  | ||||||
|  |     def processOutput(self, data): | ||||||
|  |         print ("[%s]") % self.name, data, | ||||||
|  |         self.log.append(data) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class PythonTask(Task): | ||||||
|  |  | ||||||
|  |     def _run(self): | ||||||
|  |         from twisted.internet import threads | ||||||
|  |         from enigma import eTimer | ||||||
|  |         self.aborted = False | ||||||
|  |         self.pos = 0 | ||||||
|  |         threads.deferToThread(self.work).addBoth(self.onComplete) | ||||||
|  |         self.timer = eTimer() | ||||||
|  |         self.timer.callback.append(self.onTimer) | ||||||
|  |         self.timer.start(5) | ||||||
|  |  | ||||||
|  |     def work(self): | ||||||
|  |         raise (NotImplemented, "work") | ||||||
|  |  | ||||||
|  |     def abort(self): | ||||||
|  |         self.aborted = True | ||||||
|  |         if self.callback is None: | ||||||
|  |             self.finish(aborted=True) | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |     def onTimer(self): | ||||||
|  |         self.setProgress(self.pos) | ||||||
|  |  | ||||||
|  |     def onComplete(self, result): | ||||||
|  |         self.postconditions.append(FailedPostcondition(result)) | ||||||
|  |         self.timer.stop() | ||||||
|  |         del self.timer | ||||||
|  |         self.finish() | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class ConditionTask(Task): | ||||||
|  |  | ||||||
|  |     def __init__(self, job, name, timeoutCount = None): | ||||||
|  |         Task.__init__(self, job, name) | ||||||
|  |         self.timeoutCount = timeoutCount | ||||||
|  |  | ||||||
|  |     def _run(self): | ||||||
|  |         self.triggerCount = 0 | ||||||
|  |  | ||||||
|  |     def prepare(self): | ||||||
|  |         from enigma import eTimer | ||||||
|  |         self.timer = eTimer() | ||||||
|  |         self.timer.callback.append(self.trigger) | ||||||
|  |         self.timer.start(1000) | ||||||
|  |  | ||||||
|  |     def cleanup(self, failed): | ||||||
|  |         if hasattr(self, 'timer'): | ||||||
|  |             self.timer.stop() | ||||||
|  |             del self.timer | ||||||
|  |  | ||||||
|  |     def check(self): | ||||||
|  |         return True | ||||||
|  |  | ||||||
|  |     def trigger(self): | ||||||
|  |         self.triggerCount += 1 | ||||||
|  |         try: | ||||||
|  |             if self.timeoutCount is not None and self.triggerCount > self.timeoutCount: | ||||||
|  |                 raise (Exception, "Timeout elapsed, sorry") | ||||||
|  |             res = self.check() | ||||||
|  |         except Exception as e: | ||||||
|  |             self.postconditions.append(FailedPostcondition(e)) | ||||||
|  |             res = True | ||||||
|  |  | ||||||
|  |         if res: | ||||||
|  |             self.finish() | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class JobManager: | ||||||
|  |  | ||||||
|  |     def __init__(self): | ||||||
|  |         self.active_jobs = [] | ||||||
|  |         self.failed_jobs = [] | ||||||
|  |         self.job_classes = [] | ||||||
|  |         self.in_background = False | ||||||
|  |         self.visible = False | ||||||
|  |         self.active_job = None | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |     def AddJob(self, job, onSuccess = None, onFail = None): | ||||||
|  |         job.onSuccess = onSuccess | ||||||
|  |         if onFail is None: | ||||||
|  |             job.onFail = self.notifyFailed | ||||||
|  |         else: | ||||||
|  |             job.onFail = onFail | ||||||
|  |         self.active_jobs.append(job) | ||||||
|  |         self.kick() | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |     def kick(self): | ||||||
|  |         if self.active_job is None: | ||||||
|  |             if self.active_jobs: | ||||||
|  |                 self.active_job = self.active_jobs.pop(0) | ||||||
|  |                 self.active_job.start(self.jobDone) | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |     def notifyFailed(self, job, task, problems): | ||||||
|  |         from Tools import Notifications | ||||||
|  |         from Screens.MessageBox import MessageBox | ||||||
|  |         if problems[0].RECOVERABLE: | ||||||
|  |             Notifications.AddNotificationWithCallback(self.errorCB, MessageBox, _('Error: %s\nRetry?') % problems[0].getErrorMessage(task)) | ||||||
|  |             return True | ||||||
|  |         else: | ||||||
|  |             Notifications.AddNotification(MessageBox, job.name + '\n' + _('Error') + ': %s' % problems[0].getErrorMessage(task), type=MessageBox.TYPE_ERROR) | ||||||
|  |             return False | ||||||
|  |  | ||||||
|  |     def jobDone(self, job, task, problems): | ||||||
|  |         print ("job"), job, ("completed with"), problems, ("in"), task | ||||||
|  |         if problems: | ||||||
|  |             if not job.onFail(job, task, problems): | ||||||
|  |                 self.errorCB(False) | ||||||
|  |         else: | ||||||
|  |             self.active_job = None | ||||||
|  |             if job.onSuccess: | ||||||
|  |                 job.onSuccess(job) | ||||||
|  |             self.kick() | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |     def popupTaskView(self, job): | ||||||
|  |         if not self.visible: | ||||||
|  |             from Tools import Notifications | ||||||
|  |             from Screens.TaskView import JobView | ||||||
|  |             self.visible = True | ||||||
|  |             Notifications.AddNotification(JobView, job) | ||||||
|  |  | ||||||
|  |     def errorCB(self, answer): | ||||||
|  |         if answer: | ||||||
|  |             print ("retrying job") | ||||||
|  |             self.active_job.retry() | ||||||
|  |         else: | ||||||
|  |             print ("not retrying job.") | ||||||
|  |             self.failed_jobs.append(self.active_job) | ||||||
|  |             self.active_job = None | ||||||
|  |             self.kick() | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |     def getPendingJobs(self): | ||||||
|  |         list = [] | ||||||
|  |         if self.active_job: | ||||||
|  |             list.append(self.active_job) | ||||||
|  |         list += self.active_jobs | ||||||
|  |         return list | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class Condition: | ||||||
|  |     RECOVERABLE = False | ||||||
|  |  | ||||||
|  |     def getErrorMessage(self, task): | ||||||
|  |         return _('An unknown error occurred!') + ' (%s @ task %s)' % (self.__class__.__name__, task.__class__.__name__) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class WorkspaceExistsPrecondition(Condition): | ||||||
|  |  | ||||||
|  |     def check(self, task): | ||||||
|  |         return os.access(task.job.workspace, os.W_OK) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class DiskspacePrecondition(Condition): | ||||||
|  |  | ||||||
|  |     def __init__(self, diskspace_required): | ||||||
|  |         self.diskspace_required = diskspace_required | ||||||
|  |         self.diskspace_available = 0 | ||||||
|  |  | ||||||
|  |     def check(self, task): | ||||||
|  |         import os | ||||||
|  |         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 disk space. Please free up some disk space and try again. (%d MB required, %d MB available)') % (self.diskspace_required / 1024 / 1024, self.diskspace_available / 1024 / 1024) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class ToolExistsPrecondition(Condition): | ||||||
|  |  | ||||||
|  |     def check(self, task): | ||||||
|  |         import os | ||||||
|  |         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 absolutes: | ||||||
|  |             self.realpath = absolutes[0] | ||||||
|  |             return True | ||||||
|  |         return False | ||||||
|  |  | ||||||
|  |     def getErrorMessage(self, task): | ||||||
|  |         return _('A required tool (%s) was not found.') % self.realpath | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class AbortedPostcondition(Condition): | ||||||
|  |  | ||||||
|  |     def getErrorMessage(self, task): | ||||||
|  |         return 'Cancelled upon user request' | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class ReturncodePostcondition(Condition): | ||||||
|  |  | ||||||
|  |     def check(self, task): | ||||||
|  |         return task.returncode == 0 | ||||||
|  |  | ||||||
|  |     def getErrorMessage(self, task): | ||||||
|  |         if hasattr(task, 'log') and task.log: | ||||||
|  |             log = ''.join(task.log).strip() | ||||||
|  |             log = log.split('\n')[-3:] | ||||||
|  |             log = '\n'.join(log) | ||||||
|  |             return log | ||||||
|  |         else: | ||||||
|  |             return _('Error code') + ': %s' % task.returncode | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class FailedPostcondition(Condition): | ||||||
|  |  | ||||||
|  |     def __init__(self, exception): | ||||||
|  |         self.exception = exception | ||||||
|  |  | ||||||
|  |     def getErrorMessage(self, task): | ||||||
|  |         if isinstance(self.exception, int): | ||||||
|  |             if hasattr(task, 'log'): | ||||||
|  |                 log = ''.join(task.log).strip() | ||||||
|  |                 log = log.split('\n')[-4:] | ||||||
|  |                 log = '\n'.join(log) | ||||||
|  |                 return log | ||||||
|  |             else: | ||||||
|  |                 return _('Error code') + ' %s' % self.exception | ||||||
|  |         return str(self.exception) | ||||||
|  |  | ||||||
|  |     def check(self, task): | ||||||
|  |         return self.exception is None or self.exception == 0 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | job_manager = JobManager() | ||||||
							
								
								
									
										26
									
								
								NeoBoot/files/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								NeoBoot/files/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | |||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  |  | ||||||
|  | from __future__ import print_function | ||||||
|  | from Components.Language import language | ||||||
|  | from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE | ||||||
|  | import os, gettext | ||||||
|  | PluginLanguageDomain = 'NeoBoot' | ||||||
|  | PluginLanguagePath = 'Extensions/NeoBoot/locale' | ||||||
|  |  | ||||||
|  | def localeInit(): | ||||||
|  |     lang = language.getLanguage()[:2] | ||||||
|  |     os.environ['LANGUAGE'] = lang | ||||||
|  |     print ("[NeoBoot] set language to "), lang | ||||||
|  |     gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath)) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def _(txt): | ||||||
|  |     t = gettext.dgettext(PluginLanguageDomain, txt) | ||||||
|  |     if t == txt: | ||||||
|  |         print ("[NeoBoot] fallback to default translation for"), txt | ||||||
|  |         t = gettext.dgettext('enigma2', txt) | ||||||
|  |     return t | ||||||
|  |  | ||||||
|  |  | ||||||
|  | localeInit() | ||||||
|  | language.addCallback(localeInit) | ||||||
							
								
								
									
										
											BIN
										
									
								
								NeoBoot/files/__init__.pyo
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								NeoBoot/files/__init__.pyo
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										714
									
								
								NeoBoot/files/devices.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										714
									
								
								NeoBoot/files/devices.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,714 @@ | |||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  |   | ||||||
|  | from Plugins.Extensions.NeoBoot.__init__ import _  | ||||||
|  | from enigma import getDesktop | ||||||
|  | from Plugins.Plugin import PluginDescriptor | ||||||
|  | from Screens.ChoiceBox import ChoiceBox | ||||||
|  | from Screens.InputBox import InputBox | ||||||
|  | from Screens.Screen import Screen | ||||||
|  | from Screens.MessageBox import MessageBox | ||||||
|  | from Screens.Standby import TryQuitMainloop | ||||||
|  | from enigma import eTimer | ||||||
|  | from Components.ActionMap import ActionMap, NumberActionMap | ||||||
|  | from Components.Button import Button | ||||||
|  | from Components.Label import Label | ||||||
|  | from Components.MenuList import MenuList | ||||||
|  | from Components.Pixmap import Pixmap | ||||||
|  | from Components.ConfigList import ConfigListScreen | ||||||
|  | from Components.config import getConfigListEntry, config, ConfigSelection, NoSave, configfile | ||||||
|  | from Components.Console import Console | ||||||
|  | from Components.Sources.List import List | ||||||
|  | from Components.Sources.StaticText import StaticText | ||||||
|  | from commands import getoutput | ||||||
|  | from Plugins.Extensions.NeoBoot.files.Harddisk import Harddisk | ||||||
|  | from Tools.LoadPixmap import LoadPixmap | ||||||
|  | from Tools.Directories import fileExists, resolveFilename, SCOPE_CURRENT_SKIN | ||||||
|  | from os import system, rename, path, mkdir, remove, listdir | ||||||
|  | from time import sleep | ||||||
|  | import fileinput | ||||||
|  | import re | ||||||
|  | import os | ||||||
|  | from Screens.VirtualKeyBoard import VirtualKeyBoard | ||||||
|  | import gettext, os | ||||||
|  | from Plugins.Extensions.NeoBoot.files.stbbranding import getTunerModel  | ||||||
|  | LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot' | ||||||
|  |  | ||||||
|  |      | ||||||
|  | class ManagerDevice(Screen): | ||||||
|  |     screenwidth = getDesktop(0).size().width() | ||||||
|  |     if screenwidth and screenwidth == 1920: | ||||||
|  |  | ||||||
|  |         skin = """<screen name="ManagerDevice" position="400,150" size="1235,748"> | ||||||
|  |             <widget name="key_red" position="14,17" zPosition="1" size="271,49" font="dugme;30" halign="center" valign="center" backgroundColor="red" transparent="1"   foregroundColor="red" /> | ||||||
|  |             <widget name="key_green" position="289,17" zPosition="1" size="369,49" font="dugme;30" halign="center" valign="center" backgroundColor="green" transparent="1"   foregroundColor="green" /> | ||||||
|  |             <widget name="key_yellow" position="661,17" zPosition="1" size="302,49" font="dugme;30" halign="center" valign="center" backgroundColor="yellow" transparent="1"   foregroundColor="yellow" /> | ||||||
|  |             <widget name="key_blue" position="967,17" zPosition="1" size="257,49" font="dugme;30" halign="center" valign="center" backgroundColor="blue" transparent="1"   foregroundColor="blue" />                                                                                                                               | ||||||
|  |             <eLabel position="18,70" size="1204,2" backgroundColor="blue" foregroundColor="blue" name="linia" /> | ||||||
|  |             <eLabel position="18,670" size="1204,2" backgroundColor="blue" foregroundColor="blue" name="linia" /> | ||||||
|  |             <eLabel backgroundColor="black" font="dugme; 30" foregroundColor="orange" position="536,674" size="197,56" text="Exit - Back" transparent="1" /> | ||||||
|  |             <widget source="list" render="Listbox" position="14,137" size="1210,530" scrollbarMode="showOnDemand"> | ||||||
|  |             <convert type="TemplatedMultiContent">\n\n\t\t\t\t{"template": [\n\n\t\t\t\t MultiContentEntryText(pos = (90, 5), size = (600, 75), font=0, text = 0),\n\n\t\t\t\t MultiContentEntryText(pos = (110, 60), size = (900, 80), font=1, flags = RT_VALIGN_TOP, text = 1),\n\n\t\t\t\t MultiContentEntryPixmapAlphaBlend(pos = (0, 0), size = (150, 130,)),\n\n\t\t\t\t],\n\t\t\t\t"fonts": [gFont("Regular", 33),gFont("Regular", 33)],\n\n\t\t\t\t"itemHeight": 140\n\t\t\t\t}</convert> | ||||||
|  |             </widget> | ||||||
|  |             <widget name="lab1" zPosition="2" position="28,163" size="1182,69" font="baslk;30" halign="center" transparent="1" /> | ||||||
|  |             </screen>""" | ||||||
|  |     else: | ||||||
|  |         skin = """<screen name="ManagerDevice" position="center,center" size="752,460"> | ||||||
|  |         <eLabel backgroundColor="black" font="Regular; 30" foregroundColor="orange" position="315,405" size="169,51" text="Exit - Back" transparent="1" />         | ||||||
|  |         <widget name="key_red" position="21,0" zPosition="1" size="151,47" font="Regular;20" halign="center" valign="center" backgroundColor="red" transparent="1" foregroundColor="red" /> | ||||||
|  |         <widget name="key_green" position="216,0" zPosition="1" size="140,47" font="Regular;20" halign="center" valign="center" backgroundColor="green" transparent="1" foregroundColor="green" /> | ||||||
|  |         <widget name="key_yellow" position="400,0" zPosition="1" size="140,47" font="Regular;20" halign="center" valign="center" backgroundColor="yellow" transparent="1" foregroundColor="yellow" />        | ||||||
|  |         <widget name="key_blue" position="587,0" zPosition="1" size="149,46" font="Regular;20" halign="center" valign="center" backgroundColor="blue" transparent="1" foregroundColor="blue" /> | ||||||
|  |         <widget source="list" render="Listbox" position="18,63" size="721,341" scrollbarMode="showOnDemand"> | ||||||
|  |         <convert type="TemplatedMultiContent">\n\t\t\t\t{"template": [\n\t\t\t\t MultiContentEntryText(pos = (90, 0), size = (600, 30), font=0, text = 0),\n\t\t\t\t MultiContentEntryText(pos = (110, 30), size = (600, 50), font=1, flags = RT_VALIGN_TOP, text = 1),\n\t\t\t\t MultiContentEntryPixmapAlphaBlend(pos = (0, 0), size = (80, 80)),\n\t\t\t\t],\n\t\t\t\t"fonts": [gFont("Regular", 24),gFont("Regular", 20)],\n\t\t\t\t"itemHeight": 85\n\t\t\t\t}\n\t\t\t</convert> | ||||||
|  |         </widget> | ||||||
|  |         <widget name="lab1" zPosition="2" position="29,111" size="699,40" font="Regular;22" halign="center" transparent="1" /> | ||||||
|  |         </screen>""" | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     def __init__(self, session): | ||||||
|  |         Screen.__init__(self, session) | ||||||
|  |         Screen.setTitle(self, _('Mount Manager')) | ||||||
|  |         self['key_red'] = Label(_('Initialize ext3')) | ||||||
|  |         self['key_green'] = Label(_('SetupMounts')) | ||||||
|  |         self['key_yellow'] = Label(_('Initialize ext4')) | ||||||
|  |         self['key_blue'] = Label(_('Exit')) | ||||||
|  |         self['lab1'] = Label() | ||||||
|  |         self.onChangedEntry = [] | ||||||
|  |         self.list = [] | ||||||
|  |         self['list'] = List(self.list) | ||||||
|  |         self['list'].onSelectionChanged.append(self.selectionChanged) | ||||||
|  |         self['actions'] = ActionMap(['WizardActions', 'ColorActions', 'MenuActions'], {'back': self.close, | ||||||
|  |          'red': self.Format_ext3, | ||||||
|  |          'green': self.SetupMounts, | ||||||
|  |          'yellow': self.Format_ext4, | ||||||
|  |          'blue': self.ExitBack, | ||||||
|  |          'back': self.close}) | ||||||
|  |         self.activityTimer = eTimer() | ||||||
|  |         self.activityTimer.timeout.get().append(self.updateList2) | ||||||
|  |         self.updateList() | ||||||
|  |         self.onShown.append(self.setWindowTitle) | ||||||
|  |  | ||||||
|  |     def Format_ext3(self): | ||||||
|  |         try: | ||||||
|  |             if fileExists('/etc/vtiversion.info') or fileExists('/etc/bhversion'):                     | ||||||
|  |                 self.session.open(MessageBox, _("This option is available only from openpli or derivatives."), MessageBox.TYPE_INFO, timeout=10) | ||||||
|  |             else: | ||||||
|  |                 from Harddisk import HarddiskSelection | ||||||
|  |                 self.session.openWithCallback(self.updateList, HarddiskSelection) | ||||||
|  |         except: | ||||||
|  |             self.session.open(MessageBox, _("This option is available only from openpli or derivatives."), MessageBox.TYPE_INFO, timeout=10) | ||||||
|  |  | ||||||
|  |     def Format_ext4(self): | ||||||
|  |         from Screens.HarddiskSetup import HarddiskSelection | ||||||
|  |         self.session.openWithCallback(self.updateList, HarddiskSelection) | ||||||
|  |  | ||||||
|  |     def ExitBack(self): | ||||||
|  |         self.close()     | ||||||
|  |  | ||||||
|  |     def setWindowTitle(self): | ||||||
|  |         self.setTitle(_('Mount Manager')) | ||||||
|  |  | ||||||
|  |     def createSummary(self): | ||||||
|  |         return DeviceManagerSummary | ||||||
|  |  | ||||||
|  |     def selectionChanged(self): | ||||||
|  |         if len(self.list) == 0: | ||||||
|  |             return | ||||||
|  |         self.sel = self['list'].getCurrent() | ||||||
|  |         seldev = self.sel | ||||||
|  |         if self.sel: | ||||||
|  |             try: | ||||||
|  |                 name = str(self.sel[0]) | ||||||
|  |                 desc = str(self.sel[1].replace('\t', '  ')) | ||||||
|  |             except: | ||||||
|  |                 name = '' | ||||||
|  |                 desc = '' | ||||||
|  |         else: | ||||||
|  |             name = '' | ||||||
|  |             desc = '' | ||||||
|  |         for cb in self.onChangedEntry: | ||||||
|  |             cb(name, desc) | ||||||
|  |  | ||||||
|  |     def updateList(self, result = None, retval = None, extra_args = None): | ||||||
|  |         scanning = _('Wait please while scanning for devices...') | ||||||
|  |         self['lab1'].setText(scanning) | ||||||
|  |         self.activityTimer.start(10) | ||||||
|  |  | ||||||
|  |     def updateList2(self): | ||||||
|  |         self.activityTimer.stop() | ||||||
|  |         self.list = [] | ||||||
|  |         list2 = [] | ||||||
|  |         f = open('/proc/partitions', 'r') | ||||||
|  |         for line in f.readlines(): | ||||||
|  |             parts = line.strip().split() | ||||||
|  |             if not parts: | ||||||
|  |                 continue | ||||||
|  |             device = parts[3] | ||||||
|  |             if not re.search('sd[a-z][1-9]', device): | ||||||
|  |                 continue | ||||||
|  |             if device in list2: | ||||||
|  |                 continue | ||||||
|  |             self.buildMy_rec(device) | ||||||
|  |             list2.append(device) | ||||||
|  |  | ||||||
|  |         f.close() | ||||||
|  |         self['list'].list = self.list | ||||||
|  |         self['lab1'].hide() | ||||||
|  |  | ||||||
|  |     def buildMy_rec(self, device): | ||||||
|  |         mypath = SkinPath() | ||||||
|  |         device2 = re.sub('[0-9]', '', device) | ||||||
|  |         devicetype = path.realpath('/sys/block/' + device2 + '/device') | ||||||
|  |         d2 = device | ||||||
|  |         name = _('HARD DISK: ')         | ||||||
|  |         mypixmap = '' + LinkNeoBoot + '/images/dev_hdd.png' | ||||||
|  |         model = file('/sys/block/' + device2 + '/device/model').read() | ||||||
|  |         model = str(model).replace('\n', '') | ||||||
|  |         des = '' | ||||||
|  |         if devicetype.find('usb') != -1: | ||||||
|  |             name = _('USB: ') | ||||||
|  |             mypixmap = '' + LinkNeoBoot + '/images/dev_usb.png' | ||||||
|  |         if devicetype.find('usb1') != -1: | ||||||
|  |             name = _('USB1: ') | ||||||
|  |             mypixmap = '' + LinkNeoBoot + '/images/dev_usb.png'    | ||||||
|  |         if devicetype.find('usb2') != -1: | ||||||
|  |             name = _('USB2: ') | ||||||
|  |             mypixmap = '' + LinkNeoBoot + '/images/dev_usb.png'                       | ||||||
|  |         if devicetype.find('card') != -1: | ||||||
|  |             name = _('CARD: ') | ||||||
|  |             mypixmap = '' + LinkNeoBoot + '/images/dev_sd.png'  | ||||||
|  |  | ||||||
|  |         name = name + model | ||||||
|  |         self.Console = Console() | ||||||
|  |         self.Console.ePopen("sfdisk -l /dev/sd? | grep swap | awk '{print $(NF-9)}' >/tmp/devices.tmp") | ||||||
|  |         sleep(0.5) | ||||||
|  |         f = open('/tmp/devices.tmp', 'r') | ||||||
|  |         swapdevices = f.read() | ||||||
|  |         f.close() | ||||||
|  |         if path.exists('/tmp/devices.tmp'): | ||||||
|  |             remove('/tmp/devices.tmp') | ||||||
|  |         swapdevices = swapdevices.replace('\n', '') | ||||||
|  |         swapdevices = swapdevices.split('/') | ||||||
|  |         f = open('/proc/mounts', 'r') | ||||||
|  |         for line in f.readlines(): | ||||||
|  |             if line.find(device) != -1: | ||||||
|  |                 parts = line.strip().split() | ||||||
|  |                 d1 = parts[1] | ||||||
|  |                 dtype = parts[2] | ||||||
|  |                 rw = parts[3] | ||||||
|  |                 break | ||||||
|  |                 continue | ||||||
|  |             elif device in swapdevices: | ||||||
|  |                 parts = line.strip().split() | ||||||
|  |                 d1 = _('None') | ||||||
|  |                 dtype = 'swap' | ||||||
|  |                 rw = _('None') | ||||||
|  |                 break | ||||||
|  |                 continue | ||||||
|  |             else: | ||||||
|  |                 d1 = _('None') | ||||||
|  |                 dtype = _('unavailable') | ||||||
|  |                 rw = _('None') | ||||||
|  |  | ||||||
|  |         f.close() | ||||||
|  |         size = Harddisk(device).diskSize() | ||||||
|  |         if float(size) / 1024 / 1024 >= 1: | ||||||
|  |             des = _('Size: ') + str(round(float(size) / 1024 / 1024, 2)) + _('TB') | ||||||
|  |         elif size / 1024 >= 1: | ||||||
|  |             des = _('Size: ') + str(round(float(size) / 1024, 2)) + _('GB') | ||||||
|  |         elif size >= 1: | ||||||
|  |             des = _('Size: ') + str(size) + _('MB') | ||||||
|  |         else: | ||||||
|  |             des = _('Size: ') + _('unavailable') | ||||||
|  |         if des != '': | ||||||
|  |             if rw.startswith('rw'): | ||||||
|  |                 rw = ' R/W' | ||||||
|  |             elif rw.startswith('ro'): | ||||||
|  |                 rw = ' R/O' | ||||||
|  |             else: | ||||||
|  |                 rw = '' | ||||||
|  |             des += '\t' + _('Mount: ') + d1 + '\n' + _('Device: ') + '/dev/' + device + '\t' + _('Type: ') + dtype + rw | ||||||
|  |             png = LoadPixmap(mypixmap) | ||||||
|  |             res = (name, des, png) | ||||||
|  |             self.list.append(res) | ||||||
|  |  | ||||||
|  |     def SetupMounts(self): | ||||||
|  |         if not fileExists('/etc/fstab.org'): | ||||||
|  |             os.system('cp -f /etc/fstab /etc/fstab.org') | ||||||
|  |         elif fileExists('/etc/fstab.org'): | ||||||
|  |             os.system('cp /etc/fstab.org /etc/fstab') | ||||||
|  |         self.session.openWithCallback(self.updateList, DevicesConf) | ||||||
|  |  | ||||||
|  |     def Unmount(self): | ||||||
|  |         sel = self['list'].getCurrent() | ||||||
|  |         if sel: | ||||||
|  |             des = sel[1] | ||||||
|  |             des = des.replace('\n', '\t') | ||||||
|  |             parts = des.strip().split('\t') | ||||||
|  |             mountp = parts[1].replace(_('Mount: '), '') | ||||||
|  |             device = parts[2].replace(_('Device: '), '') | ||||||
|  |             system('umount ' + mountp) | ||||||
|  |             try: | ||||||
|  |                 mounts = open('/proc/mounts') | ||||||
|  |                 mountcheck = mounts.readlines() | ||||||
|  |                 mounts.close() | ||||||
|  |                 for line in mountcheck: | ||||||
|  |                     parts = line.strip().split(' ') | ||||||
|  |                     if path.realpath(parts[0]).startswith(device): | ||||||
|  |                         self.session.open(MessageBox, _("Can't unmount partition, make sure it is not being used for swap or record/timeshift paths"), MessageBox.TYPE_INFO, timeout=10) | ||||||
|  |  | ||||||
|  |             except IOError: | ||||||
|  |                 return -1 | ||||||
|  |  | ||||||
|  |             self.updateList() | ||||||
|  |  | ||||||
|  |     def saveMypoints(self): | ||||||
|  |         sel = self['list'].getCurrent() | ||||||
|  |         if sel: | ||||||
|  |             parts = sel[1].split() | ||||||
|  |             self.device = parts[5] | ||||||
|  |             self.mountp = parts[3] | ||||||
|  |             self.Console.ePopen('umount ' + self.device) | ||||||
|  |             if self.mountp.find('/media/hdd') < 0: | ||||||
|  |                 self.Console.ePopen('umount /media/hdd') | ||||||
|  |                 self.Console.ePopen('/sbin/blkid | grep ' + self.device, self.add_fstab, [self.device, self.mountp]) | ||||||
|  |             else: | ||||||
|  |                 self.session.open(MessageBox, _('This Device is already mounted as HDD.'), MessageBox.TYPE_INFO, timeout=10, close_on_any_key=True) | ||||||
|  |  | ||||||
|  |     def add_fstab(self, result = None, retval = None, extra_args = None): | ||||||
|  |         self.device = extra_args[0] | ||||||
|  |         self.mountp = extra_args[1] | ||||||
|  |         self.device_uuid = 'UUID=' + result.split('UUID=')[1].split(' ')[0].replace('"', '') | ||||||
|  |         if not path.exists(self.mountp): | ||||||
|  |             mkdir(self.mountp, 493) | ||||||
|  |         file('/etc/fstab.tmp', 'w').writelines([ l for l in file('/etc/fstab').readlines() if '/media/hdd' not in l ]) | ||||||
|  |         rename('/etc/fstab.tmp', '/etc/fstab') | ||||||
|  |         file('/etc/fstab.tmp', 'w').writelines([ l for l in file('/etc/fstab').readlines() if self.device not in l ]) | ||||||
|  |         rename('/etc/fstab.tmp', '/etc/fstab') | ||||||
|  |         file('/etc/fstab.tmp', 'w').writelines([ l for l in file('/etc/fstab').readlines() if self.device_uuid not in l ]) | ||||||
|  |         rename('/etc/fstab.tmp', '/etc/fstab') | ||||||
|  |         out = open('/etc/fstab', 'a') | ||||||
|  |         line = self.device_uuid + '\t/media/hdd\tauto\tdefaults\t0 0\n' | ||||||
|  |         out.write(line) | ||||||
|  |         out.close() | ||||||
|  |         self.Console.ePopen('mount -a', self.updateList) | ||||||
|  |  | ||||||
|  |     def restBo(self, answer): | ||||||
|  |         if answer is True: | ||||||
|  |             self.session.open(TryQuitMainloop, 2) | ||||||
|  |         else: | ||||||
|  |             self.updateList() | ||||||
|  |             self.selectionChanged() | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class DevicesConf(Screen, ConfigListScreen): | ||||||
|  |     screenwidth = getDesktop(0).size().width() | ||||||
|  |     if screenwidth and screenwidth == 1920: | ||||||
|  |         skin = """<screen name="DevicesConfFullHD" position="400,150" size="976,728" title="Choose where to mount your devices to:">         | ||||||
|  |         <eLabel backgroundColor="black" font="baslk; 25" foregroundColor="red" position="150,900" size="800,30" text=" Exit - Back " transparent="1" />  | ||||||
|  |         <widget name="key_red" position="110,13" zPosition="1" size="335,67" font="baslk;30" halign="center" valign="center" backgroundColor="red" transparent="1" foregroundColor="red" /> | ||||||
|  |         <widget name="key_green" position="549,15" zPosition="1" size="362,65" font="baslk;30" halign="center" valign="center" backgroundColor="green" transparent="1" foregroundColor="green" /> | ||||||
|  |         <widget name="config" position="33,179" size="891,385" font="Regular;21" scrollbarMode="showOnDemand" /> | ||||||
|  |         </screen>""" | ||||||
|  |     else: | ||||||
|  |         skin = """<screen name="DevicesConfHD" position="171,130" size="903,460" title="Choose where to mount your devices to:"> | ||||||
|  |         <eLabel backgroundColor="black" font="Regular;30" foregroundColor="orange" position="366,388" size="295,65" text="Exit - Back" transparent="1" /> | ||||||
|  |         <widget name="key_red" position="36,0" zPosition="1" size="363,59" font="Regular;30" halign="center" valign="center" backgroundColor="black" transparent="1" foregroundColor="red" /> | ||||||
|  |         <widget name="key_green" position="548,0" zPosition="1" size="332,60" font="Regular;30" halign="center" valign="center" backgroundColor="black" transparent="1" foregroundColor="green" /> | ||||||
|  |         <widget name="config" position="31,85" size="839,279" scrollbarMode="showOnDemand" /> | ||||||
|  |         </screen>""" | ||||||
|  |  | ||||||
|  |     def __init__(self, session): | ||||||
|  |         Screen.__init__(self, session) | ||||||
|  |         self.list = [] | ||||||
|  |         ConfigListScreen.__init__(self, self.list) | ||||||
|  |         Screen.setTitle(self, _('Choose where to mount your devices to:')) | ||||||
|  |         self['key_green'] = Label(_('Save')) | ||||||
|  |         self['key_red'] = Label(_('Cancel')) | ||||||
|  |         self['Linconn'] = Label(_('Wait please while scanning your %s %s devices...n\\ Looking for a disk...')) | ||||||
|  |         self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'green': self.saveMypoints, | ||||||
|  |          'red': self.close, | ||||||
|  |          'back': self.close}) | ||||||
|  |         self.updateList() | ||||||
|  |          | ||||||
|  |     def updateList(self): | ||||||
|  |         self.list = [] | ||||||
|  |         list2 = [] | ||||||
|  |         self.Console = Console() | ||||||
|  |         self.Console.ePopen("sfdisk -l /dev/sd? | grep swap | awk '{print $(NF-9)}' >/tmp/devices.tmp") | ||||||
|  |         sleep(0.5) | ||||||
|  |         f = open('/tmp/devices.tmp', 'r') | ||||||
|  |         swapdevices = f.read() | ||||||
|  |         f.close() | ||||||
|  |         if path.exists('/tmp/devices.tmp'): | ||||||
|  |             remove('/tmp/devices.tmp') | ||||||
|  |         swapdevices = swapdevices.replace('\n', '') | ||||||
|  |         swapdevices = swapdevices.split('/') | ||||||
|  |         f = open('/proc/partitions', 'r') | ||||||
|  |         for line in f.readlines(): | ||||||
|  |             parts = line.strip().split() | ||||||
|  |             if not parts: | ||||||
|  |                 continue | ||||||
|  |             device = parts[3] | ||||||
|  |             if not re.search('sd[a-z][1-9]', device): | ||||||
|  |                 continue | ||||||
|  |             if device in list2: | ||||||
|  |                 continue | ||||||
|  |             if device in swapdevices: | ||||||
|  |                 continue | ||||||
|  |             self.buildMy_rec(device) | ||||||
|  |             list2.append(device) | ||||||
|  |  | ||||||
|  |         f.close() | ||||||
|  |         self['config'].list = self.list | ||||||
|  |         self['config'].l.setList(self.list) | ||||||
|  |         self['Linconn'].hide() | ||||||
|  |  | ||||||
|  |     def buildMy_rec(self, device): | ||||||
|  |         mypath = SkinPath() | ||||||
|  |         device2 = re.sub('[0-9]', '', device) | ||||||
|  |         devicetype = path.realpath('/sys/block/' + device2 + '/device') | ||||||
|  |         d2 = device | ||||||
|  |         name = _('HARD DISK: ') | ||||||
|  |         mypixmap = '' + LinkNeoBoot + '/images/dev_hdd.png' | ||||||
|  |         model = file('/sys/block/' + device2 + '/device/model').read() | ||||||
|  |         model = str(model).replace('\n', '') | ||||||
|  |         des = '' | ||||||
|  |         if devicetype.find('usb') != -1: | ||||||
|  |             name = _('USB: ') | ||||||
|  |             mypixmap = '' + LinkNeoBoot + '/images/dev_usb.png' | ||||||
|  |         if devicetype.find('usb1') != -1: | ||||||
|  |             name = _('USB1: ') | ||||||
|  |             mypixmap = '' + LinkNeoBoot + '/images/dev_usb.png' | ||||||
|  |         if devicetype.find('usb2') != -1: | ||||||
|  |             name = _('USB2: ') | ||||||
|  |             mypixmap = '' + LinkNeoBoot + '/images/dev_usb.png'             | ||||||
|  |         if devicetype.find('card') != -1: | ||||||
|  |             name = _('CARD: ') | ||||||
|  |             mypixmap = '' + LinkNeoBoot + '/images/dev_sd.png' | ||||||
|  |              | ||||||
|  |         name = name + model | ||||||
|  |         f = open('/proc/mounts', 'r') | ||||||
|  |         for line in f.readlines(): | ||||||
|  |             if line.find(device) != -1: | ||||||
|  |                 parts = line.strip().split() | ||||||
|  |                 d1 = parts[1] | ||||||
|  |                 dtype = parts[2] | ||||||
|  |                 break | ||||||
|  |                 continue | ||||||
|  |             else: | ||||||
|  |                 d1 = _('None') | ||||||
|  |                 dtype = _('unavailable') | ||||||
|  |  | ||||||
|  |         f.close() | ||||||
|  |         size = Harddisk(device).diskSize() | ||||||
|  |         if float(size) / 1024 / 1024 >= 1: | ||||||
|  |             des = _('Size: ') + str(round(float(size) / 1024 / 1024, 2)) + _('TB') | ||||||
|  |         elif size / 1024 >= 1: | ||||||
|  |             des = _('Size: ') + str(round(float(size) / 1024, 2)) + _('GB') | ||||||
|  |         elif size >= 1: | ||||||
|  |             des = _('Size: ') + str(size) + _('MB') | ||||||
|  |         else: | ||||||
|  |             des = _('Size: ') + _('unavailable') | ||||||
|  |         item = NoSave(ConfigSelection(default='/media/' + device, choices=[('/media/' + device, '/media/' + device), | ||||||
|  |          ('/media/hdd', '/media/hdd'), | ||||||
|  |          ('/media/hdd2', '/media/hdd2'), | ||||||
|  |          ('/media/hdd3', '/media/hdd3'), | ||||||
|  |          ('/media/usb', '/media/usb'), | ||||||
|  |          ('/media/usb1', '/media/usb1'), | ||||||
|  |          ('/media/usb2', '/media/usb2'), | ||||||
|  |          ('/media/usb3', '/media/usb3'), | ||||||
|  |          ('/media/usb3', '/media/cf'), | ||||||
|  |          ('/media/usb3', '/media/card'), | ||||||
|  |          ('/media/cf', '/media/cf'), | ||||||
|  |          ('/media/card', '/media/card')])) | ||||||
|  |         if dtype == 'Linux': | ||||||
|  |             dtype = 'ext2', 'ext3', 'ext4'  | ||||||
|  |         else: | ||||||
|  |             dtype = 'auto' | ||||||
|  |         item.value = d1.strip() | ||||||
|  |         text = name + ' ' + des + ' /dev/' + device | ||||||
|  |         res = getConfigListEntry(text, item, device, dtype) | ||||||
|  |         if des != '' and self.list.append(res): | ||||||
|  |             pass | ||||||
|  |  | ||||||
|  |     def saveMypoints(self):        | ||||||
|  |         self.Console = Console() | ||||||
|  |         mycheck = False | ||||||
|  |         for x in self['config'].list: | ||||||
|  |             self.device = x[2] | ||||||
|  |             self.mountp = x[1].value | ||||||
|  |             self.type = x[3] | ||||||
|  |             self.Console.ePopen('umount ' + self.device) | ||||||
|  |             self.Console.ePopen('/sbin/blkid | grep ' + self.device + ' && opkg list-installed ntfs-3g', self.add_fstab, [self.device, self.mountp]) | ||||||
|  |  | ||||||
|  |         message = _('Continues mounting equipment...') | ||||||
|  |         ybox = self.session.openWithCallback(self.delay, MessageBox, message, type=MessageBox.TYPE_INFO, timeout=5, enable_input=False) | ||||||
|  |         ybox.setTitle(_('Please, wait....')) | ||||||
|  |  | ||||||
|  |     def delay(self, val): | ||||||
|  |         #if fileExists('/etc/init.d/volatile-media.sh'): | ||||||
|  |             #system('mv /etc/init.d/volatile-media.sh /etc/init.d/volatile-media.sh.org') | ||||||
|  |         message = _('Completed assembly of disks.\nReturn to installation ?') | ||||||
|  |         ybox = self.session.openWithCallback(self.myclose, MessageBox, message, MessageBox.TYPE_YESNO) | ||||||
|  |         ybox.setTitle(_('MOUNTING....')) | ||||||
|  |  | ||||||
|  |     def myclose(self, answer): | ||||||
|  |         if answer is True: | ||||||
|  |             self.messagebox = self.session.open(MessageBox, _('Return to installation...'), MessageBox.TYPE_INFO) | ||||||
|  |             self.close() | ||||||
|  |         else: | ||||||
|  |             self.messagebox = self.session.open(MessageBox, _('Return to installation...'), MessageBox.TYPE_INFO) | ||||||
|  |             self.close() | ||||||
|  |  | ||||||
|  |     def add_fstab(self, result = None, retval = None, extra_args = None): | ||||||
|  |         print ("[MountManager] RESULT:"), result | ||||||
|  |         if result: | ||||||
|  |             self.device = extra_args[0] | ||||||
|  |             self.mountp = extra_args[1] | ||||||
|  |             self.device_uuid = 'UUID=' + result.split('UUID=')[1].split(' ')[0].replace('"', '') | ||||||
|  |             self.device_type = result.split('TYPE=')[1].split(' ')[0].replace('"', '') | ||||||
|  |             if self.device_type.startswith('ext'): | ||||||
|  |                 self.device_type = 'auto' | ||||||
|  |             elif self.device_type.startswith('ntfs') and result.find('ntfs-3g') != -1: | ||||||
|  |                 self.device_type = 'ntfs-3g' | ||||||
|  |             elif self.device_type.startswith('ntfs') and result.find('ntfs-3g') == -1: | ||||||
|  |                 self.device_type = 'ntfs' | ||||||
|  |             if not path.exists(self.mountp): | ||||||
|  |                 mkdir(self.mountp, 493) | ||||||
|  |             file('/etc/fstab.tmp', 'w').writelines([ l for l in file('/etc/fstab').readlines() if self.device not in l ]) | ||||||
|  |             rename('/etc/fstab.tmp', '/etc/fstab') | ||||||
|  |             file('/etc/fstab.tmp', 'w').writelines([ l for l in file('/etc/fstab').readlines() if self.device_uuid not in l ]) | ||||||
|  |             rename('/etc/fstab.tmp', '/etc/fstab') | ||||||
|  |             out = open('/etc/fstab', 'a') | ||||||
|  |             line = self.device_uuid + '\t' + self.mountp + '\t' + self.device_type + '\tdefaults\t0 0\n' | ||||||
|  |             out.write(line) | ||||||
|  |             out.close() | ||||||
|  |  | ||||||
|  |             self.device_uuid2 = result.split('UUID=')[1].split(' ')[0].replace('"', '') | ||||||
|  | #            if fileExists('/usr/lib/enigma2/python/Plugins/SystemPlugins/DeviceManager2'): | ||||||
|  | #                out1 = open('/etc/devicemanager.cfg', 'a') | ||||||
|  | #                line1 = '"' + self.device_uuid2 + '"' + ':' + self.mountp + '\n' | ||||||
|  | #                out1.write(line1) | ||||||
|  | #                out1.close() | ||||||
|  | #            elif fileExists('/usr/lib/enigma2/python/Plugins/SystemPlugins/DeviceManager'): | ||||||
|  | #                out2 = open('/usr/lib/enigma2/python/Plugins/SystemPlugins/DeviceManager/devicemanager.cfg', 'a') | ||||||
|  | #                line2 = '"' + self.device_uuid2 + '"' + ':' + self.mountp + '\n' | ||||||
|  | #                out2.write(line2) | ||||||
|  | #                out2.close() | ||||||
|  |                                                                                | ||||||
|  |  | ||||||
|  |             | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #SetDiskLabel - dziekuje autorowi | ||||||
|  | class SetDiskLabel(Screen): | ||||||
|  |     screenwidth = getDesktop(0).size().width() | ||||||
|  |     if screenwidth and screenwidth == 1920:     | ||||||
|  |         skin ="""<screen name="SetDiskLabel" position="400,188" size="1100,601" title="Set Disk Label v1.1"> | ||||||
|  |       <widget name="infoTXT" position="22,62" zPosition="1" size="591,86" font="baslk;28" halign="left" valign="center" backgroundColor="transpBlack" transparent="1" /> | ||||||
|  |  | ||||||
|  |       <widget name="devlist" position="685,60" size="310,132" font="Regular;20" valign="center" /> | ||||||
|  |        | ||||||
|  |       <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/k_left.png" position="628,86" size="40,40" alphatest="on" /> | ||||||
|  |       <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/k_right.png" position="1015,85" size="40,40" alphatest="on" /> | ||||||
|  |       <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/k_up.png" position="630,381" size="40,42" alphatest="on" /> | ||||||
|  |       <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/k_down.png" position="1010,383" size="40,40" alphatest="on" /> | ||||||
|  |  | ||||||
|  |       <widget name="labelname" position="22,209" zPosition="1" size="591,86" font="baslk;30" valign="center" backgroundColor="transpBlack" transparent="1" /> | ||||||
|  |       <widget name="disklabel" position="697,212" size="290,77" zPosition="1" font="baslk;30" valign="left" /> | ||||||
|  |       <widget name="labeltoset" position="22,363" zPosition="1" size="591,86" font="baslk;30" valign="center" backgroundColor="transpBlack" transparent="1" /> | ||||||
|  |       <widget name="listlabel" position="685,354" size="310,145" zPosition="1" font="Regular;20" valign="center" /> | ||||||
|  |  | ||||||
|  |       <ePixmap pixmap="skin_default/buttons/key_red.png" position="14,534" size="40,40" alphatest="on" /> | ||||||
|  |       <ePixmap pixmap="skin_default/buttons/key_green.png" position="259,535" size="40,40" alphatest="on" /> | ||||||
|  |       <ePixmap pixmap="skin_default/buttons/key_yellow.png" position="567,535" size="40,40" alphatest="on" /> | ||||||
|  |       <ePixmap pixmap="skin_default/buttons/key_blue.png" position="814,532" size="40,40" alphatest="on" /> | ||||||
|  |        | ||||||
|  |       <widget name="key_red" position="60,526" zPosition="1" size="196,40" font="baslk;25" halign="left" valign="left" backgroundColor="transpBlack" transparent="1" /> | ||||||
|  |       <widget name="key_green" position="304,526" zPosition="1" size="255,40" font="baslk;25" halign="left" valign="left" backgroundColor="transpBlack" transparent="1" /> | ||||||
|  |       <widget name="key_yellow" position="613,526" zPosition="1" size="196,40" font="baslk;25" halign="left" valign="left" backgroundColor="transpBlack" transparent="1" /> | ||||||
|  |       <widget name="key_blue" position="860,526" zPosition="1" size="233,40" font="baslk;25" halign="left" valign="left" backgroundColor="transpBlack" transparent="1" /> | ||||||
|  |       <eLabel text="%s" font="Regular; 25" position="23,-10" size="968,57" halign="center" foregroundColor="yellow" backgroundColor="black" transparent="1" /> | ||||||
|  |       </screen> """ % (_('!!!Do not set the label for /dev/mmcblk0p !!!')) | ||||||
|  |     else: | ||||||
|  |         skin = """<screen position="center,center" size="600,200" title="Set Disk Label v1.1" > | ||||||
|  |       <widget name="infoTXT" position="25,20" zPosition="1" size="310,38" font="Regular;20" halign="left" valign="center" backgroundColor="transpBlack" transparent="1" /> | ||||||
|  |       <widget name="devlist" position="400,20" size="125,25" /> | ||||||
|  |       <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/k_left.png" position="350,15" size="40,40" alphatest="on" /> | ||||||
|  |       <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/k_right.png" position="550,15" size="40,40" alphatest="on" /> | ||||||
|  |       <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/k_up.png" position="350,105" size="40,40" alphatest="on" /> | ||||||
|  |       <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/k_down.png" position="550,105" size="40,40" alphatest="on" /> | ||||||
|  |       <widget name="labelname" position="25,65" zPosition="1" size="310,25" font="Regular;20" halign="left" valign="center" backgroundColor="transpBlack" transparent="1"/> | ||||||
|  |       <widget name="disklabel" position="400,65" size="125,25" zPosition="1" font="Regular;20" halign="center" valign="left"/> | ||||||
|  |       <widget name="labeltoset" position="25,110" zPosition="1" size="310,25" font="Regular;20" halign="left" valign="center" backgroundColor="transpBlack" transparent="1"/> | ||||||
|  |       <widget name="listlabel" position="400,110" size="125,25" zPosition="1" font="Regular;20" valign="left"/> | ||||||
|  |       <ePixmap pixmap="skin_default/buttons/key_red.png" position="40,167" size="40,40" alphatest="on" /> | ||||||
|  |       <ePixmap pixmap="skin_default/buttons/key_green.png" position="170,167" size="40,40" alphatest="on" /> | ||||||
|  |       <ePixmap pixmap="skin_default/buttons/key_yellow.png" position="300,167" size="40,40" alphatest="on" /> | ||||||
|  |       <ePixmap pixmap="skin_default/buttons/key_blue.png" position="430,167" size="40,40" alphatest="on" /> | ||||||
|  |       <widget name="key_red" position="70,160" zPosition="1" size="90,40" font="Regular;14" halign="center" valign="left" backgroundColor="transpBlack" transparent="1" /> | ||||||
|  |       <widget name="key_green" position="200,160" zPosition="1" size="90,40" font="Regular;14" halign="center" valign="left" backgroundColor="transpBlack" transparent="1" /> | ||||||
|  |       <widget name="key_yellow" position="330,160" zPosition="1" size="90,40" font="Regular;14" halign="center" valign="left" backgroundColor="transpBlack" transparent="1" /> | ||||||
|  |       <widget name="key_blue" position="460,160" zPosition="1" size="90,40" font="Regular;14" halign="center" valign="left" backgroundColor="transpBlack" transparent="1" /> | ||||||
|  |       </screen>""" | ||||||
|  |  | ||||||
|  |     def __init__(self, session): | ||||||
|  |         global liczymy | ||||||
|  |         Screen.__init__(self, session) | ||||||
|  |         self.labList = ['hdd', 'usb','card', 'cf'] | ||||||
|  |         self.list = [] | ||||||
|  |         self.sprDev() | ||||||
|  |         self.devlist = [] | ||||||
|  |         self.disklabel = [] | ||||||
|  |         self['devlist'] = MenuList(self.devlist) | ||||||
|  |         self['disklabel'] = Label(self.disklabel) | ||||||
|  |         self['listlabel'] = MenuList(self.labList) | ||||||
|  |         liczymy = 0 | ||||||
|  |         for x in lista: | ||||||
|  |             self.devlist.append(x) | ||||||
|  |             liczymy += 1 | ||||||
|  |  | ||||||
|  |         self.sprLabel() | ||||||
|  |         self['labelname'] = Label(_('Current partition label:')) | ||||||
|  |         self['labeltoset'] = Label(_('Choice label to set:')) | ||||||
|  |         self['infoTXT'] = Label(_('Select partition to set label:')) | ||||||
|  |         self['key_red'] = Button(_('Exit')) | ||||||
|  |         self['key_green'] = Button(_('Set label')) | ||||||
|  |         self['key_yellow'] = Button(_('Add label')) | ||||||
|  |         self['key_blue'] = Button(_('Delete label')) | ||||||
|  |         self['actions'] = ActionMap(['OkCancelActions', 'ColorActions', 'DirectionActions'], {'cancel': self.cancel, | ||||||
|  |          'red': self.cancel, | ||||||
|  |          'green': self.wlacz, | ||||||
|  |          'yellow': self.addlabel, | ||||||
|  |          'blue': self.dellabel, | ||||||
|  |          'left': self.left, | ||||||
|  |          'right': self.right, | ||||||
|  |          'up': self.up, | ||||||
|  |          'down': self.down}, -2) | ||||||
|  |  | ||||||
|  |     def sprDev(self): | ||||||
|  |         global lista | ||||||
|  |         lista = [''] | ||||||
|  |         if getTunerModel() in ('sf8008', 'sf8008s', 'sf8008t'): | ||||||
|  |             blackL = 'mmcblk0' | ||||||
|  |         else: | ||||||
|  |             blackL = getoutput('cat /etc/udev/mount-helper.sh | grep "BLACKLISTED="') | ||||||
|  |             blackL = blackL[13:-1] | ||||||
|  |         devL = getoutput('cat /proc/partitions | grep "sd\\|mmc" | awk \'{print $4}\'') | ||||||
|  |         devL = devL.split('\n') | ||||||
|  |         ilosc = len(devL) | ||||||
|  |         i = 0 | ||||||
|  |         while i < ilosc: | ||||||
|  |             if len(devL[i]) == 9 or len(devL[i]) == 4: | ||||||
|  |                 if devL[i][:7] != blackL: | ||||||
|  |                     if self.sprLinux(devL[i]) == True: | ||||||
|  |                         lista.append(devL[i]) | ||||||
|  |             i += 1 | ||||||
|  |  | ||||||
|  |         if ilosc > 0: | ||||||
|  |             lista.remove('') | ||||||
|  |         elif lista[0] == '': | ||||||
|  |             lista.remove('') | ||||||
|  |             lista.insert(0, 'No Disk') | ||||||
|  |  | ||||||
|  |     def cancel(self): | ||||||
|  |         self.close() | ||||||
|  |  | ||||||
|  |     def wlacz(self): | ||||||
|  |         self.session.openWithCallback(self.wlaczyes, MessageBox, _('Set label on %s?') % str(self['devlist'].getCurrent()), MessageBox.TYPE_YESNO, default=False) | ||||||
|  |  | ||||||
|  |     def wlaczyes(self, w): | ||||||
|  |         if w == True: | ||||||
|  |             os.system('e2label /dev/%s "%s"' % (str(self['devlist'].getCurrent()), self['listlabel'].getCurrent())) | ||||||
|  |             self.session.open(MessageBox, _('Selected label is set'), type=MessageBox.TYPE_INFO, timeout=10) | ||||||
|  |             self.sprLabel() | ||||||
|  |  | ||||||
|  |     def addlabel(self): | ||||||
|  |         self.session.openWithCallback(self.addlabeltolist, VirtualKeyBoard, title=_('Add new partition label:'), text=self['disklabel'].getText()) | ||||||
|  |  | ||||||
|  |     def dellabel(self): | ||||||
|  |         self.session.openWithCallback(self.delabelyes, MessageBox, _('Delete label from %s?') % str(self['devlist'].getCurrent()), MessageBox.TYPE_YESNO, default=False) | ||||||
|  |  | ||||||
|  |     def delabelyes(self, k): | ||||||
|  |         if k == True: | ||||||
|  |             os.system('e2label /dev/%s ""' % str(self['devlist'].getCurrent())) | ||||||
|  |             self.session.open(MessageBox, _('Label is delete'), type=MessageBox.TYPE_INFO, timeout=10) | ||||||
|  |             self.sprLabel() | ||||||
|  |  | ||||||
|  |     def zamknij(self, data): | ||||||
|  |         self.close() | ||||||
|  |  | ||||||
|  |     def left(self): | ||||||
|  |         self['devlist'].up() | ||||||
|  |         self.sprLabel() | ||||||
|  |  | ||||||
|  |     def right(self): | ||||||
|  |         self['devlist'].down() | ||||||
|  |         self.sprLabel() | ||||||
|  |  | ||||||
|  |     def up(self): | ||||||
|  |         self['listlabel'].up() | ||||||
|  |  | ||||||
|  |     def down(self): | ||||||
|  |         self['listlabel'].down() | ||||||
|  |  | ||||||
|  |     def addlabeltolist(self, z): | ||||||
|  |         if z is not None: | ||||||
|  |             self.labList.insert(0, z) | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |     def sprLabel(self): | ||||||
|  |         lab = getoutput('blkid /dev/' + self['devlist'].getCurrent()) | ||||||
|  |         lab1 = lab.split(' ') | ||||||
|  |         licz1 = len(lab1) | ||||||
|  |         i = 0 | ||||||
|  |         while i < licz1: | ||||||
|  |             if lab1[i][:5] == 'LABEL': | ||||||
|  |                 self['disklabel'].setText(lab1[i][7:-1]) | ||||||
|  |                 break | ||||||
|  |             else: | ||||||
|  |                 self['disklabel'].setText(_('No label')) | ||||||
|  |             i += 1 | ||||||
|  |  | ||||||
|  |     def sprLinux(self, dev): | ||||||
|  |         lab = getoutput('blkid /dev/' + dev) | ||||||
|  |         lab1 = lab.split(' ') | ||||||
|  |         licz1 = len(lab1) | ||||||
|  |         jest = False | ||||||
|  |         j = 0 | ||||||
|  |         while j < licz1: | ||||||
|  |             if lab1[j][:9] == 'TYPE="ext': | ||||||
|  |                 jest = True | ||||||
|  |                 return jest | ||||||
|  |             jest = False | ||||||
|  |             j += 1 | ||||||
|  |  | ||||||
|  |         return jest | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class DeviceManagerSummary(Screen): | ||||||
|  |     def __init__(self, session, parent): | ||||||
|  |         Screen.__init__(self, session, parent=parent) | ||||||
|  |         self['entry'] = StaticText('') | ||||||
|  |         self['desc'] = StaticText('') | ||||||
|  |         self.onShow.append(self.addWatcher) | ||||||
|  |         self.onHide.append(self.removeWatcher) | ||||||
|  |  | ||||||
|  |     def addWatcher(self): | ||||||
|  |         self.parent.onChangedEntry.append(self.selectionChanged) | ||||||
|  |         self.parent.selectionChanged() | ||||||
|  |  | ||||||
|  |     def removeWatcher(self): | ||||||
|  |         self.parent.onChangedEntry.remove(self.selectionChanged) | ||||||
|  |  | ||||||
|  |     def selectionChanged(self, name, desc): | ||||||
|  |         self['entry'].text = name | ||||||
|  |         self['desc'].text = desc | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def SkinPath(): | ||||||
|  |     myskinpath = resolveFilename(SCOPE_CURRENT_SKIN, '') | ||||||
|  |     if myskinpath == '' + LinkNeoBoot + '/images/': | ||||||
|  |         myskinpath = '' + LinkNeoBoot + '/images/' | ||||||
|  |     return myskinpath | ||||||
							
								
								
									
										16
									
								
								NeoBoot/files/modulecheck.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								NeoBoot/files/modulecheck.sh
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | |||||||
|  | #!/bin/sh | ||||||
|  | #DESCRIPTION=This script by gutosie | ||||||
|  |  | ||||||
|  | opkg update | ||||||
|  | opkg install --force-reinstall mtd-utils | ||||||
|  | opkg install --force-reinstall mtd-utils-ubifs | ||||||
|  | opkg install --force-reinstall mtd-utils-jffs2 | ||||||
|  | opkg install --force-reinstall kernel-module-nandsim | ||||||
|  | opkg install --force-reinstall python-subprocess | ||||||
|  | opkg install --force-reinstall python-argparse | ||||||
|  | opkg install --force-reinstall curl | ||||||
|  | opkg install --force-reinstall liblzo2-2 | ||||||
|  | opkg install --force-reinstall python-imaging | ||||||
|  | opkg install --force-maintainer --force-reinstall --force-overwrite kernel-image | ||||||
|  | opkg configure update-modules | ||||||
|  | cd | ||||||
							
								
								
									
										27
									
								
								NeoBoot/files/neobackup.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								NeoBoot/files/neobackup.sh
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | |||||||
|  | #!/bin/sh | ||||||
|  | #script by gutosie | ||||||
|  |  | ||||||
|  | if `grep -q 'osd.language=pl_PL' </etc/enigma2/settings`; then | ||||||
|  |   PL=1 | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | IMAGE=ImageBoot | ||||||
|  | LOCATIONBACKUP=CopyNEOBoot | ||||||
|  | NEOBOOTMOUNT=$( cat /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location)  | ||||||
|  | TiME=$(date +"%Y%m%d_%H%M%S") | ||||||
|  | UPDATEv=$(cat $NEOBOOTMOUNT/ImageBoot/.updateversion) | ||||||
|  | NB=_NeoBoot_  | ||||||
|  |          | ||||||
|  | if [ ! -e $NEOBOOTMOUNT$LOCATIONBACKUP  ]; then | ||||||
|  |     mkdir $NEOBOOTMOUNT$LOCATIONBACKUP > /dev/null 2>&1 | ||||||
|  |     /bin/tar -czf $NEOBOOTMOUNT/CopyNEOBoot/Copy_$UPDATEv$NB$TiME.tar.gz /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot*/ | ||||||
|  |     echo " " | ||||||
|  |     [ $PL ] && echo "Kopia wtyczki neoboot o nazwie Copy_$UPDATEv$NB$TiME.tar.gz utworzono w:"    $NEOBOOTMOUNT$LOCATIONBACKUP"  "  || echo "Copy named Copy_$UPDATEv$NB$TiME.tar.gz was created at location:"    $NEOBOOTMOUNT$LOCATIONBACKUP"  "  | ||||||
|  |     echo " "      | ||||||
|  | else         | ||||||
|  |     /bin/tar -czf $NEOBOOTMOUNT/CopyNEOBoot/Copy_$UPDATEv$NB$TiME.tar.gz /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot*/ | ||||||
|  |     echo " " | ||||||
|  |     [ $PL ] && echo "Kopia wtyczki o nazwie Copy_$UPDATEv$NB$TiME.tar.gz utworzono w:"    $NEOBOOTMOUNT$LOCATIONBACKUP"  "  || echo "Copy named Copy_$UPDATEv$NB$TiME.tar.gz was created at location:"    $NEOBOOTMOUNT$LOCATIONBACKUP"  "  | ||||||
|  |     echo " "       | ||||||
|  | fi | ||||||
|  | exit 0  | ||||||
							
								
								
									
										221
									
								
								NeoBoot/files/neoconsole.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										221
									
								
								NeoBoot/files/neoconsole.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,221 @@ | |||||||
|  | # -*- coding: utf-8 -*-  | ||||||
|  |   | ||||||
|  | from Plugins.Extensions.NeoBoot.__init__ import _  | ||||||
|  | #from __future__ import print_function | ||||||
|  | from enigma import eConsoleAppContainer | ||||||
|  | from Screens.Screen import Screen | ||||||
|  | from Components.ActionMap import ActionMap | ||||||
|  | from Components.ScrollLabel import ScrollLabel | ||||||
|  | from Components.Sources.StaticText import StaticText | ||||||
|  | from Screens.MessageBox import MessageBox | ||||||
|  | from Components.Label import Label | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class Console(Screen): | ||||||
|  |     skin = """<screen name="ConsoleN" position="80,100" size="1010,230" title="Command execution..."> | ||||||
|  |     <widget name="text" position="-2,-1" size="1015,230" font="Console;14" /> | ||||||
|  |     </screen>""" | ||||||
|  |  | ||||||
|  | #    def __init__(self, session, title = 'Console', cmdlist = None, finishedCallback = None, closeOnSuccess = False): | ||||||
|  | #        Screen.__init__(self, session) | ||||||
|  |  | ||||||
|  |     def __init__(self, session, title = _('Console'), cmdlist = None, finishedCallback = None, closeOnSuccess = False): | ||||||
|  |         Screen.__init__(self, session) | ||||||
|  |         self.finishedCallback = finishedCallback | ||||||
|  |         self.closeOnSuccess = closeOnSuccess | ||||||
|  |         self.errorOcurred = False | ||||||
|  |         self['key_red'] = Label(_('Stop action')) | ||||||
|  |         self['key_green'] = Label(_('Hide Console'))                                                 | ||||||
|  |         self['text'] = ScrollLabel('') | ||||||
|  |         self['summary_description'] = StaticText('') | ||||||
|  |         self['actions'] = ActionMap(['WizardActions', 'DirectionActions', 'ColorActions'], {'ok': self.cancel, | ||||||
|  |          'back': self.cancel, | ||||||
|  |          'up': self.key_up, | ||||||
|  |          'down': self.key_down,         | ||||||
|  |          'green': self.key_green, | ||||||
|  |          'red': self.key_red}, -1) | ||||||
|  |         self.cmdlist = cmdlist | ||||||
|  |         self.newtitle = title | ||||||
|  |         self.screen_hide = False | ||||||
|  |         self.cancel_msg = None | ||||||
|  |         self.output_file = '' | ||||||
|  |         self.onShown.append(self.updateTitle) | ||||||
|  |         self.container = eConsoleAppContainer() | ||||||
|  |         self.run = 0 | ||||||
|  |         self.container.appClosed.append(self.runFinished) | ||||||
|  |         self.container.dataAvail.append(self.dataAvail) | ||||||
|  |         self.onLayoutFinish.append(self.startRun) | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |     def updateTitle(self): | ||||||
|  |         self.setTitle(self.newtitle) | ||||||
|  |  | ||||||
|  |     def doExec(self, cmd): | ||||||
|  |         if isinstance(cmd, (list, tuple)): | ||||||
|  |             return self.container.execute(cmd[0], *cmd) | ||||||
|  |         else: | ||||||
|  |             return self.container.execute(cmd) | ||||||
|  |  | ||||||
|  |     def startRun(self): | ||||||
|  |         self['text'].setText(_('Execution progress:') + '\n\n') | ||||||
|  |         self['summary_description'].setText(_('Execution progress:')) | ||||||
|  |         print ("[Console] executing in run"), self.run, (" the command:"), self.cmdlist[self.run] | ||||||
|  |         if self.doExec(self.cmdlist[self.run]): | ||||||
|  |             self.runFinished(-1) | ||||||
|  |  | ||||||
|  |     def runFinished(self, retval): | ||||||
|  |         if retval: | ||||||
|  |             self.errorOcurred = True | ||||||
|  |             self.toggleScreenHide(True) | ||||||
|  |         self.run += 1 | ||||||
|  |         if self.run != len(self.cmdlist): | ||||||
|  |             if self.doExec(self.cmdlist[self.run]): | ||||||
|  |                 self.runFinished(-1) | ||||||
|  |         else: | ||||||
|  | #            self['key_red'].setText(_('Close')) | ||||||
|  | #            self['key_green'].setText(_('Save')) | ||||||
|  |             self.toggleScreenHide(True) | ||||||
|  |             if self.cancel_msg: | ||||||
|  |                 self.cancel_msg.close() | ||||||
|  |             from Tools.Directories import fileExists     | ||||||
|  |             if not fileExists('/etc/vtiversion.info'): | ||||||
|  |                 lastpage = self['text'].isAtLastPage() | ||||||
|  |             self['text'].appendText('\n' + _('Execution finished!!')) | ||||||
|  |             self['summary_description'].setText('\n' + _('Execution finished!!')) | ||||||
|  |             if self.finishedCallback is not None: | ||||||
|  |                 self.finishedCallback() | ||||||
|  |             if not self.errorOcurred and self.closeOnSuccess: | ||||||
|  |                 self.output_file = 'end' | ||||||
|  |                 self.cancel() | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |     def key_up(self): | ||||||
|  |         if self.screen_hide: | ||||||
|  |             self.toggleScreenHide() | ||||||
|  |             return | ||||||
|  |         self['text'].pageUp() | ||||||
|  |  | ||||||
|  |     def key_down(self): | ||||||
|  |         if self.screen_hide: | ||||||
|  |             self.toggleScreenHide() | ||||||
|  |             return | ||||||
|  |         self['text'].pageDown() | ||||||
|  |  | ||||||
|  |     def key_green(self): | ||||||
|  |         if self.screen_hide: | ||||||
|  |             self.toggleScreenHide() | ||||||
|  |             return | ||||||
|  |         if self.output_file == 'end': | ||||||
|  |             pass | ||||||
|  |         elif self.output_file.startswith('/tmp/'): | ||||||
|  |             self['text'].setText(self.readFile(self.output_file)) | ||||||
|  |             self['key_green'].setText(_(' ')) | ||||||
|  |             self.output_file = 'end' | ||||||
|  |         elif self.run == len(self.cmdlist): | ||||||
|  |             self.saveOutputText() | ||||||
|  |             #self.toggleScreenHide() | ||||||
|  |         else: | ||||||
|  |             self.toggleScreenHide() | ||||||
|  |  | ||||||
|  |     def key_red(self): | ||||||
|  |         if self.screen_hide: | ||||||
|  |             self.toggleScreenHide() | ||||||
|  |             return | ||||||
|  |         if self.run == len(self.cmdlist): | ||||||
|  |             self.cancel() | ||||||
|  |         else: | ||||||
|  |             self.cancel_msg = self.session.openWithCallback(self.cancelCB, MessageBox, _('Cancel execution?'), type=MessageBox.TYPE_YESNO, default=False) | ||||||
|  |  | ||||||
|  |     def cancelCB(self, ret = None): | ||||||
|  |         self.cancel_msg = None | ||||||
|  |         if ret: | ||||||
|  |             self.cancel(True) | ||||||
|  |         return | ||||||
|  |  | ||||||
|  |     def saveOutputText(self): | ||||||
|  |         from time import time, localtime | ||||||
|  |         lt = localtime(time()) | ||||||
|  |         self.output_file = '/tmp/%02d%02d%02d_console.txt' % (lt[3], lt[4], lt[5]) | ||||||
|  |         self.session.openWithCallback(self.saveOutputTextCB, MessageBox, _("Save the commands and the output to a file?\n('%s')") % self.output_file, type=MessageBox.TYPE_YESNO, default=True) | ||||||
|  |  | ||||||
|  |     def formatCmdList(self, source): | ||||||
|  |         if isinstance(source, (list, tuple)): | ||||||
|  |             for x in source: | ||||||
|  |                 for y in self.formatCmdList(x): | ||||||
|  |                     yield y | ||||||
|  |  | ||||||
|  |         else: | ||||||
|  |             yield source | ||||||
|  |  | ||||||
|  |     def saveOutputTextCB(self, ret = None): | ||||||
|  |         if ret: | ||||||
|  |             from os import path | ||||||
|  |             failtext = _("Path to save not exist: '/tmp/'") | ||||||
|  |             if path.exists('/tmp/'): | ||||||
|  |                 text = 'commands ...\n\n' | ||||||
|  |                 try: | ||||||
|  |                     cmdlist = list(self.formatCmdList(self.cmdlist)) | ||||||
|  |                     text += 'command line: %s\n\n' % cmdlist[0] | ||||||
|  |                     script = '' | ||||||
|  |                     for cmd in cmdlist[0].split(): | ||||||
|  |                         if '.' in cmd: | ||||||
|  |                             if cmd[-3:] in ('.py', '.sh'): | ||||||
|  |                                 script = cmd | ||||||
|  |                             break | ||||||
|  |  | ||||||
|  |                     if script and path.isfile(script): | ||||||
|  |                         text += 'script listing: %s\n\n%s\n\n' % (script, self.readFile(script)) | ||||||
|  |                     if len(cmdlist) > 1: | ||||||
|  |                         text += 'next commands:\n\n' + '\n'.join(cmdlist[1:]) + '\n\n' | ||||||
|  |                 except: | ||||||
|  |                     text += 'error read commands!!!\n\n' | ||||||
|  |  | ||||||
|  |                 text += '-' * 50 + '\n\noutputs ...\n\n%s' % self['text'].getText() | ||||||
|  |                 try: | ||||||
|  |                     f = open(self.output_file, 'w') | ||||||
|  |                     f.write(text) | ||||||
|  |                     f.close() | ||||||
|  |                     self['key_green'].setText(_('Load')) | ||||||
|  |                     return | ||||||
|  |                 except: | ||||||
|  |                     failtext = _("File write error: '%s'") % self.output_file | ||||||
|  |  | ||||||
|  |             self.output_file = 'end' | ||||||
|  |             self['key_green'].setText(_(' ')) | ||||||
|  |             self.session.open(MessageBox, failtext, type=MessageBox.TYPE_ERROR) | ||||||
|  |         else: | ||||||
|  |             self.output_file = '' | ||||||
|  |  | ||||||
|  |     def toggleScreenHide(self, setshow = False): | ||||||
|  |         if self.screen_hide or setshow: | ||||||
|  |             self.show() | ||||||
|  |         else: | ||||||
|  |             self.hide() | ||||||
|  |         self.screen_hide = not (self.screen_hide or setshow) | ||||||
|  |  | ||||||
|  |     def readFile(self, file): | ||||||
|  |         try: | ||||||
|  |             with open(file, 'r') as rdfile: | ||||||
|  |                 rd = rdfile.read() | ||||||
|  |             rdfile.close() | ||||||
|  |         except: | ||||||
|  |             if file == self.output_file: | ||||||
|  |                 rd = self['text'].getText() | ||||||
|  |             else: | ||||||
|  |                 rd = "File read error: '%s'\n" % file | ||||||
|  |  | ||||||
|  |         return rd | ||||||
|  |  | ||||||
|  |     def cancel(self, force = False): | ||||||
|  |         if self.screen_hide: | ||||||
|  |             self.toggleScreenHide() | ||||||
|  |             return | ||||||
|  |         if force or self.run == len(self.cmdlist): | ||||||
|  |             self.close() | ||||||
|  |             self.container.appClosed.remove(self.runFinished) | ||||||
|  |             self.container.dataAvail.remove(self.dataAvail) | ||||||
|  |             if self.run != len(self.cmdlist): | ||||||
|  |                 self.container.kill() | ||||||
|  |  | ||||||
|  |     def dataAvail(self, str): | ||||||
|  |         self['text'].appendText(str) | ||||||
							
								
								
									
										93
									
								
								NeoBoot/files/neoreboot.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								NeoBoot/files/neoreboot.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,93 @@ | |||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  | # system modules | ||||||
|  |   | ||||||
|  | from __future__ import print_function | ||||||
|  | #from Plugins.Extensions.NeoBoot.__init__ import _   | ||||||
|  | import codecs | ||||||
|  | from enigma import getDesktop | ||||||
|  | from Components.ActionMap import ActionMap | ||||||
|  | from Components.Label import Label | ||||||
|  | from Components.ScrollLabel import ScrollLabel | ||||||
|  | from Components.Pixmap import Pixmap | ||||||
|  | from Components.Sources.List import List | ||||||
|  | from Components.ConfigList import ConfigListScreen | ||||||
|  | from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest | ||||||
|  | from Components.config import getConfigListEntry, config, ConfigYesNo, ConfigText, ConfigSelection, NoSave | ||||||
|  | from Plugins.Extensions.NeoBoot.plugin import Plugins, PLUGINVERSION, UPDATEVERSION | ||||||
|  | from Plugins.Plugin import PluginDescriptor | ||||||
|  | from Screens.Standby import TryQuitMainloop | ||||||
|  | from Screens.MessageBox import MessageBox | ||||||
|  | from Screens.Screen import Screen | ||||||
|  | from Tools.LoadPixmap import LoadPixmap | ||||||
|  | from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE, SCOPE_CURRENT_SKIN, fileExists, pathExists, createDir, fileCheck | ||||||
|  | from os import system, listdir, mkdir, chdir, getcwd, rename as os_rename, remove as os_remove, popen | ||||||
|  | from os.path import dirname, isdir, isdir as os_isdir | ||||||
|  | from enigma import eTimer | ||||||
|  | from Plugins.Extensions.NeoBoot.files.stbbranding import getNeoLocation, getImageNeoBoot, getKernelVersionString, getBoxHostName, getCPUtype, getBoxVuModel, getTunerModel, getCPUSoC, getImageATv  | ||||||
|  | import os | ||||||
|  | import time | ||||||
|  | import sys | ||||||
|  | import struct, shutil | ||||||
|  | if fileExists('/etc/vtiversion.info') or fileExists('/usr/lib/python3.8') and fileExists('/.multinfo'):    | ||||||
|  |     from Screens.Console import Console                    | ||||||
|  | else: | ||||||
|  |     from Plugins.Extensions.NeoBoot.files.neoconsole import Console | ||||||
|  | LinkNeoBoot = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot'                                               | ||||||
|  |  | ||||||
|  | class ForceReboot(Screen): | ||||||
|  |     __module__ = __name__ | ||||||
|  |     skin = """<screen name="TunerInfo" title="NeoBoot - Sat Tuners " position="center,center" size="700,300" flags="wfNoBorder"> | ||||||
|  |         <widget name="lab1" position="20,20" size="660,210" font="baslk;25" halign="center" valign="center" transparent="1" /> | ||||||
|  |         <ePixmap position="200,250" size="34,34" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/red.png" alphatest="blend" zPosition="1" /> | ||||||
|  |         <widget name="key_red" position="250,250" zPosition="2" size="280,35" font="baslk;30" halign="left" valign="center" backgroundColor="red" transparent="1" foregroundColor="red" /> | ||||||
|  |         </screen>""" | ||||||
|  |  | ||||||
|  |     def __init__(self, session): | ||||||
|  |         Screen.__init__(self, session) | ||||||
|  |         self['lab1'] = Label(_('Force reboot to flash ?')) | ||||||
|  |         self['key_red'] = Label(_('To reboot press red!')) | ||||||
|  |         self['actions'] = ActionMap(['WizardActions', 'ColorActions'], {'back': self.close, | ||||||
|  |          'red': self.iNFO}) | ||||||
|  |           | ||||||
|  |     def iNFO(self): | ||||||
|  |         try: | ||||||
|  |             cmd = "echo -e '\n\n%s '" % _('Please wait, NeoBoot is working...') | ||||||
|  |             cmd1 = 'chmod 0755 ' + LinkNeoBoot + '/files/mountpoint.sh' | ||||||
|  |             cmd2 = '' + LinkNeoBoot + '/files/mountpoint.sh' | ||||||
|  |             cmd3 = "echo -e '\n\n%s '" % _('NeoBoot: Force reboot to flash image now...')             | ||||||
|  |             cmd4 = 'sleep 8; reboot -dfhi'             | ||||||
|  |             self.session.open(Console, _('NeoBoot: Backu to flash!'), [cmd, | ||||||
|  |              cmd1, | ||||||
|  |              cmd2, | ||||||
|  |              cmd3,              | ||||||
|  |              cmd4]) | ||||||
|  |             out = open('%sImageBoot/.neonextboot' % getNeoLocation(), 'w' ) | ||||||
|  |             out.write('Flash') | ||||||
|  |             out.close()             | ||||||
|  |             self.close() | ||||||
|  |  | ||||||
|  |         except: | ||||||
|  |             False | ||||||
|  |  | ||||||
|  | def main(session, **kwargs): | ||||||
|  |         try: | ||||||
|  |             session.open(ForceReboot) | ||||||
|  |         except: | ||||||
|  |             False | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def startSetup(menuid): | ||||||
|  |     if menuid != 'setup': | ||||||
|  |         return [] | ||||||
|  |     return [(_('NeoReboot'), | ||||||
|  |       main, | ||||||
|  |       'NeoReboot', | ||||||
|  |       50)] | ||||||
|  |  | ||||||
|  | def Plugins(path, **kwargs): | ||||||
|  |     global plugin_path | ||||||
|  |     plugin_path = path | ||||||
|  |     list = [PluginDescriptor(name=_('NeoReboot'), description=_('Force reboot to flash.'), where=PluginDescriptor.WHERE_MENU, fnc=startSetup)] | ||||||
|  |     return list    | ||||||
|  |      | ||||||
|  |              | ||||||
							
								
								
									
										756
									
								
								NeoBoot/files/stbbranding.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										756
									
								
								NeoBoot/files/stbbranding.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,756 @@ | |||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  |  | ||||||
|  | #from Plugins.Extensions.NeoBoot.__init__ import _  | ||||||
|  | import sys | ||||||
|  | import os | ||||||
|  | import time         | ||||||
|  | from Tools.Directories import fileExists, SCOPE_PLUGINS | ||||||
|  |  | ||||||
|  | def fileCheck(f, mode = 'r'): | ||||||
|  |     return fileExists(f, mode) and f   | ||||||
|  |      | ||||||
|  | def getSupportedTuners(): | ||||||
|  |     supportedT='' | ||||||
|  |     if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/stbinfo.cfg'): | ||||||
|  |         with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/stbinfo.cfg', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if lines.find("%s" % getBoxHostName()) != -1:        | ||||||
|  |             supportedT='%s' % getBoxHostName() | ||||||
|  |     return supportedT | ||||||
|  |      | ||||||
|  |          | ||||||
|  | def getFreespace(dev): | ||||||
|  |     statdev = os.statvfs(dev) | ||||||
|  |     space = statdev.f_bavail * statdev.f_frsize / 1024 | ||||||
|  |     print ("[NeoBoot] Free space on %s = %i kilobytes") % (dev, space) | ||||||
|  |     return space         | ||||||
|  |  | ||||||
|  | #check install | ||||||
|  | def getCheckInstal1(): | ||||||
|  |     neocheckinstal='UNKNOWN'     | ||||||
|  |     if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/install'): | ||||||
|  |         with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/install', 'r') as f: | ||||||
|  |             lines1 = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if not lines1.find('/dev/') != -1: | ||||||
|  |             neocheckinstal='1' | ||||||
|  |     return neocheckinstal | ||||||
|  |      | ||||||
|  | def getCheckInstal2(): | ||||||
|  |     neocheckinstal='UNKNOWN'  | ||||||
|  |     if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location'): | ||||||
|  |         with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location', 'r') as f: | ||||||
|  |             lines2 = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if not lines2.find('/media/') != -1: | ||||||
|  |             neocheckinstal='2' | ||||||
|  |     return neocheckinstal | ||||||
|  |                  | ||||||
|  | def getCheckInstal3(): | ||||||
|  |     neocheckinstal='UNKNOWN'  | ||||||
|  |     if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/neo.sh'): | ||||||
|  |         with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/neo.sh', 'r') as f: | ||||||
|  |             lines3 = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if not lines3.find('/bin/mount') != -1: | ||||||
|  |             neocheckinstal='3' | ||||||
|  |  | ||||||
|  |     return neocheckinstal | ||||||
|  |  | ||||||
|  | #check imageATV | ||||||
|  | def getImageATv(): | ||||||
|  |     atvimage='UNKNOWN' | ||||||
|  |     if os.path.exists('/etc/issue.net'): | ||||||
|  |         with open('/etc/issue.net', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if lines.find('openatv') != -1: | ||||||
|  |             atvimage='okfeedCAMatv' | ||||||
|  |     return atvimage | ||||||
|  |  | ||||||
|  | #check install | ||||||
|  | def getNeoLocation(): | ||||||
|  |     locatino='UNKNOWN' | ||||||
|  |     if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location'): | ||||||
|  |         with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location', 'r') as f: | ||||||
|  |             locatino = f.readline().strip() | ||||||
|  |             f.close()      | ||||||
|  |     return locatino | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #check ext | ||||||
|  | def getFormat(): | ||||||
|  |     neoformat='UNKNOWN'     | ||||||
|  |     if os.path.exists('/proc/mounts'): | ||||||
|  |         with open('/proc/mounts', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if lines.find('ext2') != -1: | ||||||
|  |             neoformat='ext2' | ||||||
|  |         elif lines.find('ext3') != -1: | ||||||
|  |             neoformat='ext3' | ||||||
|  |         elif lines.find('ext4') != -1: | ||||||
|  |             neoformat='ext4' | ||||||
|  |         elif lines.find('nfs') != -1: | ||||||
|  |             neoformat='nfs' | ||||||
|  |  | ||||||
|  |     return neoformat  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def getNEO_filesystems(): | ||||||
|  |     neo_filesystems='UNKNOWN'     | ||||||
|  |     if os.path.exists('/tmp/.neo_format'): | ||||||
|  |         with open('/tmp/.neo_format', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if lines.find('ext2') != -1: | ||||||
|  |             neo_filesystems='1' | ||||||
|  |         elif lines.find('ext3') != -1: | ||||||
|  |             neo_filesystems='1' | ||||||
|  |         elif lines.find('ext4') != -1: | ||||||
|  |             neo_filesystems='1' | ||||||
|  |         elif lines.find('nfs') != -1: | ||||||
|  |             neo_filesystems='1' | ||||||
|  |  | ||||||
|  |     return neo_filesystems | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def Log(param = ''): | ||||||
|  |     global LogFileObj | ||||||
|  |     #first close object if exists | ||||||
|  |     if param.lower() in ['open','write','append','close']: | ||||||
|  |         if LogFileObj is not None: | ||||||
|  |             LogFileObj.close() | ||||||
|  |             if LogFileObj.closed: | ||||||
|  |                 LogFileObj = None | ||||||
|  |                 try: | ||||||
|  |                     with open('/tmp/NeoBoot.log','a') as f: | ||||||
|  |                         f.write('LogFile closed properly\n') | ||||||
|  |                         f.close() | ||||||
|  |                 except Exception: | ||||||
|  |                     print("ERROR closing LogFile!!!") | ||||||
|  |             else: | ||||||
|  |                 print("ERROR closing LogFile!!!") | ||||||
|  |     #second create object if does not exist | ||||||
|  |     if LogFileObj is None: | ||||||
|  |         if param.lower() in ['open','write']: | ||||||
|  |             LogFileObj = open(LogFile, "w") | ||||||
|  |         elif param.lower() in ['append']: | ||||||
|  |             LogFileObj = open(LogFile, "a") | ||||||
|  |         elif param.lower() in ['close']: | ||||||
|  |             pass | ||||||
|  |     elif param.lower() in ['flush']: | ||||||
|  |         LogFileObj.flush() | ||||||
|  |     return LogFileObj | ||||||
|  |      | ||||||
|  | def clearMemory(): | ||||||
|  |     with open("/proc/sys/vm/drop_caches", "w") as f: | ||||||
|  |         f.write("1\n") | ||||||
|  |         f.close() | ||||||
|  | ############################################### | ||||||
|  |  | ||||||
|  | #typ procesora arm lub mips | ||||||
|  | def getCPUtype(): | ||||||
|  |     cpu='UNKNOWN' | ||||||
|  |     if os.path.exists('/proc/cpuinfo'): | ||||||
|  |         with open('/proc/cpuinfo', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if lines.find('ARMv7') != -1: | ||||||
|  |             cpu='ARMv7' | ||||||
|  |         elif lines.find('mips') != -1: | ||||||
|  |             cpu='MIPS' | ||||||
|  |     return cpu     | ||||||
|  |  | ||||||
|  | #check install | ||||||
|  | def getFSTAB(): | ||||||
|  |     install='UNKNOWN' | ||||||
|  |     if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid'): | ||||||
|  |         with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if lines.find('UUID') != -1: | ||||||
|  |             install='UUID' | ||||||
|  |         elif not lines.find('UUID') != -1: | ||||||
|  |             install='NOUUID' | ||||||
|  |     return install  | ||||||
|  |      | ||||||
|  | def getFSTAB2(): | ||||||
|  |     install='UNKNOWN' | ||||||
|  |     if os.path.exists('/etc/fstab'): | ||||||
|  |         with open('/etc/fstab', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if lines.find('UUID') != -1: | ||||||
|  |             install='OKinstall' | ||||||
|  |         elif not lines.find('UUID') != -1: | ||||||
|  |             install='NOUUID' | ||||||
|  |     return install     | ||||||
|  |  | ||||||
|  | def getINSTALLNeo(): | ||||||
|  |     neoinstall='UNKNOWN' | ||||||
|  |     if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/installNeo'): | ||||||
|  |         with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/installNeo', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if lines.find('/dev/sda1') != -1: | ||||||
|  |             neoinstall='/dev/sda1' | ||||||
|  |         elif lines.find('/dev/sda2') != -1: | ||||||
|  |             neoinstall='/dev/sda2'             | ||||||
|  |         elif lines.find('/dev/sdb1') != -1: | ||||||
|  |             neoinstall='/dev/sdb1' | ||||||
|  |         elif lines.find('/dev/sdb2') != -1: | ||||||
|  |             neoinstall='/dev/sdb2' | ||||||
|  |         elif lines.find('/dev/sdc1') != -1: | ||||||
|  |             neoinstall='/dev/sdc1'              | ||||||
|  |         elif lines.find('/dev/sdd1') != -1: | ||||||
|  |             neoinstall='/dev/sdd1'  | ||||||
|  |         elif lines.find('/dev/sde1') != -1: | ||||||
|  |             neoinstall='/dev/sde1'                          | ||||||
|  |         elif lines.find('/dev/sdf1') != -1: | ||||||
|  |             neoinstall='/dev/sdf1'    | ||||||
|  |  | ||||||
|  |     return neoinstall | ||||||
|  |      | ||||||
|  |  | ||||||
|  | def getLocationMultiboot():     | ||||||
|  |     LocationMultiboot='UNKNOWN' | ||||||
|  |     if os.path.exists('/media/sda1/ImageBoot'): | ||||||
|  |             LocationMultiboot='/dev/sda1' | ||||||
|  |     if os.path.exists('/media/sda2/ImageBoot'): | ||||||
|  |             LocationMultiboot='/dev/sda2' | ||||||
|  |     if os.path.exists('/media/sdb1/ImageBoot'): | ||||||
|  |             LocationMultiboot='/dev/sdb1' | ||||||
|  |     if os.path.exists('/media/sdb2/ImageBoot'): | ||||||
|  |             LocationMultiboot='/dev/sdb2'                         | ||||||
|  |     if os.path.exists('/media/sdc1/ImageBoot'): | ||||||
|  |             LocationMultiboot='/dev/sdc1'             | ||||||
|  |     if os.path.exists('/media/sdd1/ImageBoot'): | ||||||
|  |             LocationMultiboot='/dev/sdd1'                         | ||||||
|  |     if os.path.exists('/media/sde1/ImageBoot'): | ||||||
|  |             LocationMultiboot='/dev/sde1'             | ||||||
|  |     if os.path.exists('/media/sdf1/ImageBoot'): | ||||||
|  |             LocationMultiboot='/dev/sdf1'    | ||||||
|  |  | ||||||
|  |     return LocationMultiboot | ||||||
|  |  | ||||||
|  | def getLabelDisck(): | ||||||
|  |     label='UNKNOWN' | ||||||
|  |     if os.path.exists('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid'): | ||||||
|  |         with open('/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/bin/reading_blkid', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if lines.find('LABEL=') != -1: | ||||||
|  |             label='LABEL='       | ||||||
|  |     return label    | ||||||
|  |  | ||||||
|  | #checking device  neo       | ||||||
|  | def getNeoMount(): | ||||||
|  |     neo='UNKNOWN' | ||||||
|  |     if os.path.exists('/proc/mounts'): | ||||||
|  |         with open('/proc/mounts', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if lines.find('/dev/sda1 /media/hdd') != -1: | ||||||
|  |             neo='hdd_install_/dev/sda1' | ||||||
|  |         elif lines.find('/dev/sdb1 /media/hdd') != -1: | ||||||
|  |             neo='hdd_install_/dev/sdb1' | ||||||
|  |         elif lines.find('/dev/sda2 /media/hdd') != -1: | ||||||
|  |             neo='hdd_install_/dev/sda2' | ||||||
|  |         elif lines.find('/dev/sdb2 /media/hdd') != -1: | ||||||
|  |             neo='hdd_install_/dev/sdb2' | ||||||
|  |         elif lines.find('/dev/sdc1 /media/hdd') != -1: | ||||||
|  |             neo='hdd_install_/dev/sdc1' | ||||||
|  |         elif lines.find('/dev/sdd1 /media/hdd') != -1: | ||||||
|  |             neo='hdd_install_/dev/sdd1' | ||||||
|  |         elif lines.find('/dev/sde1 /media/hdd') != -1: | ||||||
|  |             neo='hdd_install_/dev/sde1' | ||||||
|  |         elif lines.find('/dev/sdf1 /media/hdd') != -1: | ||||||
|  |             neo='hdd_install_/dev/sdf1' | ||||||
|  |  | ||||||
|  |     return neo  | ||||||
|  |  | ||||||
|  | def getNeoMount2(): | ||||||
|  |     neo='UNKNOWN' | ||||||
|  |     if os.path.exists('/proc/mounts'): | ||||||
|  |         with open('/proc/mounts', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if lines.find('/dev/sda1 /media/usb') != -1: | ||||||
|  |             neo='usb_install_/dev/sda1' | ||||||
|  |         elif lines.find('/dev/sdb1 /media/usb') != -1: | ||||||
|  |             neo='usb_install_/dev/sdb1' | ||||||
|  |         elif lines.find('/dev/sdb2 /media/usb') != -1: | ||||||
|  |             neo='usb_install_/dev/sdb2' | ||||||
|  |         elif lines.find('/dev/sdc1 /media/usb') != -1: | ||||||
|  |             neo='usb_install_/dev/sdc1' | ||||||
|  |         elif lines.find('/dev/sdd1 /media/usb') != -1: | ||||||
|  |             neo='usb_install_/dev/sdd1' | ||||||
|  |         elif lines.find('/dev/sde1 /media/usb') != -1: | ||||||
|  |             neo='usb_install_/dev/sde1' | ||||||
|  |         elif lines.find('/dev/sdf1 /media/usb') != -1: | ||||||
|  |             neo='usb_install_/dev/sdf1'             | ||||||
|  |         elif lines.find('/dev/sda1 /media/usb2') != -1: | ||||||
|  |             neo='usb_install_/dev/sda1' | ||||||
|  |         elif lines.find('/dev/sdb1 /media/usb2') != -1: | ||||||
|  |             neo='usb_install_/dev/sdb1' | ||||||
|  |         elif lines.find('/dev/sdb2 /media/usb2') != -1: | ||||||
|  |             neo='usb_install_/dev/sdb2' | ||||||
|  |         elif lines.find('/dev/sdc1 /media/usb2') != -1: | ||||||
|  |             neo='usb_install_/dev/sdc1' | ||||||
|  |         elif lines.find('/dev/sdd1 /media/usb2') != -1: | ||||||
|  |             neo='usb_install_/dev/sdd1' | ||||||
|  |         elif lines.find('/dev/sde1 /media/usb2') != -1: | ||||||
|  |             neo='usb_install_/dev/sde1' | ||||||
|  |         elif lines.find('/dev/sdf1 /media/usb2') != -1: | ||||||
|  |             neo='usb_install_/dev/sdf1' | ||||||
|  |  | ||||||
|  |     return neo | ||||||
|  |  | ||||||
|  | def getNeoMount3(): | ||||||
|  |     neo='UNKNOWN' | ||||||
|  |     if os.path.exists('/proc/mounts'): | ||||||
|  |         with open('/proc/mounts', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if lines.find('/dev/sda1 /media/cf') != -1: | ||||||
|  |             neo='cf_install_/dev/sda1' | ||||||
|  |         elif lines.find('/dev/sdb1 /media/cf') != -1: | ||||||
|  |             neo='cf_install_/dev/sdb1' | ||||||
|  |     return neo | ||||||
|  |  | ||||||
|  | def getNeoMount4(): | ||||||
|  |     neo='UNKNOWN' | ||||||
|  |     if os.path.exists('/proc/mounts'): | ||||||
|  |         with open('/proc/mounts', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close()             | ||||||
|  |         if lines.find('/dev/sda1 /media/card') != -1: | ||||||
|  |             neo='card_install_/dev/sda1' | ||||||
|  |         elif lines.find('/dev/sdb1 /media/card') != -1: | ||||||
|  |             neo='card_install_/dev/sdb1' | ||||||
|  |     return neo | ||||||
|  |      | ||||||
|  | def getNeoMount5(): | ||||||
|  |     neo='UNKNOWN' | ||||||
|  |     if os.path.exists('/proc/mounts'): | ||||||
|  |         with open('/proc/mounts', 'r') as f: | ||||||
|  |             lines = f.read() | ||||||
|  |             f.close() | ||||||
|  |         if lines.find('/dev/sda1 /media/mmc') != -1: | ||||||
|  |             neo='mmc_install_/dev/sda1' | ||||||
|  |         elif lines.find('/dev/sdb1 /media/mmc') != -1: | ||||||
|  |             neo='mmc_install_/dev/sdb1' | ||||||
|  |     return neo | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #zwraca typ chipa prcesora     | ||||||
|  | def getCPUSoC(): | ||||||
|  |     chipset='UNKNOWN' | ||||||
|  |     if os.path.exists('/proc/stb/info/chipset'): | ||||||
|  |         with open('/proc/stb/info/chipset', 'r') as f: | ||||||
|  |             chipset = f.readline().strip() | ||||||
|  |             f.close()      | ||||||
|  |         if chipset == '7405(with 3D)': | ||||||
|  |                 chipset = '7405' | ||||||
|  |     return chipset | ||||||
|  |      | ||||||
|  | def getCPUSoCModel(): | ||||||
|  |     devicetree='UNKNOWN' | ||||||
|  |     if os.path.exists('/proc/device-tree/model'): | ||||||
|  |         with open('/proc/device-tree/model', 'r') as f: | ||||||
|  |             devicetree = f.readline().strip() | ||||||
|  |             f.close()         | ||||||
|  |     return devicetree    | ||||||
|  |  | ||||||
|  | #zwraca wybrane image w neoboot do uruchomienia    | ||||||
|  | def getImageNeoBoot():    | ||||||
|  |     imagefile='UNKNOWN' | ||||||
|  |     if os.path.exists('%sImageBoot/.neonextboot' % getNeoLocation() ): | ||||||
|  |         with open('%sImageBoot/.neonextboot' % getNeoLocation() , 'r') as f: | ||||||
|  |             imagefile = f.readline().strip() | ||||||
|  |             f.close()  | ||||||
|  |     return imagefile | ||||||
|  |  | ||||||
|  | #zwraca model vuplus    | ||||||
|  | def getBoxVuModel(): | ||||||
|  |     vumodel='UNKNOWN' | ||||||
|  |     if fileExists("/proc/stb/info/vumodel") and not fileExists("/proc/stb/info/boxtype"): | ||||||
|  |         with open('/proc/stb/info/vumodel', 'r') as f: | ||||||
|  |             vumodel = f.readline().strip() | ||||||
|  |             f.close()  | ||||||
|  |     elif fileExists("/proc/stb/info/boxtype") and not fileExists("/proc/stb/info/vumodel"): | ||||||
|  |         with open('/proc/stb/info/boxtype', 'r') as f: | ||||||
|  |             vumodel = f.readline().strip() | ||||||
|  |             f.close() | ||||||
|  |     return vumodel | ||||||
|  |  | ||||||
|  | def getVuModel(): | ||||||
|  |     if fileExists("/proc/stb/info/vumodel") and not fileExists("/proc/stb/info/boxtype"): | ||||||
|  |         brand = "Vu+" | ||||||
|  |         f = open("/proc/stb/info/vumodel",'r') | ||||||
|  |         procmodel = f.readline().strip() | ||||||
|  |         f.close() | ||||||
|  |         model = procmodel.title().replace("olose", "olo SE").replace("olo2se", "olo2 SE").replace("2", "²") | ||||||
|  |     return model     | ||||||
|  |  | ||||||
|  | #zwraca nazwe stb z pliku hostname     | ||||||
|  | def getBoxHostName(): | ||||||
|  |     if os.path.exists('/etc/hostname'): | ||||||
|  |         with open('/etc/hostname', 'r') as f: | ||||||
|  |             myboxname = f.readline().strip() | ||||||
|  |             f.close()    | ||||||
|  |     return myboxname     | ||||||
|  |  | ||||||
|  | #zwraca vuplus/vumodel  | ||||||
|  | def getTunerModel(): #< neoboot.py | ||||||
|  |     BOX_NAME = '' | ||||||
|  |     if os.path.isfile('/proc/stb/info/vumodel') and not os.path.isfile("/proc/stb/info/boxtype"): | ||||||
|  |         BOX_NAME = open('/proc/stb/info/vumodel').read().strip() | ||||||
|  |         ImageFolder = 'vuplus/%s' % BOX_NAME | ||||||
|  |     elif os.path.isfile('proc/stb/info/boxtype'): | ||||||
|  |         BOX_NAME = open('/proc/stb/info/boxtype').read().strip() | ||||||
|  |     elif os.path.isfile('proc/stb/info/model') and not os.path.isfile("/proc/stb/info/mid"): | ||||||
|  |         BOX_NAME = open('/proc/stb/info/model').read().strip() | ||||||
|  |     return BOX_NAME | ||||||
|  |      | ||||||
|  | def getBoxModelVU(): | ||||||
|  |     try: | ||||||
|  |         if os.path.isfile('/proc/stb/info/vumodel'): | ||||||
|  |             return open('/proc/stb/info/vumodel').read().strip().upper() | ||||||
|  |     except: | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  |     return _('unavailable') | ||||||
|  |  | ||||||
|  | #zwraca strukture folderu zip - vuplus/vumodel | ||||||
|  | def getImageFolder(): | ||||||
|  |     if os.path.isfile('/proc/stb/info/vumodel'): | ||||||
|  |         BOX_NAME = getBoxModelVU() | ||||||
|  |         ImageFolder = 'vuplus/' + BOX_NAME | ||||||
|  |     return ImageFolder | ||||||
|  |  | ||||||
|  | #zwraca nazwe kernela z /lib/modules | ||||||
|  | def getKernelVersion(): | ||||||
|  |     try: | ||||||
|  |         return open('/proc/version', 'r').read().split(' ', 4)[2].split('-', 2)[0] | ||||||
|  |     except: | ||||||
|  |         return _('unknown') | ||||||
|  |  | ||||||
|  | # czysci pamiec | ||||||
|  | def runCMDS(cmdsList): | ||||||
|  |     clearMemory() | ||||||
|  |     if isinstance(cmdsList, (list, tuple)): | ||||||
|  |         myCMD = '\n'.join(cmdsList)# + '\n' | ||||||
|  |     ret = os.system(myCMD) | ||||||
|  |     return rett            | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def getImageDistroN():  | ||||||
|  |     image='Internal storage'              | ||||||
|  |  | ||||||
|  |     if fileExists('/.multinfo') and fileExists ('%sImageBoot/.imagedistro' % getNeoLocation() ):  | ||||||
|  |                     with open('%sImageBoot/.imagedistro' % getNeoLocation() , 'r') as f: | ||||||
|  |                         image = f.readline().strip() | ||||||
|  |                         f.close() | ||||||
|  |                          | ||||||
|  |     elif not fileExists('/.multinfo') and fileExists('/etc/vtiversion.info'): | ||||||
|  |                     f = open("/etc/vtiversion.info",'r') | ||||||
|  |                     imagever = f.readline().strip().replace("Release ", " ") | ||||||
|  |                     f.close() | ||||||
|  |                     image = imagever | ||||||
|  |  | ||||||
|  |     elif not fileExists('/.multinfo') and fileExists('/etc/bhversion'): | ||||||
|  |                     f = open("/etc/bhversion",'r') | ||||||
|  |                     imagever = f.readline().strip() | ||||||
|  |                     f.close() | ||||||
|  |                     image = imagever | ||||||
|  |  | ||||||
|  | #    elif not fileExists('/.multinfo') and fileExists('/etc/vtiversion.info'): | ||||||
|  | #                    image = 'VTI Team Image '  | ||||||
|  |                      | ||||||
|  |     elif fileExists('/.multinfo') and fileExists('/etc/bhversion'): | ||||||
|  |                     image = 'Flash ' + ' ' + getBoxHostName() | ||||||
|  |  | ||||||
|  |     elif fileExists('/.multinfo') and fileExists('/etc/vtiversion.info'): | ||||||
|  |                     image = 'Flash ' + ' ' + getBoxHostName() | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     elif fileExists('/usr/lib/enigma2/python/boxbranding.so') and not fileExists('/.multinfo'):  | ||||||
|  |                     from boxbranding import getImageDistro | ||||||
|  |                     image = getImageDistro() | ||||||
|  |  | ||||||
|  |     elif fileExists('/media/InternalFlash/etc/issue.net') and fileExists('/.multinfo') and not fileExists('%sImageBoot/.imagedistro' % getNeoLocation() ): | ||||||
|  |                     obraz = open('/media/InternalFlash/etc/issue.net', 'r').readlines() | ||||||
|  |                     imagetype = obraz[0][:-3] | ||||||
|  |                     image = imagetype | ||||||
|  |       | ||||||
|  |     elif fileExists('/etc/issue.net') and not fileExists('/.multinfo'): | ||||||
|  |                     obraz = open('/etc/issue.net', 'r').readlines() | ||||||
|  |                     imagetype = obraz[0][:-3] | ||||||
|  |                     image = imagetype                         | ||||||
|  |  | ||||||
|  |     else: | ||||||
|  |                     image = 'Inernal Flash ' + ' ' + getBoxHostName() | ||||||
|  |  | ||||||
|  |     return image | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def getKernelVersionString(): | ||||||
|  |     try: | ||||||
|  |         result = popen('uname -r', 'r').read().strip('\n').split('-') | ||||||
|  |         kernel_version = result[0] | ||||||
|  |         return kernel_version | ||||||
|  |     except: | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  |     return 'unknown' | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def getKernelImageVersion(): | ||||||
|  |     try: | ||||||
|  |         from glob import glob | ||||||
|  |         lines = open(glob('/var/lib/opkg/info/kernel-*.control')[0], 'r').readlines() | ||||||
|  |         kernelimage = lines[1][:-1] | ||||||
|  |     except: | ||||||
|  |         kernelimage = getKernelVersionString | ||||||
|  |  | ||||||
|  |     return kernelimage | ||||||
|  |  | ||||||
|  | def getTypBoxa(): | ||||||
|  |     if not fileExists('/etc/typboxa'): | ||||||
|  |         os.system('touch /etc/typboxa') | ||||||
|  |         f2 = open('/etc/hostname', 'r') | ||||||
|  |         mypath2 = f2.readline().strip() | ||||||
|  |         f2.close() | ||||||
|  |         if mypath2 == 'vuuno': | ||||||
|  |             out = open('/etc/typboxa ', 'w') | ||||||
|  |             out.write('Vu+Uno ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'vuultimo': | ||||||
|  |             out = open('/etc/typboxa', 'w') | ||||||
|  |             out.write('Vu+Ultimo ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'vuduo': | ||||||
|  |             out = open('/etc/typboxa ', 'w') | ||||||
|  |             out.write('Vu+Duo ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'vuduo2': | ||||||
|  |             out = open('/etc/typboxa ', 'w') | ||||||
|  |             out.write('Vu+Duo2 ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'vusolo': | ||||||
|  |             out = open('/etc/typboxa ', 'w') | ||||||
|  |             out.write('Vu+Solo ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'vusolo2': | ||||||
|  |             out = open('/etc/typboxa ', 'w') | ||||||
|  |             out.write('Vu+Solo2 ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'vusolose': | ||||||
|  |             out = open('/etc/typboxa ', 'w') | ||||||
|  |             out.write('Vu+Solo-SE ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'vuvzero': | ||||||
|  |             out = open('/etc/typboxa ', 'w') | ||||||
|  |             out.write('Vu+Zero ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'vuuno4k': | ||||||
|  |             out = open('/etc/typboxa ', 'w') | ||||||
|  |             out.write('Vu+Uno4k ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'vuultimo4k': | ||||||
|  |             out = open('/etc/typboxa ', 'w') | ||||||
|  |             out.write('Vu+Ultimo4k ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'vusolo4k': | ||||||
|  |             out = open('/etc/typboxa ', 'w') | ||||||
|  |             out.write('Vu+Solo4k ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'mbmini': | ||||||
|  |             out = open('/etc/typboxa', 'w') | ||||||
|  |             out.write('Miraclebox-Mini ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'mutant51': | ||||||
|  |             out = open('/etc/typboxa', 'w') | ||||||
|  |             out.write('Mutant 51 ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'sf4008': | ||||||
|  |             out = open('/etc/typboxa', 'w') | ||||||
|  |             out.write('Ocatgon sf4008 ') | ||||||
|  |             out.close() | ||||||
|  |         elif mypath2 == 'ax51': | ||||||
|  |             out = open('/etc/typboxa', 'w') | ||||||
|  |             out.write('ax51 ') | ||||||
|  |             out.close() | ||||||
|  |  | ||||||
|  |     try: | ||||||
|  |         lines = open('/etc/typboxa', 'r').readlines() | ||||||
|  |         typboxa = lines[0][:-1] | ||||||
|  |     except: | ||||||
|  |         typboxa = 'not detected' | ||||||
|  |  | ||||||
|  |     return typboxa | ||||||
|  |  | ||||||
|  | def getImageVersionString(): | ||||||
|  |     try: | ||||||
|  |         if os.path.isfile('/var/lib/opkg/status'): | ||||||
|  |             st = os.stat('/var/lib/opkg/status') | ||||||
|  |         else: | ||||||
|  |             st = os.stat('/usr/lib/ipkg/status') | ||||||
|  |         tm = time.localtime(st.st_mtime) | ||||||
|  |         if tm.tm_year >= 2015: | ||||||
|  |             return time.strftime('%Y-%m-%d %H:%M:%S', tm) | ||||||
|  |     except: | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  |     return _('unavailable') | ||||||
|  |  | ||||||
|  | def getModelString(): | ||||||
|  |     try: | ||||||
|  |         file = open('/proc/stb/info/boxtype', 'r') | ||||||
|  |         model = file.readline().strip() | ||||||
|  |         file.close() | ||||||
|  |         return model | ||||||
|  |     except IOError: | ||||||
|  |         return 'unknown' | ||||||
|  |  | ||||||
|  | def getChipSetString(): | ||||||
|  |     try: | ||||||
|  |         f = open('/proc/stb/info/chipset', 'r') | ||||||
|  |         chipset = f.read() | ||||||
|  |         f.close() | ||||||
|  |         return str(chipset.lower().replace('\n', '').replace('bcm', '')) | ||||||
|  |     except IOError: | ||||||
|  |         return 'unavailable' | ||||||
|  |          | ||||||
|  | def getCPUString(): | ||||||
|  |     try: | ||||||
|  |         file = open('/proc/cpuinfo', 'r') | ||||||
|  |         lines = file.readlines() | ||||||
|  |         for x in lines: | ||||||
|  |             splitted = x.split(': ') | ||||||
|  |             if len(splitted) > 1: | ||||||
|  |                 splitted[1] = splitted[1].replace('\n', '') | ||||||
|  |                 if splitted[0].startswith('system type'): | ||||||
|  |                     system = splitted[1].split(' ')[0] | ||||||
|  |                 elif splitted[0].startswith('Processor'): | ||||||
|  |                     system = splitted[1].split(' ')[0] | ||||||
|  |  | ||||||
|  |         file.close() | ||||||
|  |         return system | ||||||
|  |     except IOError: | ||||||
|  |         return 'unavailable' | ||||||
|  |  | ||||||
|  | def getCpuCoresString(): | ||||||
|  |     try: | ||||||
|  |         file = open('/proc/cpuinfo', 'r') | ||||||
|  |         lines = file.readlines() | ||||||
|  |         for x in lines: | ||||||
|  |             splitted = x.split(': ') | ||||||
|  |             if len(splitted) > 1: | ||||||
|  |                 splitted[1] = splitted[1].replace('\n', '') | ||||||
|  |                 if splitted[0].startswith('processor'): | ||||||
|  |                     if int(splitted[1]) > 0: | ||||||
|  |                         cores = 2 | ||||||
|  |                     else: | ||||||
|  |                         cores = 1 | ||||||
|  |  | ||||||
|  |         file.close() | ||||||
|  |         return cores | ||||||
|  |     except IOError: | ||||||
|  |         return 'unavailable' | ||||||
|  |          | ||||||
|  | def getEnigmaVersionString(): | ||||||
|  |     import enigma | ||||||
|  |     enigma_version = enigma.getEnigmaVersionString() | ||||||
|  |     if '-(no branch)' in enigma_version: | ||||||
|  |         enigma_version = enigma_version[:-12] | ||||||
|  |     return enigma_version | ||||||
|  |      | ||||||
|  | def getKernelVersionString(): | ||||||
|  |     try: | ||||||
|  |         f = open('/proc/version', 'r') | ||||||
|  |         kernelversion = f.read().split(' ', 4)[2].split('-', 2)[0] | ||||||
|  |         f.close() | ||||||
|  |         return kernelversion | ||||||
|  |     except: | ||||||
|  |         return _('unknown') | ||||||
|  |  | ||||||
|  | def getHardwareTypeString(): | ||||||
|  |     try: | ||||||
|  |         if os.path.isfile('/proc/stb/info/boxtype'): | ||||||
|  |             return open('/proc/stb/info/boxtype').read().strip().upper() + ' (' + open('/proc/stb/info/board_revision').read().strip() + '-' + open('/proc/stb/info/version').read().strip() + ')' | ||||||
|  |         if os.path.isfile('/proc/stb/info/vumodel'): | ||||||
|  |             return 'VU+' + open('/proc/stb/info/vumodel').read().strip().upper() + '(' + open('/proc/stb/info/version').read().strip().upper() + ')' | ||||||
|  |         if os.path.isfile('/proc/stb/info/model'): | ||||||
|  |             return open('/proc/stb/info/model').read().strip().upper() | ||||||
|  |     except: | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  |     return _('unavailable') | ||||||
|  |  | ||||||
|  | def getImageTypeString(): | ||||||
|  |     try: | ||||||
|  |         return open('/etc/issue').readlines()[-2].capitalize().strip()[:-6] | ||||||
|  |     except: | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  |     return _('undefined') | ||||||
|  |  | ||||||
|  | def getMachineBuild(): | ||||||
|  |     try: | ||||||
|  |         return open('/proc/version', 'r').read().split(' ', 4)[2].split('-', 2)[0] | ||||||
|  |     except: | ||||||
|  |         return 'unknown' | ||||||
|  |  | ||||||
|  | def getVuBoxModel(): | ||||||
|  |     if fileExists('/proc/stb/info/vumodel'): | ||||||
|  |         try: | ||||||
|  |             l = open('/proc/stb/info/vumodel') | ||||||
|  |             model = l.read() | ||||||
|  |             l.close() | ||||||
|  |             BOX_NAME = str(model.lower().strip()) | ||||||
|  |             l.close() | ||||||
|  |             BOX_MODEL = 'vuplus' | ||||||
|  |         except: | ||||||
|  |             BOX_MODEL = 'not detected' | ||||||
|  |  | ||||||
|  |     return BOX_MODEL | ||||||
|  |  | ||||||
|  | def getMachineProcModel(): | ||||||
|  |     if os.path.isfile('/proc/stb/info/vumodel'): | ||||||
|  |         BOX_NAME = getBoxModel() | ||||||
|  |         BOX_MODEL = getVuBoxModel() | ||||||
|  |         if BOX_MODEL == 'vuplus': | ||||||
|  |             if BOX_NAME == 'duo': | ||||||
|  |                 GETMACHINEPROCMODEL = 'bcm7335' | ||||||
|  |             elif BOX_NAME == 'solo': | ||||||
|  |                 GETMACHINEPROCMODEL = 'bcm7325' | ||||||
|  |             elif BOX_NAME == 'solo2': | ||||||
|  |                 GETMACHINEPROCMODEL = 'bcm7346' | ||||||
|  |             elif BOX_NAME == 'solose': | ||||||
|  |                 GETMACHINEPROCMODEL = 'bcm7241' | ||||||
|  |             elif BOX_NAME == 'ultimo' or BOX_NAME == 'uno': | ||||||
|  |                 GETMACHINEPROCMODEL = 'bcm7413' | ||||||
|  |             elif BOX_NAME == 'zero': | ||||||
|  |                 GETMACHINEPROCMODEL = 'bcm7362' | ||||||
|  |             elif BOX_NAME == 'duo2': | ||||||
|  |                 GETMACHINEPROCMODEL = 'bcm7425' | ||||||
|  |             elif BOX_NAME == 'ultimo4k': | ||||||
|  |                 GETMACHINEPROCMODEL = 'bcm7444S' | ||||||
|  |             elif BOX_NAME == 'uno4k': | ||||||
|  |                 GETMACHINEPROCMODEL = 'bcm7252S' | ||||||
|  |             elif BOX_NAME == 'solo4k': | ||||||
|  |                 GETMACHINEPROCMODEL = 'bcm7376'  | ||||||
|  |             elif BOX_NAME == 'zero4K': | ||||||
|  |                 GETMACHINEPROCMODEL = 'bcm72604' | ||||||
|  |             elif BOX_NAME == 'uno4kse': | ||||||
|  |                 GETMACHINEPROCMODEL = ''                                                | ||||||
|  |             procmodel = getMachineProcModel() | ||||||
|  |     return procmodel | ||||||
|  |      | ||||||
|  |  | ||||||
|  | boxbrand = sys.modules[__name__] | ||||||
|  |  | ||||||
							
								
								
									
										1853
									
								
								NeoBoot/files/tools.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1853
									
								
								NeoBoot/files/tools.py
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										66
									
								
								NeoBoot/files/userscript.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								NeoBoot/files/userscript.sh
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | |||||||
|  | #!/bin/sh  | ||||||
|  | # script gutosie  | ||||||
|  | # here you can add your own command to perform | ||||||
|  | # line - Checking internet connection by @j00zek thank you     | ||||||
|  |  | ||||||
|  | IMAGEKATALOG=ImageBoot                 | ||||||
|  |  | ||||||
|  | if [ -e /.control_boot_new_image ] ; then | ||||||
|  |     passwd -d root | ||||||
|  |     ln -sf "/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot" "/NeoBoot" | ||||||
|  | fi | ||||||
|  |  | ||||||
|  |  | ||||||
|  | if [ ! -e `cat /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location`$IMAGEKATALOG/.neonextboot ] ; then | ||||||
|  |         mkdir `cat /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/.location`  | ||||||
|  |         /usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/files/neo.sh   | ||||||
|  |         echo "_(_________Start mountpoint location NEOBOOT_________)"           | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | echo "_(Checking internet connection)..." | ||||||
|  | ping -c 1 github.com 1>/dev/null 2>%1  | ||||||
|  | if [ $? -gt 0 ]; then  | ||||||
|  |       echo -n "_(github server unavailable, update impossible)\n!!! network restart...!!! )"        | ||||||
|  |       /etc/init.d/networking stop;  | ||||||
|  | 	  echo "_____(stopping network connection)_____"  | ||||||
|  | 	  sleep 1;  | ||||||
|  | 	  /etc/init.d/networking start;  | ||||||
|  | 	  echo "_____(start network connection)_____" 	   | ||||||
|  | 	  sleep 5 | ||||||
|  | 	   | ||||||
|  |       if [ $? -gt 0 ]; then | ||||||
|  |           if [ -e /usr/bin/curl ]; then | ||||||
|  |               cd /tmp; curl -O --ftp-ssl https://raw.githubusercontent.com/gutosie/NeoBoot8/master/ver.txt;  | ||||||
|  |               cd / | ||||||
|  |           elif [ -e /usr/bin/wget ]; then | ||||||
|  |               wget https://raw.githubusercontent.com/gutosie/NeoBoot8/master/ver.txt -O /tmp/ver.txt | ||||||
|  |               cd / | ||||||
|  |  | ||||||
|  |           fi | ||||||
|  |           if [ ! -f /tmp/ver.txt ] ; then | ||||||
|  |               /etc/init.d/networking stop;  | ||||||
|  | 			  echo "_____(stopping network connection)_____"  | ||||||
|  |               sleep 2;  | ||||||
|  |               /etc/init.d/networking start; | ||||||
|  | 			  echo "_____(start network connection)_____" | ||||||
|  | 			   | ||||||
|  |           fi | ||||||
|  |       fi | ||||||
|  |        | ||||||
|  | #      echo "        dns-nameservers 1.1.1.1 " >> /etc/network/interfaces      | ||||||
|  | else | ||||||
|  |     echo "_____!!!(github server available)!!!_____"   | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | if [ -e /%1 ] ; then | ||||||
|  |     rm -f /%1 | ||||||
|  | fi | ||||||
|  | if [ -e /home/root/%1 ] ; then | ||||||
|  |     rm -f /home/root/%1 | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | echo "!!!_____([NEOBOOT] used userscript)_____!!! "   | ||||||
|  | echo ok  | ||||||
|  |  | ||||||
|  | exit 0  | ||||||
|  |                                               | ||||||
		Reference in New Issue
	
	Block a user