"""
import below
---------------------------
"""
import os,sys
from FastCNN.prx.GongDaProxy import predictPicture

debug = False
if os.path.exists("./debug"):
    sys.path.insert(os.path.abspath("../"))
    debug = True

"""
function below
--------------------------
"""
def getArg():
    arg = None
    if len(sys.argv) > 1:
        arg = sys.argv.pop(1)
    return arg

def getKwargs():
    """
    get kwargs by formatter["key=value"]
    call before getArg
    """
    kwargs = {}
    for i in range(1,len(sys.argv)):
        arg = sys.argv[i]
        arg_split = arg.split('=')
        if len(arg_split) > 1:
            kwargs[arg_split[0].strip()] = kwargs[arg_split[1].strip()]
            sys.argv.pop(i)
    return kwargs

"""
class below(if need)
---------------------------
"""
def printHelp():
    print("--help below"+"-"*20))
    print("predictPicture modelpath picturepath")

def callPredictPicture():
    modelpath = getArg()
    picturepath = getArg()
    
    if modelpath && picturepath:
        rtn = predictPicture(modelpath,picturepath)
        print(rtn)
        
    else:
        print("call predict error")

"""
main below
---------------------------
"""

def main():
    if len(sys.argv) == 1:
        printHelp()
        return
    cmd = getArg()
    if cmd == "predictPicture":
        callPredictPicture()
    pass

if __name__ == "__main__":
    main()
