Esempio n. 1
0
def modulePath():
    """
    This will get us the program's directory, even if we are frozen
    using py2exe
    """

    return os.path.dirname(getUnicode(sys.executable if weAreFrozen() else __file__, sys.getfilesystemencoding()))
Esempio n. 2
0
def modulePath():
    """
    This will get us the program's directory, even if we are frozen
    using py2exe
    """

    try:
        _ = sys.executable if weAreFrozen() else __file__
    except NameError:
        _ = inspect.getsourcefile(modulePath)

    return getUnicode(os.path.dirname(os.path.realpath(_)), encoding=sys.getfilesystemencoding())
Esempio n. 3
0
def modulePath():
    """
    This will get us the program's directory, even if we are frozen
    using py2exe
    """

    try:
        _ = sys.executable if weAreFrozen() else __file__
    except NameError:
        _ = inspect.getsourcefile(modulePath)

    return getUnicode(os.path.dirname(os.path.realpath(_)),
                      encoding=sys.getfilesystemencoding() or UNICODE_ENCODING)
Esempio n. 4
0
def modulePath():  # 当打包的时候获取路径
    """
    This will get us the program's directory, even if we are frozen
    using py2exe
    """

    try:
        # weAreFrozen返回是否使用py2exe进行打包
        _ = sys.executable if weAreFrozen(
        ) else __file__  # sys.executable  python可执行文件路径  __file__文件当前路径
    except NameError:
        _ = inspect.getsourcefile(modulePath)  # 返回object的python源文件名

    # 进行编码
    return getUnicode(os.path.dirname(os.path.realpath(_)),
                      encoding=sys.getfilesystemencoding() or UNICODE_ENCODING)
Esempio n. 5
0
def modulePath():
    """
    返回sqlmap.py程序的路径
    首先判断weAreFrozen()是否为真
    如果weAreFrozen()为真说明sqlmap被py2exe打包成了exe可执行程序
    sys.executable返回Python可执行文件路径
    否则就是当前文件名也就是sqlmap.py
    """

    try:
        _ = sys.executable if weAreFrozen(
        ) else __file__  # 'D:/Python27/sqlmap/sqlmap.py'
    except NameError:
        _ = inspect.getsourcefile(modulePath)

    return getUnicode(os.path.dirname(os.path.realpath(_)),
                      encoding=sys.getfilesystemencoding() or UNICODE_ENCODING)