Python sys 模块,_MEIPASS 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用sys._MEIPASS

项目:Crypter    作者:sithis993    | 项目源码 | 文件源码
def start_gui(self):
    '''
    @summary: Initialises and launches the ransomware GUI screen
    '''

    # Get Crypter start_time
    start_time = self.get_start_time()

    app = wx.App()
    # TODO Update this to new path and place in __init__
    #sys._MEIPASS = "..\\build\\images"
    crypter_gui = Gui.Gui(
        image_path=sys._MEIPASS, 
        start_time=start_time,
        decrypter=self,
        config=self.__config)

    crypter_gui.Show()
    app.MainLoop()
项目:GAMADV-XTD    作者:taers232c    | 项目源码 | 文件源码
def readDiscoveryFile(api_version):
  disc_filename = u'%s.json' % (api_version)
  disc_file = os.path.join(GM.Globals[GM.GAM_PATH], disc_filename)
  if hasattr(sys, u'_MEIPASS'):
    pyinstaller_disc_file = os.path.join(sys._MEIPASS, disc_filename)
  else:
    pyinstaller_disc_file = None
  if os.path.isfile(disc_file):
    json_string = readFile(disc_file, continueOnError=True, displayError=True)
  elif pyinstaller_disc_file:
    json_string = readFile(pyinstaller_disc_file, continueOnError=True, displayError=True)
  else:
    json_string = None
  if not json_string:
    invalidDiscoveryJsonExit(disc_file)
  try:
    discovery = json.loads(json_string)
    return (disc_file, discovery)
  except ValueError:
    invalidDiscoveryJsonExit(disc_file)
项目:GAMADV-XTD    作者:taers232c    | 项目源码 | 文件源码
def initGDataObject(gdataObj, api):
  if hasattr(sys, u'_MEIPASS') and not GM.Globals[GM.CACERTS_TXT]:
    GM.Globals[GM.CACERTS_TXT] = os.path.join(sys._MEIPASS, u'httplib2', u'cacerts.txt')
    os.environ['REQUESTS_CA_BUNDLE'] = GM.Globals[GM.CACERTS_TXT]
    os.environ['DEFAULT_CA_BUNDLE_PATH'] = GM.Globals[GM.CACERTS_TXT]
  _, _, api_version, cred_family = API.getVersion(api)
  disc_file, discovery = readDiscoveryFile(api_version)
  GM.Globals[GM.CURRENT_API_USER] = None
  credentials = getClientCredentials(cred_family)
  try:
    GM.Globals[GM.CURRENT_API_SCOPES] = list(set(list(discovery[u'auth'][u'oauth2'][u'scopes'])).intersection(credentials.scopes))
  except KeyError:
    invalidDiscoveryJsonExit(disc_file)
  if not GM.Globals[GM.CURRENT_API_SCOPES]:
    systemErrorExit(NO_SCOPES_FOR_API_RC, Msg.NO_SCOPES_FOR_API.format(discovery.get(u'title', api_version)))
  getGDataOAuthToken(gdataObj, credentials)
  if GC.Values[GC.DEBUG_LEVEL] > 0:
    gdataObj.debug = True
  return gdataObj
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def run():
    app = QtWidgets.QApplication(sys.argv)

    # Translates standard-buttons (Ok, Cancel) and mac menu bar to german
    try:
        base_path = sys._MEIPASS
    except Exception:
        base_path = os.path.abspath(".")
    path = os.path.join(base_path, 'bin', 'qtbase_de.qm')
    translator = QtCore.QTranslator()
    translator.load(path)
    app.installTranslator(translator)

    window = MainWindow()
    window.show()
    app.exec_()
项目:Python_Study    作者:thsheep    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
            if hasattr(sys, 'frozen'):
                # We have to set original _MEIPASS2 value from sys._MEIPASS
                # to get --onefile mode working.
                os.putenv('_MEIPASS2', sys._MEIPASS)
            try:
                super(_Popen, self).__init__(*args, **kw)
            finally:
                if hasattr(sys, 'frozen'):
                    # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                    # available. In those cases we cannot delete the variable
                    # but only set it to the empty string. The bootloader
                    # can handle this case.
                    if hasattr(os, 'unsetenv'):
                        os.unsetenv('_MEIPASS2')
                    else:
                        os.putenv('_MEIPASS2', '')

    # Second override 'Popen' class with our modified version.
项目:TTPassGen    作者:tp7309    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
            if hasattr(sys, 'frozen'):
                # We have to set original _MEIPASS2 value from sys._MEIPASS
                # to get --onefile mode working.
                os.putenv('_MEIPASS2', sys._MEIPASS)
            try:
                super(_Popen, self).__init__(*args, **kw)
            finally:
                if hasattr(sys, 'frozen'):
                    # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                    # available. In those cases we cannot delete the variable
                    # but only set it to the empty string. The bootloader
                    # can handle this case.
                    if hasattr(os, 'unsetenv'):
                        os.unsetenv('_MEIPASS2')
                    else:
                        os.putenv('_MEIPASS2', '')

    # Second override 'Popen' class with our modified version.
项目:driveboardapp    作者:nortd    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
            if hasattr(sys, 'frozen'):
                # We have to set original _MEIPASS2 value from sys._MEIPASS
                # to get --onefile mode working.
                os.putenv('_MEIPASS2', sys._MEIPASS)
            try:
                super(_Popen, self).__init__(*args, **kw)
            finally:
                if hasattr(sys, 'frozen'):
                    # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                    # available. In those cases we cannot delete the variable
                    # but only set it to the empty string. The bootloader
                    # can handle this case.
                    if hasattr(os, 'unsetenv'):
                        os.unsetenv('_MEIPASS2')
                    else:
                        os.putenv('_MEIPASS2', '')

    # Second override 'Popen' class with our modified version.
项目:driveboardapp    作者:nortd    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
        if hasattr(sys, 'frozen'):
            # We have to set original _MEIPASS2 value from sys._MEIPASS
            # to get --onefile mode working.
            # Last character is stripped in C-loader. We have to add
            # '/' or '\\' at the end.
            os.putenv('_MEIPASS2', sys._MEIPASS + os.sep)
        try:
            super(_Popen, self).__init__(*args, **kw)
        finally:
            if hasattr(sys, 'frozen'):
                # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                # available. In those cases we cannot delete the variable
                # but only set it to the empty string. The bootloader
                # can handle this case.
                if hasattr(os, 'unsetenv'):
                    os.unsetenv('_MEIPASS2')
                else:
                    os.putenv('_MEIPASS2', '')
项目:driveboardapp    作者:nortd    | 项目源码 | 文件源码
def main():
    # This is required so that app.quit can be invoked when the quickview
    # is closed. If it is not present then the app does not exit. It is 
    # possibly a bug in PyQt or Qt.
    global app 

    app = QtWidgets.QApplication(sys.argv)
    quickview = QtQuick.QQuickView()
    if getattr(sys, 'frozen', None):
        basedir = sys._MEIPASS
    else:
        basedir = os.path.dirname(__file__)

    # The app dir is in the default import path but we can't put the QtQuick
    # import lib dirs there because of a name clash (on OSX) with the QtQuick
    # dll.
    print(("Qt5 Qml import paths: " \
                + unicode(quickview.engine().importPathList())))
    quickview.setSource(QtCore.QUrl('qrc:/hello.qml'))
    quickview.engine().quit.connect(app.quit)
    quickview.show()

    app.exec_()
项目:PancakeViewer    作者:forensicmatt    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
            if hasattr(sys, 'frozen'):
                # We have to set original _MEIPASS2 value from sys._MEIPASS
                # to get --onefile mode working.
                os.putenv('_MEIPASS2', sys._MEIPASS)
            try:
                super(_Popen, self).__init__(*args, **kw)
            finally:
                if hasattr(sys, 'frozen'):
                    # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                    # available. In those cases we cannot delete the variable
                    # but only set it to the empty string. The bootloader
                    # can handle this case.
                    if hasattr(os, 'unsetenv'):
                        os.unsetenv('_MEIPASS2')
                    else:
                        os.putenv('_MEIPASS2', '')

    # Second override 'Popen' class with our modified version.
项目:cryptoluggage    作者:miguelinux314    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
        if hasattr(sys, 'frozen'):
            # We have to set original _MEIPASS2 value from sys._MEIPASS
            # to get --onefile mode working.
            os.putenv('_MEIPASS2', sys._MEIPASS)
        try:
            super(_Popen, self).__init__(*args, **kw)
        finally:
            if hasattr(sys, 'frozen'):
                # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                # available. In those cases we cannot delete the variable
                # but only set it to the empty string. The bootloader
                # can handle this case.
                if hasattr(os, 'unsetenv'):
                    os.unsetenv('_MEIPASS2')
                else:
                    os.putenv('_MEIPASS2', '')
项目:unist_bb_downloader    作者:kcm4482    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
            if hasattr(sys, 'frozen'):
                # We have to set original _MEIPASS2 value from sys._MEIPASS
                # to get --onefile mode working.
                os.putenv('_MEIPASS2', sys._MEIPASS)
            try:
                super(_Popen, self).__init__(*args, **kw)
            finally:
                if hasattr(sys, 'frozen'):
                    # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                    # available. In those cases we cannot delete the variable
                    # but only set it to the empty string. The bootloader
                    # can handle this case.
                    if hasattr(os, 'unsetenv'):
                        os.unsetenv('_MEIPASS2')
                    else:
                        os.putenv('_MEIPASS2', '')

    # Second override 'Popen' class with our modified version.
项目:MaruCrawler    作者:KiririnLover    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
            if hasattr(sys, 'frozen'):
                # We have to set original _MEIPASS2 value from sys._MEIPASS
                # to get --onefile mode working.
                os.putenv('_MEIPASS2', sys._MEIPASS)
            try:
                super(_Popen, self).__init__(*args, **kw)
            finally:
                if hasattr(sys, 'frozen'):
                    # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                    # available. In those cases we cannot delete the variable
                    # but only set it to the empty string. The bootloader
                    # can handle this case.
                    if hasattr(os, 'unsetenv'):
                        os.unsetenv('_MEIPASS2')
                    else:
                        os.putenv('_MEIPASS2', '')

    # Second override 'Popen' class with our modified version.
项目:EventMonkey    作者:devgc    | 项目源码 | 文件源码
def GetResource(frozen_loc,resource_loc,resource_name):
    ''' Get resource by location and name. This will compensate for frozen or not.

    args:
        frozen_loc: location of resource when frozen
        resource_loc: location of resource in package (not frozen)
        resource_name: name of the file
    returns:
        location: The abs location
    '''
    location = None

    if getattr(sys,'frozen',False):
        location = os.path.join(sys._MEIPASS,frozen_loc)
        location = os.path.join(location,resource_name)
        location = os.path.abspath(location)
    else:
        location = os.path.abspath(
            pkg_resources.resource_filename(
               resource_loc,
                resource_name
            )
        )

    return location
项目:EventMonkey    作者:devgc    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
            if hasattr(sys, 'frozen'):
                # We have to set original _MEIPASS2 value from sys._MEIPASS
                # to get --onefile mode working.
                os.putenv('_MEIPASS2', sys._MEIPASS)
            try:
                super(_Popen, self).__init__(*args, **kw)
            finally:
                if hasattr(sys, 'frozen'):
                    # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                    # available. In those cases we cannot delete the variable
                    # but only set it to the empty string. The bootloader
                    # can handle this case.
                    if hasattr(os, 'unsetenv'):
                        os.unsetenv('_MEIPASS2')
                    else:
                        os.putenv('_MEIPASS2', '')

    # Second override 'Popen' class with our modified version.
项目:GAMADV-X    作者:taers232c    | 项目源码 | 文件源码
def readDiscoveryFile(api_version):
  disc_filename = u'%s.json' % (api_version)
  disc_file = os.path.join(GM.Globals[GM.GAM_PATH], disc_filename)
  if hasattr(sys, u'_MEIPASS'):
    pyinstaller_disc_file = os.path.join(sys._MEIPASS, disc_filename)
  else:
    pyinstaller_disc_file = None
  if os.path.isfile(disc_file):
    json_string = readFile(disc_file, continueOnError=True, displayError=True)
  elif pyinstaller_disc_file:
    json_string = readFile(pyinstaller_disc_file, continueOnError=True, displayError=True)
  else:
    json_string = None
  if not json_string:
    invalidDiscoveryJsonExit(disc_file)
  try:
    discovery = json.loads(json_string)
    return (disc_file, discovery)
  except ValueError:
    invalidDiscoveryJsonExit(disc_file)
项目:GAMADV-X    作者:taers232c    | 项目源码 | 文件源码
def initGDataObject(gdataObj, api):
  if hasattr(sys, u'_MEIPASS') and not GM.Globals[GM.CACERTS_TXT]:
    GM.Globals[GM.CACERTS_TXT] = os.path.join(sys._MEIPASS, u'httplib2', u'cacerts.txt')
    os.environ['REQUESTS_CA_BUNDLE'] = GM.Globals[GM.CACERTS_TXT]
    os.environ['DEFAULT_CA_BUNDLE_PATH'] = GM.Globals[GM.CACERTS_TXT]
  _, _, api_version, cred_family = API.getVersion(api)
  disc_file, discovery = readDiscoveryFile(api_version)
  GM.Globals[GM.CURRENT_API_USER] = None
  credentials = getClientCredentials(cred_family)
  try:
    GM.Globals[GM.CURRENT_API_SCOPES] = list(set(list(discovery[u'auth'][u'oauth2'][u'scopes'])).intersection(credentials.scopes))
  except KeyError:
    invalidDiscoveryJsonExit(disc_file)
  if not GM.Globals[GM.CURRENT_API_SCOPES]:
    systemErrorExit(NO_SCOPES_FOR_API_RC, Msg.NO_SCOPES_FOR_API.format(discovery.get(u'title', api_version)))
  getGDataOAuthToken(gdataObj, credentials)
  if GC.Values[GC.DEBUG_LEVEL] > 0:
    gdataObj.debug = True
  return gdataObj
项目:nRF5-multi-prog    作者:NordicPlayground    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
            if hasattr(sys, 'frozen'):
                # We have to set original _MEIPASS2 value from sys._MEIPASS
                # to get --onefile mode working.
                os.putenv('_MEIPASS2', sys._MEIPASS)
            try:
                super(_Popen, self).__init__(*args, **kw)
            finally:
                if hasattr(sys, 'frozen'):
                    # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                    # available. In those cases we cannot delete the variable
                    # but only set it to the empty string. The bootloader
                    # can handle this case.
                    if hasattr(os, 'unsetenv'):
                        os.unsetenv('_MEIPASS2')
                    else:
                        os.putenv('_MEIPASS2', '')

    # Second override 'Popen' class with our modified version.
项目:stash-scanner    作者:senuido    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
            if hasattr(sys, 'frozen'):
                # We have to set original _MEIPASS2 value from sys._MEIPASS
                # to get --onefile mode working.
                os.putenv('_MEIPASS2', sys._MEIPASS)
            try:
                super(_Popen, self).__init__(*args, **kw)
            finally:
                if hasattr(sys, 'frozen'):
                    # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                    # available. In those cases we cannot delete the variable
                    # but only set it to the empty string. The bootloader
                    # can handle this case.
                    if hasattr(os, 'unsetenv'):
                        os.unsetenv('_MEIPASS2')
                    else:
                        os.putenv('_MEIPASS2', '')

    # Second override 'Popen' class with our modified version.
项目:Enhance-GoodReads-Export    作者:PaulKlinger    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
        if hasattr(sys, 'frozen'):
            # We have to set original _MEIPASS2 value from sys._MEIPASS
            # to get --onefile mode working.
            os.putenv('_MEIPASS2', sys._MEIPASS)
        try:
            super(_Popen, self).__init__(*args, **kw)
        finally:
            if hasattr(sys, 'frozen'):
                # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                # available. In those cases we cannot delete the variable
                # but only set it to the empty string. The bootloader
                # can handle this case.
                if hasattr(os, 'unsetenv'):
                    os.unsetenv('_MEIPASS2')
                else:
                    os.putenv('_MEIPASS2', '')


# Second override 'Popen' class with our modified version.
项目:mac-package-build    作者:persepolisdm    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
            if hasattr(sys, 'frozen'):
                # We have to set original _MEIPASS2 value from sys._MEIPASS
                # to get --onefile mode working.
                os.putenv('_MEIPASS2', sys._MEIPASS)
            try:
                super(_Popen, self).__init__(*args, **kw)
            finally:
                if hasattr(sys, 'frozen'):
                    # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                    # available. In those cases we cannot delete the variable
                    # but only set it to the empty string. The bootloader
                    # can handle this case.
                    if hasattr(os, 'unsetenv'):
                        os.unsetenv('_MEIPASS2')
                    else:
                        os.putenv('_MEIPASS2', '')

    # Second override 'Popen' class with our modified version.
项目:mac-package-build    作者:persepolisdm    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
        if hasattr(sys, 'frozen'):
            # We have to set original _MEIPASS2 value from sys._MEIPASS
            # to get --onefile mode working.
            # Last character is stripped in C-loader. We have to add
            # '/' or '\\' at the end.
            os.putenv('_MEIPASS2', sys._MEIPASS + os.sep)
        try:
            super(_Popen, self).__init__(*args, **kw)
        finally:
            if hasattr(sys, 'frozen'):
                # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                # available. In those cases we cannot delete the variable
                # but only set it to the empty string. The bootloader
                # can handle this case.
                if hasattr(os, 'unsetenv'):
                    os.unsetenv('_MEIPASS2')
                else:
                    os.putenv('_MEIPASS2', '')
项目:mac-package-build    作者:persepolisdm    | 项目源码 | 文件源码
def main():
    # This is required so that app.quit can be invoked when the quickview
    # is closed. If it is not present then the app does not exit. It is 
    # possibly a bug in PyQt or Qt.
    global app 

    app = QtWidgets.QApplication(sys.argv)
    quickview = QtQuick.QQuickView()
    if getattr(sys, 'frozen', None):
        basedir = sys._MEIPASS
    else:
        basedir = os.path.dirname(__file__)

    # The app dir is in the default import path but we can't put the QtQuick
    # import lib dirs there because of a name clash (on OSX) with the QtQuick
    # dll.
    print(("Qt5 Qml import paths: " \
                + unicode(quickview.engine().importPathList())))
    quickview.setSource(QtCore.QUrl('qrc:/hello.qml'))
    quickview.engine().quit.connect(app.quit)
    quickview.show()

    app.exec_()
项目:shadowsocks-pyqt    作者:falseen    | 项目源码 | 文件源码
def __init__(self, *args, **kw):
            if hasattr(sys, 'frozen'):
                # We have to set original _MEIPASS2 value from sys._MEIPASS
                # to get --onefile mode working.
                os.putenv('_MEIPASS2', sys._MEIPASS)
            try:
                super(_Popen, self).__init__(*args, **kw)
            finally:
                if hasattr(sys, 'frozen'):
                    # On some platforms (e.g. AIX) 'os.unsetenv()' is not
                    # available. In those cases we cannot delete the variable
                    # but only set it to the empty string. The bootloader
                    # can handle this case.
                    if hasattr(os, 'unsetenv'):
                        os.unsetenv('_MEIPASS2')
                    else:
                        os.putenv('_MEIPASS2', '')

    # Second override 'Popen' class with our modified version.
项目:IoTcube-HMark-cli    作者:squizz617    | 项目源码 | 文件源码
def get_version():
    global osName
    global bits

    pf = platform.platform()
    if 'Windows' in pf:
        osName = 'w'
    elif 'Linux' in pf:
        osName = 'l'
    else:
        osName = 'osx'

    bits, _ = platform.architecture()
    if '64' in bits:
        bits = '64'
    else:
        bits = '86'

    if osName == 'osx':
        bits = ''

# sys.path.append(sys._MEIPASS)
项目:IoTcube-HMark-cli    作者:squizz617    | 项目源码 | 文件源码
def setEnvironment(caller):
    get_version()
    global javaCallCommand
    if caller == "GUI":
        # try:
        #   base_path = sys._MEIPASS
        # except:
        #   base_path = os.path.abspath(".")
        cwd = os.getcwd()
        if osName == 'w':
            # full_path = os.path.join(base_path, "FuncParser.exe")
            javaCallCommand = os.path.join(cwd, "FuncParser-opt.exe ")

        elif osName == 'l' or osName == "osx":
            # full_path = os.path.join(base_path, "FuncParser.jar")
            # javaCallCommand = "java -Xmx1024m -jar " + full_path + " "
            javaCallCommand = "java -Xmx1024m -jar \"" + os.path.join(cwd, "FuncParser-opt.jar") + "\" "

    else:
        if osName == 'w':
            javaCallCommand = "FuncParser-opt.exe "
        elif osName == 'l' or osName == "osx":
            javaCallCommand = "java -Xmx1024m -jar \"FuncParser-opt.jar\" "
项目:TWTools    作者:ZeX2    | 项目源码 | 文件源码
def resource_path(relative_path):
    """ Get absolute path to resource, works for dev and for PyInstaller """
    if hasattr(sys, '_MEIPASS'):
        return path.join(sys._MEIPASS, relative_path)
    return path.join(path.abspath("."), relative_path)
项目:Fuxenpruefung    作者:andb0t    | 项目源码 | 文件源码
def resource_path(basePath, relativePath):
    """ Get absolute path to resource, works for dev and for PyInstaller """
    try:
        # PyInstaller creates a temp folder and stores path in _MEIPASS
        basePath = sys._MEIPASS
    except Exception:
        basePath = os.path.abspath(".")
    finalPath = os.path.join(basePath, relativePath)
    if sys.platform != 'win32':
        finalPath = finalPath.replace('\\', '/')
    return finalPath
项目:uPyLoader    作者:BetaRavener    | 项目源码 | 文件源码
def resource_path(relative_path):
        """ Get absolute path to resource, works for dev and for PyInstaller """
        try:
            # PyInstaller creates a temp folder and stores path in _MEIPASS
            base_path = sys._MEIPASS
        except Exception:
            base_path = os.path.abspath(".")

        return os.path.join(base_path, relative_path)
项目:3ds-to-cia    作者:drizzt    | 项目源码 | 文件源码
def get_tools_path():
    if getattr(sys, 'frozen', False):
        # we are running in a bundle
        bundle_dir = sys._MEIPASS
    else:
        # we are running in a normal Python environment
        bundle_dir = os.path.dirname(os.path.abspath(__file__))

    if sys.platform == "win32":
        return os.path.join(bundle_dir, "tools", "win" + BITS)
    elif sys.platform == "linux" or sys.platform == "linux2":
        return os.path.join(bundle_dir, "tools", "linux" + BITS)
项目:tvlinker    作者:ozmartian    | 项目源码 | 文件源码
def get_path(path: str = None, override: bool = False) -> str:
        if override:
            if getattr(sys, 'frozen', False):
                return os.path.join(sys._MEIPASS, path)
            return os.path.join(QFileInfo(__file__).absolutePath(), path)
        return ':assets/%s' % path
项目:tvlinker    作者:ozmartian    | 项目源码 | 文件源码
def get_path(path: str) -> str:
        prefix = sys._MEIPASS if getattr(sys, 'frozen', False) else QFileInfo(__file__).absolutePath()
        return os.path.join(prefix, path)
项目:csirtg-smrt-py    作者:csirtgadgets    | 项目源码 | 文件源码
def __init__(self, token=TOKEN, remote=REMOTE_ADDR, client='stdout', username=None, feed=None, archiver=None,
                 fireball=False, no_fetch=False, verify_ssl=True, goback=False, skip_invalid=False, send_retries=5,
                 send_retries_wait=30):

        self.logger = logging.getLogger(__name__)

        self.client = None
        if client != 'stdout':
            plugin_path = os.path.join(os.path.dirname(__file__), 'client')
            if getattr(sys, 'frozen', False):
                plugin_path = os.path.join(sys._MEIPASS, 'csirtg_smrt', 'client')

            self.client = load_plugin(plugin_path, client)

            if not self.client:
                raise RuntimeError("Unable to load plugin: {}".format(client))

            self.client = self.client(remote=remote, token=token, username=username, feed=feed, fireball=fireball,
                                      verify_ssl=verify_ssl)

        self.archiver = archiver or NOOPArchiver()
        self.fireball = fireball
        self.no_fetch = no_fetch
        self.goback = goback
        self.skip_invalid = skip_invalid
        self.verify_ssl = verify_ssl
        self.last_cache = None
        self.send_retries = send_retries
        self.send_retries_wait = send_retries_wait
项目:csirtg-smrt-py    作者:csirtgadgets    | 项目源码 | 文件源码
def load_parser(self, rule, feed, limit=None, data=None, filters=None):
        if isinstance(rule, str):
            rule = Rule(rule)

        fetch = Fetcher(rule, feed, data=data, no_fetch=self.no_fetch, verify_ssl=self.verify_ssl, limit=limit)
        self.last_cache = fetch.cache

        parser_name = rule.feeds[feed].get('parser') or rule.parser or PARSER_DEFAULT

        if not parser_name:
            from csirtg_smrt.utils.zcontent import get_type
            try:
                parser_name = get_type(self.last_cache)
            except Exception as e:
                logger.error(e)

        if not parser_name:
            parser_name = PARSER_DEFAULT

        plugin_path = os.path.join(os.path.dirname(__file__), 'parser')

        if getattr(sys, 'frozen', False):
            plugin_path = os.path.join(sys._MEIPASS, plugin_path)

        parser = load_plugin(plugin_path, parser_name)

        if parser is None:
            self.logger.info('trying z{}'.format(parser_name))
            parser = load_plugin(csirtg_smrt.parser.__path__[0], 'z{}'.format(parser_name))
            if parser is None:
                raise SystemError('Unable to load parser: {}'.format(parser_name))

        self.logger.debug("loading parser: {}".format(parser))

        return parser(self.client, fetch, rule, feed, limit=limit, filters=filters, fireball=self.fireball)
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def get_pathToTemp(self, relative_path, css=False):
        # relative_path is a List or Array
        # set css to True if used for .setStyleSheet so '/' is set as separator instead of '\\'
        try:
            base_path = sys._MEIPASS
        except Exception:
            base_path = os.path.abspath(".")

        if css and sys.platform == "win32":
            # Fixes "could not parse stylesheet of object ..." thrown by .setStyleSheet
            return os.path.join(base_path, *relative_path).replace("\\", "/")

        return os.path.join(base_path, *relative_path)
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def get_pathToTemp(self, relative_path):
        try:
            base_path = sys._MEIPASS
        except Exception:
            base_path = os.path.abspath(".")

        return os.path.join(base_path, relative_path)
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def get_pathToTemp(self, relative_path):
        try:
            base_path = sys._MEIPASS
        except Exception:
            base_path = os.path.abspath(".")

        return os.path.join(base_path, relative_path)
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def get_pathToTemp(self, relative_path):
        try:
            base_path = sys._MEIPASS
        except Exception:
            base_path = os.path.abspath(".")

        return os.path.join(base_path, relative_path)

    # def isFrozen(self):
    #     if getattr(sys, 'frozen', False):
    #         return True
    #     else:
    #         return False
项目:adblockradio    作者:quasoft    | 项目源码 | 文件源码
def resource_filename(filename):
    if is_frozen():
        path = os.path.join(sys._MEIPASS, filename)
    else:
        path = pkg_resources.resource_filename("adblockradio", filename)

    return path
项目:adblockradio    作者:quasoft    | 项目源码 | 文件源码
def set_gst_plugin_path():
    path = sys._MEIPASS + ";" + os.path.join(sys._MEIPASS, 'gst_plugins')
    os.environ["GST_PLUGIN_PATH"] = path
    os.environ["GST_PLUGIN_PATH_1_0"] = path
项目:nodemcu-pyflasher    作者:marcelstoer    | 项目源码 | 文件源码
def _get_bundle_dir(self):
        # set by PyInstaller, see http://pyinstaller.readthedocs.io/en/v3.2/runtime-information.html
        if getattr(sys, 'frozen', False):
            return sys._MEIPASS
        else:
            return os.path.dirname(os.path.abspath(__file__))
项目:SWProxy-plugins    作者:lstern    | 项目源码 | 文件源码
def resource_path(relative_path):
    # function to locate data files for pyinstaller single file executable
    # ref: http://stackoverflow.com/a/32048136
    if hasattr(sys, '_MEIPASS'):
        return os.path.join(sys._MEIPASS, relative_path)

    return os.path.join(os.path.abspath("."), relative_path)
项目:mdx-server    作者:ninja33    | 项目源码 | 文件源码
def get_definition_mdx(word, builder):
    """???????MDX?????"""
    content = builder.mdx_lookup(word)
    str_content = ""
    if len(content) > 0:
        for c in content:
            str_content += c.replace("\r\n","").replace("entry:/","")

    injection = []
    injection_html = ''
    output_html = ''

    try:
        # PyInstaller creates a temp folder and stores path in _MEIPASS
        # base_path = sys._MEIPASS
        base_path = os.path.dirname(sys.executable)
    except Exception:
        base_path = os.path.abspath(".")

    resource_path = os.path.join(base_path, 'mdx')

    file_util_get_files(resource_path, injection)

    for p in injection:
        if file_util_is_ext(p, 'html'):
            injection_html += file_util_read_text(p)

    #return [bytes(str_content, encoding='utf-8')]
    output_html = str_content
    return [output_html.encode('utf-8')]
项目:device-updater    作者:spark    | 项目源码 | 文件源码
def setup_working_dir():
    # This is needed to set the current working folder when extracting from a single executable
    if hasattr(sys, '_MEIPASS'):
        p = os.path.join(sys._MEIPASS)
        os.chdir(p)
        print("changed folder to "+p)
项目:Comictagger    作者:dickloraine    | 项目源码 | 文件源码
def baseDir():
        if getattr(sys, 'frozen', None):
            if platform.system() == "Darwin":
                return sys._MEIPASS
            else: # Windows
                #Preserve this value, in case sys.argv gets changed importing a plugin script
                if ComicTaggerSettings.frozen_win_exe_path is None:
                    ComicTaggerSettings.frozen_win_exe_path = os.path.dirname( os.path.abspath( sys.argv[0] ) )
                return ComicTaggerSettings.frozen_win_exe_path
        else:
            return os.path.dirname( os.path.abspath( __file__) )
项目:mail.ru-uploader    作者:instefa    | 项目源码 | 文件源码
def resource_path(relative_path):
    """ Get absolute path to resource (source or frozen) """
    if hasattr(sys, '_MEIPASS'):
        return os.path.join(sys._MEIPASS, relative_path)

    return os.path.join(os.path.abspath('.'), relative_path)
项目:bitencrypt    作者:OriginalMy    | 项目源码 | 文件源码
def loadOpenSSL():
    global OpenSSL
    from os import path, environ
    from ctypes.util import find_library

    libdir = []
    if getattr(sys,'frozen', None):
        if 'darwin' in sys.platform:
            libdir.extend([
                path.join(environ['RESOURCEPATH'], '..', 'Frameworks','libcrypto.dylib'),
                path.join(environ['RESOURCEPATH'], '..', 'Frameworks','libcrypto.1.0.0.dylib')
                ])
        elif 'win32' in sys.platform or 'win64' in sys.platform:
            libdir.append(path.join(sys._MEIPASS, 'libeay32.dll'))
        else:
            libdir.extend([
                path.join(sys._MEIPASS, 'libcrypto.so'),
                path.join(sys._MEIPASS, 'libssl.so'),
                path.join(sys._MEIPASS, 'libcrypto.so.1.0.0'),
                path.join(sys._MEIPASS, 'libssl.so.1.0.0'),
            ])
    if 'darwin' in sys.platform:
        libdir.extend(['libcrypto.dylib', '/usr/local/opt/openssl/lib/libcrypto.dylib'])
    elif 'win32' in sys.platform or 'win64' in sys.platform:
        libdir.append('libeay32.dll')
    else:
        libdir.append('libcrypto.so')
        libdir.append('libssl.so')
    if 'linux' in sys.platform or 'darwin' in sys.platform or 'freebsd' in sys.platform:
        libdir.append(find_library('ssl'))
    elif 'win32' in sys.platform or 'win64' in sys.platform:
        libdir.append(find_library('libeay32'))
    for library in libdir:
        try:
            OpenSSL = _OpenSSL(library)
            return
        except:
            pass
    raise Exception("Couldn't find and load the OpenSSL library. You must install it.")
项目:bitmask-dev    作者:leapcode    | 项目源码 | 文件源码
def start_pixelated_user_agent(userid, soledad, keymanager, account):

    try:
        leap_session = LeapSessionAdapter(
            userid, soledad, keymanager, account)
    except Exception as exc:
        log.error("Got error! %r" % exc)

    config = Config()
    leap_home = os.path.join(get_path_prefix(), 'leap')
    config.leap_home = leap_home
    leap_session.config = config

    services_factory = SingleUserServicesFactory(
        UserAgentMode(is_single_user=True))

    if getattr(sys, 'frozen', False):
        # we are running in a |PyInstaller| bundle
        static_folder = os.path.join(sys._MEIPASS, 'leap', 'pixelated_www')
    else:
        static_folder = os.path.abspath(leap.pixelated_www.__path__[0])

    set_static_folder(static_folder)
    resource = RootResource(services_factory, static_folder=static_folder)

    config.host = 'localhost'
    config.port = 9090
    config.sslkey = None
    config.sslcert = None
    config.manhole = False

    d = leap_session.account.callWhenReady(
        lambda _: _start_in_single_user_mode(
            leap_session, config,
            resource, services_factory))
    return d
项目:bitmask-dev    作者:leapcode    | 项目源码 | 文件源码
def here(module=None):
    if STANDALONE:
        # we are running in a |PyInstaller| bundle
        return sys._MEIPASS
    else:
        if module:
            return dirname(module.__file__)
        else:
            return dirname(__file__)
项目:bitmask-dev    作者:leapcode    | 项目源码 | 文件源码
def here(module=None):
    global STANDALONE

    if STANDALONE:
        # we are running in a |PyInstaller| bundle
        return sys._MEIPASS
    else:
        dirname = os.path.dirname
        if module:
            return dirname(module.__file__)
        else:
            return dirname(__file__)