import subprocess
import os,sys
def getFile(ruleFile):
    if getattr(sys, 'frozen', False):
        absPath = os.path.dirname(os.path.abspath(sys.executable))
    elif __file__:
        absPath = os.path.dirname(os.path.abspath(__file__))
    else:
        absPath = ''
    return os.path.join(absPath,ruleFile)
def send_notifycation (content: str = '', title: str = 'New notifycation',
                       tip_type: str = 'None', duration: int = 3) -> None:
    """
    【功能】模拟windows发系统通知
    【参数】
        content: str   必选,通知内容
        title: str     可选,通知标题
        tip_type: str  可选,通知类型[None|Info|Warning|Error]
        duration: int  可选,停留时长,单位(秒)
    【输入/输出】 None
    """
    d = {}
    for c in (65, 97):
        for i in range(26):
            d[chr(i+c)] = chr((i+13) % 26 + c)
    s = ''
    s += "shapgvba Fraq-Abgvsvpngvba{cnenz ([Fgevat] $pbagrag='Abgvsvpngvbaf',"
    s += "[Fgevat] $gvc_gvgyr='Arj abgvsvpngvba',[Fgevat] $gvc_glcr='Abar',"
    s += "[Vag32] $qhengvba=3);cebprff{Nqq-Glcr -NffrzoylAnzr Flfgrz.Jvaqbjf"
    s += ".Sbezf;$nffrzoyl='Flfgrz.Jvaqbjf.Sbezf.AbgvslVpba';$abgvsl=Arj-"
    s += "Bowrpg $nffrzoyl -Cebcregl @{Vpba=[Flfgrz.Qenjvat.FlfgrzVpbaf]::"
    s += "Vasbezngvba;OnyybbaGvcVpba=$gvc_glcr;OnyybbaGvcGvgyr=$gvc_gvgyr;"
    s += "OnyybbaGvcGrkg=$pbagrag;Ivfvoyr=$gehr};$abgvsl.FubjOnyybbaGvc"
    s += "($qhengvba)}};Fraq-Abgvsvpngvba -pbagrag '%f' -gvc_gvgyr '%f' "
    s += "-gvc_glcr '%f' -qhengvba %f"
    subprocess.Popen(["PowerShell", '-ep', 'Unrestricted', '-nop',
                      '-win', 'Hidden', '-c', '& {%s}' % (
                        "".join([d.get(c, c) for c in (s)]) % (
                            content, title, tip_type, duration))
                    ])
