星期五, 4月 14, 2017

OBS with openSUSELeap42.2小記

OBS with openSUSE Leap 42.2 小記

OS: openSUSE Leap 42.2

先說結論, 目前沒有 OBS_Server 的 Pattern 

  • 沒有辦法使用 #zypper  in  -t  pattern OBS_Server
  • 所以要研究如何就單一角色安裝



上面的 ISO 是 Leap 42.1 的 ISO, 考量到 Leap 42.1 的 life time 在2017/5 就到期, 所以嘗試使用 Leap42.2
參考上面的其他部屬方式 2017-04-14 00-24-26 的螢幕擷圖.png

上面有看到不同的 images 可以選擇

2017-04-14 00-25-39 的螢幕擷圖.png

下次要來試試看 VMware Image 方式

繼續往下看
openSUSE Leap 42.1 的安裝方式

#zypper  ar   -f   http://download.opensuse.org/repositories/OBS:/Server:/2.8/openSUSE_42.1/OBS:Server:2.8.repo
#zypper  in  -t  pattern   OBS_Server

從網頁看一下是否有 Leap 42.2 的路徑, 果然就找到了

另外參考他裏面提到的 README
If you already have a Linux server running you can use our binary packages to install OBS and follow our README to set everything up yourself.


另外又有提到如果是進階設定, 例如分散式設定可以參考

看來要好好用功了 :)

開始嘗試安裝

首先新增套件庫


正在新增套件庫 '2.8 version of the Open Build Service Server (openSUSE_42.2)' ............................................................[完成]
已成功新增套件庫 '2.8 version of the Open Build Service Server (openSUSE_42.2)'

位址         : http://download.opensuse.org/repositories/OBS:/Server:/2.8/openSUSE_42.2/
已啟用       : 是                                                                       
GPG 檢查     : 是                                                                       
自動重新整理 : 是                                                                       
優先權       : 99 (default priority)                                                    

Repository priorities are without effect. All enabled repositories share the same priority.


確認是否安裝了套件庫

# zypper  lr
Repository priorities are without effect. All enabled repositories share the same priority.

#  | 別名                      | 名稱                                                         | 已啟用 | GPG 檢查 | 重新整理
---+---------------------------+--------------------------------------------------------------+--------+----------+---------
1 | OBS_Server_2.8            | 2.8 version of the Open Build Service Server (openSUSE_42.2) | 是     | ( p) 是  | 是    

安裝相關套件

# zypper  in  -t  pattern   OBS_Server
正在取出套件庫 '2.8 version of the Open Build Service Server (openSUSE_42.2)' 中繼資料 ------------------------------------------------------[|]

收到新的套件庫或套件簽署金鑰:

 套件庫:        2.8 version of the Open Build Service Server (openSUSE_42.2)
 金鑰名稱:      OBS OBS Project <OBS@build.opensuse.org>                    
 金鑰指紋:      660FD3F9 F16602A3 722ABF6D E8420AB8 C5C219E7                
 金鑰建立日期:  西元2015年04月21日 (週二) 21時59分15秒                      
 金鑰過期日期:  西元2017年06月29日 (週四) 21時59分15秒 (在 76 天內過期)     
 RPM 名稱:      gpg-pubkey-c5c219e7-553657b3                                


您想要拒絕此金鑰,暫時信任,或永遠信任? [r/t/a/? 顯示所有選項] (r): a

安裝失敗, 因為Leap 42.2 沒有  OBS_Server 的 pattern


可能真的要嘗試其他方式

VMware VMDK 檔案

整合ISO with Leap 42.1


Reference:

星期二, 1月 31, 2017

20170131 python Python程式設計實務_練習小記

20170131_python_Python程式設計實務_練習小記

Github:

Client: openSUSE Leap 42.2 with vi and PyCharm

今天接觸 os, shutil 以及 glob 模組
覺得接觸不同模組來練習, 感覺還不錯, 另外也更新心智圖 :)

練習相關檔案

檔案: 5-2.py

# -*- coding: utf-8 -*-
# 因為是學習 python, 所以用了很多 print() 來觀察
import os, shutil, glob
source_dir = "images/"
# 透過 os 模組來取得 / 目錄相關狀態
disk = os.statvfs("/")
print(disk)

# 目前可用空間計算
freespace = disk.f_bsize * disk.f_blocks
print(freespace)

# 透過 glob 模組來取得目前檔案, 以 list 型態存放
pngfiles = glob.glob(source_dir+"*.png")
jpgfiles = glob.glob(source_dir+"*.jpg")
giffiles = glob.glob(source_dir+"*.gif")
allfiles = pngfiles + jpgfiles + giffiles
print(allfiles)

allfilesize = 0
# allfilesize 型態是 int, 所以用 str轉型來顯示
print("allfilesize:  " + str(allfilesize))

# 使用 for 來計算目前檔案大小
for f in allfiles:
   allfilesize += os.path.getsize(f)
print("allfilesize:  " + str(allfilesize))

# 如果所有檔案大小 > 目前可用空間 顯示空間不足, 離開程式
if allfilesize > freespace:
   print("磁碟空間不足")
   exit(1)

# 設定輸出資料夾, 預設在該目錄下的 output
target_dir = source_dir + "output"
print("target_dir:  " + target_dir)

# 檢查 target_dir 是否存在, 存在就離開
if os.path.exists(target_dir):
   print("資料夾已存在")
   exit(1)

# 建立  target_dir
os.mkdir(target_dir)
imageno = 0

for f in allfiles:
   # split() 將字串根據指定字元切成 list
   # 這邊最主要要取出檔案名稱 filename
   print("---- loop start ----")
   dirname, filename = f.split('/')
   print(dirname)
   print(filename)
   # 使用 split() 切出檔案名稱還有副檔名
   mainname, extname = filename.split('.')
   print(mainname)
   print(extname)
   # 定義輸出的檔案名稱在 target_dir 下, 以 imageno 為序號加副檔名
   targetfile = target_dir + '/' + str(imageno) + '.' + extname
   print(targetfile)
   # 使用 shutil 複製檔案
   shutil.copyfile(f, targetfile)
   # 將 imageno 加1
   imageno += 1
   print("---- loop end ----")



~ enjoy it

星期一, 1月 30, 2017

Jupyterhub with openSUSE Leap 42.2 小記

Jupyterhub with openSUSE Leap 42.2 小記

之前的 jupyterhub 由於工作的關係,使用OS是配合 iCAIR 使用 CentOS 以及 ubuntu 版本
今天來建立openSUSE Leap 42.2 的 jupyterhub

OS: openSUSE Leap 42.2

測試安裝 jupyterhub 與 ansible 並容器化

安裝相關套件
# zypper  -n  install   python3  npm4  wget  unzip

# npm  install  -g   configurable-http-proxy

# zypper  -n  install  python3-pip

# pip3   install   jupyterhub   jupyter

# zypper   -n   install   python3-paramiko   python3-matplotlib   python3-numpy

# zypper  -n   install  ansible

使用 jupyterhub 指令執行
#jupyterhub

這樣就會在本機的 :8000 執行

為了以後方便執行, 接下來將 jupyterhub 容器化

# Jupyterhub / Ansible on openSUSE Leap 42.2
FROM opensuse:42.2
# Author
MAINTAINER Max Huang <sakana@cycu.org.tw>

# Install Python and pre-requisite packages
RUN \
 zypper -n  install \
  python3 \
  python3-pip \
  python3-paramiko \
  python3-matplotlib \
  python3-numpy \
  wget \
  npm4 \
  unzip

# run npm configurable-http-proxy
RUN npm install -g configurable-http-proxy

# Install Jupyterhub
RUN pip3  install --upgrade pip
RUN pip3  install  jupyter jupyterhub

# Install Ansible
RUN zypper -n install ansible

#expose ports
EXPOSE 8000

# create user
RUN useradd -m ansible && echo "ansible:2016StudyArea"|chpasswd

# Get playbook
RUN wget https://github.com/sakanamax/LearnJupyter/archive/master.zip -O /home/ansible/master.zip
RUN su - ansible -c "unzip master.zip"


# Define default command.
CMD ["jupyterhub"]

建立 docker image 並上傳到 dockerhub

下載方式

# docker  pull  sakana/jupyterhub

使用方式
# docker  run  -d  -p 8000:8000  sakana/jupyterhub

就會在本機的 port 8000 啟動 jupyterhub
帳號: ansible
密碼: 2016StudyArea

先記下來

~ enjoy it



星期日, 1月 29, 2017

20170129_python_Python程式設計實務_練習小記

20170129_python_Python程式設計實務_練習小記
Github:
Client: openSUSE Leap 42.2 with vi and PyCharm
昨天練習相關檔案
檔案: 2-3.py
# 匯入 requests
import requests
# 透過 requests.get 去抓 民視的網頁
www = requests.get( "http://m.ftv.com.tw/newslist.aspx?class=L" )
# 如果使用 print( www ) 會得到 網頁回覆, 例如 200
# 所以如果要列出網頁內容使用書上的 print( www.text )
print( www )
print( "=========================================" )
print( www.text )
檔案: 3-1.py
a, b = 2, 3
# 列出 a 以及 b
print( a, b)
# 將 a 與 b 交換
a, b = b, a
print( a, b)
檔案: 3-2.py
# 書上的作法是 a = range(5), 他其實是要列出 list 0 到 4
# 這個時候 print( a ) 在 python 3, 會出現 range(0, 5)
# 所以 python3 內的寫法, 如果要使用 a = range(5)來列出 list 0 - 4, 應該是 print( list(a) )
# 所以將程式碼改為
# 註解寫了中文在 python 好像就會產生 error, 先無視他吧
a = list( range(4) )
#print( a )
#print( list(a) )
# 同理可證 b
b = list( range(10, 15) )
# 不然 c = a + b 在 python 3 就會出現錯誤
c = a + b
print( "List a", a )
print( "List b", b )
print( "List a + List b", c )
Chapter 4
確認是否有安裝相關模組
主要練習為 python 3 版本
# zypper   search  numPy
Loading repository data...
Reading installed packages...
S | Name                     | Summary                              | Type      
--+--------------------------+--------------------------------------+-----------
 | python-numpy             | NumPy array processing for numbers-> | srcpackage
i | python-numpy             | NumPy array processing for numbers-> | package   
 | python3-numpy            | NumPy array processing for numbers-> | package   
# zypper   search   python3-matplo
Loading repository data...
Reading installed packages...
S | Name                         | Summary                                                 | Type   
--+------------------------------+---------------------------------------------------------+--------
 | python3-matplotlib           | Plotting Library for Python                             | package
預設沒有安裝 python3 的 numpy 以及 matplotlib 模組
安裝相關模組
# zypper   install   python3-matplotlib   python3-numpy
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 16 NEW packages are going to be installed:
 libwebpmux1 python-Cycler python-Pillow python-functools32 python-matplotlib python-matplotlib-tk python-pyparsing
 python-python-dateutil python-pytz python-tk python3-dateutil python3-matplotlib python3-numpy python3-pyparsing
 python3-pytz python3-six
The following 2 recommended packages were automatically selected:
 python-Pillow python-matplotlib-tk
16 new packages to install.
Overall download size: 79.1 MiB. Already cached: 0 B. After the operation, additional 154.7 MiB will be used.
Continue? [y/n/? shows all options] (y): Y
檔案: 4-1.py
# -*- coding: utf-8 -*-
# 目前沒有成功, 圖形介面沒有顯示, 後續再來研究
import numpy as np
import matplotlib.pyplot as pt
x = np.arange(0, 360)
y = np.sin(x * np.pi / 180.0)
pt.plot(x, y)
pt.xlim(0, 360)
pt.ylim(-1.2, 1.2)
pt.title("SIN function")
pt.show()
今天先這樣
~ enjoy it