2015年8月25日 星期二

How to pack the python source code with data files into one file by Pyinstaller

In your source code, add the res_path(cpath) function as follows:

:fwi.py
def res_path(cpath):
    try:
        base_path = sys._MEIPASS
    except Exception:
        base_path = os.path.abspath(".")
    return os.path.join(base_path,cpath)

[unpack mode]
res_path("app")   => Show the current path with app program 
ex. /opt/app

[After pack]
res_path("app")   => show the _MEIPASS folder path with app program
ex. /tmp/_MEIPASS/app

PS: You must used res_path function with fulled path in your python code. If you want to pack your python code.

Add your data files into fwi.spec files
:fwi.spec 
+ a.datas = [('smartctl','./source/smartctl','DATA'),('hdparm','./source/hdparm','DATA')]

Pack by pyinstaller:
python pyinstaller.py --onefile fwi.spec

2015年7月11日 星期六

Return value from function in shell script -- bash

Note the method to get the return value from function in shell script (bash)

#!/bin/bash 
#function 
func()
{
     num=100
     echo ${num}
}

# main 
res=$(func)    # Execute the function -- func and then get the return value


How to pass your CEH v11 exam quickly ?

1. You must buy the old CEH v11 exam under the online shopping platform. such as shopee. Select the 1st SEO buyer.  2. Create the practice t...