2018年3月29日 星期四

Use mkvirtualenv of virtualenvwrapper-win to create diffenrent Python version of env

應用Python的virtualenv和virtualenvwrapper可方便建立Python的virtual enviroment,方便在不同的environment切換,各env有獨立的pip list和Python版本

首先要安裝Python (Linux已有內建Python2)

  1. Windows安裝完後要將PATH設定包含到C:\Python27
  2. 安裝virtualenv, pip install virtualenv
  3. 安裝virtualenvwrapper或是virtualenvwrapper-win (Windows版)
  4. 建立virtualenv
    1. mkvirtualenv env01
  5. 查看pip list, pip list
  6. 跳出env01, deactivate
  7. 查看目前有多少virtualenv, workon
  8. 進入virtualenv env01, workon env01
  9. 若要建立Python3的virtualenv, 先安裝Python3
  10. 確認Pyhon3的python.exe位置 (C:\Users\Jack_Lin\AppData\Local\Programs\Python\Python35\python.exe), 若是Linux, 可用which python3指令查看
  11. 建立一Python3的virtualenv
    1. mkvirtualenv -p C:\Users\Jack_Lin\AppData\Local\Programs\Python\Python35\python.exe python35
    2. python -V

2018年2月8日 星期四

ipmitool ipmi-raw ipmiutil cmd (icmd) raw command format

ipmitool:
ipmitool -I lanplus -H 192.168.1.123 -U admin -P password raw 0x06 0x01

ipmi-raw:
ipmi-raw -D LAN_2_0 -h 192.168.1.123 -u admin -p password 0x00 0x06 0x01

icmd:
icmd -J 3 -N 192.168.1.123 -U admin -P password 00 20 18 01

redfishtool on ubuntu

1. apt-get update
2. apt-get install python python3 python-pip
3. make a file /etc/pip.conf if you need proxy setting for pip
[list]
format=columns
[global]
trusted-host = pypi.python.org
proxy = http://127.0.0.1:3128
4. pip install virtualenvwrapper
5. login with normal user (not root)
6. add one line in tail of .bashrc
source $(which virtualenvwrapper.sh)
7. re-login
8. create a virtualenv of python3
mkvirtualenv -p $(which python3) redfish
9. pip install redfishtool

redfishtool commands:

redfishtool -u admin -p password -r 192.168.1.123 -S Always System
redfishtool -u admin -p password -r 192.168.1.123 -S Always System -a
redfishtool -u admin -p password -r 192.168.1.123 -S Always raw /redfish/v1/xxxx/xxxx

======
For Ubuntu 17.10, before step5
Need to add ~/.local/bin to PATH, edit ~/.bashrc
# set PATH ~/.local/bin
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

2018年2月7日 星期三

Install freeipmi on ubuntu

1. Download source from https://www.gnu.org/software/freeipmi/
2. install libgcrypt-dev
# sudo apt-get install libgcrypt-dev
3. compiler
# tar zxvf freeipmi-1.6.1.tar.gz
# cd freeipmi-1.6.1
# ./configure
# make
# sudo make install
4. make the change permanent you can add /usr/local/lib to /etc/ld.so.conf (or something it includes) and run ldconfig as root.
https://unix.stackexchange.com/questions/67781/use-shared-libraries-in-usr-local-lib


2018年1月24日 星期三

docker named volume path

Located at host's /var/lib/docker/volumes/

https://stackoverflow.com/questions/36312699/chown-docker-volumes-on-host-possibly-through-docker-compose/36321403#36321403

https://github.com/CWSpear/local-persist

Python project scaffold

http://docs.python-guide.org/en/latest/writing/structure/
https://www.kennethreitz.org/essays/repository-structure-and-python
https://github.com/pypa/sampleproject
https://github.com/sroberts/python-starter

找到這個generator,感覺更方便,處理方式也比較先進。
https://pypi.python.org/pypi/PyScaffold
pip install pyscaffold
putup my_project

如果是Django project可加--django參數,不過應該只是單純的幫你多下一次
django-admin.py startproject my_project而已

如果想要把apps放到不是project的root,而是像src的資料夾
在startapp之前要先把資料夾建好
mkdir ./src/newapp
然後才startapp
python manage.py startapp newapp ./src/newapp

之後要在project的setting.py多加這兩行
import sys
sys.path.insert(0, os.path.join(BASE_DIR, "src"))
才能在runserver時找到newapp
參考這個的

2018年1月16日 星期二

用Bitbucket存放Source code (如果ssh port22被擋)


SSH的 git@bitbucket.org:farwill/testlink_converter.git
改成HTTPS的 https://farwill@bitbucket.org/farwill/testlink_converter.git

所以是
git remote add origin https://farwill@bitbucket.org/farwill/testlink_converter.git
git push -u origin master