bool Gcc::run(QString filename) { if(!compile(filename)) return false; QString outputString; QFileInfo outputFileInfo(m_outputFileName); QFile scriptFile; #ifdef Q_OS_WIN32 scriptFile.setFileName(QDir::temp().absoluteFilePath("kiprBatchFile.cmd")); outputString += "@echo off\n"; outputString += "\"" + QDir::toNativeSeparators(outputFileInfo.absolutePath()) + "\\" + outputFileInfo.fileName() + "\"\n"; outputString += "pause\n"; #else scriptFile.setFileName(QDir::temp().absoluteFilePath("kiprScript.sh")); outputString += "#!/bin/bash\n"; outputString += "cd \"" + outputFileInfo.absolutePath() + "\"\n"; outputString += "\"./" + outputFileInfo.fileName() + "\"\n"; #endif if(!scriptFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { qWarning("Gcc::run() Unable to open temp file for writing"); return false; } scriptFile.setPermissions(scriptFile.permissions() | QFile::ExeOwner); scriptFile.write(outputString.toLocal8Bit()); scriptFile.close(); QStringList args; QFileInfo scriptInfo(scriptFile); m_outputBinary.setWorkingDirectory(outputFileInfo.absolutePath()); #ifdef Q_OS_WIN32 QString startLine = "start \"" + m_outputFileName + "\" \"cmd /c " + scriptInfo.absoluteFilePath() + "\"\n"; args << "/k"; m_outputBinary.start("cmd", args); m_outputBinary.write(startLine.toLocal8Bit()); m_outputBinary.write("exit\n"); #elif defined(Q_OS_MAC) args << "-a" << "/Applications/Utilities/Terminal.app" << scriptInfo.absoluteFilePath(); m_outputBinary.start("open", args); #else args << "-e" << scriptInfo.absoluteFilePath() + " && echo \"\nQuitting in 5 secs...\" && sleep 5"; m_outputBinary.start("xterm", args); #endif return true; }
void ScriptDebuggerPrivate::exceptionThrow(qint64 /*scriptId*/, const QScriptValue &exception, bool hasHandler) { if (!hasHandler) { errorMessage(QString::fromLatin1("uncaught exception: %0").arg(exception.toString())); QScriptContext *ctx = engine()->currentContext(); int lineNumber = QScriptContextInfo(ctx).lineNumber(); ScriptInfo *info = scriptInfo(ctx); QString lineText = info ? info->lineText(lineNumber) : QString("(no source text available)"); message(QString::fromLatin1("%0\t%1").arg(lineNumber).arg(lineText)); interactive(); } }
void VlcEncodingSystem::_DoEncode(const QString ¶mFile) { QFileInfo videoFile(QFileInfo(QFileInfo(paramFile).completeBaseName()).completeBaseName()); QDir dir(VlcStreamerApp::Instance()->DocumentRoot()); QString name; if(dir.exists(videoFile.completeBaseName())) { for(unsigned i = 1; i != ~0U; ++i) { if(dir.exists(videoFile.completeBaseName() + "_" + QString::number(i)) == false) { name = videoFile.completeBaseName() + "_" + QString::number(i); break; } } } else { name = videoFile.completeBaseName(); } if(name.isEmpty() == false) { dir.mkdir(name); dir.cd(name); dir.rename(paramFile, "params.txt"); #ifdef Q_WS_WIN QFileInfo scriptInfo(dir.path() + "/encode.bat"); #else QFileInfo scriptInfo(dir.path() + "/encode.sh"); #endif QFile script(scriptInfo.filePath()); QFile params(dir.path() + "/params.txt"); if(params.open(QIODevice::ReadWrite)) { QString paramData = params.readAll(); params.close(); bool ok; QJson::Parser parser; QVariantMap map = parser.parse(paramData.toAscii(), &ok).toMap(); if(ok && script.open(QIODevice::WriteOnly)) { QString scriptData; //#!/bin/bash //vlc -I dummy --ignore-config "/home/paulm/Videos/troops.avi" // '--sout=#transcode{vcodec=h264,soverlay,acodec=mp3,channels=2,venc=x264{profile=baseline,level=2.2,keyint=30,bframes=0,ref=1,nocabac},width=480,vb=200,ab=40,fps=25,deinterlace}: // std{access=livehttp{seglen=10,index="/home/paulm/.Hobbyist_Software/VLC_Streamer/Root/troops/stream.m3u8",index-url=stream-###.ts}, // mux=ts{use-key-frames}, // dst="/home/paulm/.Hobbyist_Software/VLC_Streamer/Root/troops/stream-###.ts"}' // vlc://quit scriptData = "#!/bin/bash\n"; QString temp = map.value("sout").toString(); temp.replace("##dest##", dir.path()); scriptData += "vlc -I dummy --ignore-config " + map.value("args").toString() + " \"" + map.value("file").toString() + "\" vlc://quit " + "'" + temp + "' -vvv\n"; script.write(scriptData.toAscii()); script.close(); script.setPermissions(QFile::ReadUser | QFile::WriteUser | QFile::ExeUser); VlcEncoder *encoder = new VlcEncoder(scriptInfo.filePath()); QThreadPool::globalInstance()->start(encoder); } else { qDebug() << "Not ok or script didn't open" << ok << script.error(); } } } }
bool ScriptDebuggerPrivate::executeCommand(const QString &command, const QStringList &args) { if (command == QLatin1String("c") || command == QLatin1String("continue")) { setMode(Run); return true; } else if (command == QLatin1String("s") || command == QLatin1String("step")) { setMode(StepInto); return true; } else if (command == QLatin1String("n") || command == QLatin1String("next")) { setMode(StepOver); m_stepDepth = 0; return true; } else if (command == QLatin1String("f") || command == QLatin1String("frame")) { bool ok = false; int index = args.value(0).toInt(&ok); if (ok) { if (index < 0 || index >= frameCount()) { errorMessage("No such frame."); } else { setCurrentFrameIndex(index); QScriptContext *ctx = currentFrameContext(); message(QString::fromLatin1("#%0 %1").arg(index).arg(ctx->toString())); } } } else if (command == QLatin1String("bt") || command == QLatin1String("backtrace")) { QScriptContext *ctx = engine()->currentContext(); int index = -1; while (ctx) { ++index; QString line = ctx->toString(); message(QString::fromLatin1("#%0 %1").arg(index).arg(line)); ctx = ctx->parentContext(); } } else if (command == QLatin1String("up")) { int index = currentFrameIndex() + 1; if (index == frameCount()) { errorMessage(QString::fromLatin1("Initial frame selected; you cannot go up.")); } else { setCurrentFrameIndex(index); QScriptContext *ctx = currentFrameContext(); message(QString::fromLatin1("#%0 %1").arg(index).arg(ctx->toString())); } } else if (command == QLatin1String("down")) { int index = currentFrameIndex() - 1; if (index < 0) { errorMessage(QString::fromLatin1("Bottom (innermost) frame selected; you cannot go down.")); } else { setCurrentFrameIndex(index); QScriptContext *ctx = currentFrameContext(); message(QString::fromLatin1("#%0 %1").arg(index).arg(ctx->toString())); } } else if (command == QLatin1String("b") || command == QLatin1String("break")) { QString str = args.value(0); int colonIndex = str.indexOf(QLatin1Char(':')); if (colonIndex != -1) { // filename:line form QString fileName = str.left(colonIndex); int lineNumber = str.mid(colonIndex+1).toInt(); int id = m_bpManager->setBreakpoint(fileName, lineNumber); message(QString::fromLatin1("Breakpoint %0 at %1, line %2.").arg(id+1).arg(fileName).arg(lineNumber)); } else { // function QScriptValue fun = engine()->globalObject().property(str); if (fun.isFunction()) { int id = m_bpManager->setBreakpoint(fun); message(QString::fromLatin1("Breakpoint %0 at %1().").arg(id+1).arg(str)); } } } else if (command == QLatin1String("d") || command == QLatin1String("delete")) { int id = args.value(0).toInt() - 1; m_bpManager->removeBreakpoint(id); } else if (command == QLatin1String("disable")) { int id = args.value(0).toInt() - 1; m_bpManager->setBreakpointEnabled(id, false); } else if (command == QLatin1String("enable")) { int id = args.value(0).toInt() - 1; m_bpManager->setBreakpointEnabled(id, true); } else if (command == QLatin1String("list")) { QScriptContext *ctx = currentFrameContext(); ScriptInfo *progInfo = scriptInfo(ctx); if (!progInfo) { errorMessage("No source text available for this frame."); } else { QScriptContextInfo ctxInfo(ctx); bool ok; int line = args.value(0).toInt(&ok); if (ok) { line = qMax(1, line - 5); } else { line = listLineNumber(); if (line == -1) line = qMax(progInfo->lineNumber(), ctxInfo.lineNumber() - 5); } for (int i = line; i < line + 10; ++i) { message(QString::fromLatin1("%0\t%1").arg(i).arg(progInfo->lineText(i))); } setListLineNumber(line + 10); } } else if (command == QLatin1String("info")) { if (args.size() < 1) { } else { QString what = args.value(0); if (what == QLatin1String("locals")) { QScriptValueIterator it(currentFrameContext()->activationObject()); while (it.hasNext()) { it.next(); QString line; line.append(it.name()); line.append(QLatin1String(" = ")); line.append(safeValueToString(it.value())); message(line); } } } } else if (command == QLatin1String("help")) { message("continue - continue execution\n" "step - step into statement\n" "next - step over statement\n" "list - show where you are\n" "\n" "break - set breakpoint\n" "delete - remove breakpoint\n" "disable - disable breakpoint\n" "enable - enable breakpoint\n" "\n" "backtrace - show backtrace\n" "up - one frame up\n" "down - one frame down\n" "frame - set frame\n" "\n" "info locals - show local variables"); } else { errorMessage(QString::fromLatin1("Undefined command \"%0\". Try \"help\".") .arg(command)); } return false; }