Archive for the ‘Python’ Category

 

nagios plugin API | pythonで書いてみる。

11月 25th, 2012

http://nagiosplug.sourceforge.net/developer-guidelines.html // http://nagios.sourceforge.net/docs/3_0/pluginapi.html 決め事はシンプルかな 基本3点 * 80字以内の1行で出力する * return code 0 OK 1 Warning 2 Critical 3 Unknown * option There are a few reserved options that should not be used for other purposes: -V version (–version) -h help (–help) -t timeout (–timeout) -w warning threshold (–warning) -c critical threshold (–critical) -H hostname (–hostname) -v […]

Read full article | コメントは受け付けていません。

fabric でデプロイ&システム設定

11月 20th, 2012

fabricでデプロイ http://docs.fabfile.org/en/1.5/ 関係ないけど、スクリプトをpythonで書く方針にしたので fabricを使ってみます。 python 2.6.6 Fabric is a Python (2.5 or higher) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks. と書いてあるので、現在シェルで書いてある部分の設定などもfabricにしてしまおうと思います。 インストール http://docs.fabfile.org/en/1.5/installation.html $ sudo pip-python install fabric Successfully installed fabric paramiko pycrypto Cleaning up… warningいっぱい出たけど・・・ チュートリアル http://docs.fabfile.org/en/1.5/tutorial.html fabfile.py def hello():  print(“hello world”) $ fab hello hello […]

Read full article | コメントは受け付けていません。

lz4 or snappy | lz4 php,python

11月 8th, 2012

http://code.google.com/p/snappy/ http://code.google.com/p/lz4/ snappy wikipedia http://en.wikipedia.org/wiki/Snappy_(software) lz4 komiyaさんのslideshare http://www.slideshare.net/komiyaatsushi/dsirnlp-3-lz4 lz4のほうが速度は速いらしいです。 とりあえずlz4入れてみます。 php と pythonで確認してみます。 php用 https://github.com/kjdev/php-ext-lz4 # git clone https://github.com/kjdev/php-ext-lz4.git . # phpize # ./configure # make # make install Installing shared extensions:     /usr/lib64/php/modules/ Installing header files:          /usr/include/php/ # echo “extension=lz4.so” > /etc/php.d/lz4.ini python用 http://pypi.python.org/pypi/lz4 # python-pip install lz4 Successfully […]

Read full article | コメントは受け付けていません。

pythonの命名規則とか

10月 14th, 2012

sh,perl,phpなど混在しているので、 これから作る物は、すべてpythonに変えようかと Style Guide for Python Code http://www.python.org/dev/peps/pep-0008/

Read full article | コメントは受け付けていません。

@staticmethod static function | Python

9月 26th, 2011

@staticmethod def generateKey( auction_id, user_id, price, updated_at ): key = auction_id + ‘__’ + user_id @staticmethodをつけるとpublic staticになる。 暗黙の第一引数 selfを取らない。

Read full article | コメントは受け付けていません。

GQLで検索

6月 29th, 2011

q = db.GqlQuery(“SELECT * FROM items WHERE endtime > DATETIME(‘2010-06-01 00:00:00′) order by endtime,bpoint desc LIMIT 10″) if q.count() > 0 : for i in q: print(i.key().name()) ・不等式を endtimeで行うとき order by endtimeがまず必要。 ・i.key().name() は、key_nameの取得 memo

Read full article | コメントは受け付けていません。

GQLの制限

6月 29th, 2011

http://code.google.com/intl/ja/appengine/docs/python/datastore/queriesandindexes.html#Restrictions_on_Queries ・不等式フィルタが使用できるのは 1 つのプロパティに限られる ・他の並び替え順序より先に、不等式フィルタのプロパティを並び替える必要がある さてどうしようか。 カラムを一つ増やせば対応できるけど無理だな。 日時を日だけにしたらいけるけど時間が必要かどうか・・・ 月別統計、日別統計のデータを作りたかったらそれぞれのカラムがあったほうが使える・・・

Read full article | コメントは受け付けていません。

timeout 500 error code 104 | google app engine

5月 21st, 2011

30秒エラーが頻発しています。。。 datastoreにputしているときに起きているようなのですが 原因はわかりません、datastoreと関係なく出ていることもあるようです。 instanceが初期化されたときにこういうエラーが起きる可能性が高いような感じですがわかりません。 今までとの違いは、datastoreのデータが増えてきたことくらいです。 とは言ってもまだ 3GB程度です。 これでputが遅くなったりする理由とも考えられません。 謎。 500 30143ms 31cpu_ms 8api_cpu_ms A serious problem was encountered with the process that handled this request, causing it to exit. This is likely to cause a new process to be used for the next request to your application. If you see this message frequently, you may […]

Read full article | コメントは受け付けていません。

install Lucene PHP for centos 64bit

5月 11th, 2011

# yum search lucene Loaded plugins: fastestmirror Determining fastest mirrors * addons: ftp.nara.wide.ad.jp * base: ftp.nara.wide.ad.jp * epel: ftp.kddilabs.jp * extras: ftp.nara.wide.ad.jp * updates: ftp.nara.wide.ad.jp addons | 951 B 00:00 base | 2.1 kB 00:00 epel | 3.7 kB 00:00 epel/primary_db | 3.7 MB 00:00 extras | 2.1 kB 00:00 updates | 1.9 kB 00:00 […]

Read full article | コメントは受け付けていません。

db.Model+db.put()と Entity+datastore.Put()の速度比較 python | google app engine

5月 10th, 2011

とりあえず、書いてみたのですが予想通り。 datastore.Putは db.putの中で呼ばれてるだけなので、やってることは一緒ということで差はありませんでした。 Model , 各 propertyも何か邪魔になるようなこともしていないようで。 50件put db.Model継承 db.put 319ms 2210cpu_ms 2000api_cpu_ms | cost -254 megacycles. 273ms 2210cpu_ms 2000api_cpu_ms | cost -245 megacycles. 250ms 2210cpu_ms 2000api_cpu_ms | cost -235 megacycles. 334ms 2233cpu_ms 2000api_cpu_ms | cost -271 megacycles. 665ms 2210cpu_ms 2000api_cpu_ms | cost -267 megacycles. 直接 entity作って、datastore.Put。low level api 470ms 2233cpu_ms 2000api_cpu_ms | cost -249 […]

Read full article | コメントは受け付けていません。