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