當前位置: 首頁>>代碼示例>>Python>>正文


Python sys._MEIPASS屬性代碼示例

本文整理匯總了Python中sys._MEIPASS屬性的典型用法代碼示例。如果您正苦於以下問題:Python sys._MEIPASS屬性的具體用法?Python sys._MEIPASS怎麽用?Python sys._MEIPASS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在sys的用法示例。


在下文中一共展示了sys._MEIPASS屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: restart

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
def restart(self):
        if getattr(sys, '_MEIPASS', False):
            if platform.system() == 'Windows':
                subprocess.Popen([wl_misc.get_normalized_path('Wordless.exe')])
            elif platform.system() == 'Darwin':
                subprocess.Popen([wl_misc.get_normalized_path('Wordless')])
            elif platform.system() == 'Linux':
                subprocess.Popen([wl_misc.get_normalized_path('Wordless')])
        else:
            if platform.system() == 'Windows':
                subprocess.Popen(['python', wl_misc.get_normalized_path(__file__)])
            elif platform.system() == 'Darwin':
                subprocess.Popen(['python3', wl_misc.get_normalized_path(__file__)])
            elif platform.system() == 'Linux':
                subprocess.Popen(['python3.7', wl_misc.get_normalized_path(__file__)])

        self.save_settings()
        sys.exit(0) 
開發者ID:BLKSerene,項目名稱:Wordless,代碼行數:20,代碼來源:wl_main.py

示例2: meta_validate

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
def meta_validate(shacl_graph, inference='rdfs', **kwargs):
    shacl_shacl_graph = meta_validate.shacl_shacl_graph
    if shacl_shacl_graph is None:
        from os import path
        import pickle
        import sys
        if getattr( sys, 'frozen', False ) :
                # runs in a pyinstaller bundle
                here_dir = sys._MEIPASS
                pickle_file = path.join(here_dir, "shacl-shacl.pickle")
        else :
                here_dir = path.dirname(__file__)
                pickle_file = path.join(here_dir, "shacl-shacl.pickle")
        with open(pickle_file, 'rb') as shacl_pickle:
            u = pickle.Unpickler(shacl_pickle, fix_imports=False)
            shacl_shacl_store = u.load()
        shacl_shacl_graph = rdflib.Graph(store=shacl_shacl_store, identifier="http://www.w3.org/ns/shacl-shacl")
        meta_validate.shacl_shacl_graph = shacl_shacl_graph
    shacl_graph = load_from_source(shacl_graph, rdf_format=kwargs.pop('shacl_graph_format', None),
                                   multigraph=True)
    _ = kwargs.pop('meta_shacl', None)
    return validate(shacl_graph, shacl_graph=shacl_shacl_graph, inference=inference, **kwargs) 
開發者ID:RDFLib,項目名稱:pySHACL,代碼行數:24,代碼來源:validate.py

示例3: create_app

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
def create_app(config="cryptoadvance.specter.config.DevelopmentConfig"):
    # Enables injection of a different config via Env-Variable
    if os.environ.get("SPECTER_CONFIG"):
        config = os.environ.get("SPECTER_CONFIG")

    if getattr(sys, 'frozen', False):

        # Best understood with the snippet below this section:
        # https://pyinstaller.readthedocs.io/en/v3.3.1/runtime-information.html#using-sys-executable-and-sys-argv-0
        template_folder = os.path.join(sys._MEIPASS, 'templates')
        static_folder = os.path.join(sys._MEIPASS, 'static')
        logger.info("pyinstaller based instance running in {}".format(sys._MEIPASS))
        app = Flask(__name__, template_folder=template_folder, static_folder=static_folder)
    else:
        app = Flask(__name__, template_folder="templates", static_folder="static")
    app.config.from_object(config)
    return app 
開發者ID:cryptoadvance,項目名稱:specter-desktop,代碼行數:19,代碼來源:server.py

示例4: __init__

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
def __init__(self, loginQueue):
        tk.Toplevel.__init__(self)
        
        self.configure(pady=10, padx=20)
        
        self.wm_attributes("-topmost", True)
        self.wm_title("PyEveLiveDPS Awaiting Login")
        try:
            self.iconbitmap(sys._MEIPASS + '\\app.ico')
        except Exception:
            try:
                self.iconbitmap("app.ico")
            except Exception:
                pass
        self.geometry("200x50")
        self.update_idletasks()
            
        tk.Label(self, text='Waiting for you to login...').grid(row=1, column=1)

        self.loginStatus = loginQueue.get()

        self.destroy() 
開發者ID:ArtificialQualia,項目名稱:PyEveLiveDPS,代碼行數:24,代碼來源:fleetConnectionWindow.py

示例5: __init__

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
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. 
開發者ID:lanjelot,項目名稱:patator,代碼行數:21,代碼來源:patator.py

示例6: __init__

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
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. 
開發者ID:devgc,項目名稱:EventMonkey,代碼行數:21,代碼來源:EventMonkey.py

示例7: GetResource

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
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 
開發者ID:devgc,項目名稱:EventMonkey,代碼行數:27,代碼來源:Utilities.py

示例8: getDataDir

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
def getDataDir(path=""):
    '''
    Returns the folder where the executable is located. (This function is ran on non-Windows OS's)
    
    :param path: Additional directories/files to join to the data directory path
    
    :return unicode
    '''
    # if sys.platform == "win32":
    #     def fsdecode(x):
    #         return x.decode(sys.getfilesystemencoding())
    #
    #     dataDir = os.getcwdu()
    #     '''
    #     if getattr(sys, 'frozen', False):
    #         dataDir = os.path.dirname(sys._MEIPASS)
    #     else:
    #         dataDir = os.path.dirname(__file__)
    #     '''
    #
    # else:
    dataDir = os.getcwdu()
    if len(path) > 0:
        return os.path.join(dataDir, path)
    return dataDir 
開發者ID:mcgreentn,項目名稱:GDMC,代碼行數:27,代碼來源:directories.py

示例9: absPath

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
def absPath(myPath):
    """ Get absolute path to resource, works for dev and for PyInstaller """
    import sys

    try:
        # PyInstaller creates a temp folder and stores path in _MEIPASS
        base_path = sys._MEIPASS
        logger.debug("found MEIPASS: %s "%os.path.join(base_path, os.path.basename(myPath)))

        return os.path.join(base_path, os.path.basename(myPath))
    except Exception as e:
        logger.debug("did not find MEIPASS: %s "%e)


        base_path = os.path.abspath(os.path.dirname(__file__))
        return os.path.join(base_path, myPath) 
開發者ID:maweigert,項目名稱:spimagine,代碼行數:18,代碼來源:spimagine_gui.py

示例10: absPath

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
def absPath(myPath):
    """ Get absolute path to resource, works for dev and for PyInstaller """
    import sys

    try:
        # PyInstaller creates a temp folder and stores path in _MEIPASS
        base_path = sys._MEIPASS
        logger.debug("found MEIPASS: %s " % os.path.join(base_path, os.path.basename(myPath)))

        return os.path.join(base_path, os.path.basename(myPath))
    except Exception:
        base_path = os.path.abspath(os.path.dirname(__file__))
        return os.path.join(base_path, myPath)


############################################################################ 
開發者ID:maweigert,項目名稱:spimagine,代碼行數:18,代碼來源:data_model.py

示例11: loadcolormaps

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
def loadcolormaps():
    cmaps = {}

    try:
        basePath = sys._MEIPASS
    except:
        basePath = _absPath("../colormaps/")

    reg = re.compile("cmap_(.*)\.png")
    for fName in os.listdir(basePath):
        match = reg.match(fName)
        if match:
            try:
                cmaps[match.group(1)] = _arrayFromImage(os.path.join(basePath,fName))[0,:,:]
            except Exception as e:
                print(e)
                print("could not load %s"%fName)

    return cmaps 
開發者ID:maweigert,項目名稱:spimagine,代碼行數:21,代碼來源:loadcolormaps.py

示例12: absPath

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
def absPath(myPath):
    """ Get absolute path to resource, works for dev and for PyInstaller """
    import sys

    try:
        # PyInstaller creates a temp folder and stores path in _MEIPASS
        base_path = sys._MEIPASS
        logger.debug("found MEIPASS: %s "%os.path.join(base_path, os.path.basename(myPath)))

        return os.path.join(base_path, os.path.basename(myPath))
    except Exception:

        base_path = os.path.abspath(os.path.dirname(__file__))
        logger.debug("didnt found MEIPASS...: %s "%os.path.join(base_path, myPath))

        return os.path.join(base_path, myPath) 
開發者ID:maweigert,項目名稱:spimagine,代碼行數:18,代碼來源:keyframe_view.py

示例13: get_resource

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
def get_resource(resource):
    if not hasattr(sys, 'frozen'):
        return pkg_resources.resource_filename('rfmonitor.ui', resource)
    else:
        return os.path.join(sys._MEIPASS, 'ui', resource) 
開發者ID:EarToEarOak,項目名稱:RF-Monitor,代碼行數:7,代碼來源:utils_ui.py

示例14: path

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
def path(f):
    if hasattr(sys, "_MEIPASS"):  # when freezed with pyinstaller ;-)
        return os.path.join(sys._MEIPASS, f)
    else:
        return os.path.join(PATH, f) 
開發者ID:manatlan,項目名稱:wuy,代碼行數:7,代碼來源:wuy.py

示例15: test_path

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import _MEIPASS [as 別名]
def test_path():
    assert not hasattr(sys, "_MEIPASS")
    assert wuy.path("jo") == os.path.join(os.getcwd(), "jo") 
開發者ID:manatlan,項目名稱:wuy,代碼行數:5,代碼來源:test_utilities.py


注:本文中的sys._MEIPASS屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。