mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
hyperiond: add ability to export default config and effects (#244)
* - embed default config - add possibility to export effects and embeded default config to filesystem * do some code style
This commit is contained in:
parent
eeb9b0f7da
commit
858125510e
@ -1,6 +1,5 @@
|
||||
$(document).ready( function() {
|
||||
$("#main-nav").hide();
|
||||
$("#page-content").hide();
|
||||
$("#loading_overlay").addClass("overlay");
|
||||
loadContentTo("#container_connection_lost","connection_lost");
|
||||
initWebSocket();
|
||||
@ -62,7 +61,6 @@ $(document).ready( function() {
|
||||
});
|
||||
$("#loading_overlay").removeClass("overlay");
|
||||
$("#main-nav").show('slide', {direction: 'left'}, 1000);
|
||||
$("#page-content").show('slide', {direction: 'down'}, 2000);
|
||||
|
||||
}); // end cmd-serverinfo
|
||||
|
||||
|
@ -16,8 +16,6 @@ echo create $outfile
|
||||
tar --create --verbose --gzip --absolute-names --show-transformed-names \
|
||||
--file "$outfile" \
|
||||
--transform "s:$builddir/bin/:hyperion/bin/:" \
|
||||
--transform "s:$repodir/effects/:hyperion/effects/:" \
|
||||
--transform "s:$repodir/config/:hyperion/config/:" \
|
||||
--transform "s:$repodir/bin/hyperion.init.sh:hyperion/init.d/hyperion.init.sh:" \
|
||||
--transform "s://:/:g" \
|
||||
"$builddir/bin/hyperiond" \
|
||||
@ -25,6 +23,4 @@ tar --create --verbose --gzip --absolute-names --show-transformed-names \
|
||||
"$builddir/bin/hyperion-v4l2" \
|
||||
"$builddir/bin/gpio2spi" \
|
||||
"$builddir/bin/dispmanx2png" \
|
||||
"$repodir/effects/"* \
|
||||
"$repodir/bin/hyperion.init.sh" \
|
||||
"$repodir/config/hyperion.config.json"
|
||||
|
@ -20,8 +20,12 @@ install_file()
|
||||
echo "--- hyperion ambient light postinstall ---"
|
||||
echo "- install configuration template"
|
||||
mkdir -p /etc/hyperion
|
||||
install_file /usr/share/hyperion/config/hyperion.config.json.default /etc/hyperion/hyperion.config.json
|
||||
|
||||
if [ ! -e "/etc/hyperion/hyperion.config.json" ]
|
||||
then
|
||||
echo "install default config to /etc/hyperion"
|
||||
/usr/bin/hyperiond --export-config /etc/hyperion/hyperion.config.json
|
||||
fi
|
||||
|
||||
HYPERION_RUNNING=false
|
||||
pgrep hyperiond > /dev/null 2>&1 && HYPERION_RUNNING=true
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
QString value(Parser &parser);
|
||||
std::string getStdString(Parser &parser);
|
||||
std::wstring getStdWString(Parser &parser);
|
||||
const char* getCString(Parser &parser);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef HYPERION_COMMANDLINEPARSER_H
|
||||
#define HYPERION_COMMANDLINEPARSER_H
|
||||
#pragma once
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
@ -71,50 +70,75 @@ public:
|
||||
}
|
||||
|
||||
Parser(QString description=QString())
|
||||
{if(description.size())setApplicationDescription(description);};
|
||||
{
|
||||
if(description.size())setApplicationDescription(description);
|
||||
};
|
||||
|
||||
QCommandLineOption addHelpOption()
|
||||
{ return _parser.addHelpOption(); }
|
||||
{
|
||||
return _parser.addHelpOption();
|
||||
};
|
||||
|
||||
bool addOption(Option &option);
|
||||
bool addOption(Option *option);
|
||||
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax = QString())
|
||||
{ _parser.addPositionalArgument(name, description, syntax); }
|
||||
{
|
||||
_parser.addPositionalArgument(name, description, syntax);
|
||||
};
|
||||
|
||||
QCommandLineOption addVersionOption()
|
||||
{ return _parser.addVersionOption(); }
|
||||
{
|
||||
return _parser.addVersionOption();
|
||||
};
|
||||
|
||||
QString applicationDescription() const
|
||||
{ return _parser.applicationDescription(); }
|
||||
|
||||
void clearPositionalArguments()
|
||||
{ _parser.clearPositionalArguments(); }
|
||||
|
||||
QString helpText() const
|
||||
{ return _parser.helpText(); }
|
||||
|
||||
bool isSet(const QString &name) const
|
||||
{ return _parser.isSet(name); }
|
||||
|
||||
bool isSet(const Option &option) const
|
||||
{ return _parser.isSet(option); }
|
||||
|
||||
bool isSet(const Option *option) const
|
||||
{ return _parser.isSet(*option); }
|
||||
|
||||
QStringList optionNames() const
|
||||
{ return _parser.optionNames(); }
|
||||
|
||||
QStringList positionalArguments() const
|
||||
{ return _parser.positionalArguments(); }
|
||||
|
||||
void setApplicationDescription(const QString &description)
|
||||
{ _parser.setApplicationDescription(description); }
|
||||
|
||||
void setSingleDashWordOptionMode(QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode)
|
||||
{ _parser.setSingleDashWordOptionMode(singleDashWordOptionMode); }
|
||||
|
||||
void showHelp(int exitCode = 0)
|
||||
{ _parser.showHelp(exitCode); }
|
||||
|
||||
QStringList unknownOptionNames() const
|
||||
{ return _parser.unknownOptionNames(); }
|
||||
|
||||
QString value(const QString &optionName) const
|
||||
{ return _parser.value(optionName); }
|
||||
|
||||
QString value(const Option &option) const
|
||||
{ return _parser.value(option); }
|
||||
|
||||
QStringList values(const QString &optionName) const
|
||||
{ return _parser.values(optionName); }
|
||||
|
||||
QStringList values(const Option &option) const
|
||||
{ return _parser.values(option); }
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HYPERION_COMMANDLINEPARSER_H
|
||||
|
@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace FileUtils {
|
||||
|
||||
std::string getBaseName( std::string sourceFile);
|
||||
|
||||
|
||||
};
|
||||
|
@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Process {
|
||||
|
@ -24,3 +24,8 @@ std::wstring Option::getStdWString(Parser &parser)
|
||||
return value(parser).toStdWString();
|
||||
}
|
||||
|
||||
const char* Option::getCString(Parser &parser)
|
||||
{
|
||||
return value(parser).toLocal8Bit().constData();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file alias="hyperion-schema">hyperion.schema.json</file>
|
||||
<file alias="hyperion_default.config">../../config/hyperion.config.json.default</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -53,7 +53,7 @@ int main(int argc, char** argv)
|
||||
// create the option parser and initialize all parameters
|
||||
Parser parser("V4L capture application for Hyperion");
|
||||
|
||||
Option & argDevice = parser.add<Option> ('d', "device", "The device to use [default: %1]", "/dev/video0");
|
||||
Option & argDevice = parser.add<Option> ('d', "device", "The device to use [default: %1]", "auto");
|
||||
SwitchOption<VideoStandard> & argVideoStandard= parser.add<SwitchOption<VideoStandard>>('v', "video-standard", "The used video standard. Valid values are PAL, NTSC or no-change. [default: %1]", "no-change");
|
||||
SwitchOption<PixelFormat> & argPixelFormat = parser.add<SwitchOption<PixelFormat>> (0x0, "pixel-format", "The use pixel format. Valid values are YUYV, UYVY, RGB32 or no-change. [default: %1]", "no-change");
|
||||
IntOption & argInput = parser.add<IntOption> (0x0, "input", "Input channel (optional)", "-1");
|
||||
|
@ -41,5 +41,3 @@ endif ()
|
||||
|
||||
install ( TARGETS hyperiond DESTINATION "share/hyperion/bin/" COMPONENT "${PLATFORM}" )
|
||||
install ( DIRECTORY ${CMAKE_SOURCE_DIR}/bin/service DESTINATION "share/hyperion/" COMPONENT "${PLATFORM}" )
|
||||
install ( DIRECTORY ${CMAKE_SOURCE_DIR}/config DESTINATION "share/hyperion/" COMPONENT "${PLATFORM}" )
|
||||
install ( DIRECTORY ${CMAKE_SOURCE_DIR}/assets/webconfig DESTINATION "share/hyperion/" COMPONENT "${PLATFORM}" )
|
||||
|
@ -13,6 +13,9 @@
|
||||
#include <QLocale>
|
||||
#include <QFile>
|
||||
#include <QString>
|
||||
#include <QResource>
|
||||
#include <QDir>
|
||||
#include <QStringList>
|
||||
|
||||
#include "HyperionConfig.h"
|
||||
|
||||
@ -71,6 +74,9 @@ int main(int argc, char** argv)
|
||||
BooleanOption & silentOption = parser.add<BooleanOption>('s', "silent", "do not print any outputs");
|
||||
BooleanOption & verboseOption = parser.add<BooleanOption>('v', "verbose", "Increase verbosity");
|
||||
BooleanOption & debugOption = parser.add<BooleanOption>('d', "debug", "Show debug messages");
|
||||
Option & exportConfigOption = parser.add<Option> (0x0, "export-config", "export default config to file");
|
||||
Option & exportEfxOption = parser.add<Option> (0x0, "export-effects", "export effects to given path");
|
||||
|
||||
parser.addPositionalArgument("config-files", QCoreApplication::translate("main", "Configuration files"), "[files...]");
|
||||
|
||||
parser.process(app);
|
||||
@ -112,6 +118,54 @@ int main(int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (parser.isSet(exportConfigOption))
|
||||
{
|
||||
Q_INIT_RESOURCE(resource);
|
||||
if (QFile::copy(":/hyperion_default.config",exportConfigOption.value(parser)))
|
||||
{
|
||||
Info(log, "export complete.");
|
||||
return 0;
|
||||
}
|
||||
Error(log, "can not export to %s",exportConfigOption.getCString(parser));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (parser.isSet(exportEfxOption))
|
||||
{
|
||||
Q_INIT_RESOURCE(EffectEngine);
|
||||
QDir directory(":/effects/");
|
||||
QDir destDir(exportEfxOption.value(parser));
|
||||
if (directory.exists() && destDir.exists())
|
||||
{
|
||||
std::cout << "extract to folder: " << std::endl;
|
||||
QStringList filenames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase);
|
||||
foreach (const QString & filename, filenames)
|
||||
{
|
||||
if (QFile::exists(destDir.dirName()+"/"+filename))
|
||||
{
|
||||
QFile::remove(destDir.dirName()+"/"+filename);
|
||||
}
|
||||
|
||||
std::cout << "Extract: " << filename.toStdString() << " ... ";
|
||||
if (QFile::copy(QString(":/effects/")+filename, destDir.dirName()+"/"+filename))
|
||||
{
|
||||
std::cout << "ok" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "error, aborting" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Error(log, "can not export to %s",exportEfxOption.getCString(parser));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (configFiles.size() == 0)
|
||||
{
|
||||
Error(log, "Missing required configuration file. Usage: hyperiond <options ...> [config.file ...]");
|
||||
@ -139,7 +193,7 @@ int main(int argc, char** argv)
|
||||
|
||||
if ( argvId < 0)
|
||||
{
|
||||
Error(log, "No valid config found");
|
||||
Warning(log, "No valid config found");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user