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


Python sys.frozen方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def __init__(self, master):
            try:
                sys.frozen	# don't want to try updating python.exe
                self.updater = ctypes.cdll.WinSparkle
                self.updater.win_sparkle_set_appcast_url(update_feed)	# py2exe won't let us embed this in resources

                # set up shutdown callback
                global root
                root = master
                self.callback_t = ctypes.CFUNCTYPE(None)	# keep reference
                self.callback_fn = self.callback_t(shutdown_request)
                self.updater.win_sparkle_set_shutdown_request_callback(self.callback_fn)

                self.updater.win_sparkle_init()

            except:
                from traceback import print_exc
                print_exc()
                self.updater = None 
開發者ID:EDCD,項目名稱:EDMarketConnector,代碼行數:21,代碼來源:update.py

示例2: teardown_environment

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def teardown_environment():
    """Restore things that were remembered by the setup_environment function
    """
    (oldenv, os.name, sys.platform, path.get_home_dir, IPython.__file__, old_wd) = oldstuff
    os.chdir(old_wd)
    reload(path)

    for key in env.keys():
        if key not in oldenv:
            del env[key]
    env.update(oldenv)
    if hasattr(sys, 'frozen'):
        del sys.frozen
    if os.name == 'nt':
        (wreg.OpenKey, wreg.QueryValueEx,) = platformstuff

# Build decorator that uses the setup_environment/setup_environment 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:19,代碼來源:test_path.py

示例3: main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def main():
    sys.frozen = 'windows_exe'
    sys.setdefaultencoding('utf-8')
    aliasmbcs()

    sys.meta_path.insert(0, PydImporter())
    sys.path_importer_cache.clear()

    import linecache
    def fake_getline(filename, lineno, module_globals=None):
        return ''
    linecache.orig_getline = linecache.getline
    linecache.getline = fake_getline

    abs__file__()

    add_calibre_vars()

    # Needed for pywintypes to be able to load its DLL
    sys.path.append(os.path.join(sys.app_dir, 'app', 'DLLs'))

    return run_entry_point() 
開發者ID:kovidgoyal,項目名稱:build-calibre,代碼行數:24,代碼來源:site.py

示例4: main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def main():
    global __file__

    # Needed on OS X <= 10.8, which passes -psn_... as a command line arg when
    # starting via launch services
    for arg in tuple(sys.argv[1:]):
        if arg.startswith('-psn_'):
            sys.argv.remove(arg)

    base = sys.resourcepath
    sys.frozen = 'macosx_app'
    sys.new_app_bundle = True
    abs__file__()

    add_calibre_vars(base)
    addsitedir(sys.site_packages)

    if sys.calibre_is_gui_app and not (
            sys.stdout.isatty() or sys.stderr.isatty() or sys.stdin.isatty()):
        nuke_stdout()

    return run_entry_point() 
開發者ID:kovidgoyal,項目名稱:build-calibre,代碼行數:24,代碼來源:site.py

示例5: __init__

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def __init__(self, group, testFiles=None):
        """
        @type	group: Group
        @param	group: Group this Generator belongs to
        @type	testFiles: string
        @param	testFiles: Location of test files
        """
        Generator.__init__(self)

        p = None
        if not (hasattr(sys, "frozen") and sys.frozen == "console_exe"):
            p = Peach.Generators.static.__file__[:-10]
        else:
            p = os.path.dirname(os.path.abspath(sys.executable))

        testFiles = os.path.join(p, "xmltests")

        self._generatorList = GeneratorList(group,
                                            [XmlParserTestsInvalid(None, testFiles),
                                             XmlParserTestsNotWellFormed(None, testFiles),
                                             XmlParserTestsValid(None, testFiles)]) 
開發者ID:MozillaSecurity,項目名稱:peach,代碼行數:23,代碼來源:xmlstuff.py

示例6: appFrozen

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def appFrozen():
    ib = False
    try:
        platf = str(platform.system())
        if platf == "Darwin":
            # the sys.frozen is set by py2app and pyinstaller and is unset otherwise
            if getattr( sys, 'frozen', False ):
                ib = True
        elif platf == "Windows":
            ib = (hasattr(sys, "frozen") or # new py2exe
                hasattr(sys, "importers") # old py2exe
                or imp.is_frozen("__main__")) # tools/freeze
        elif platf == "Linux":
            if getattr(sys, 'frozen', False):
                # The application is frozen
                ib = True
    except Exception:
        pass
    return ib 
開發者ID:artisan-roaster-scope,項目名稱:artisan,代碼行數:21,代碼來源:util.py

示例7: __init__

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def __init__(self):
        import win32api
        win32api.MessageBox(0, "NextID.__init__ started", "NextID.py")
        global d
        if sys.frozen:
            for entry in sys.path:
                if entry.find('?') > -1:
                    here = os.path.dirname(entry.split('?')[0])
                    break
            else:
                here = os.getcwd()
        else:
            here = os.path.dirname(__file__)
        self.fnm = os.path.join(here, 'id.cfg')
        try:
            d = eval(open(self.fnm, 'rU').read()+'\n')
        except:
            d = {
                'systemID': 0xaaaab,
                'highID': 0
            }
        win32api.MessageBox(0, "NextID.__init__ complete", "NextID.py") 
開發者ID:Lithium876,項目名稱:ConTroll_Remote_Access_Trojan,代碼行數:24,代碼來源:NextID.py

示例8: testPythonCmd

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def testPythonCmd(self):
		app = Application('foo.py')
		cwd, argv = app._checkargs(None, ())
		self.assertEqual(argv[0], sys.executable)
		self.assertEqual(argv[1], 'foo.py')

		sys.frozen = True
		try:
			cwd, argv = app._checkargs(None, ())
			self.assertEqual(argv, ('foo.py',))
		except:
			del sys.frozen
			raise
		else:
			del sys.frozen

	# TODO fully test _decode_value
	# test e.g. values with '"' or '\t' in a string
	# see that json.loads does what it is supposed to do 
開發者ID:zim-desktop-wiki,項目名稱:zim-desktop-wiki,代碼行數:21,代碼來源:applications.py

示例9: _executable_args

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def _executable_args(self):
        profile = self.request.config.getoption('--qute-profile-subprocs')
        if hasattr(sys, 'frozen'):
            if profile:
                raise Exception("Can't profile with sys.frozen!")
            executable = os.path.join(os.path.dirname(sys.executable),
                                      'qutebrowser')
            args = []
        else:
            executable = sys.executable
            if profile:
                profile_dir = os.path.join(os.getcwd(), 'prof')
                profile_id = '{}_{}'.format(self._instance_id,
                                            next(self._run_counter))
                profile_file = os.path.join(profile_dir,
                                            '{}.pstats'.format(profile_id))
                try:
                    os.mkdir(profile_dir)
                except FileExistsError:
                    pass
                args = [os.path.join('scripts', 'dev', 'run_profile.py'),
                        '--profile-tool', 'none',
                        '--profile-file', profile_file]
            else:
                args = ['-bb', '-m', 'qutebrowser']
        return executable, args 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:28,代碼來源:quteprocess.py

示例10: test_frozen_ok

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def test_frozen_ok(self, commit_file_mock, monkeypatch):
        """Test with sys.frozen=True and a successful git-commit-id read."""
        monkeypatch.setattr(version.sys, 'frozen', True, raising=False)
        commit_file_mock.return_value = 'deadbeef'
        assert version._git_str() == 'deadbeef' 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:7,代碼來源:test_version.py

示例11: test_frozen_oserror

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def test_frozen_oserror(self, caplog, commit_file_mock, monkeypatch):
        """Test with sys.frozen=True and OSError when reading git-commit-id."""
        monkeypatch.setattr(version.sys, 'frozen', True, raising=False)
        commit_file_mock.side_effect = OSError
        with caplog.at_level(logging.ERROR, 'misc'):
            assert version._git_str() is None 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:8,代碼來源:test_version.py

示例12: test_normal_successful_frozen

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def test_normal_successful_frozen(self, git_str_subprocess_fake):
        """Test with git returning a successful result."""
        # The value is defined in scripts/freeze_tests.py.
        assert version._git_str() == 'fake-frozen-git-commit' 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:6,代碼來源:test_version.py

示例13: freezer

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def freezer(request, monkeypatch):
    if request.param and not getattr(sys, 'frozen', False):
        monkeypatch.setattr(sys, 'frozen', True, raising=False)
        monkeypatch.setattr(sys, 'executable', qutebrowser.__file__)
    elif not request.param and getattr(sys, 'frozen', False):
        # Want to test unfrozen tests, but we are frozen
        pytest.skip("Can't run with sys.frozen = True!") 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:9,代碼來源:test_utils.py

示例14: _run

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def _run(script):
	global __file__
	import os, sys
	sys.frozen = 'macosx_plugin'
	base = os.environ['RESOURCEPATH']
	__file__ = path = os.path.join(base, script)
	if sys.version_info[0] == 2:
		with open(path, 'rU') as fp:
			source = fp.read() + "\n"
	else:
		with open(path, 'r', encoding='utf-8') as fp:
			source = fp.read() + '\n'

	exec(compile(source, script, 'exec'), globals(), globals()) 
開發者ID:Tosche,項目名稱:BubbleKern,代碼行數:16,代碼來源:main.py

示例15: main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import frozen [as 別名]
def main():
    shell.check_python()

    # fix py2exe
    if hasattr(sys, "frozen") and sys.frozen in \
            ("windows_exe", "console_exe"):
        p = os.path.dirname(os.path.abspath(sys.executable))
        os.chdir(p)

    config = shell.get_config(True)

    daemon.daemon_exec(config)

    try:
        logging.info("starting local at %s:%d" %
                     (config['local_address'], config['local_port']))

        dns_resolver = asyncdns.DNSResolver()
        tcp_server = tcprelay.TCPRelay(config, dns_resolver, True)
        udp_server = udprelay.UDPRelay(config, dns_resolver, True)
        loop = eventloop.EventLoop()
        dns_resolver.add_to_loop(loop)
        tcp_server.add_to_loop(loop)
        udp_server.add_to_loop(loop)

        def handler(signum, _):
            logging.warn('received SIGQUIT, doing graceful shutting down..')
            tcp_server.close(next_tick=True)
            udp_server.close(next_tick=True)
        signal.signal(getattr(signal, 'SIGQUIT', signal.SIGTERM), handler)

        def int_handler(signum, _):
            sys.exit(1)
        signal.signal(signal.SIGINT, int_handler)

        daemon.set_user(config.get('user', None))
        loop.run()
    except Exception as e:
        shell.print_exception(e)
        sys.exit(1) 
開發者ID:ntfreedom,項目名稱:neverendshadowsocks,代碼行數:42,代碼來源:local.py


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