def logsPageContent(self, MenuStatusMSG, htmlError, DebugFileName, DBGFileContent): tempText = '<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n' tempText += IncludeMENU(MenuStatusMSG) tempText += '<div class="main">\n' if htmlError == 'deleteLogOK': tempText += '<p align="center"><b><font color="#ccE4C4">%s</font></b></p>' % _('Debug file has been deleted') elif htmlError == 'deleteLogError': tempText += '<p align="center"><b><font color="#FFE4C4">%s</font></b></p>' % _('Error during deletion of the debug file.') elif htmlError == 'deleteLogNO': tempText += '<p align="center"><b><font color="#ccE4C4">%s</font></b></p>' % _('Debug file does not exist - nothing to delete') elif getDebugMode() not in ['console', 'debugfile']: tempText += '<p align="center"><b><font color="#FFE4C4">%s</font></b></p>' % _('Debug option is disabled - nothing to display') elif getDebugMode() == 'console': tempText += '<p align="center"><b><font color="#FFE4C4">%s</font></b></p>' % _('Debug option set to console - nothing to display') elif DebugFileName == '': tempText += '<p align="center"><b><font color="#FFE4C4">%s</font></b></p>' % _('Debug option set to debugfile, but file does not exist - nothing to display') else: tempText += '<table border="0"><td>%s</td>' % formSUBMITvalue([('cmd', 'downloadLog')], _("Download log file")) try: if os.path.getsize(DebugFileName) > 100000: LogDescr = _('%s file is %d MB in size. Last %d lines are:') % (DebugFileName, os.path.getsize(DebugFileName) >> 20, settings.MaxLogLinesToShow) tempText += '<td>%s</td>' % formSUBMITvalue([('cmd', 'deleteLog')], _("Delete log file")) else: LogDescr = _('%s file is %d KB in size. Last %d lines are:') % (DebugFileName, os.path.getsize(DebugFileName) / 1024, settings.MaxLogLinesToShow) except: LogDescr = _('Last %d lines of the %s file are:') % (settings.MaxLogLinesToShow, DebugFileName) tempText += '</table>\n' tempText += '<p><b><font color="#FFE4C4">%s</font></b></p>' % LogDescr tempText += '<table border="1: style="width:520px; table-layout: fixed"><td><tt><p><font size="2">' tempText += settings.tempLogsHTML + '</font></p></tt></td></table>' #<<< data from thread if settings.tempLogsHTML != '' and not isThreadRunning('buildtempLogsHTML'): settings.tempLogsHTML = '' tempText += formSUBMITvalue([('cmd', 'downloadLog')], _("Download log file")) tempText += '</div></body>\n' return tempText
def startExecution(self): login = config.plugins.iptvplayer.myjd_login.value password = config.plugins.iptvplayer.myjd_password.value jdname = config.plugins.iptvplayer.myjd_jdname.value captcha = { 'siteKey': self.sitekey, 'sameOrigin': True, 'siteUrl': self.referer, 'contextUrl': '/'.join(self.referer.split('/')[:3]), 'boundToDomain': True, 'stoken': None } try: captcha = base64.b64encode(json.dumps(captcha)) except Exception: printExc() if getDebugMode() == '': debug = 0 else: debug = 1 cmd = GetPyScriptCmd('fakejd') + ' "%s" "%s" "%s" "%s" "%s" %d' % ( GetPluginDir('libs/'), login, password, jdname, captcha, debug) self["console"].setText(_('JDownloader script execution')) self.workconsole['console'] = eConsoleAppContainer() self.workconsole['close_conn'] = eConnectCallback( self.workconsole['console'].appClosed, self._scriptClosed) self.workconsole['stderr_conn'] = eConnectCallback( self.workconsole['console'].stderrAvail, self._scriptStderrAvail) self.workconsole['stdout_conn'] = eConnectCallback( self.workconsole['console'].stdoutAvail, self._scriptStdoutAvail) self.workconsole["console"].execute(E2PrioFix(cmd, 0)) printDBG(">>> EXEC CMD [%s]" % cmd)
def js_execute(jscode, params={}): ret = {'sts': False, 'code': -12, 'data': ''} sts, tmpPath = CreateTmpFile('.iptv_js.js', jscode) if sts: ret = duktape_execute('-t %s ' % params.get('timeout_sec', 20) + ' ' + tmpPath) # leave last script for debug purpose if getDebugMode() == '': rm(tmpPath) printDBG('js_execute cmd ret[%s]' % ret) return ret
def _cmdFinished(self, code, terminated=False): printDBG("FFMPEGDownloader._cmdFinished code[%r] terminated[%r]" % (code, terminated)) if '' == getDebugMode(): rm(self.fileCmdPath) # break circular references if None != self.console: self.console_appClosed_conn = None self.console_stderrAvail_conn = None self.console = None if terminated: self.status = DMHelper.STS.INTERRUPTED elif 0 >= self.localFileSize: self.status = DMHelper.STS.ERROR elif self.totalDuration > 0 and self.totalDuration > self.downloadDuration: self.status = DMHelper.STS.INTERRUPTED else: self.status = DMHelper.STS.DOWNLOADED if not terminated: self.onFinish()
def js_execute_ext(items, params={}): fileList = [] tmpFiles = [] tid = thread.get_ident() uniqueId = 0 ret = {'sts': False, 'code': -13, 'data': ''} try: for item in items: # we can have source file or source code path = item.get('path', '') code = item.get('code', '') name = item.get('name', '') if name: # cache enabled hash = item.get('hash', '') if not hash: # we will need to calc hash by our self if path: sts, code = ReadTextFile(path) if not sts: raise Exception('Faile to read file "%s"!' % path) hash = hexlify(md5(code).digest()) byteFileName = GetJSCacheDir(name + '.byte') metaFileName = GetJSCacheDir(name + '.meta') if fileExists(byteFileName): sts, tmp = ReadTextFile(metaFileName) if sts: tmp = tmp.split('|') # DUKTAPE_VER|hash if DUKTAPE_VER != tmp[0] or hash != tmp[-1].strip(): sts = False if not sts: rm(byteFileName) rm(metaFileName) else: sts = False if not sts: # we need compile here if not path: path = '.%s.js' % name sts, path = CreateTmpFile(path, code) if not sts: raise Exception('Faile to create file "%s" "%s"' % (path, code)) tmpFiles.append(path) # remove old meta rm(metaFileName) # compile if 0 != duktape_execute('-c "%s" "%s" ' % (byteFileName, path))['code']: raise Exception( 'Compile to bytecode file "%s" > "%s" failed!' % (path, byteFileName)) # update meta if not WriteTextFile(metaFileName, '%s|%s' % (DUKTAPE_VER, hash)): raise Exception('Faile to write "%s" file!' % metaFileName) fileList.append(byteFileName) else: if path: fileList.append(path) else: path = 'e2i_js_exe_%s_%s.js' % (uniqueId, tid) uniqueId += 1 sts, path = CreateTmpFile(path, code) if not sts: raise Exception('Faile to create file "%s"' % path) tmpFiles.append(path) fileList.append(path) #ret = duktape_execute('-t %s ' % params.get('timeout_sec', 20) + ' '.join([ '"%s"' % file for file in fileList ]) ) ret = duktape_execute(' '.join(['"%s"' % file for file in fileList])) except Exception: printExc() # leave last script for debug purpose if getDebugMode() == '': for file in tmpFiles: rm(file) return ret