mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
always output latest version of config file to webui (#307)
* always output latest version of config file to webui * fix permissions after default config export * tune code * set permissions for exported effects * use qt setperm instead of chmod update effects code style a bit * add fallback when config is not readable
This commit is contained in:
parent
82a140f5ed
commit
5b0e401ca5
@ -1,6 +1,4 @@
|
||||
import hyperion
|
||||
import time
|
||||
import colorsys
|
||||
import hyperion, time, colorsys
|
||||
|
||||
# Get the parameters
|
||||
speed = float(hyperion.args.get('speed', 1.0))
|
||||
|
@ -1,7 +1,4 @@
|
||||
import hyperion
|
||||
import time
|
||||
import colorsys
|
||||
import math
|
||||
import hyperion, time, colorsys, math
|
||||
from random import random
|
||||
|
||||
# Get the parameters
|
||||
|
@ -1,23 +1,21 @@
|
||||
import hyperion
|
||||
import time
|
||||
import colorsys
|
||||
import hyperion, time, colorsys
|
||||
|
||||
# Get the parameters
|
||||
rotationTime = float(hyperion.args.get('rotation-time', 2.0))
|
||||
colorOne = hyperion.args.get('color_one', (255,0,0))
|
||||
colorTwo = hyperion.args.get('color_two', (0,0,255))
|
||||
colorsCount = hyperion.args.get('colors_count', hyperion.ledCount/2)
|
||||
reverse = bool(hyperion.args.get('reverse', False))
|
||||
colorOne = hyperion.args.get('color_one', (255,0,0))
|
||||
colorTwo = hyperion.args.get('color_two', (0,0,255))
|
||||
colorsCount = hyperion.args.get('colors_count', hyperion.ledCount/2)
|
||||
reverse = bool(hyperion.args.get('reverse', False))
|
||||
|
||||
# Check parameters
|
||||
rotationTime = max(0.1, rotationTime)
|
||||
colorsCount = min(hyperion.ledCount/2, colorsCount)
|
||||
colorsCoun t = min(hyperion.ledCount/2, colorsCount)
|
||||
|
||||
# Initialize the led data
|
||||
hsv1 = colorsys.rgb_to_hsv(colorOne[0]/255.0, colorOne[1]/255.0, colorOne[2]/255.0)
|
||||
hsv2 = colorsys.rgb_to_hsv(colorTwo[0]/255.0, colorTwo[1]/255.0, colorTwo[2]/255.0)
|
||||
hsv1 = colorsys.rgb_to_hsv(colorOne[0]/255.0, colorOne[1]/255.0, colorOne[2]/255.0)
|
||||
hsv2 = colorsys.rgb_to_hsv(colorTwo[0]/255.0, colorTwo[1]/255.0, colorTwo[2]/255.0)
|
||||
colorBlack = (0,0,0)
|
||||
ledData = bytearray()
|
||||
ledData = bytearray()
|
||||
for i in range(hyperion.ledCount):
|
||||
if i <= colorsCount:
|
||||
rgb = colorsys.hsv_to_rgb(hsv1[0], hsv1[1], hsv1[2])
|
||||
|
@ -1,17 +1,15 @@
|
||||
import hyperion
|
||||
import time
|
||||
import colorsys
|
||||
import hyperion, time, colorsys
|
||||
|
||||
# Get the parameters
|
||||
rotationTime = float(hyperion.args.get('rotation-time', 30.0))
|
||||
brightness = float(hyperion.args.get('brightness', 1.0))
|
||||
saturation = float(hyperion.args.get('saturation', 1.0))
|
||||
reverse = bool(hyperion.args.get('reverse', False))
|
||||
brightness = float(hyperion.args.get('brightness', 1.0))
|
||||
saturation = float(hyperion.args.get('saturation', 1.0))
|
||||
reverse = bool(hyperion.args.get('reverse', False))
|
||||
|
||||
# Check parameters
|
||||
rotationTime = max(0.1, rotationTime)
|
||||
brightness = max(0.0, min(brightness, 1.0))
|
||||
saturation = max(0.0, min(saturation, 1.0))
|
||||
brightness = max(0.0, min(brightness, 1.0))
|
||||
saturation = max(0.0, min(saturation, 1.0))
|
||||
|
||||
# Calculate the sleep time and hue increment
|
||||
sleepTime = 0.1
|
||||
|
@ -8,7 +8,7 @@ centerY = float(hyperion.args.get('center_y', 0.5))
|
||||
|
||||
sleepTime = max(0.1, rotationTime) / 360
|
||||
angle = 0
|
||||
centerX = int(round(hyperion.imageWidth)*centerX)
|
||||
centerX = int(round(float(hyperion.imageWidth)*centerX))
|
||||
centerY = int(round(float(hyperion.imageHeight)*centerY))
|
||||
increment = -1 if reverse else 1
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
import hyperion
|
||||
import time
|
||||
import colorsys
|
||||
import hyperion, time, colorsys
|
||||
|
||||
# Get the parameters
|
||||
sleepTime = float(hyperion.args.get('sleepTime', 1.0))
|
||||
|
@ -1042,8 +1042,15 @@ void JsonClientConnection::handleConfigGetCommand(const QJsonObject& message, co
|
||||
result["success"] = true;
|
||||
result["command"] = command;
|
||||
result["tan"] = tan;
|
||||
const QJsonObject & config = _hyperion->getQJsonConfig();
|
||||
result["result"] = config;
|
||||
|
||||
try
|
||||
{
|
||||
result["result"] = QJsonFactory::readJson(QString::fromStdString(_hyperion->getConfigFileName()));
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
result["result"] = _hyperion->getQJsonConfig();
|
||||
}
|
||||
|
||||
// send the result
|
||||
sendMessage(result);
|
||||
|
@ -29,6 +29,8 @@
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
#define PERM0664 QFileDevice::ReadOwner | QFileDevice::ReadGroup | QFileDevice::ReadOther | QFileDevice::WriteOwner | QFileDevice::WriteGroup
|
||||
|
||||
void signal_handler(const int signum)
|
||||
{
|
||||
QCoreApplication::quit();
|
||||
@ -128,16 +130,19 @@ int main(int argc, char** argv)
|
||||
{
|
||||
std::cout << "extract to folder: " << std::endl;
|
||||
QStringList filenames = directory.entryList(QStringList() << "*", QDir::Files, QDir::Name | QDir::IgnoreCase);
|
||||
QString destFileName;
|
||||
foreach (const QString & filename, filenames)
|
||||
{
|
||||
if (QFile::exists(destDir.dirName()+"/"+filename))
|
||||
destFileName = destDir.dirName()+"/"+filename;
|
||||
if (QFile::exists(destFileName))
|
||||
{
|
||||
QFile::remove(destDir.dirName()+"/"+filename);
|
||||
QFile::remove(destFileName);
|
||||
}
|
||||
|
||||
std::cout << "Extract: " << filename.toStdString() << " ... ";
|
||||
if (QFile::copy(QString(":/effects/")+filename, destDir.dirName()+"/"+filename))
|
||||
if (QFile::copy(QString(":/effects/")+filename, destFileName))
|
||||
{
|
||||
QFile::setPermissions(destFileName, PERM0664 );
|
||||
std::cout << "ok" << std::endl;
|
||||
}
|
||||
else
|
||||
@ -176,11 +181,15 @@ int main(int argc, char** argv)
|
||||
QDir().mkpath(FileUtils::getDirName(exportConfigFileTarget));
|
||||
if (QFile::copy(":/hyperion_default.config",exportConfigFileTarget))
|
||||
{
|
||||
QFile::setPermissions(exportConfigFileTarget, PERM0664 );
|
||||
Info(log, "export complete.");
|
||||
if (exitAfterexportDefaultConfig) return 0;
|
||||
}
|
||||
Error(log, "can not export to %s",exportConfigFileTarget.toLocal8Bit().constData());
|
||||
if (exitAfterexportDefaultConfig) return 1;
|
||||
else
|
||||
{
|
||||
Error(log, "error while export to %s",exportConfigFileTarget.toLocal8Bit().constData());
|
||||
if (exitAfterexportDefaultConfig) return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (configFiles.size() == 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user