-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLI] Add --version and -v to know QGIS version
- Loading branch information
Showing
8 changed files
with
254 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgscommandlineutils.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsCommandLineUtils | ||
{ | ||
%Docstring(signature="appended") | ||
Utils class for QGIS command line tools. | ||
|
||
.. versionadded:: 3.22 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgscommandlineutils.h" | ||
%End | ||
public: | ||
|
||
static QString allVersions( ); | ||
%Docstring | ||
Display all versions in the standard output stream | ||
|
||
.. versionadded:: 3.22 | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgscommandlineutils.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/*************************************************************************** | ||
qgscommandlineutils.cpp | ||
--------------------------- | ||
begin : June 2021 | ||
copyright : (C) 2021 by Etienne Trimaille | ||
email : etienne dot trimaille at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsapplication.h" | ||
#include "qgscommandlineutils.h" | ||
#include "qgsgeos.h" | ||
#include "qgsprojutils.h" | ||
#include "qgsversion.h" | ||
|
||
#include <sqlite3.h> | ||
#include <ogr_api.h> | ||
#include <gdal_version.h> | ||
#include <proj.h> | ||
#include <QSysInfo> | ||
|
||
QString QgsCommandLineUtils::allVersions( ) | ||
{ | ||
|
||
// QGIS main version | ||
QString versionString = QStringLiteral( "QGIS %1 '%2' (%3)\n" ).arg( VERSION, RELEASE_NAME, QGSVERSION ); | ||
|
||
// QGIS code revision | ||
if ( QString( Qgis::devVersion() ) == QLatin1String( "exported" ) ) | ||
{ | ||
versionString += QLatin1String( "QGIS code branch" ); | ||
if ( Qgis::version().endsWith( QLatin1String( "Master" ) ) ) | ||
{ | ||
versionString += QLatin1String( "master\n" ); | ||
} | ||
else | ||
{ | ||
versionString += QStringLiteral( "Release %1.%2\n" ).arg( Qgis::versionInt() / 10000 ).arg( Qgis::versionInt() / 100 % 100 ); | ||
} | ||
} | ||
else | ||
{ | ||
versionString += QStringLiteral( "QGIS code revision %1\n" ).arg( Qgis::devVersion() ); | ||
} | ||
|
||
// Qt version | ||
const QString qtVersionCompiled{ QT_VERSION_STR }; | ||
const QString qtVersionRunning{ qVersion() }; | ||
if ( qtVersionCompiled != qtVersionRunning ) | ||
{ | ||
versionString += QStringLiteral( "Compiled against Qt %1\n" ).arg( qtVersionCompiled ); | ||
versionString += QStringLiteral( "Running against Qt %1\n" ).arg( qtVersionRunning ); | ||
} | ||
else | ||
{ | ||
versionString += QStringLiteral( "Qt version %1\n" ).arg( qtVersionCompiled ); | ||
} | ||
|
||
// Python version | ||
versionString += QStringLiteral( "Python version %1\n" ).arg( PYTHON_VERSION ); | ||
|
||
// GDAL version | ||
const QString gdalVersionCompiled { GDAL_RELEASE_NAME }; | ||
const QString gdalVersionRunning { GDALVersionInfo( "RELEASE_NAME" ) }; | ||
if ( gdalVersionCompiled != gdalVersionRunning ) | ||
{ | ||
versionString += QStringLiteral( "Compiled against GDAL/OGR %1\n" ).arg( gdalVersionCompiled ); | ||
versionString += QStringLiteral( "Running against GDAL/OGR %1\n" ).arg( gdalVersionRunning ); | ||
} | ||
else | ||
{ | ||
versionString += QStringLiteral( "GDAL/OGR version %1\n" ).arg( gdalVersionCompiled ); | ||
} | ||
|
||
// proj | ||
PJ_INFO info = proj_info(); | ||
const QString projVersionCompiled { QStringLiteral( "%1.%2.%3" ).arg( PROJ_VERSION_MAJOR ).arg( PROJ_VERSION_MINOR ).arg( PROJ_VERSION_PATCH ) }; | ||
const QString projVersionRunning { info.version }; | ||
if ( projVersionCompiled != projVersionRunning ) | ||
{ | ||
versionString += QStringLiteral( "Compiled against PROJ %1\n" ).arg( projVersionCompiled ); | ||
versionString += QStringLiteral( "Running against PROJ %2\n" ).arg( projVersionRunning ); | ||
} | ||
else | ||
{ | ||
versionString += QStringLiteral( "PROJ version %1\n" ).arg( projVersionCompiled ); | ||
} | ||
|
||
// CRS database versions | ||
versionString += QStringLiteral( "EPSG Registry database version %1 (%2)\n" ).arg( QgsProjUtils::epsgRegistryVersion(), QgsProjUtils::epsgRegistryDate().toString( Qt::ISODate ) ); | ||
|
||
// GEOS version | ||
const QString geosVersionCompiled { GEOS_CAPI_VERSION }; | ||
const QString geosVersionRunning { GEOSversion() }; | ||
if ( geosVersionCompiled != geosVersionRunning ) | ||
{ | ||
versionString += QStringLiteral( "Compiled against GEOS %1\n" ).arg( geosVersionCompiled ); | ||
versionString += QStringLiteral( "Running against GEOS %1\n" ).arg( geosVersionRunning ); | ||
} | ||
else | ||
{ | ||
versionString += QStringLiteral( "GEOS version %1\n" ).arg( geosVersionCompiled ); | ||
} | ||
|
||
// SQLite version | ||
const QString sqliteVersionCompiled { SQLITE_VERSION }; | ||
const QString sqliteVersionRunning { sqlite3_libversion() }; | ||
if ( sqliteVersionCompiled != sqliteVersionRunning ) | ||
{ | ||
versionString += QStringLiteral( "Compiled against SQLite %1\n" ).arg( sqliteVersionCompiled ); | ||
versionString += QStringLiteral( "Running against SQLite %1\n" ).arg( sqliteVersionRunning ); | ||
} | ||
else | ||
{ | ||
versionString += QStringLiteral( "SQLite version %1\n" ).arg( sqliteVersionCompiled ); | ||
} | ||
|
||
// Operating system | ||
versionString += QStringLiteral( "OS %1\n" ).arg( QSysInfo::prettyProductName() ); | ||
|
||
#ifdef QGISDEBUG | ||
versionString += QStringLiteral( "This copy of QGIS writes debugging output.\n" ); | ||
#endif | ||
|
||
return versionString; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*************************************************************************** | ||
qgscommandlineutils.h | ||
--------------------------- | ||
begin : June 2021 | ||
copyright : (C) 2021 by Etienne Trimaille | ||
email : etienne dot trimaille at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSCOMMANDLINEUTILS_H | ||
#define QGSCOMMANDLINEUTILS_H | ||
|
||
#include "qgis.h" | ||
|
||
/** | ||
* \ingroup core | ||
* \class QgsCommandLineUtils | ||
* \brief Utils class for QGIS command line tools. | ||
* \since QGIS 3.22 | ||
*/ | ||
class CORE_EXPORT QgsCommandLineUtils | ||
{ | ||
public: | ||
|
||
/** | ||
* Display all versions in the standard output stream | ||
* \since QGIS 3.22 | ||
*/ | ||
static QString allVersions( ); | ||
|
||
}; | ||
|
||
#endif // QGSCOMMANDLINEUTILS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters