本文整理汇总了Python中mozrunner.Runner类的典型用法代码示例。如果您正苦于以下问题:Python Runner类的具体用法?Python Runner怎么用?Python Runner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Runner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MozRunnerLauncher
class MozRunnerLauncher(Launcher):
tempdir = None
runner = None
app_name = 'undefined'
profile_class = Profile
binary = None
def _install(self, dest):
self.tempdir = tempfile.mkdtemp()
self.binary = mozinstall.get_binary(
mozinstall.install(src=dest, dest=self.tempdir),
self.app_name)
def _start(self, profile=None, addons=(), cmdargs=()):
if profile:
profile = self.profile_class(profile=profile, addons=addons)
elif len(addons):
profile = self.profile_class(addons=addons)
else:
profile = self.profile_class()
process_args = {'processOutputLine': [self._logger.debug]}
self.runner = Runner(binary=self.binary,
cmdargs=cmdargs,
profile=profile,
process_args=process_args)
self.runner.start()
def _stop(self):
self.runner.stop()
rmtree(self.tempdir)
def _get_app_info(self):
return mozversion.get_version(binary=self.binary)
示例2: GaiaUnitTestRunner
class GaiaUnitTestRunner(object):
def __init__(self, binary=None, profile=None, symbols_path=None,
browser_arg=()):
self.binary = binary
self.profile = profile
self.symbols_path = symbols_path
self.browser_arg = browser_arg
def run(self):
self.profile_dir = os.path.join(tempfile.mkdtemp(suffix='.gaiaunittest'),
'profile')
shutil.copytree(self.profile, self.profile_dir)
cmdargs = ['--runapp', 'Test Agent']
if self.browser_arg:
cmdargs += list(self.browser_arg)
profile = Profile(profile=self.profile_dir)
self.runner = Runner(binary=self.binary,
profile=profile,
clean_profile=False,
cmdargs=cmdargs,
symbols_path=self.symbols_path)
self.runner.start()
def cleanup(self):
print 'checking for crashes'
crashed = self.runner.check_for_crashes()
self.runner.cleanup()
shutil.rmtree(os.path.dirname(self.profile_dir))
return crashed
__del__ = cleanup
示例3: start
def start(self):
profile_args = {"preferences": deepcopy(self.required_prefs)}
profile_args["preferences"]["marionette.defaultPrefs.port"] = self.marionette_port
if self.prefs:
profile_args["preferences"].update(self.prefs)
if self.verbose:
level = "TRACE" if self.verbose >= 2 else "DEBUG"
profile_args["preferences"]["marionette.logging"] = level
if '-jsdebugger' in self.app_args:
profile_args["preferences"].update({
"devtools.browsertoolbox.panel": "jsdebugger",
"devtools.debugger.remote-enabled": True,
"devtools.chrome.enabled": True,
"devtools.debugger.prompt-connection": False,
"marionette.debugging.clicktostart": True,
})
if self.addons:
profile_args['addons'] = self.addons
if hasattr(self, "profile_path") and self.profile is None:
if not self.profile_path:
if self.workspace:
profile_args['profile'] = tempfile.mkdtemp(
suffix='.mozrunner-{:.0f}'.format(time.time()),
dir=self.workspace)
self.profile = Profile(**profile_args)
else:
profile_args["path_from"] = self.profile_path
profile_name = '{}-{:.0f}'.format(
os.path.basename(self.profile_path),
time.time()
)
if self.workspace:
profile_args["path_to"] = os.path.join(self.workspace,
profile_name)
self.profile = Profile.clone(**profile_args)
process_args = {
'processOutputLine': [NullOutput()],
}
if self.gecko_log == '-':
process_args['stream'] = sys.stdout
else:
process_args['logfile'] = self.gecko_log
env = os.environ.copy()
# environment variables needed for crashreporting
# https://developer.mozilla.org/docs/Environment_variables_affecting_crash_reporting
env.update({ 'MOZ_CRASHREPORTER': '1',
'MOZ_CRASHREPORTER_NO_REPORT': '1', })
self.runner = Runner(
binary=self.bin,
profile=self.profile,
cmdargs=['-no-remote', '-marionette'] + self.app_args,
env=env,
symbols_path=self.symbols_path,
process_args=process_args)
self.runner.start()
示例4: start
def start(self):
profile_args = {"preferences": self.required_prefs}
if not self.profile_path:
profile_args["restore"] = False
profile = Profile(**profile_args)
else:
profile_args["path_from"] = self.profile_path
profile = Profile.clone(**profile_args)
if self.gecko_log is None:
self.gecko_log = 'gecko.log'
elif os.path.isdir(self.gecko_log):
fname = "gecko-%d.log" % time.time()
self.gecko_log = os.path.join(self.gecko_log, fname)
self.gecko_log = os.path.realpath(self.gecko_log)
if os.access(self.gecko_log, os.F_OK):
os.remove(self.gecko_log)
env = os.environ.copy()
# environment variables needed for crashreporting
# https://developer.mozilla.org/docs/Environment_variables_affecting_crash_reporting
env.update({ 'MOZ_CRASHREPORTER': '1',
'MOZ_CRASHREPORTER_NO_REPORT': '1', })
self.runner = Runner(
binary=self.bin,
profile=profile,
cmdargs=['-no-remote', '-marionette'] + self.app_args,
env=env,
symbols_path=self.symbols_path,
process_args={
'processOutputLine': [NullOutput()],
'logfile': self.gecko_log})
self.runner.start()
示例5: start
def start(self):
profile = self.profile
if not profile:
prefs = {"marionette.defaultPrefs.enabled": True,
"marionette.defaultPrefs.port": 2828}
profile = {"preferences": prefs, "restore":False}
print "starting runner"
self.runner = Runner.create(binary=self.bin, profile_args=profile, cmdargs=['-no-remote'])
self.runner.start()
示例6: start
def start(self):
profile_args = {"preferences": deepcopy(self.required_prefs)}
if self.prefs:
profile_args["preferences"].update(self.prefs)
if not self.profile_path:
profile_args["restore"] = False
profile = Profile(**profile_args)
else:
profile_args["path_from"] = self.profile_path
profile = Profile.clone(**profile_args)
if self.gecko_log is None:
self.gecko_log = 'gecko.log'
elif os.path.isdir(self.gecko_log):
fname = "gecko-%d.log" % time.time()
self.gecko_log = os.path.join(self.gecko_log, fname)
self.gecko_log = os.path.realpath(self.gecko_log)
if os.access(self.gecko_log, os.F_OK):
if platform.system() is 'Windows':
# NOTE: windows has a weird filesystem where it happily 'closes'
# the file, but complains if you try to delete it. You get a
# 'file still in use' error. Sometimes you can wait a bit and
# a retry will succeed.
# If all retries fail, we'll just continue without removing
# the file. In this case, if we are restarting the instance,
# then the new logs just get appended to the old file.
tries = 0
while tries < 10:
try:
os.remove(self.gecko_log)
break
except WindowsError as e:
if e.errno == errno.EACCES:
tries += 1
time.sleep(0.5)
else:
raise e
else:
os.remove(self.gecko_log)
env = os.environ.copy()
# environment variables needed for crashreporting
# https://developer.mozilla.org/docs/Environment_variables_affecting_crash_reporting
env.update({ 'MOZ_CRASHREPORTER': '1',
'MOZ_CRASHREPORTER_NO_REPORT': '1', })
self.runner = Runner(
binary=self.bin,
profile=profile,
cmdargs=['-no-remote', '-marionette'] + self.app_args,
env=env,
symbols_path=self.symbols_path,
process_args={
'processOutputLine': [NullOutput()],
'logfile': self.gecko_log})
self.runner.start()
示例7: run
def run(self):
self.profile_dir = os.path.join(tempfile.mkdtemp(suffix='.gaiaunittest'),
'profile')
shutil.copytree(self.profile, self.profile_dir)
self.runner = Runner.create(binary=self.binary,
profile_args={'profile': self.profile_dir},
clean_profile=False,
cmdargs=['--runapp', 'Test Agent'])
self.runner.start()
示例8: _start
def _start(self, profile=None, addons=(), cmdargs=(), preferences=None):
profile = self._create_profile(profile=profile, addons=addons,
preferences=preferences)
self._logger.info("Launching %s" % self.binary)
process_args = {'processOutputLine': [self._logger.debug]}
self.runner = Runner(binary=self.binary,
cmdargs=cmdargs,
profile=profile,
process_args=process_args)
self.runner.start()
示例9: start
def start(self, profile, addons, cmdargs):
if profile:
profile = self.profileClass(profile=profile, addons=addons)
elif len(addons):
profile = self.profileClass(addons=addons)
else:
profile = self.profileClass()
self.runner = Runner(binary=self.binary, cmdargs=cmdargs, profile=profile)
self.runner.start()
return True
示例10: NightlyRunner
class NightlyRunner(object):
def __init__(self, addons=None, appname="firefox", repo_name=None,
profile=None, cmdargs=[]):
if appname.lower() == 'thunderbird':
self.app = ThunderbirdNightly(repo_name=repo_name)
elif appname.lower() == 'mobile':
self.app = FennecNightly(repo_name=repo_name)
else:
self.app = FirefoxNightly(repo_name=repo_name)
self.addons = addons
self.profile = profile
self.cmdargs = cmdargs
def install(self, date=datetime.date.today()):
if not self.app.download(date=date):
print "could not find nightly from " + str(date)
return False # download failed
print "Starting nightly\n"
self.app.install()
def start(self, date=datetime.date.today()):
self.install(date)
if self.profile:
profile = self.app.profileClass(profile=self.profile, addons=self.addons)
elif len(self.addons):
profile = self.app.profileClass(addons=self.addons)
else:
profile = self.app.profileClass()
self.runner = Runner(binary=self.app.binary, cmdargs=self.cmdargs, profile=profile)
self.runner.names = [self.app.processName]
self.runner.start()
return True
def stop(self):
self.runner.stop()
def getAppInfo(self):
return self.app.getAppInfo()
示例11: start
def start(self, date=datetime.date.today()):
self.install(date)
if self.profile:
profile = self.app.profileClass(profile=self.profile, addons=self.addons)
elif len(self.addons):
profile = self.app.profileClass(addons=self.addons)
else:
profile = self.app.profileClass()
self.runner = Runner(binary=self.app.binary, cmdargs=self.cmdargs, profile=profile)
self.runner.names = [self.app.processName]
self.runner.start()
return True
示例12: _start
def _start(self, profile=None, addons=(), cmdargs=()):
if profile:
profile = self.profile_class(profile=profile, addons=addons)
elif len(addons):
profile = self.profile_class(addons=addons)
else:
profile = self.profile_class()
process_args = {'processOutputLine': [self._logger.debug]}
self.runner = Runner(binary=self.binary,
cmdargs=cmdargs,
profile=profile,
process_args=process_args)
self.runner.start()
示例13: MozRunnerLauncher
class MozRunnerLauncher(Launcher):
tempdir = None
runner = None
app_name = 'undefined'
binary = None
def _install(self, dest):
self.tempdir = tempfile.mkdtemp()
self.binary = mozinstall.get_binary(
mozinstall.install(src=dest, dest=self.tempdir),
self.app_name)
def _start(self, profile=None, addons=(), cmdargs=(), preferences=None):
profile = self._create_profile(profile=profile, addons=addons,
preferences=preferences)
self._logger.info("Launching %s" % self.binary)
process_args = {'processOutputLine': [self._logger.debug]}
self.runner = Runner(binary=self.binary,
cmdargs=cmdargs,
profile=profile,
process_args=process_args)
self.runner.start()
def _stop(self):
self.runner.stop()
def __del__(self):
try:
Launcher.__del__(self)
finally:
# always remove tempdir
if self.tempdir is not None:
rmtree(self.tempdir)
def get_app_info(self):
return mozversion.get_version(binary=self.binary)
示例14: run
def run(self):
self.profile_dir = os.path.join(tempfile.mkdtemp(suffix='.gaiaunittest'),
'profile')
shutil.copytree(self.profile, self.profile_dir)
cmdargs = ['--runapp', 'Test Agent']
if self.browser_arg:
cmdargs += list(self.browser_arg)
self.runner = Runner.create(binary=self.binary,
profile_args={'profile': self.profile_dir},
clean_profile=False,
cmdargs=cmdargs,
symbols_path=self.symbols_path)
self.runner.start()
示例15: start
def start(self, date=datetime.date.today()):
if not self.app.download(date=date):
print "could not find nightly from " + str(date)
return False # download failed
self.app.install()
if self.profile:
profile = self.app.profileClass(profile=self.profile, addons=self.addons)
elif len(self.addons):
profile = self.app.profileClass(addons=self.addons)
else:
profile = self.app.profileClass()
print "running nightly from " + str(date) + "\n"
self.runner = Runner(binary=self.app.binary, cmdargs=self.cmdargs, profile=profile)
self.runner.names = [self.app.processName]
self.runner.start()
return True