Python sys._MEIPASS() Examples

The following are code examples for showing how to use sys._MEIPASS(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: Crypter   Author: sithis993   File: Main.py    (license) View Source Project 9 votes vote down vote up
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() 
Example 2
Project: GAMADV-XTD   Author: taers232c   File: gam.py    (license) View Source Project 6 votes vote down vote up
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) 
Example 3
Project: GAMADV-XTD   Author: taers232c   File: gam.py    (license) View Source Project 6 votes vote down vote up
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 
Example 4
Project: FuME   Author: fupadev   File: app.py    (license) View Source Project 6 votes vote down vote up
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_() 
Example 5
Project: Python_Study   Author: thsheep   File: pyinstaller?????.py    (license) View Source Project 6 votes vote down vote up
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. 
Example 6
Project: TTPassGen   Author: tp7309   File: ttpassgen.py    (license) View Source Project 6 votes vote down vote up
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. 
Example 7
Project: driveboardapp   Author: nortd   File: pyi_multiprocess_pool.py    (license) View Source Project 6 votes vote down vote up
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. 
Example 8
Project: driveboardapp   Author: nortd   File: pyi_multiprocess_forking.py    (license) View Source Project 6 votes vote down vote up
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', '') 
Example 9
Project: driveboardapp   Author: nortd   File: test_pyqt5_qml.py    (license) View Source Project 6 votes vote down vote up
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_() 
Example 10
Project: PancakeViewer   Author: forensicmatt   File: pancakeViewerApp.py    (license) View Source Project 6 votes vote down vote up
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. 
Example 11
Project: cryptoluggage   Author: miguelinux314   File: pypdfocr_multiprocessing.py    (license) View Source Project 6 votes vote down vote up
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', '') 
Example 12
Project: unist_bb_downloader   Author: kcm4482   File: bb_downloader_func.py    (license) View Source Project 6 votes vote down vote up
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. 
Example 13
Project: MaruCrawler   Author: KiririnLover   File: MaruCrawler.py    (license) View Source Project 6 votes vote down vote up
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. 
Example 14
Project: EventMonkey   Author: devgc   File: Utilities.py    (license) View Source Project 6 votes vote down vote up
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 
Example 15
Project: EventMonkey   Author: devgc   File: EventMonkey.py    (license) View Source Project 6 votes vote down vote up
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. 
Example 16
Project: GAMADV-X   Author: taers232c   File: gam.py    (license) View Source Project 6 votes vote down vote up
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) 
Example 17
Project: GAMADV-X   Author: taers232c   File: gam.py    (license) View Source Project 6 votes vote down vote up
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 
Example 18
Project: nRF5-multi-prog   Author: NordicPlayground   File: nrf5_multi_prog.py    (license) View Source Project 6 votes vote down vote up
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. 
Example 19
Project: stash-scanner   Author: senuido   File: StashHelper.py    (license) View Source Project 6 votes vote down vote up
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. 
Example 20
Project: Enhance-GoodReads-Export   Author: PaulKlinger   File: enhance_goodreads_export_gui.py    (license) View Source Project 6 votes vote down vote up
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. 
Example 21
Project: mac-package-build   Author: persepolisdm   File: pyi_multiprocess_pool.py    (license) View Source Project 6 votes vote down vote up
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. 
Example 22
Project: mac-package-build   Author: persepolisdm   File: pyi_multiprocess_forking.py    (license) View Source Project 6 votes vote down vote up
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', '') 
Example 23
Project: mac-package-build   Author: persepolisdm   File: test_pyqt5_qml.py    (license) View Source Project 6 votes vote down vote up
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_() 
Example 24
Project: shadowsocks-pyqt   Author: falseen   File: main.py    (license) View Source Project 6 votes vote down vote up
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. 
Example 25
Project: IoTcube-HMark-cli   Author: squizz617   File: parseutility.py    (license) View Source Project 6 votes vote down vote up
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) 
Example 26
Project: IoTcube-HMark-cli   Author: squizz617   File: parseutility.py    (license) View Source Project 6 votes vote down vote up
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\" " 
Example 27
Project: TWTools   Author: ZeX2   File: Functions.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
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) 
Example 28
Project: Fuxenpruefung   Author: andb0t   File: files.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
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 
Example 29
Project: uPyLoader   Author: BetaRavener   File: pyinstaller_helper.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 30
Project: 3ds-to-cia   Author: drizzt   File: 3ds-to-cia.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 31
Project: tvlinker   Author: ozmartian   File: __main__.py    (license) View Source Project 5 votes vote down vote up
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 
Example 32
Project: tvlinker   Author: ozmartian   File: downloader.py    (license) View Source Project 5 votes vote down vote up
def get_path(path: str) -> str:
        prefix = sys._MEIPASS if getattr(sys, 'frozen', False) else QFileInfo(__file__).absolutePath()
        return os.path.join(prefix, path) 
Example 33
Project: csirtg-smrt-py   Author: csirtgadgets   File: smrt.py    (license) View Source Project 5 votes vote down vote up
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 
Example 34
Project: csirtg-smrt-py   Author: csirtgadgets   File: smrt.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 35
Project: FuME   Author: fupadev   File: app.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 36
Project: FuME   Author: fupadev   File: ReserveProcessor.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 37
Project: FuME   Author: fupadev   File: ChromeDriverProcessor.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 38
Project: FuME   Author: fupadev   File: SettingsDialog.py    (license) View Source Project 5 votes vote down vote up
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 
Example 39
Project: adblockradio   Author: quasoft   File: utils.py    (license) View Source Project 5 votes vote down vote up
def resource_filename(filename):
    if is_frozen():
        path = os.path.join(sys._MEIPASS, filename)
    else:
        path = pkg_resources.resource_filename("adblockradio", filename)

    return path 
Example 40
Project: adblockradio   Author: quasoft   File: utils.py    (license) View Source Project 5 votes vote down vote up
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 
Example 41
Project: nodemcu-pyflasher   Author: marcelstoer   File: About.py    (license) View Source Project 5 votes vote down vote up
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__)) 
Example 42
Project: SWProxy-plugins   Author: lstern   File: SWProxy.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 43
Project: mdx-server   Author: ninja33   File: mdx_util.py    (license) View Source Project 5 votes vote down vote up
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')] 
Example 44
Project: device-updater   Author: spark   File: gui.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 45
Project: Comictagger   Author: dickloraine   File: settings.py    (license) View Source Project 5 votes vote down vote up
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__) ) 
Example 46
Project: mail.ru-uploader   Author: instefa   File: upload.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 47
Project: bitencrypt   Author: OriginalMy   File: openssl.py    (license) View Source Project 5 votes vote down vote up
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.") 
Example 48
Project: bitmask-dev   Author: leapcode   File: pixelizer.py    (license) View Source Project 5 votes vote down vote up
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 
Example 49
Project: bitmask-dev   Author: leapcode   File: launcher.py    (license) View Source Project 5 votes vote down vote up
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__) 
Example 50
Project: bitmask-dev   Author: leapcode   File: util.py    (license) View Source Project 5 votes vote down vote up
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__)