本文整理匯總了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
示例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
示例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()
示例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()
示例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)])
示例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
示例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")
示例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
示例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
示例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'
示例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
示例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'
示例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!")
示例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())
示例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)