#!/usr/bin/env python -u # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""action_config_script.py
Demonstrate actions and config. """
import os import sys import time
sys.path.insert(1, os.path.dirname(sys.path[0]))
from mozharness.base.script import BaseScript
# ActionsConfigExample {{{1 class ActionsConfigExample(BaseScript):
config_options = [
[
[ "--beverage",
],
{ "action": "store", "dest": "beverage", "type": "string", "help": "Specify your beverage of choice",
},
],
[
[ "--ship-style",
],
{ "action": "store", "dest": "ship_style", "type": "choice", "choices": ["1", "2", "3"], "help": "Specify the type of ship",
},
],
[
[ "--long-sleep-time",
],
{ "action": "store", "dest": "long_sleep_time", "type": "int", "help": "Specify how long to sleep",
},
],
]
def nap(self): for var_name in self.config.keys(): if var_name.startswith("random_config_key"):
self.info("This is going to be %s!" % self.config[var_name])
sleep_time = self.config["long_sleep_time"] if sleep_time > 60:
self.info( "Ok, grab a %s. This is going to take a while."
% self.config["beverage"]
) else:
self.info( "This will be quick, but grab a %s anyway." % self.config["beverage"]
)
self._sleep(self.config["long_sleep_time"])
def ship_it(self):
name = "_ship%s" % self.config["ship_style"] if hasattr(self, name):
getattr(self, name)()
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.