Skip to content

Commit

Permalink
Tak into account suggestions from PR AIDASoft#1021
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusFrankATcernch committed Nov 22, 2022
1 parent 9a5d617 commit 6618841
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
7 changes: 5 additions & 2 deletions DDG4/python/DDG4.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,14 @@ def _registerGlobalFilter(self, filter):
def _evalProperty(data):
"""
Function necessary to extract real strings from the property value.
Strings may be emraced by quotes: '<value>'
Strings may be embraced by quotes: '<value>'
"""
try:
if isinstance(data, str):
return eval(data)
import ast
return ast.literal_eval(data)
except ValueError:
pass
except TypeError:
pass
finally:
Expand Down
40 changes: 26 additions & 14 deletions DDG4/src/Geant4UIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ void Geant4UIManager::configure() {
}
/// Execute the chained command statements
for(const auto& c : m_configureCommands) {
info("++ Executing configure command:%s",c.c_str());
mgr->ApplyCommand(c.c_str());
info("++ Executing configure command: %s",c.c_str());
G4int ret = mgr->ApplyCommand(c.c_str());
if ( ret != 0 ) {
except("Failed to execute command: %s",c.c_str());
}
}
}

Expand All @@ -87,8 +90,11 @@ void Geant4UIManager::initialize() {
G4UImanager* mgr = G4UImanager::GetUIpointer();
/// Execute the chained command statements
for(const auto& c : m_initializeCommands) {
info("++ Executing initialization command:%s",c.c_str());
mgr->ApplyCommand(c.c_str());
info("++ Executing initialization command: %s",c.c_str());
G4int ret = mgr->ApplyCommand(c.c_str());
if ( ret != 0 ) {
except("Failed to execute command: %s",c.c_str());
}
}
}

Expand All @@ -98,8 +104,11 @@ void Geant4UIManager::terminate() {
G4UImanager* mgr = G4UImanager::GetUIpointer();
/// Execute the chained command statements
for(const auto& c : m_terminateCommands) {
info("++ Executing finalization command:%s",c.c_str());
mgr->ApplyCommand(c.c_str());
info("++ Executing finalization command: %s",c.c_str());
G4int ret = mgr->ApplyCommand(c.c_str());
if ( ret != 0 ) {
except("Failed to execute command: %s",c.c_str());
}
}
}

Expand All @@ -109,8 +118,11 @@ void Geant4UIManager::applyCommand(const string& command) {
G4UImanager* mgr = G4UImanager::GetUIpointer();
if ( mgr ) {
info("++ Executing G4 command: %s",command.c_str());
mgr->ApplyCommand(command.c_str());
return;
G4int ret = mgr->ApplyCommand(command.c_str());
if ( ret == 0 ) {
return;
}
except("Failed to execute command: %s",command.c_str());
}
except("No UI reference present. Too early to interact with Geant4!");
}
Expand Down Expand Up @@ -180,24 +192,24 @@ void Geant4UIManager::start() {
}
/// Configure visualization instance
if ( !m_visSetup.empty() ) {
info("++ Executing visualization setup:%s",m_visSetup.c_str());
info("++ Executing visualization setup: %s",m_visSetup.c_str());
mgr->ApplyCommand(make_cmd(m_visSetup).c_str());
}
/// Configure UI instance
if ( !m_uiSetup.empty() ) {
info("++ Executing UI setup:%s",m_uiSetup.c_str());
info("++ Executing UI setup: %s",m_uiSetup.c_str());
mgr->ApplyCommand(make_cmd(m_uiSetup).c_str());
executed_statements = true;
}
/// Execute the chained macro files
for(const auto& m : m_macros) {
info("++ Executing Macro file:%s",m.c_str());
info("++ Executing Macro file: %s",m.c_str());
mgr->ApplyCommand(make_cmd(m.c_str()));
executed_statements = true;
}
/// Execute the chained pre-run command statements
for(const auto& c : m_preRunCommands) {
info("++ Executing pre-run statement:%s",c.c_str());
info("++ Executing pre-run statement: %s",c.c_str());
mgr->ApplyCommand(c.c_str());
executed_statements = true;
}
Expand All @@ -206,7 +218,7 @@ void Geant4UIManager::start() {
m_ui->SessionStart();
/// Execute the chained post-run command statements
for(const auto& c : m_postRunCommands) {
info("++ Executing post-run statement:%s",c.c_str());
info("++ Executing post-run statement: %s",c.c_str());
mgr->ApplyCommand(c.c_str());
executed_statements = true;
}
Expand All @@ -219,7 +231,7 @@ void Geant4UIManager::start() {
else if ( executed_statements ) {
/// Execute the chained post-run command statements
for(const auto& c : m_postRunCommands) {
info("++ Executing post-run statement:%s",c.c_str());
info("++ Executing post-run statement: %s",c.c_str());
mgr->ApplyCommand(c.c_str());
}
return;
Expand Down

0 comments on commit 6618841

Please sign in to comment.