| 563 | } |
| 564 | |
| 565 | void |
| 566 | AppInstance::loadInternal(const CLArgs& cl, |
| 567 | bool makeEmptyInstance) |
| 568 | { |
| 569 | try { |
| 570 | declareCurrentAppVariable_Python(); |
| 571 | } catch (const std::exception& e) { |
| 572 | throw std::runtime_error( e.what() ); |
| 573 | } |
| 574 | |
| 575 | if (makeEmptyInstance) { |
| 576 | return; |
| 577 | } |
| 578 | |
| 579 | executeCommandLinePythonCommands(cl); |
| 580 | |
| 581 | QString exportDocPath = cl.getExportDocsPath(); |
| 582 | if ( !exportDocPath.isEmpty() ) { |
| 583 | exportDocs(exportDocPath); |
| 584 | |
| 585 | return; |
| 586 | } |
| 587 | |
| 588 | ///if the app is a background project autorun and the project name is empty just throw an exception. |
| 589 | if ( ( (appPTR->getAppType() == AppManager::eAppTypeBackgroundAutoRun) || |
| 590 | ( appPTR->getAppType() == AppManager::eAppTypeBackgroundAutoRunLaunchedFromGui) ) ) { |
| 591 | const QString& scriptFilename = cl.getScriptFilename(); |
| 592 | |
| 593 | if ( scriptFilename.isEmpty() ) { |
| 594 | // cannot start a background process without a file |
| 595 | throw std::invalid_argument( tr("Project file name is empty.").toStdString() ); |
| 596 | } |
| 597 | |
| 598 | |
| 599 | QFileInfo info(scriptFilename); |
| 600 | if ( !info.exists() ) { |
| 601 | throw std::invalid_argument( tr("%1: No such file.").arg(scriptFilename).toStdString() ); |
| 602 | } |
| 603 | |
| 604 | std::list<AppInstance::RenderWork> writersWork; |
| 605 | |
| 606 | |
| 607 | if ( info.suffix() == QString::fromUtf8(NATRON_PROJECT_FILE_EXT) ) { |
| 608 | ///Load the project |
| 609 | if ( !_imp->_currentProject->loadProject( info.path(), info.fileName() ) ) { |
| 610 | throw std::invalid_argument( tr("Project file loading failed.").toStdString() ); |
| 611 | } |
| 612 | } else if ( info.suffix() == QString::fromUtf8("py") ) { |
| 613 | ///Load the python script |
| 614 | loadPythonScript(info); |
| 615 | } else { |
| 616 | throw std::invalid_argument( tr("%1 only accepts python scripts or .ntp project files.").arg( QString::fromUtf8(NATRON_APPLICATION_NAME) ).toStdString() ); |
| 617 | } |
| 618 | |
| 619 | // exec the python script specified via --onload |
| 620 | const QString& extraOnProjectCreatedScript = cl.getDefaultOnProjectLoadedScript(); |
| 621 | if ( !extraOnProjectCreatedScript.isEmpty() ) { |
| 622 | QFileInfo cbInfo(extraOnProjectCreatedScript); |
nothing calls this directly
no test coverage detected