Skip to content

Commit

Permalink
Add scripting function to retrieve environment variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
gzotti committed Jun 6, 2018
1 parent e992a7a commit a0ac500
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/scripting/StelMainScriptAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1424,3 +1424,12 @@ QVariantMap StelMainScriptAPI::getScreenXYFromAltAzi(const QString &alt, const Q

return map;
}

QString StelMainScriptAPI::getEnv(const QString &var)
{
#if QT_VERSION>=0x051000
return qEnvironmentVariable(var);
#else
return QString::fromLocal8Bit(qgetenv(var.toLocal8Bit().constData()));
#endif
}
4 changes: 4 additions & 0 deletions src/scripting/StelMainScriptAPI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,10 @@ public slots:
//! @param spec "local" or "utc"
void waitFor(const QString& dt, const QString& spec="utc");

//! Retrieve value of environment variable @param name.
//! On desktop Windows and Qt before 5.10, this call may result in data loss if the original
//! string contains Unicode characters not representable in the ANSI encoding.
QString getEnv(const QString& var);

signals:

Expand Down

0 comments on commit a0ac500

Please sign in to comment.