blender : python api, get world matrix
8月 12th, 2014
http://blender.stackexchange.com/questions/1283/how-to-get-world-space-matrix-of-any-pose-bone ぼーんのmatrix * id_data.matrix_worldだけでした! 基準boneを決めて、全体の高さを揃えるのが簡単に出来るようになりました。 bone.location の並びが x,z,yのようです。 設定で変えられるかも?
blender : python で dopesheetを編集する。
8月 12th, 2014
bvhなどを利用する時にkeyframeを間引きしたりするのにスクリプトで一括操作してみます。 1. コマンドでblenderを起動 macの場合。 $ /Applications/Blender/blender.app/Contents/MacOS/blender 2. 編集するファイルを普通に開く 3. Scriptingに変更 4. pythonで書いて Run Scriptすると print()からterminalへ表示されます。 blender python api http://www.blender.org/documentation/blender_python_api_2_71_release/ 適当に触れるようになりました。 import bpy for action in bpy.data.actions: if action.name == “Reviving”: print(action.name) for channel in action.fcurves: print ( channel.data_path ) for i in range(0,11): for key in channel.keyframe_points: # key.select_control_point = False print(key.type) print(key.handle_left[0]) print(key.handle_left[1]) print(key.co[0]) […]
ダイジェスト認証、ベーシック認証でログインしたときのユーザー名を取得 php python
5月 20th, 2013
php <?php echo $_SERVER['REMOTE_USER']; python wsgi def application(environ, start_response): status = “200 OK” response_headers = [("Content-type", "text/plain")] start_response(status, response_headers) return [environ['REMOTE_USER']]
python 2.4.3 … pip とかいろいろ
4月 22nd, 2013
pythonbrewで 2.4.3を入れたけど全然動かない^^^ いろいろバージョンが pip-1.1 https://pypi.python.org/pypi/simplejson/2.1.0 https://github.com/simplegeo/python-oauth2 2.4.3だと https://bugzilla.redhat.com/show_bug.cgi?id=787003 なエラーとか
subprocess check_output , check kyototycoon
2月 8th, 2013
http://docs.python.org/2/library/subprocess.html#replacing-older-functions-with-the-subprocess-module nagios用のスクリプト pythonからktremotemgrを呼んで状態を確認する 2.6なのでcheck_outputが使えなかった http://docs.python.org/2.6/library/subprocess.html#module-subprocess popenのところだけ from subprocess import Popen,PIPE # 略 p = Popen(["ktremotemgr","report","-host",options.hostname,"-port",str(options.port),"-tout","2"], stdout=PIPE) output = p.communicate()[0] if re.search(r’db_total_count’, output ): m = re.search(r’db_total_count: ([0-9]*)’, output ) count = m.group(1) m = re.search(r’db_total_size: ([0-9]*)’, output ) size = m.group(1) print “OK: %s %s:%d count:%s size:%s” % (service, options.hostname, […]
mysql-python mysqldb
2月 8th, 2013
http://mysql-python.sourceforge.net/ http://sourceforge.net/projects/mysql-python/ python 2.6 で 2.7は最新、3.xはこれからのようです。 インストール pip-python install MySQL-python Complete output from command python setup.py egg_info: [localhost] out: The required version of distribute (>=0.6.28) is not available, こんなメッセージが出たので更新してから再度 easy_install -U distribute Successfully installed MySQL-python Cleaning up… === 参考:fabric に設定して fabric update_python_egg install_python_mysql -R all で10数台1回で更新出来ます。 参考:fabric + cuisineで管理 Fabric, Cuisine and Watchdog […]
fabric parallel modeでsudoを使うとき
2月 5th, 2013
Fatal error: Needed to prompt for a connection or sudo password, but input would be ambiguous in parallel mode パラレルモードだと、どっちのパスワードかわからなくなるよ。と オプションでパスワードを付ける fab production init_deploy -p pass
python PIL thumbnail, resize
2月 5th, 2013
サムネイルを作る時は Image.ANTIALIASを指定した方が良い。 RBGで無い時は convert(‘PBG’)をしてから。 がおすすめなようです。 im = Image.open(infile) im.thumbnail( (100,100 )) ↓ im.resize((100,100), Image.ANTIALIAS).save(outfile, “PNG”) http://stackoverflow.com/questions/1386400/pil-image-resizing-algorithm-similar-to-firefoxs
Python pillow PIL で画像変換
1月 31st, 2013
http://pypi.python.org/pypi/Pillow/ Pillow is the “friendly” PIL fork. PIL is the Python Imaging Library. Pillow was started for and is currently maintained by the Plone community. But it is used by many other folks in the Python web community, and probably elsewhere too. PIL forkでPILが更新されていないのでpillowで更新することが目的なようです。 中身はPILと同じなので、利用方法なども同じようです。 Build instructions (all platforms)を参考に centosに入れてみる。 1. ライブラリ準備 jpeg # yum […]
fabric 環境切替
11月 29th, 2012
こんな感じで env.roledefs={} env.roledefs_dev = { ‘proxy':['192.168.0.100'] } env.roledefs_prod = { ‘proxy':['192.168.1.99'] } env.development = True def dev(): env.roledefs = env.roledefs_dev def production(): env.development = False env.roledefs = env.roledefs_prod @roles(‘proxy’) def print_proxy(): print env.host で $ fab dev print_proxy 192.168.0.100 こんな感じで、ちゃんとrolesが反映されました。