Python click.Tuple() Examples
The following are 4
code examples of click.Tuple().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
click
, or try the search function
.
Example #1
Source File: quick.py From quick with GNU General Public License v3.0 | 6 votes |
def data(self, index, role=QtCore.Qt.DisplayRole): if role == QtCore.Qt.DisplayRole: dstr = QtGui.QStandardItemModel.data(self, index, role) if dstr == "" or dstr is None: if isinstance(self.type, click.types.Tuple): row = index.row() if 0 <= row < len(self.type.types): tp = self.type.types[row] dstr = tp.name else: dstr = self.type.name return dstr if role == _GTypeRole: tp = click.STRING if isinstance(self.type, click.types.Tuple): row = index.row() if 0 <= row < len(self.type.types): tp = self.type.types[row] elif isinstance(self.type, click.types.ParamType): tp = self.type return tp return QtGui.QStandardItemModel.data(self, index, role)
Example #2
Source File: commands.py From websocks with Apache License 2.0 | 5 votes |
def client( policy: str, rulefile: typing.List[str], server_url: typing.List[str], address: typing.Tuple[str, int], ): from .rule import FilterRule FilterRule(rulefile) from .client import Client, set_policy, Pools, Pool set_policy(policy) Pools( [ Pool( "wss://" + s if not s.startswith("ws://") and not s.startswith("wss://") else s ) for s in server_url ] ) Client(address[0], address[1]).run()
Example #3
Source File: commands.py From websocks with Apache License 2.0 | 5 votes |
def server(address: typing.Tuple[str, int], userpass: typing.List[str]): from .server import Server Server( {_userpass.split(":")[0]: _userpass.split(":")[1] for _userpass in userpass}, host=address[0], port=address[1], ).run()
Example #4
Source File: multi_cell_monitor.py From treadmill with Apache License 2.0 | 4 votes |
def init(): """Return top level command handler""" @click.command() @click.option('--cell', required=True, envvar='TREADMILL_CELL', callback=cli.handle_context_opt, expose_value=False) @click.option('--monitor', nargs=2, type=click.Tuple([str, int]), multiple=True, required=True) @click.option('--once', help='Run once.', is_flag=True, default=False) @click.option('--interval', help='Wait interval between checks.', default=_DEFAULT_INTERVAL) @click.argument('name') def controller(monitor, once, interval, name): """Control app monitors across cells""" monitors = list(monitor) while True: intended_total = 0 actual_total = 0 intended = 0 for cellname, count in monitors: if cellname == context.GLOBAL.cell: intended = count else: actual = _count(cellname, name) _LOGGER.info('state for cell %s, actual: %s, intended: %s', cellname, actual, count) intended_total += count actual_total += actual missing = intended_total - actual_total # If there are missing instances, start them locally. If there are # extra instances (missing < 0) just keep the indended state for # the cell. my_count = intended + max(0, missing) _LOGGER.info('intended: %s, actual: %s, missing: %s, my count: %s', intended_total, actual_total, missing, my_count) _configure_monitor(name, my_count) if once: break time.sleep(utils.to_seconds(interval)) return controller