fabric-py3
公開しています
本家ではfabric2.0からpy3に本格対応するっていうアナウンスがあるので、 どうしても今、python3系でfabric使いたいって人向けです
基本的には2.7系で本家fabric使った方がいいと思います
参考にしたサイト
2to3を使ってコードをPython 3に移植する - Dive Into Python 3 日本語版
Python 3.3 からの with 文 - AtsuoIshimoto's blog
だいたいこのへん見れば、結構誰でも2to3できます
gitpython つかってみた
目的
- これを使う GitPython Documentation — GitPython 1.0.1 documentation
- 環境はpython 3.4です
手順
いれる
$ pip install gitpython
こんな感じでリポジトリを仮に作ってみる
やりたいこと
- git clone
- git branch -b
- git add
- git commit
こんな感じで書く
import os import git _repo_path = os.path.join('./', 'repo') # clone from remote git_repo = git.Repo.clone_from('git@github.com:rane-hs/test.git', _repo_path, branch='master') # create new branch from head git_repo.checkout('HEAD', b='new_branch') # 更新対象を生成 _test_dir = os.path.join(_repo_path, 'test1') os.mkdir(_test_dir) f = open(os.path.join(_test_dir, 'test.txt'), 'w', encoding='utf-8') f.write('this is test') f.close # git add & commit git_repo.index.add(['test1']) git_repo.index.commit('new commit!') # git push origin HEAD git_repo.remotes.origin.push('HEAD') # ここでパスとかなんやかんや聞かれる
その他
# from existing dir git_repo= git.Repo(_git_dir) # fetch all git_repo.remotes.origin.fetch() # origin/hogehoge があればここで自動でhogehogeになる。gitと動きは同じ git_repo.git.checkout('hogehoge') git_repo.git.pull()
.git.{任意のコマンド} でたいていなんとかなる
次回予告
- github3pyを使ってPRまで自動化しちゃおう!
flask で static content のフォルダーを指定する
flaskでアプリを作るんだけど
- model - manager (管理画面用アプリ) - static - {css,js} <- CMSで使うcss, jsを入れる場所 - app (アプリ層)
みたいなフォルダ構成だった場合に、管理画面2号を作りたくなったけどstaticは共通でやりたいよねみたいなその時に
app = Flask(__name__) app.static_folder = os.path.join('path', 'to', 'your', 'static', 'folder')
ssh keyをパス有りで生成しちゃったけどパスなしに変えたいとき
ssh コマンドってパス指定できないんだよね なんでなの?
$ ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
ubuntu 12.10をアップデートしたかった
とりあえずなんかアップデートができない。なぞい
なんかsources.lstの内容がdeprecatedになっているような記述がちらほら見える
さて対策方法をエラーメッセージでぐぐったところ、
この対策をやるといいようだ
アップグレードできないubuntuの為に用意されたaptリポジトリ - ksaitoの日記
このとおりsources.lstを編集して
$ dksu update-manager
で完了します
備忘録:ipython notebook つかってみた
win+xubuntu VMで開発していることが多いんですが ipython notebookってのがあるらしいことがわかったので入れてみました
$ pip install ipython $ pip install tornado $ pip install pyzmq
notebook server 作成
$ ipython profile create nbserver
profile 変更
$ vim ~/.ipython/profile_nbserver/ipython_config.py
c.NotebookApp.ip = 'VMのIP'
を追加- デフォルトポートは8888なのでそこも変えたかったら変更
起動
$ ipython notebook --profile=nbserver
ホストとポートを入れてアクセスすればOK
- enter で改行
- shift-enterで実行
楽だ!