ホーム » ASUSTOR NAS (ページ 3)
「ASUSTOR NAS」カテゴリーアーカイブ
Python tkinter インストール
Windows から Raspberry Pi 環境に接続できる様に samba を追加しようと…
検索して次の所を参考に設定.
https://qiita.com/fstyle/items/1670d260f58f77a43144
https://www.raspberrypirulo.net/entry/samba
この中で書かれている nano というエディタ.
CUI で使えるみたいで NAS などの幾つかの環境にインストール.
sudo opkg install nano
他に CUI のファイルマネージャ.
sudo opkg install mc
操作性など異なるが,エコロジーⅡを思い出す.
https://unilab.gbb60166.jp/T98Next/T98Next2.htm
NAS VirtualBox に Win10 … できず
ASUSTOR NAS の VirtualBox で動作させている Win10 が不安定なので,VirtualBox 上にインストールから…
ASUSTOR NAS の VirtualBox で作成した vdi をコピーしてそれを指定すると,
VirtualBox error: rc=0x80bb0001 Cannot register the hard disk ‘/volume1/Public/VHD/DevA/DevA.vdi’ {f7577f3a-2c71-49bb-b349-5b6aa27133bd} because a hard disk ‘/root/VirtualBox VMs/DevA/DevA.vdi’ with UUID {f7577f3a-2c71-49bb-b349-5b6aa27133bd} already exists (0x80070057)
コマンドプロンプトで,
Microsoft Windows [Version 10.0.18362.1016]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\Iwao>cd %TMP%
C:\Users\Iwao\AppData\Local\Temp>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands sethduuid B:\VHD\DevA\DevA.vdi
UUID changed to: 7bf3a9e5-06f0-4718-b8ed-c48322cc99f9
C:\Users\Iwao\AppData\Local\Temp>
コピーした vdi を選択して起動すると,
UUID {bee82a51-4b3e-4856-9d86-f035dee8bd25} of the medium ‘/volume1/Public/VHD/DevA/DevA.vdi’ does not match the value {7bf3a9e5-06f0-4718-b8ed-c48322cc99f9} stored in the media registry (‘/root/.config/VirtualBox/VirtualBox.xml’)
検索 してわかりやすかったのが次の所.
https://katurakuno.xsrv.jp/Linux/LinuxMint/virtualbox/error.html
C:\Users\Iwao\AppData\Local\Temp>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands sethduuid B:\VHD\DevA\DevA.vdi 7bf3a9e5-06f0-4718-b8ed-c48322cc99f9
UUID changed to: 7bf3a9e5-06f0-4718-b8ed-c48322cc99f9
C:\Users\Iwao\AppData\Local\Temp>
VirtualBox 内でセットアップは起動するが,リモートデスクトップサーバとして動作させる方法がわからない.
今までは既存の vdi を使用していたが,インストールからとなると NAS 本体に接続するしかないのか?
以前,一時的に仮想マシンが起動する前に RDP 接続できていた時があったが,どこかの設定なのか?
QNAP NAS の Virtualization Station は,ブラウザから操作が可能 .
2020/09/20
VirtualBox の更新があり?リモートデスクトップ接続 できるようになった.
TS-253D セットアップ – 4
Virtualization Station 3 のエクスポート.
先日作成した Win10 を VirtualBox などで開くためにエクスポート.
仮想マシンの下にある「エクスポート」ボタンを押して,*.ovf で「スタート」.
18 GB の img で 40 分位かかった.出力された vmdk は 9 GB .
AS5202T の VirtualBox で「ファイル」-「仮想アプライアンスのインポート」.
変換に 5 分位.
そのまま実行すると 0xc0000225 .
チップセットを「ICH9」,「I/O APIC を有効化」にチェック.
安定して動作はするが,どこかで間違えたみたいでネットワークがうまく機能しない.
PC の VirtualBox で読み込んでみたが,やはりネットワークがうまく動作していない.
今度は VirtualBox のエクスポート.
PC の VirtualBox で「仮想アプライアンスのエクスポート」,AS5202T 上の DevX をエクスポート.50 分位.
QNAP NAS Virtualization Station 3 で「VM のインポート」.20 分位.
最初うまく起動しなかった(実際は表示がうまくされていなかっただけ?).
「設定」-「ビデオ」-「タイプ」を「Cirrus」になっていたものを「VGA」に.
これでうまくいった.VNC 接続も問題なし.
NAS 環境に Flask のインストール
先ず Debian 環境に Flask をインストール.
pip3 install Flask
サンプルの hello.py を実行,ブラウザで表示.
AS5202T でも同様に Flask をインストール.
pip3 install Flask
Synology NAS では pip のインストールから.
suto opkg install python-pip
suto opkg install python3-pip
Flask をインストールしてみたが …
Iwao@DS116:~/pyt_test/t_flask$ pip3 install Flask Collecting Flask Using cached https://files.pythonhosted.org/packages/f2/28/2a03252dfb9ebf377f40fba6a7841b47083260bf8bd8e737b0c6952df83f/Flask-1.1.2-py2.py3-none-any.whl Collecting click>=5.1 (from Flask) Using cached https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl Collecting itsdangerous>=0.24 (from Flask) Using cached https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl Collecting Werkzeug>=0.15 (from Flask) Using cached https://files.pythonhosted.org/packages/cc/94/5f7079a0e00bd6863ef8f1da638721e9da21e5bacee597595b318f71d62e/Werkzeug-1.0.1-py2.py3-none-any.whl Collecting Jinja2>=2.10.1 (from Flask) Using cached https://files.pythonhosted.org/packages/30/9e/f663a2aa66a09d838042ae1a2c5659828bb9b41ea3a6efa20a20fd92b121/Jinja2-2.11.2-py2.py3-none-any.whl Collecting MarkupSafe>=0.23 (from Jinja2>=2.10.1->Flask) Using cached https://files.pythonhosted.org/packages/b9/2e/64db92e53b86efccfaea71321f597fa2e1b2bd3853d8ce658568f7a13094/MarkupSafe-1.1.1.tar.gz Complete output from command python setup.py egg_info: /opt/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'project_urls' /opt/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'include_package_data' /opt/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires' usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: -c --help [cmd1 cmd2 ...] or: -c --help-commands or: -c cmd --help error: invalid command 'egg_info' ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-dsqn65uh/MarkupSafe/ Iwao@DS116:~/pyt_test/t_flask$
「 Command python setup.py egg_info faild with error code 1 」で検索 をかけると pip などが古いとある.
次の様にして pip などを更新.
sudo pip install –upgrade pip setuptools
Python から CPP の呼出し – 3
//////////////////////////////////////////////////////////////////// // test_cpp.hpp // #pragma once #include "_s_func.hxx" #include "_t_func.hxx" #include "_tdefine.hxx" class test_class { public: test_class (LPCTSTR n) { name = n ; std::tout<< name + _T("\t***") << std::endl ; } virtual ~test_class () { std::tout<< name + _T("\t---") << std::endl ; } public: tstring name ; } ; inline test_class* get_test_class (void) { static test_class G_tc("G_test") ; return &G_tc ; } //////////////////////////////////////////////////////////////////// // test_cpp.cpp // #include "test_cpp.hpp" #include <clocale> #include <iostream> test_class tc(_T("global")) ; int _tmain (int argc,TCHAR* argv[]) { _tsetlocale(LC_ALL,_T("")) ; test_class tc(_T("local 1")) ; { test_class tc(_T("local 2")) ; std::tout << _T("hello") << std::endl ; } { test_class* gt = ::get_test_class() ; std::tout << gt->name << std::endl ; } return 0 ; } ////////////////////////////////////////////////////////////////////
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/call_cpp/test_cpp $ g++ test_cpp.cpp -Wall Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/call_cpp/test_cpp $ ./a.out global *** local 1 *** local 2 *** hello local 2 --- G_test *** G_test local 1 --- G_test --- global --- Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/call_cpp/test_cpp $
//////////////////////////////////////////////////////////////////// // t_cpp.cpp // #include <Python.h> #include "test_cpp.hpp" #include <clocale> #include <iostream> test_class tc(_T("global")) ; static PyObject* local__ (PyObject* self, PyObject* args) { test_class tc(_T("local")) ; std::tout << tc.name << std::endl ; return Py_None; } static PyObject* global_ (PyObject* self, PyObject* args) { test_class* gt = ::get_test_class() ; std::tout << gt->name << std::endl ; return Py_None; } static PyMethodDef t_cpp_methods[] = { { "local__", local__, METH_NOARGS, "local__" }, { "global_", global_, METH_NOARGS, "global_" }, { NULL }, } ; static struct PyModuleDef t_cpp = { PyModuleDef_HEAD_INIT, "t_cpp", "test cpp module", -1, t_cpp_methods } ; PyMODINIT_FUNC PyInit_t_cpp(void) { return PyModule_Create(&t_cpp) ; } ////////////////////////////////////////////////////////////////////
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/call_cpp/test_cpp $ g++ t_cpp.cpp -Wall -fPIC -shared -o t_cpp.so -I /volume1/.@plugins/AppCentral/python3/include/python3.7m/ Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/call_cpp/test_cpp $ python3 Python 3.7.0 (default, Aug 23 2018, 17:48:39) [GCC 4.6.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import t_cpp global *** >>> dir(t_cpp) ['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'global_', 'local__'] >>> t_cpp.local__() local *** local local --- >>> t_cpp.local__() local *** local local --- >>> t_cpp.global_() G_test *** G_test >>> t_cpp.global_() G_test >>> import t_cpp >>> t_cpp.local__() local *** local local --- >>> t_cpp.global_() G_test >>> exit() G_test --- global --- Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/call_cpp/test_cpp $
Python から CPP の呼出し – 2
予めデータ(vv_PLF)を作成して,必要に応じてファイルに出力するコード.
vv_PLF* get_vv_PLF (void) { static vv_PLF G_PLF ; return &G_PLF ; } static PyObject* check_rd (PyObject* self, PyObject* args) { vv_PLF* gvv_plf = get_vv_PLF() ; vv_PLF vv_plf_ = ::Check_Revise_deg() ; *gvv_plf = vv_plf_ ; return Py_None ; } static PyObject* dump_svg (PyObject* self, PyObject* args) { vv_PLF* gvv_plf = get_vv_PLF() ; ::Dump_SVG(*gvv_plf) ; return Py_None ; } static PyObject* dump_ipl (PyObject* self, PyObject* args) { vv_PLF* gvv_plf = get_vv_PLF() ; ::Dump_ipl(*gvv_plf) ; return Py_None ; }
Python 側では
* check_rd でデータを作成.
* dump_svg などでデータを出力.
3D データを読み込んで,指定されたファイル名(拡張子により形式を判断)で出力.
static PyObject* load (PyObject* self, PyObject* args) { const char* str_file = NULL ; if (!PyArg_ParseTuple(args,"s",&str_file)) { return NULL ; } tstring g3_file = str_file ; GonsA gnsa = ::To_GonsA(g3_file.c_str()) ; set_GonsA(gnsa) ; return Py_None; } static PyObject* save (PyObject* self, PyObject* args) { const char* str_file = NULL ; if (!PyArg_ParseTuple(args,"s",&str_file)) { return NULL ; } tstring g3_file = str_file ; GonsA* gnsa = ::get_GonsA() ; ::GonsA_To(*gnsa,g3_file.c_str()) ; return Py_None; } static PyObject* gons_to (PyObject* self, PyObject* args) { const char* str_file = NULL ; if (!PyArg_ParseTuple(args,"s",&str_file)) { return NULL ; } tstring g3_file = str_file ; gons_to(g3_file.c_str()) ; return Py_None; }
Python から CPP の呼出し
雰囲気はつかめてきたので,以前作成した cpp を呼んでみることに…
実際の処理部分は C++ のコードだが,呼び出しは C の関数.
また引数もない状態なので,C 関数の system(“a.out”) と呼んでいるのと同様.
#include "i_rd_dbg.hxx" int _tmain(int argc, TCHAR* argv[]) { ::Test_Revise_deg() ; return 0 ; }
#include <Python.h> #include "i_rd_dbg.hxx" #include "messbar.cxx" static PyObject* call_cpp(PyObject* self, PyObject* args) { ::Test_Revise_deg() ; return Py_None ; } static PyMethodDef myMethods[] = { { "_call_cpp_", call_cpp, METH_NOARGS, "call cpp" }, { NULL }, } ; static struct PyModuleDef call_mod = { PyModuleDef_HEAD_INIT, "call_mod", "call_cpp module", -1, myMethods } ; PyMODINIT_FUNC PyInit_call_mod(void) { return PyModule_Create(&call_mod) ; }
コンパイルして import まではできたが,メソッドをうまく呼び出せない.
>>> call_mod.call_cpp()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module ‘call_mod’ has no attribute ‘call_cpp’
>>>
それで,メソッドを表示できないかと思い検索すると,
python でメソッドの一覧を取得する方法
他に dir(call_mod) もあった.
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/call_cpp/T_Rvs_sc $ g++ rvs_sc_w.cpp -o call_mod.so -fPIC -Wall -shared -I /volume1/.@plugins/AppCentral/python3/include/python3.7m/ Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/call_cpp/T_Rvs_sc $ Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/call_cpp/T_Rvs_sc $ python3 Python 3.7.0 (default, Aug 23 2018, 17:48:39) [GCC 4.6.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import call_mod >>> call_mod.call_cpp Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'call_mod' has no attribute 'call_cpp' >>> call_mod.call_cpp() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'call_mod' has no attribute 'call_cpp' >>> obj = call_mod >>> import inspect >>> for m in inspect.getmembers(obj): ... print(m) ... ('__doc__', 'call_cpp module') ('__file__', '/volume1/home/Iwao/test/test_py/call_c/call_cpp/T_Rvs_sc/call_mod.so') ('__loader__', <_frozen_importlib_external.ExtensionFileLoader object at 0x7f5a1a35ec50>) ('__name__', 'call_mod') ('__package__', '') ('__spec__', ModuleSpec(name='call_mod', loader=<_frozen_importlib_external.ExtensionFileLoader object at 0x7f5a1a35ec50>, origin='/volume1/home/Iwao/test/test_py/call_c/call_cpp/T_Rvs_sc/call_mod.so')) ('_call_cpp_', <built-in function _call_cpp_>) >>> call_mod._call_cpp_() >>>
ASUSTOR NAS に SSH 接続できない
AS5202T に SSH 接続 しようとすると,次のメッセージが表示されて接続できなくなった.
ssh_exchange_identification: read: Connection reset
Microsoft Windows [Version 10.0.18362.959] (c) 2019 Microsoft Corporation. All rights reserved. C:\Users\Iwao>ssh -l Iwao 192.168.1.75 ssh_exchange_identification: read: Connection reset C:\Users\Iwao>ssh -l Iwao as5202t Password: Iwao@AS5202T:/volume1/home/Iwao $ exit Connection to as5202t closed. C:\Users\Iwao>ssh -l Iwao 192.168.1.75 Password: Iwao@AS5202T:/volume1/home/Iwao $ exit Connection to 192.168.1.75 closed. C:\Users\Iwao>ssh -l Iwao 192.168.1.75 Password: Password: Password: Iwao@192.168.1.75's password: Connection closed by 192.168.1.75 port 22 C:\Users\Iwao>ssh -l Iwao 192.168.1.75 ssh_exchange_identification: read: Connection reset C:\Users\Iwao>
対応方法:
ADM に入って「設定」-「ADMディフェンダー」の「自動ブラックリスト」で「削除」する.
スマートフォンの「AiMaster」では「オンラインユーザー」-「ブラックリスト」から.
Python から C の呼出し
C のコードを Python から呼出せないかと…
Python のドキュメントとしては次の所にある
C や C++ による Python の拡張
Win10 C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\include\Python.h debian10 /usr/include/python3.7/Python.h AS5202T /volume1/.@plugins/AppCentral/python3/include/python3.7m/Python.h Iwao@AS5202T:/volume1/.@plugins/AppCentral/python3/include/python3.7m $ find / -name Python.h /volume1/.@plugins/AppCentral/linux-center/containers/debian10/rootfs/usr/include/python2.7/Python.h /volume1/.@plugins/AppCentral/linux-center/containers/debian10/rootfs/usr/include/python3.7m/Python.h /volume1/.@plugins/AppCentral/python/include/python2.7/Python.h /volume1/.@plugins/AppCentral/python3/include/python3.7m/Python.h
検索 して見つけたもの.
https://www.fsi-embedded.jp/kumico/columns/?cat=python
https://qiita.com/donkonishi/items/b7825b34d0711e336c61
https://www.quark.kj.yamagata-u.ac.jp/~hiroki/python/?id=19
http://owa.as.wakwak.ne.jp/zope/docs/Python/BindingC/
https://cpp-learning.com/?s=”Python+C+API”
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello/bak $ cat hellWrap.c #include <Python.h> extern int add(int, int); extern void out(const char*, const char*); PyObject* hello_add(PyObject* self, PyObject* args) { int x, y, g; if (!PyArg_ParseTuple(args, "ii", &x, &y)) return NULL; g = add(x, y); return Py_BuildValue("i", g); } PyObject* hello_out(PyObject* self, PyObject* args, PyObject* kw) { const char* adrs = NULL; const char* name = NULL; static char* argnames[] = {"adrs", "name", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kw, "|ss", argnames, &adrs, &name)) return NULL; out(adrs, name); return Py_BuildValue(""); } static PyMethodDef hellomethods[] = { {"add", hello_add, METH_VARARGS}, {"out", hello_out, METH_VARARGS | METH_KEYWORDS}, {NULL} }; void initchello(){ Py_InitModule("hello", hellomethods); } Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello/bak $ gcc -fPIC -Wall -c -o hellWrap.o hellWrap.c -I /volume1/.@plugins/AppCentral/python/include/python2.7/ hellWrap.c:30:13: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types] {"out", hello_out, METH_VARARGS | METH_KEYWORDS}, ^~~~~~~~~ hellWrap.c:30:13: note: (near initialization for 'hellomethods[1].ml_meth') Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello/bak $ gcc -fPIC -Wall -c -o hellWrap.o hellWrap.c -I /volume1/.@plugins/AppCentral/python/include/python2.7/ Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello/bak $
PyMethodDef の所でエラーとなっていていろいろと探すと,型を指定しているものがあり,それを指定.
https://bty.sakura.ne.jp/wp/archives/83
static PyMethodDef hellomethods[] = { {"add", (PyCFunction)hello_add, METH_VARARGS}, {"out", (PyCFunction)hello_out, METH_VARARGS | METH_KEYWORDS}, {NULL} };
コンパイルは通る様になった.
Python から試そうとすると …
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello $ gcc -fPIC -Wall -c -o helloWrap.o helloWrap.c -I /volume1/.@plugins/AppCentral/python/include/python2.7/ Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello $ gcc -fPIC -Wall -shared -o hellomodule.so hello.o helloWrap.o Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello $ ll total 44 drwxrwxrwx 3 Iwao users 4.0K Jul 29 18:16 ./ drwxrwxrwx 5 Iwao users 4.0K Jul 29 15:31 ../ drwxrwxrwx 2 Iwao users 4.0K Jul 29 18:05 bak/ -rwxrwxrwx 1 Iwao users 188 Jul 29 16:29 hello.c* -rw-r--r-- 1 Iwao users 1.6K Jul 29 16:33 hello.o -rwxrwxrwx 1 Iwao users 910 Jul 29 16:32 helloWrap.BAK* -rwxrwxrwx 1 Iwao users 936 Jul 29 16:37 helloWrap.c* -rw-r--r-- 1 Iwao users 3.1K Jul 29 18:16 helloWrap.o -rwxr-xr-x 1 Iwao users 8.3K Jul 29 18:16 hellomodule.so* Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello $ python3 Python 3.7.0 (default, Aug 23 2018, 17:48:39) [GCC 4.6.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import hello Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'hello' >>> exit() Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello $ python Python 2.7.10 (default, Aug 19 2015, 09:18:54) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import hello Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dynamic module does not define init function (inithello) >>> exit() Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/hello $
まだ何か違うみたい.
メッセージは inithello がないとなっているので helloWrap.c を見直すと…
void initchello() { … } となっている.
関数名を inithello に変更してビルドすると通った.
2020/07/30
今日は次の所を参考にさせてもらって…
https://cpp-learning.com/python_c_api_step1/
Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/py_hello $ gcc ph_hello.c -o mymodule.so -fPIC -Wall -shared -I /volume1/.@plugins/AppCentral/python3/include/python3.7m/ Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/py_hello $ python3 Python 3.7.0 (default, Aug 23 2018, 17:48:39) [GCC 4.6.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import mymodule Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dynamic module does not define module export function (PyInit_mymodule) >>> import myModule Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'myModule' >>> Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/py_hello $ cp mymodule.so myModule.so Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/py_hello $ ll total 44 drwxrwxrwx 3 Iwao users 4.0K Jul 30 16:49 ./ drwxrwxrwx 6 Iwao users 4.0K Jul 30 14:59 ../ drwxrwxrwx 2 Iwao users 4.0K Jul 30 16:48 bak/ -rwxr-xr-x 1 Iwao users 8.1K Jul 30 16:49 myModule.so* -rwxr-xr-x 1 Iwao users 8.1K Jul 30 16:47 mymodule.so* -rwxrwxrwx 1 Iwao users 188 Jul 29 16:29 ph_hello.BAK* -rwxrwxrwx 1 Iwao users 1.3K Jul 30 16:27 ph_hello.c* Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/py_hello $ python3 Python 3.7.0 (default, Aug 23 2018, 17:48:39) [GCC 4.6.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import myModule >>> myModule.helloworld <built-in function helloworld> >>> myModule.helloworld() Hello World >>> >>> >>> >>> Iwao@AS5202T:/volume1/home/Iwao/test/test_py/call_c/py_hello $
コンパイル時の出力ファイル名 mymodule.so が間違っていた.正しくは myModule.so .
そこ には詳しく書かれているが,自分用にメモ.
PyMethodDef の “メソッド名” は Python 側での (モジュール名).(メソッド名) .
同様に PyModuleDef の “モジュール名” は import 時の名称..so の出力ファイル名も対応している必要がある?
文字列なので,異なっていてもコンパイル時のエラーにはならない.
実行時に見つからないなどのエラーとなる.
2020/07/31
続きの内容をやっていて…
https://cpp-learning.com/python_c_api_step2/
Fatal Python error: GC object already tracked
c_list は Python 側で確保しているため Py_DECREF はうまくないのではないか?
Python 負のインデックス
次の所を読ませてもらっていて感じたことを…
けいしゅけのブログ薬局 情報館
https://keisyuke-blogyakkyoku.xyz/python-list-index
今私が習得するのにタイミングや更新サイクルが丁度良いので助かっている.
ASUSTOR NAS AS5202T に SSH 接続して Python を操作.
C:\Program Files\Microsoft Office\Office14>cd C:\Users\Iwao\AppData\Local\Temp C:\Users\Iwao\AppData\Local\Temp>ssh -l Iwao -p 22 192.168.1.75 Password: Iwao@AS5202T:/volume1/home/Iwao $ python Python 2.7.10 (default, Aug 19 2015, 09:18:54) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a=[0,1,2,3,4] >>> print(a[0]) 0 >>> print(a[4]) 4 >>> print(a[5]) Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range >>> print(a[-1]) 4 >>> print(a[-4]) 1 >>> print(a[-5]) 0 >>> print(a[-6]) Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range >>>
似たようなことを C++ でやろうとすると次の様な感じ.
std::cout << a[a.size()-1] ;
この様な記述ができるからか,今まで負のインデックスの必要性は感じたことがなかった.
また配列の検索で該当するものがないと -1 を返す様なコードもよく書く.
インデックスを変数で持つ時は?
いろいろ考えると個人的にはあまり使わないのではないかと思う.
Python などをやればもっと有効な使い方が出てくるのか?
Debian 環境に pip のインストール
PyOpenGL を使おうとして pip コマンドを打つと,コマンドがない.
どうも pip が入っていないみたいで,次の様に入力してインストール.
sudo apt install python-pip
更に PyOpenGL のインストール.
pip install PyOpenGL
pip3 のインストールは
sudo apt install python3-pip
C:\WINDOWS\System32>cd C:\Users\Iwao\AppData\Local\Temp C:\Users\Iwao\AppData\Local\Temp>ssh -l admin -p 22 lxcdebian10 admin@lxcdebian10's password: Linux lxcdebian10 4.14.x #1 SMP Wed May 13 00:37:48 CST 2020 x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Thu Jul 9 10:51:02 2020 from fe80::ed6f:4991:21c9:1882%eth0 admin@lxcdebian10:~$ cat /usr/bin/pip #!/usr/bin/python # GENERATED BY DEBIAN import sys # Run the main entry point, similarly to how setuptools does it, but because # we didn't install the actual entry point from setup.py, don't use the # pkg_resources API. from pip._internal import main if __name__ == '__main__': sys.exit(main()) admin@lxcdebian10:~$ cat /usr/bin/pip3 #!/usr/bin/python3 # GENERATED BY DEBIAN import sys # Run the main entry point, similarly to how setuptools does it, but because # we didn't install the actual entry point from setup.py, don't use the # pkg_resources API. from pip._internal import main if __name__ == '__main__': sys.exit(main()) admin@lxcdebian10:~$
AS5202T Debian 10 に Image Magick
Raspberry Pi などと同様 に
sudo apt install imagemagick
特に難しいことはない.
AS5202T Debian 10 と VC
VC で ASUSTOR NAS Linux Center の Debian 10 Desktop を使用するための設定.
SSH 接続を可能にして gcc などをインストールしておく必要がある.
Linux development with C++ in Visual Studio
VC の「ツール」-「オプション」,「クロスプラットフォーム」-「接続マネージャー」-「追加」.
SSH 接続する時の情報を設定する.
追加後「接続マネージャー」-「リモートヘッダー…」で「更新」するとエラー.
エラーが発生しました。Could not start the ‘rsync’ command on the remote host, please install it using your system package manager. Please see https://aka.ms/AA23jat for troubleshooting。詳細については、C:\Users\Iwao\AppData\Local\Temp\vslinux_header_update_log.txt を参照してください。トラブルシューティングを行うには、https://aka.ms/AA23jat をご覧ください。
この部分の対応方法はよくわからない.
これでビルドすれば大丈夫なはずだが,何故かエラー.
VC を再起動したり,プロジェクトを読み直したりしていたら通る様になった.
AS5202T Debian 10
以前 インストールしてそのままになっていた環境.
その時わからなかったのが「タイムゾーン」の設定.
次の所を参考にさせてもらって設定.
Debian 10 busterをインストールして最初に行う設定と確認 10項目
共通のソースなどを参照するために…
Linux から Windows 環境への接続
接続先は,最終的には変更する予定.
AS5202T に mono インストール
Synology NAS にもあるので気になっていた mono .
以前 MonoDevelop をインストールして少しは試したことがある.
それで,どこまでのものとして入るかをやってみた.
Iwao@AS5202T:/volume1/home/Iwao/test/mono $ ls /usr/local/AppCentral/mono/bin/ al* gacutil2* mono-api-info* nunit-console2* al2* genxs* mono-boehm* nunit-console4* asp-state* httpcfg* mono-cil-strip* pdb2mdb* asp-state2* ikdasm* mono-configuration-crypto* pedump* asp-state4* ilasm* mono-find-provides* permview* caspol* illinkanalyzer* mono-find-requires* peverify* cccheck* installvst* mono-gdb.py resgen* ccrewrite* lc* mono-heapviz* resgen2* cert-sync* macpack* mono-package-runtime* secutil* cert2spc* makecert* mono-service* setreg* certmgr* mconfig* mono-service2* sgen* chktrust* mcs* mono-sgen* sgen-grep-binprot* crlupdate* mdassembler* mono-sgen-gdb.py signcode* csc* mdbrebase* mono-shlib-cop* sn* csc-dim* mdoc* mono-symbolicate* soapsuds* csharp* mdoc-assemble* mono-test-install* sqlmetal* csi* mdoc-export-html* mono-xmltool* sqlsharp* dbsessmgr* mdoc-export-msxdoc* monodis* svcutil* dbsessmgr2* mdoc-update* monodocer* vbc* dbsessmgr4* mdoc-validate* monodocs2html* wsdl* disco* mdvalidater* monodocs2slashdoc* wsdl2* dmcs* mkbundle* monograph* xbuild* dtd2rng* mod* monolinker* xsd* dtd2xsd* mod-mono-server* monop* xsp* fastcgi-mono-server* mod-mono-server2* monop2* xsp2* fastcgi-mono-server2* mod-mono-server4* mozroots* xsp4* fastcgi-mono-server4* mono@ mprof-report* gacutil* mono-api-html* nunit-console* Iwao@AS5202T:/volume1/home/Iwao/test/mono $
「mono 使い方」で検索.
mcs test.cs でコンパイル,mono test.exe で実行できるみたい.
2020/06/24
phpinfo() を見てみると mod_mono が読み込まれている.
AS5202T VirtualBox – 2
AS5202T の CPU 温度を見るといつもより高い.
「プロセス」情報を見ると VirtualBox が消費している.
VNC で接続すると TiWorker.exe が CPU を食っている.
丁度 Windows Update のタイミングみたい.
VNC 接続の仮想マシンは遅くて操作できないが,接続しているクライアントからソースなどは見える.
前回 の様なネットワークが途切れる状態にはまだなっていない.
「リモートデスクトップ」であれば仮想マシンも操作できた.
落ち着くまでそのままにしておくしかなさそう.
その後「再起動」待ちになっていたので仮想マシンを再起動.
また止まったような表示.
CPU は食っているのでこのまま様子見.
2020/06/11
そのまま変わらないので,仮想マシンの「電源オフ」.
PC の VirtualBox で再起動.
Windows Update での再起動がうまく動作しないのか?
AS5202T VirtualBox の仮想マシンとして起動した時,いつもより時間がかかることがある.
また,ネットワークがうまく接続されていないこともあり.
安定するまで何度か再起動の必要があるのかもしれない.
起動時止まった様に見えても 30 分程度はそのままにして様子を見た方が良さそう.
仮想マシンの CPU や HDD などのリソースへのアクセス状況が見えると良いのに…
弦と矢と半径 – 4
先日の Python コードのバグ(整数で計算されてしまうため結果が異なる).
原因はすぐわかるが,対応は悩む所.
コードを分解して動作を確認してみた.
def r_cs_o (c , s) : return ( ( c*c ) / ( 8 *s ) + s/2 ) def r_cs_n (c , s) : return ( ( c*c ) / ( 8.*s ) + s/2. ) print (6*6) print (8*1) print (36/8) print (36/8.) print (1/2) print (1/2.) print ("") print (36/8 +1/2 ) print (36/8.+1/2.) print ("") print (r_cs_o(6,1)) print (r_cs_n(6,1))
https://docs.python.org/ja/3/howto/pyporting.html?highlight=除算
Synology NAS DSM では Python 2.7 が標準で入っているみたい.
「パッケージ センター」で Python3 を追加できる.
C:\Program Files\Microsoft Office\Office14>cd C:\Users\Iwao\AppData\Local\Temp C:\Users\Iwao\AppData\Local\Temp>ssh -l Iwao -p 2200 192.168.1.116 Iwao@192.168.1.116's password: Iwao@DS116:~$ python3 Python 3.5.1 (default, Jan 29 2018, 14:16:30) [GCC 4.9.3 20150311 (prerelease)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> Iwao@DS116:~$ python2 Python 2.7.12 (default, May 12 2020, 04:48:57) [GCC 4.9.3 20150311 (prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> Iwao@DS116:~$ python Python 2.7.12 (default, May 12 2020, 04:48:57) [GCC 4.9.3 20150311 (prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> Iwao@DS116:~$
ASUSTOR NAS ADM では入ってない.「App Central」でインストール可能.
2020/11/20
QNAP NAS での Python3 は,他の NAS と異なるみたい.
opkg install python3 でインストールしなければならなかった.
https://mish.myds.me/wordpress/dev/2020/08/29/ts253d-setup-3-opkg/
https://mish.myds.me/wordpress/dev/2020/08/17/ts-253d-setup-7-python3/
AS5202T 温度
最近気温が少し高くなってきたので,ちょっと気になる ASUSTOR NAS の温度.
HDD の温度が Synology NAS と比べると高い.
Synology NAS では 40℃前後.AS5202T は 50℃前後になっている.
CPU温度は ASUSTOR NAS の場合は問題ないらしい.
UNISTAR のサポート情報 CPU温度が70度というのは正常ですか?
ここを読むと,ファン速度を「自動」にしている限りは HDD の温度の許容範囲ということか?
ファン速度は 770 RPM なので「低速」の状態.
手動で「中速」や「高速」にすると,それぞれ 2590 RPM と 4280 RPM .
今も使用している WD Cloud も 50℃前後.
以前 WD Cloud に大量のデータをコピーしていたら 55℃を超えた位からコピー速度が遅くなった.
この動作は WD Cloud によるのか WD Red によるものなのかは不明.
WD Red は PC でも使用しているが,こちらは十分冷却されているので遅くなったと感じたことはない.
AS5202T VirtualBox
以前よりは良くなってきたと思うが,昨夜からまた調子が…
昨夜 ASUSTOR NAS の OS ADM のアップデートがあったので更新した.
ADM 更新後 VirtualBox も問題なく起動してうまく動作していると思ったが…
仮想マシン DevX がネットワークから見えない.
リモートデスクトップでは開けるが,VNC ではつながらない.
DevX を再起動すると,途中で止まってしまうことも…
今回試したこと.
AppCentral の VirtualBox 5.2.22.r08 を一度 OFF にして ON に.
仮想マシンの設定は変更していない.
これでうまく起動したが,何度か再起動させると止まってしまった.
もう一度 AppCentral で OFF にして ON に.
これで起動したのでそのままに.
2020/09/21
6.1.12 に更新.安定している.
AS5202T 再セットアップ – 9
Linux Center を入れて Debian 10 Desktop をインストール.
次のページを参考にさせてもらって日本語化.
https://www.server-world.info/query?os=Debian_10&p=japanese
WSLのDebian環境を日本語化する
sudo apt -y install task-japanese locales-all
sudo apt -y install task-japanese-desktop
再起動させて日本語になった.
2020/05/05
gcc のインストール.
sudo apt install build-essential
glut のインストール.
sudo apt install freeglut3 freeglut3-dev
他によく使う tree のインストール.
sudo apt install tree
https://dev.mish.work/wordpress/2019/08/16/glut-install/
https://jml.mish.work/index.php/cpp/install-glut.html
https://jml.mish.work/index.php/cpp/glut.html
2020/05/06
Debian の環境の実体は以下に存在している.
/volume1/.@plugins/AppCentral/linux-center/containers/debian10/rootfs/home/admin