当前位置: 首页>>代码示例>>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;未经允许,请勿转载。