1

Docker Hub の Docker イメージ (最新 = 0.9.1) を使用して、独自のサーバーに Wirecloud をインストールしています。https://wirecloud.readthedocs.io/en/latest/development/platform/themes/の手順を使用して、「基本テーマ」セクションに従ってみました。しかし、テーマをファイル システムのどこに配置する必要があるかは明確ではありません。

 1. created the directory structure in the example 
 2. created a file __init__.py with one line: parent = "wirecloud.defaulttheme" 
 3. created a file _variables.scss and pasted the example into it. Put the file in babblerTheme/static/css/ 
 4. created a header.png image and placed it in babblerTheme/static/images/logos/ 
 5. Then updated settings.py with the name of our basic theme with the setting: THEME_ACTIVE = "babblerTheme" 
 6. Then ran python manage.py collectstatic --noinput

エラーが発生します:

...ファイル "/usr/local/lib/python2.7/site-packages/wirecloud/platform/themes.py"、82 行目、get_theme_metadata で ValueError("%s は有効な WireCloud テーマではありません" % theme_name ) ValueError: babblerTheme は有効な WireCloud テーマではありません

テーマディレクトリを次の場所に配置しようとしましたが、うまくいきませんでした:

/opt/wirecloud_instance/wirecloud_instance/babblerTheme
/opt/wirecloud_instance/babblerTheme
/usr/local/lib/python2.7/site-packages/wirecloud/babblerTheme

3 か所すべて、同じ情報量のないエラーです。

これは本当に簡単なはずですが、すでに半日以上費やしています。デフォルトのテーマの内容を変更することでこのバグを回避できますが、Wirecloud のアップグレード時に問題が発生することが予想されます。

Wirecloud にカスタム テーマを取得させるにはどうすればよいでしょうか?

4

2 に答える 2

1

私はあなたの手順に従いましたが、それらは機能しています。あなたが報告したエラーは表示されません。手順に返信するために、クリーンなコンテナーと 1 つのスクリプトを使用しました。

$ docker run -dP --name wirecloud_test_latest fiware/wirecloud:latest
47ca7b90c7bf85401eeb7bd4c915d560eb9d2bdcb543fb365fa900934a10812f

$ docker cp test_script.sh wirecloud_test_latest:/opt/wirecloud_instance/test_script.sh

$ docker exec -it wirecloud_test_latest /bin/bash
root@47ca7b90c7bf:/opt/wirecloud_instance# su wirecloud
wirecloud@47ca7b90c7bf:/opt/wirecloud_instance# bash test_script.sh
.....
wirecloud@47ca7b90c7bf:/opt/wirecloud_instance# exit
root@47ca7b90c7bf:/opt/wirecloud_instance# apache2ctl graceful
root@47ca7b90c7bf:/opt/wirecloud_instance# exit

結果:

テーマが適用された WireCloud

とにかく、WireCloud が無効なテーマや見つからないテーマを読み込もうとしたときに適切なエラー メッセージを表示できなかったことは明らかなので、これらのケースを改善するためのチケットを作成しました。新しいテーマの作成方法に関するドキュメントも更新し、docker image docsにいくつかのセクションを追加しました。/opt/wirecloud_instanceテーマを に配置することで問題を解決しましたが/usr/local/lib/python2.7/site-packages/、最適な場所は/opt/wirecloud_instance/babblerThemeです。

WireCloud を使用してこれらの問題を報告していただきありがとうございます :)。

ノート

および標準の python パッケージで作成されたフォルダーは変更しsite-packagesないでください。これらのフォルダは手動で編集するためのものではなく、WireCloud をアップグレードまたは削除すると (たとえば を使用して) 変更が失われます。dist-packagesvirtualenvpip

さらに、docker を使用してこれを行うと、WireCloud イメージの新しいバージョンをプルした後に行った変更がすべて失われます。

于 2016-05-19T19:08:21.703 に答える
0

解決しました!!

ステップ1

wirecloud では、/usr/local/lib/python2.7/site-packages/ の後にすべてを Python ドット区切りのファイル名形式で追加する必要があります。

したがって、カスタム テーマが /usr/local/lib/python2.7/site-packages/wirecloud/mytheme ディレクトリにある場合

次に、settings.py には次のエントリが必要です: Wirecloud が起動時に mytheme テーマを選択するには、THEME_ACTIVE = "wirecloud.mytheme" です。

ステップ2

コマンド python manage.py collectstatic --noinput が起動時に、Apache Web サーバーを再起動する直前に実行されていることを確認してください。docker-entrypoint.sh スタートアップ ファイルを次のように変更することで、カスタム Docker イメージでこれを実現しました。

#!/bin/bash

sed -i "s/SECRET_KEY = 'TOCHANGE_SECRET_KEY'/SECRET_KEY = '$(python -c "from django.utils.crypto import get_random_string; import re;  print(re.escape(get_random_string(50, 'abcdefghijklmnopqrstuvwxyz0123456789%^&*(-_=+)')))")'/g" /opt/wirecloud_instance/wirecloud_instance/settings.py

echo ===> migrating python modules with python manage.py migrate
python /opt/wirecloud_instance/manage.py migrate # Apply database migrations
python /opt/wirecloud_instance/manage.py collectstatic --noinput # Collect static files

# Start apache processes in foreground
/usr/sbin/apache2ctl graceful-stop
exec /usr/sbin/apache2ctl -D FOREGROUND

注: Python コマンドの順序は重要です。collectstatic の行は最後に実行する必要があります。そうしないと、静的リソースがブラウザーに提供されません。

Wirecloud 開発者は、Docker イメージにマイナーな変更を加えたログファイルがある場合のみ、ドキュメントを更新してください。これは痛すぎた!

于 2016-05-17T18:39:29.317 に答える