<EOL>return parse_netmhcpan3_stdout(<EOL>stdout=stdout,<EOL>prediction_method_name=prediction_method_name,<EOL>sequence_key_mapping=sequence_key_mapping)<EOL>

# NetMHCpan version 4.0

# Tmpdir made /var/folders/jc/fyrvcrcs3sb8g4mkdg6nl_t80000gp/T//netMHCpanuH3SvY
# Input is in PEPTIDE format

# Make binding affinity predictions

HLA-A02:01 : Distance to training data  0.000 (using nearest neighbor HLA-A02:01)

# Rank Threshold for Strong binding peptides   0.500
# Rank Threshold for Weak binding peptides   2.000
-----------------------------------------------------------------------------------
  Pos          HLA         Peptide       Core Of Gp Gl Ip Il        Icore        Identity     Score Aff(nM)   %Rank  BindLevel
-----------------------------------------------------------------------------------
    1  HLA-A*02:01        SIINFEKL  SIINF-EKL  0  0  0  5  1     SIINFEKL         PEPLIST 0.1141340 14543.1 18.9860
-----------------------------------------------------------------------------------

Protein PEPLIST. Allele HLA-A*02:01. Number of high binders 0. Number of weak binders 0. Number of peptides 1


<EOL>with open(os.devnull, '<STR_LIT:w>') as devnull:<EOL><INDENT>output = check_output([<EOL>program_name, "<STR_LIT>", "<STR_LIT>"],<EOL>stderr=devnull)<EOL><DEDENT>output_str = output.decode("<STR_LIT:ascii>", "<STR_LIT:ignore>")<EOL>common_kwargs = {<EOL>"<STR_LIT>": alleles,<EOL>"<STR_LIT>": default_peptide_lengths,<EOL>"<STR_LIT>": program_name,<EOL>"<STR_LIT>": process_limit,<EOL>"<STR_LIT>": extra_flags,<EOL>}<EOL>if "<STR_LIT>" in output_str:<EOL><INDENT>return NetMHCpan28(**common_kwargs)<EOL><DEDENT>elif "<STR_LIT>" in output_str:<EOL><INDENT>return NetMHCpan3(**common_kwargs)<EOL><DEDENT>elif "<STR_LIT>" in output_str:<EOL><INDENT>return NetMHCpan4(**common_kwargs)<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError(<EOL>"<STR_LIT>")<EOL><DEDENT>

This function wraps NetMHCpan28 and NetMHCpan3 to automatically detect which class
to use, with the help of the miraculous and strange '--version' netmhcpan argument.


for cls in self:<EOL><INDENT>cls.create_table(fail_silently=True)<EOL><DEDENT>


return self.paginator<EOL>


fields = self._meta.get_primary_keys()<EOL>assert fields<EOL>values = {field.name:self.__data__[field.name] for field in fields}<EOL>return values<EOL>

Returns dict of values to uniquely reference this item


for router in self.routers:<EOL><INDENT>r = router.get_database(model)<EOL>if r is not None:<EOL><INDENT>return r<EOL><DEDENT><DEDENT>return self.get('<STR_LIT:default>')<EOL>


return self.get(**cursor)<EOL>

Returns model instance from unique cursor reference


try:<EOL><INDENT>return cls.get(**kwargs)<EOL><DEDENT>except cls.DoesNotExist:<EOL><INDENT>return None<EOL><DEDENT>


ref = self.to_cursor_ref()<EOL>return self.from_cursor_ref(ref)<EOL>

Return new model instance with fresh data from database
Only works on models which have a primary or compound key
See https://github.com/coleifer/peewee/issues/638

XXX: Add support for models without PK


assert isinstance(filters, dict), "<STR_LIT>"<EOL>assert isinstance(cursor, dict), "<STR_LIT>"<EOL>query = self.get_query()<EOL>assert isinstance(query, peewee.Query)<EOL>paginator = self.get_paginator()<EOL>assert isinstance(paginator, Pagination)<EOL>count += <NUM_LIT:1><EOL>pquery = paginator.filter_query(query, cursor, count)<EOL>items = [ item for item in pquery ]<EOL>next_item = items.pop(<NUM_LIT:1>)<EOL>next_cursor = next_item.to_cursor_ref()<EOL>'''<STR_LIT>'''<EOL>return items, next_cursor<EOL>


return datetime.datetime.utcnow().replace(microsecond=<NUM_LIT:0>)<EOL>


@classmethod<EOL><INDENT>def paginate_query(self, query, count, offset=None, sort=None):<DEDENT>

assert isinstance(query, peewee.Query)<EOL>assert isinstance(count, int)<EOL>assert isinstance(offset, (str, int, type(None)))<EOL>assert isinstance(sort, (list, set, tuple, type(None)))<EOL>fields = query.model._meta.get_primary_keys()<EOL>if len(fields) == <NUM_LIT:0>:<EOL><INDENT>raise peewee.ProgrammingError(<EOL>'<STR_LIT>')<EOL><DEDENT>if len(fields) > <NUM_LIT:1>:<EOL><INDENT>raise peewee.ProgrammingError(<EOL>'<STR_LIT>')<EOL><DEDENT>if offset is not None:<EOL><INDENT>query = query.where(fields[<NUM_LIT:0>] >= offset)<EOL><DEDENT>order_bys = []<EOL>if sort:<EOL><INDENT>for field, direction in sort:<EOL><INDENT>if not isinstance(direction, str):<EOL><INDENT>raise ValueError("<STR_LIT>".format(field))<EOL><DEDENT>direction = direction.lower().strip()<EOL>if direction not in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>raise ValueError("<STR_LIT>".format(field))<EOL><DEDENT>order_by = peewee.SQL(field)<EOL>order_by = getattr(order_by, direction)()<EOL>order_bys += [order_by]<EOL><DEDENT><DEDENT>order_bys += [fields[<NUM_LIT:0>].asc()]<EOL>query = query.order_by(*order_bys)<EOL>query = query.limit(count)<EOL>return query<EOL>

Apply pagination to query

:attr query: Instance of `peewee.Query`
:attr count: Max rows to return
:attr offset: Pagination offset, str/int
:attr sort: List of tuples, e.g. [('id', 'asc')]

:returns: Instance of `peewee.Query`


assert isinstance(cursor, dict), "<STR_LIT>"<EOL>query = self.get_query()<EOL>assert isinstance(query, peewee.Query)<EOL>query<EOL>return query.get(**cursor)<EOL>


return self.query<EOL>


fake = Faker()<EOL>fake.seed(<NUM_LIT:0>)<EOL>cities = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>items = []<EOL>for x in range(<NUM_LIT:100>):<EOL><INDENT>city = cities[x % len(cities)]<EOL>items += [dict(name=fake.name(), city=city)]<EOL><DEDENT>Person.insert_many(items).execute()<EOL>assert Person.select().count() == <NUM_LIT:100><EOL>

Populate test models with (predictable) fake data


Install polyaxon using the current config to the correct platform.


@classmethod<EOL><INDENT>def find_matching(cls, path, patterns):<DEDENT>

for pattern in patterns:<EOL><INDENT>if pattern.match(path):<EOL><INDENT>yield pattern<EOL><DEDENT><DEDENT>


for glob in patterns:<EOL><INDENT>try:<EOL><INDENT>if PurePath(path).match(glob):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>except TypeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return False<EOL>

Given a list of patterns, returns a if a path matches any pattern.


@classmethod<EOL><INDENT>def _ignore_path(cls, path, ignore_list=None, white_list=None):<DEDENT>

ignore_list = ignore_list or []<EOL>white_list = white_list or []<EOL>return (cls._matches_patterns(path, ignore_list) and<EOL>not cls._matches_patterns(path, white_list))<EOL>

Returns a whether a path should be ignored or not.


@click.group()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True, default=False, help='<STR_LIT>')<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def cli(context, verbose):

configure_logger(verbose or GlobalConfigManager.get_value('<STR_LIT>'))<EOL>non_check_cmds = ['<STR_LIT>', '<STR_LIT:version>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>if context.invoked_subcommand not in non_check_cmds:<EOL><INDENT>check_cli_version()<EOL><DEDENT>

Polyaxon CLI tool to:

        * Parse, Validate, and Check Polyaxonfiles.

        * Interact with Polyaxon server.

        * Run and Monitor experiments.

    Check the help available for each command listed below.


click.echo(<EOL>json.dumps(value,<EOL>sort_keys=True,<EOL>indent=<NUM_LIT:4>,<EOL>separators=('<STR_LIT:U+002C>', '<STR_LIT>')))<EOL>


@config.command()<EOL>@click.option('<STR_LIT>', type=bool, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=str, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=int, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=int, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=bool, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=bool,<EOL>help='<STR_LIT>')<EOL>@clean_outputs<EOL>def set(verbose,  <EOL>host,<EOL>http_port,<EOL>ws_port,<EOL>use_https,<EOL>verify_ssl):

_config = GlobalConfigManager.get_config_or_default()<EOL>if verbose is not None:<EOL><INDENT>_config.verbose = verbose<EOL><DEDENT>if host is not None:<EOL><INDENT>_config.host = host<EOL><DEDENT>if http_port is not None:<EOL><INDENT>_config.http_port = http_port<EOL><DEDENT>if ws_port is not None:<EOL><INDENT>_config.ws_port = ws_port<EOL><DEDENT>if use_https is not None:<EOL><INDENT>_config.use_https = use_https<EOL><DEDENT>if verify_ssl is False:<EOL><INDENT>_config.verify_ssl = verify_ssl<EOL><DEDENT>GlobalConfigManager.set_config(_config)<EOL>Printer.print_success('<STR_LIT>')<EOL>CliConfigManager.purge()<EOL>

Set the global config values.

    Example:

    \b
    ```bash
    $ polyaxon config set --hots=localhost http_port=80
    ```


@click.group(invoke_without_command=True)<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True, help='<STR_LIT>')<EOL>@clean_outputs<EOL>def config(list):

if list:<EOL><INDENT>_config = GlobalConfigManager.get_config_or_default()<EOL>Printer.print_header('<STR_LIT>')<EOL>dict_tabulate(_config.to_dict())<EOL><DEDENT>


@config.command()<EOL>@click.argument('<STR_LIT>', type=str, nargs=-<NUM_LIT:1>)<EOL>@clean_outputs<EOL>def get(keys):

_config = GlobalConfigManager.get_config_or_default()<EOL>if not keys:<EOL><INDENT>return<EOL><DEDENT>print_values = {}<EOL>for key in keys:<EOL><INDENT>if hasattr(_config, key):<EOL><INDENT>print_values[key] = getattr(_config, key)<EOL><DEDENT>else:<EOL><INDENT>click.echo('<STR_LIT>'.format(key))<EOL><DEDENT><DEDENT>dict_tabulate(print_values, )<EOL>

Get the global config values by keys.

    Example:

    \b
    ```bash
    $ polyaxon config get host http_port
    ```


try:<EOL><INDENT>pip_upgrade(PROJECT_CLI_NAME)<EOL><DEDENT>except Exception as e:<EOL><INDENT>logger.error(e)<EOL><DEDENT>


@admin.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=click.Path(exists=True),<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=click.Path(exists=True),<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>')<EOL>@clean_outputs<EOL>def deploy(file, manager_path, check, dry_run):

config = read_deployment_config(file)<EOL>manager = DeployManager(config=config,<EOL>filepath=file,<EOL>manager_path=manager_path,<EOL>dry_run=dry_run)<EOL>exception = None<EOL>if check:<EOL><INDENT>manager.check()<EOL>Printer.print_success('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>manager.install()<EOL><DEDENT>except Exception as e:<EOL><INDENT>Printer.print_error('<STR_LIT>')<EOL>exception = e<EOL><DEDENT><DEDENT>if exception:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(exception))<EOL><DEDENT>


@click.group()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=str, help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=int, help="<STR_LIT>")<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def build(ctx, project, build):

ctx.obj = ctx.obj or {}<EOL>ctx.obj['<STR_LIT>'] = project<EOL>ctx.obj['<STR_LIT>'] = build<EOL>


user, project_name, _build = get_build_or_local(ctx.obj.get('<STR_LIT>'), ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>PolyaxonClient().build_job.unbookmark(user, project_name, _build)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_build))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success("<STR_LIT>")<EOL>

Unbookmark build job.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon build unbookmark
    ```

    \b
    ```bash
    $ polyaxon build -b 2 unbookmark
    ```


user, project_name, _build = get_build_or_local(ctx.obj.get('<STR_LIT>'), ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>PolyaxonClient().build_job.bookmark(user, project_name, _build)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_build))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success("<STR_LIT>")<EOL>

Bookmark build job.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon build bookmark
    ```

    \b
    ```bash
    $ polyaxon build -b 2 bookmark
    ```


@build.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True, help='<STR_LIT>')<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def resources(ctx, gpu):

user, project_name, _build = get_build_or_local(ctx.obj.get('<STR_LIT>'), ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>message_handler = Printer.gpu_resources if gpu else Printer.resources<EOL>PolyaxonClient().build_job.resources(user,<EOL>project_name,<EOL>_build,<EOL>message_handler=message_handler)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_build))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>

Get build job resources.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon build -b 2 resources
    ```

    For GPU resources

    \b
    ```bash
    $ polyaxon build -b 2 resources --gpu
    ```


@build.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True, default=False,<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>")<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def stop(ctx, yes):

user, project_name, _build = get_build_or_local(ctx.obj.get('<STR_LIT>'), ctx.obj.get('<STR_LIT>'))<EOL>if not yes and not click.confirm("<STR_LIT>"<EOL>"<STR_LIT>".format(_build)):<EOL><INDENT>click.echo('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>try:<EOL><INDENT>PolyaxonClient().build_job.stop(user, project_name, _build)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_build))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success("<STR_LIT>")<EOL>

Stop build job.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon build stop
    ```

    \b
    ```bash
    $ polyaxon build -b 2 stop
    ```


user, project_name, _build = get_build_or_local(ctx.obj.get('<STR_LIT>'), ctx.obj.get('<STR_LIT>'))<EOL>if not click.confirm("<STR_LIT>".format(_build)):<EOL><INDENT>click.echo('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>try:<EOL><INDENT>response = PolyaxonClient().build_job.delete_build(<EOL>user, project_name, _build)<EOL>BuildJobManager.purge()<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_build))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if response.status_code == <NUM_LIT>:<EOL><INDENT>Printer.print_success("<STR_LIT>".format(_build))<EOL><DEDENT>

Delete build job.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Example:

    \b
    ```bash
    $ polyaxon build delete
    ```

    \b
    ```bash
    $ polyaxon build -b 2 delete
    ```


@build.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True, help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True, default=False,<EOL>help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help="<STR_LIT>")<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def logs(ctx, past, follow, hide_time):

user, project_name, _build = get_build_or_local(ctx.obj.get('<STR_LIT>'), ctx.obj.get('<STR_LIT>'))<EOL>if past:<EOL><INDENT>try:<EOL><INDENT>response = PolyaxonClient().build_job.logs(<EOL>user, project_name, _build, stream=False)<EOL>get_logs_handler(handle_job_info=False,<EOL>show_timestamp=not hide_time,<EOL>stream=False)(response.content.decode().split('<STR_LIT:\n>'))<EOL>print()<EOL>if not follow:<EOL><INDENT>return<EOL><DEDENT><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>if not follow:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_build))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT><DEDENT>try:<EOL><INDENT>PolyaxonClient().build_job.logs(<EOL>user,<EOL>project_name,<EOL>_build,<EOL>message_handler=get_logs_handler(handle_job_info=False, show_timestamp=not hide_time))<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_build))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>

Get build logs.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon build -b 2 logs
    ```

    \b
    ```bash
    $ polyaxon build logs
    ```


@click.group()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=str, help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=int, help="<STR_LIT>")<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def job(ctx, project, job):

ctx.obj = ctx.obj or {}<EOL>ctx.obj['<STR_LIT>'] = project<EOL>ctx.obj['<STR_LIT>'] = job<EOL>


user, project_name, _job = get_job_or_local(ctx.obj.get('<STR_LIT>'), ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>response = PolyaxonClient().job.get_job(user, project_name, _job)<EOL>cache.cache(config_manager=JobManager, response=response)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_job))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>get_job_details(response)<EOL>

Get job.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon job --job=1 get
    ```

    \b
    ```bash
    $ polyaxon job --job=1 --project=project_name get
    ```


user, project_name, _job = get_job_or_local(ctx.obj.get('<STR_LIT>'), ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>PolyaxonClient().job.bookmark(user, project_name, _job)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_job))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success("<STR_LIT>")<EOL>

Bookmark job.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon job bookmark
    ```

    \b
    ```bash
    $ polyaxon job -xp 2 bookmark
    ```


@job.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True, help='<STR_LIT>')<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def resources(ctx, gpu):

user, project_name, _job = get_job_or_local(ctx.obj.get('<STR_LIT>'), ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>message_handler = Printer.gpu_resources if gpu else Printer.resources<EOL>PolyaxonClient().job.resources(user,<EOL>project_name,<EOL>_job,<EOL>message_handler=message_handler)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_job))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>

Get job resources.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon job -j 2 resources
    ```

    For GPU resources

    \b
    ```bash
    $ polyaxon job -j 2 resources --gpu
    ```


user, project_name, _job = get_job_or_local(ctx.obj.get('<STR_LIT>'), ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>PolyaxonClient().job.unbookmark(user, project_name, _job)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_job))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success("<STR_LIT>")<EOL>

Unbookmark job.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon job unbookmark
    ```

    \b
    ```bash
    $ polyaxon job -xp 2 unbookmark
    ```


@job.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT:-c>', is_flag=True, default=False,<EOL>help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', '<STR_LIT>', multiple=True, type=click.Path(exists=True),<EOL>help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help="<STR_LIT>")<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def restart(ctx, copy, file, u):

config = None<EOL>update_code = None<EOL>if file:<EOL><INDENT>config = rhea.read(file)<EOL><DEDENT>if u:<EOL><INDENT>ctx.invoke(upload, sync=False)<EOL>update_code = True<EOL><DEDENT>user, project_name, _job = get_job_or_local(ctx.obj.get('<STR_LIT>'), ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>if copy:<EOL><INDENT>response = PolyaxonClient().job.copy(<EOL>user, project_name, _job, config=config, update_code=update_code)<EOL><DEDENT>else:<EOL><INDENT>response = PolyaxonClient().job.restart(<EOL>user, project_name, _job, config=config, update_code=update_code)<EOL><DEDENT><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_job))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>get_job_details(response)<EOL>

Restart job.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon job --job=1 restart
    ```


try:<EOL><INDENT>user = PolyaxonClient().auth.get_user()<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>')<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>click.echo("<STR_LIT>".format(**user.to_dict()))<EOL>


specification = None<EOL>job_config = None<EOL>if file:<EOL><INDENT>specification = check_polyaxonfile(file, log=False).specification<EOL><DEDENT>if specification:<EOL><INDENT>check_polyaxonfile_kind(specification=specification, kind=specification._TENSORBOARD)<EOL>job_config = specification.parsed_data<EOL><DEDENT>user, project_name = get_project_or_local(ctx.obj.get('<STR_LIT>'))<EOL>group = ctx.obj.get('<STR_LIT>')<EOL>experiment = ctx.obj.get('<STR_LIT>')<EOL>if experiment:<EOL><INDENT>try:<EOL><INDENT>response = PolyaxonClient().experiment.start_tensorboard(<EOL>username=user,<EOL>project_name=project_name,<EOL>experiment_id=experiment,<EOL>job_config=job_config)<EOL>obj = '<STR_LIT>'.format(experiment)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(experiment))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>elif group:<EOL><INDENT>try:<EOL><INDENT>response = PolyaxonClient().experiment_group.start_tensorboard(<EOL>username=user,<EOL>project_name=project_name,<EOL>group_id=group,<EOL>job_config=job_config)<EOL>obj = '<STR_LIT>'.format(group)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(group))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>response = PolyaxonClient().project.start_tensorboard(<EOL>username=user,<EOL>project_name=project_name,<EOL>job_config=job_config)<EOL>obj = '<STR_LIT>'.format(project_name)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(project_name))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>if response.status_code == <NUM_LIT:200>:<EOL><INDENT>Printer.print_header("<STR_LIT>".format(obj))<EOL>click.echo(get_tensorboard_url(user=user,<EOL>project_name=project_name,<EOL>experiment=experiment,<EOL>group=group))<EOL>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>if response.status_code != <NUM_LIT>:<EOL><INDENT>Printer.print_error('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success('<STR_LIT>'.format(obj))<EOL>clint.textui.puts("<STR_LIT>")<EOL>clint.textui.puts("<STR_LIT>")<EOL>with clint.textui.indent(<NUM_LIT:4>):<EOL><INDENT>clint.textui.puts(get_tensorboard_url(user, project_name, experiment, group))<EOL><DEDENT>

Start a tensorboard deployment for project/experiment/experiment group.

    Project tensorboard will aggregate all experiments under the project.

    Experiment group tensorboard will aggregate all experiments under the group.

    Experiment tensorboard will show all metrics for an experiment.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Example: using the default tensorflow image 1.4.1.

    \b
    ```bash
    $ polyaxon tensorboard start
    ```

    Example: with custom image and resources

    \b
    ```bash
    $ polyaxon tensorboard start -f file -f file_override ...
    ```

    Example: starting a tensorboard for an experiment group

    \b
    ```bash
    $ polyaxon tensorboard -g 1 start -f file
    ```

    Example: starting a tensorboard for an experiment

    \b
    ```bash
    $ polyaxon tensorboard -xp 112 start -f file
    ```


@click.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=str)<EOL>@click.option('<STR_LIT>', '<STR_LIT>', multiple=True, type=click.Path(exists=True),<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=str,<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=str, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=str,<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=int,<EOL>help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>')<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def run(ctx, project, file, name, tags, description, ttl, u, l):

if not file:<EOL><INDENT>file = PolyaxonFile.check_default_path(path='<STR_LIT:.>')<EOL><DEDENT>if not file:<EOL><INDENT>file = '<STR_LIT>'<EOL><DEDENT>specification = check_polyaxonfile(file, log=False).specification<EOL>spec_cond = (specification.is_experiment or<EOL>specification.is_group or<EOL>specification.is_job or<EOL>specification.is_build)<EOL>if not spec_cond:<EOL><INDENT>Printer.print_error(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(specification.kind))<EOL>if specification.is_notebook:<EOL><INDENT>click.echo('<STR_LIT>')<EOL><DEDENT>elif specification.is_tensorboard:<EOL><INDENT>click.echo('<STR_LIT>')<EOL><DEDENT>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if u:<EOL><INDENT>if project:<EOL><INDENT>Printer.print_error('<STR_LIT>')<EOL>click.echo('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>ctx.invoke(upload, sync=False)<EOL><DEDENT>user, project_name = get_project_or_local(project)<EOL>project_client = PolyaxonClient().project<EOL>tags = validate_tags(tags)<EOL>def run_experiment():<EOL><INDENT>click.echo('<STR_LIT>')<EOL>experiment = ExperimentConfig(<EOL>name=name,<EOL>description=description,<EOL>tags=tags,<EOL>config=specification.parsed_data,<EOL>ttl=ttl)<EOL>try:<EOL><INDENT>response = PolyaxonClient().project.create_experiment(user,<EOL>project_name,<EOL>experiment)<EOL>cache.cache(config_manager=ExperimentManager, response=response)<EOL>Printer.print_success('<STR_LIT>'.format(response.id))<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>')<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>def run_group():<EOL><INDENT>click.echo('<STR_LIT>')<EOL>experiments_def = specification.experiments_def<EOL>get_group_experiments_info(**experiments_def)<EOL>experiment_group = ExperimentGroupConfig(<EOL>name=name,<EOL>description=description,<EOL>tags=tags,<EOL>content=specification._data)  <EOL>try:<EOL><INDENT>response = project_client.create_experiment_group(user,<EOL>project_name,<EOL>experiment_group)<EOL>cache.cache(config_manager=GroupManager, response=response)<EOL>Printer.print_success('<STR_LIT>'.format(response.id))<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>')<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>def run_job():<EOL><INDENT>click.echo('<STR_LIT>')<EOL>job = JobConfig(<EOL>name=name,<EOL>description=description,<EOL>tags=tags,<EOL>config=specification.parsed_data,<EOL>ttl=ttl)<EOL>try:<EOL><INDENT>response = project_client.create_job(user,<EOL>project_name,<EOL>job)<EOL>cache.cache(config_manager=JobManager, response=response)<EOL>Printer.print_success('<STR_LIT>'.format(response.id))<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>')<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>def run_build():<EOL><INDENT>click.echo('<STR_LIT>')<EOL>job = JobConfig(<EOL>name=name,<EOL>description=description,<EOL>tags=tags,<EOL>config=specification.parsed_data,<EOL>ttl=ttl)<EOL>try:<EOL><INDENT>response = project_client.create_build(user,<EOL>project_name,<EOL>job)<EOL>cache.cache(config_manager=BuildJobManager, response=response)<EOL>Printer.print_success('<STR_LIT>'.format(response.id))<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>')<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>logs = None<EOL>if specification.is_experiment:<EOL><INDENT>run_experiment()<EOL>logs = experiment_logs<EOL><DEDENT>elif specification.is_group:<EOL><INDENT>run_group()<EOL><DEDENT>elif specification.is_job:<EOL><INDENT>run_job()<EOL>logs = job_logs<EOL><DEDENT>elif specification.is_build:<EOL><INDENT>run_build()<EOL>logs = build_logs<EOL><DEDENT>if l and logs:<EOL><INDENT>ctx.obj = {'<STR_LIT>': '<STR_LIT>'.format(user, project_name)}<EOL>ctx.invoke(logs)<EOL><DEDENT>

Run polyaxonfile specification.

    Examples:

    \b
    ```bash
    $ polyaxon run -f file -f file_override ...
    ```

    Upload before running

    \b
    ```bash
    $ polyaxon run -f file -u
    ```

    Run and set description and tags for this run

    \b
    ```bash
    $ polyaxon run -f file -u --description="Description of the current run" --tags="foo, bar, moo"
    ```
    Run and set a unique name for this run

    \b
    ```bash
    polyaxon run --name=foo
    ```

    Run for a specific project

    \b
    ```bash
    $ polyaxon run -p project1 -f file.yaml
    ```


Delete a user.

    Example:

    \b
    ```bash
    $ polyaxon user delete david
    ```


@click.group()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=str, help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=int, help="<STR_LIT>")<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def experiment(ctx, project, experiment):

ctx.obj = ctx.obj or {}<EOL>ctx.obj['<STR_LIT>'] = project<EOL>ctx.obj['<STR_LIT>'] = experiment<EOL>


@experiment.command()<EOL>@click.option('<STR_LIT>', type=str,<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=str, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=str, help='<STR_LIT>')<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def update(ctx, name, description, tags):

user, project_name, _experiment = get_project_experiment_or_local(ctx.obj.get('<STR_LIT>'),<EOL>ctx.obj.get('<STR_LIT>'))<EOL>update_dict = {}<EOL>if name:<EOL><INDENT>update_dict['<STR_LIT:name>'] = name<EOL><DEDENT>if description:<EOL><INDENT>update_dict['<STR_LIT:description>'] = description<EOL><DEDENT>tags = validate_tags(tags)<EOL>if tags:<EOL><INDENT>update_dict['<STR_LIT>'] = tags<EOL><DEDENT>if not update_dict:<EOL><INDENT>Printer.print_warning('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>try:<EOL><INDENT>response = PolyaxonClient().experiment.update_experiment(<EOL>user, project_name, _experiment, update_dict)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_experiment))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success("<STR_LIT>")<EOL>get_experiment_details(response)<EOL>

Update experiment.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon experiment -xp 2 update --description="new description for my experiments"
    ```

    \b
    ```bash
    $ polyaxon experiment -xp 2 update --tags="foo, bar" --name="unique-name"
    ```


user, project_name, _experiment = get_project_experiment_or_local(ctx.obj.get('<STR_LIT>'),<EOL>ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>PolyaxonClient().experiment.download_outputs(user, project_name, _experiment)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_experiment))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success('<STR_LIT>')<EOL>

Download outputs for experiment.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon experiment -xp 1 outputs
    ```


@experiment.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True, default=False,<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>")<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def stop(ctx, yes):

user, project_name, _experiment = get_project_experiment_or_local(ctx.obj.get('<STR_LIT>'),<EOL>ctx.obj.get('<STR_LIT>'))<EOL>if not yes and not click.confirm("<STR_LIT>"<EOL>"<STR_LIT>".format(_experiment)):<EOL><INDENT>click.echo('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>try:<EOL><INDENT>PolyaxonClient().experiment.stop(user, project_name, _experiment)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_experiment))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success("<STR_LIT>")<EOL>

Stop experiment.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon experiment stop
    ```

    \b
    ```bash
    $ polyaxon experiment -xp 2 stop
    ```


user, project_name, _experiment = get_project_experiment_or_local(ctx.obj.get('<STR_LIT>'),<EOL>ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>PolyaxonClient().experiment.unbookmark(user, project_name, _experiment)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_experiment))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success("<STR_LIT>")<EOL>

Unbookmark experiment.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon experiment unbookmark
    ```

    \b
    ```bash
    $ polyaxon experiment -xp 2 unbookmark
    ```


@experiment.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=int, help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True, help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True, default=False,<EOL>help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help="<STR_LIT>")<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def logs(ctx, job, past, follow, hide_time):

def get_experiment_logs():<EOL><INDENT>if past:<EOL><INDENT>try:<EOL><INDENT>response = PolyaxonClient().experiment.logs(<EOL>user, project_name, _experiment, stream=False)<EOL>get_logs_handler(handle_job_info=True,<EOL>show_timestamp=not hide_time,<EOL>stream=False)(response.content.decode().split('<STR_LIT:\n>'))<EOL>print()<EOL>if not follow:<EOL><INDENT>return<EOL><DEDENT><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>if not follow:<EOL><INDENT>Printer.print_error(<EOL>'<STR_LIT>'.format(_experiment))<EOL>Printer.print_error(<EOL>'<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT><DEDENT>try:<EOL><INDENT>PolyaxonClient().experiment.logs(<EOL>user,<EOL>project_name,<EOL>_experiment,<EOL>message_handler=get_logs_handler(handle_job_info=True,<EOL>show_timestamp=not hide_time))<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_experiment))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>def get_experiment_job_logs():<EOL><INDENT>if past:<EOL><INDENT>try:<EOL><INDENT>response = PolyaxonClient().experiment_job.logs(<EOL>user,<EOL>project_name,<EOL>_experiment,<EOL>_job,<EOL>stream=False)<EOL>get_logs_handler(handle_job_info=True,<EOL>show_timestamp=not hide_time,<EOL>stream=False)(response.content.decode().split('<STR_LIT:\n>'))<EOL>print()<EOL>if not follow:<EOL><INDENT>return<EOL><DEDENT><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>if not follow:<EOL><INDENT>Printer.print_error(<EOL>'<STR_LIT>'.format(_experiment))<EOL>Printer.print_error(<EOL>'<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT><DEDENT>try:<EOL><INDENT>PolyaxonClient().experiment_job.logs(<EOL>user,<EOL>project_name,<EOL>_experiment,<EOL>_job,<EOL>message_handler=get_logs_handler(handle_job_info=True,<EOL>show_timestamp=not hide_time))<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_job))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>user, project_name, _experiment = get_project_experiment_or_local(ctx.obj.get('<STR_LIT>'),<EOL>ctx.obj.get('<STR_LIT>'))<EOL>if job:<EOL><INDENT>_job = get_experiment_job_or_local(job)<EOL>get_experiment_job_logs()<EOL><DEDENT>else:<EOL><INDENT>get_experiment_logs()<EOL><DEDENT>

Get experiment or experiment job logs.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples for getting experiment logs:

    \b
    ```bash
    $ polyaxon experiment logs
    ```

    \b
    ```bash
    $ polyaxon experiment -xp 10 -p mnist logs
    ```

    Examples for getting experiment job logs:

    \b
    ```bash
    $ polyaxon experiment -xp 1 -j 1 logs
    ```


@experiment.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT:-c>', is_flag=True, default=False,<EOL>help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', '<STR_LIT>', multiple=True, type=click.Path(exists=True),<EOL>help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help="<STR_LIT>")<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def restart(ctx, copy, file, u):

config = None<EOL>update_code = None<EOL>if file:<EOL><INDENT>config = rhea.read(file)<EOL><DEDENT>if u:<EOL><INDENT>ctx.invoke(upload, sync=False)<EOL>update_code = True<EOL><DEDENT>user, project_name, _experiment = get_project_experiment_or_local(ctx.obj.get('<STR_LIT>'),<EOL>ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>if copy:<EOL><INDENT>response = PolyaxonClient().experiment.copy(<EOL>user, project_name, _experiment, config=config, update_code=update_code)<EOL>Printer.print_success('<STR_LIT>'.format(response.id))<EOL><DEDENT>else:<EOL><INDENT>response = PolyaxonClient().experiment.restart(<EOL>user, project_name, _experiment, config=config, update_code=update_code)<EOL>Printer.print_success('<STR_LIT>'.format(response.id))<EOL><DEDENT><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_experiment))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>

Restart experiment.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon experiment --experiment=1 restart
    ```


user, project_name, _experiment = get_project_experiment_or_local(ctx.obj.get('<STR_LIT>'),<EOL>ctx.obj.get('<STR_LIT>'))<EOL>if not click.confirm("<STR_LIT>".format(_experiment)):<EOL><INDENT>click.echo('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>try:<EOL><INDENT>response = PolyaxonClient().experiment.delete_experiment(<EOL>user, project_name, _experiment)<EOL>ExperimentManager.purge()<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_experiment))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if response.status_code == <NUM_LIT>:<EOL><INDENT>Printer.print_success("<STR_LIT>".format(_experiment))<EOL><DEDENT>

Delete experiment.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Example:

    \b
    ```bash
    $ polyaxon experiment delete
    ```


@notebook.command()<EOL>@click.option('<STR_LIT>', type=bool,<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>')<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def stop(ctx, commit, yes):

user, project_name = get_project_or_local(ctx.obj.get('<STR_LIT>'))<EOL>if not yes and not click.confirm("<STR_LIT>"<EOL>"<STR_LIT>".format(user, project_name)):<EOL><INDENT>click.echo('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if commit is None:<EOL><INDENT>commit = True<EOL><DEDENT>try:<EOL><INDENT>PolyaxonClient().project.stop_notebook(user, project_name, commit)<EOL>Printer.print_success('<STR_LIT>')<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(project_name))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>

Stops the notebook deployment for this project if it exists.

    Uses [Caching](/references/polyaxon-cli/#caching)


user, project_name = get_project_or_local(ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>response = PolyaxonClient().project.get_project(user, project_name)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(project_name))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if response.has_notebook:<EOL><INDENT>click.echo(get_notebook_url(user, project_name))<EOL><DEDENT>else:<EOL><INDENT>Printer.print_warning(<EOL>'<STR_LIT>'.format(project_name))<EOL>click.echo('<STR_LIT>')<EOL><DEDENT>

Prints the notebook url for this project.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Example:

    \b
    ```bash
    $ polyaxon notebook url
    ```


@notebook.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', multiple=True, type=click.Path(exists=True),<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>')<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def start(ctx, file, u):

specification = None<EOL>job_config = None<EOL>if file:<EOL><INDENT>specification = check_polyaxonfile(file, log=False).specification<EOL><DEDENT>if u:<EOL><INDENT>ctx.invoke(upload, sync=False)<EOL><DEDENT>if specification:<EOL><INDENT>check_polyaxonfile_kind(specification=specification, kind=specification._NOTEBOOK)<EOL>job_config = specification.parsed_data<EOL><DEDENT>user, project_name = get_project_or_local(ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>response = PolyaxonClient().project.start_notebook(user, project_name, job_config)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(project_name))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if response.status_code == <NUM_LIT:200>:<EOL><INDENT>Printer.print_header("<STR_LIT>")<EOL>click.echo(get_notebook_url(user, project_name))<EOL>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>if response.status_code != <NUM_LIT>:<EOL><INDENT>Printer.print_error('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success('<STR_LIT>'.format(project_name))<EOL>clint.textui.puts("<STR_LIT>")<EOL>clint.textui.puts("<STR_LIT>")<EOL>with clint.textui.indent(<NUM_LIT:4>):<EOL><INDENT>clint.textui.puts(get_notebook_url(user, project_name))<EOL><DEDENT>

Start a notebook deployment for this project.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Example:

    \b
    ```bash
    $ polyaxon notebook start -f file -f file_override ...
    ```

    Example: upload before running

    \b
    ```bash
    $ polyaxon -p user12/mnist notebook start -f file -u
    ```


@project.command()<EOL>@click.option('<STR_LIT>', type=int, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=str,<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=str, help='<STR_LIT>')<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def tensorboards(ctx, query, sort, page):

user, project_name = get_project_or_local(ctx.obj.get('<STR_LIT>'))<EOL>page = page or <NUM_LIT:1><EOL>try:<EOL><INDENT>response = PolyaxonClient().project.list_tensorboards(username=user,<EOL>project_name=project_name,<EOL>query=query,<EOL>sort=sort,<EOL>page=page)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(project_name))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>meta = get_meta_response(response)<EOL>if meta:<EOL><INDENT>Printer.print_header('<STR_LIT>'.format(user, project_name))<EOL>Printer.print_header('<STR_LIT>')<EOL>dict_tabulate(meta)<EOL><DEDENT>else:<EOL><INDENT>Printer.print_header('<STR_LIT>'.format(user,<EOL>project_name))<EOL><DEDENT>objects = [Printer.add_status_color(o.to_light_dict(humanize_values=True))<EOL>for o in response['<STR_LIT>']]<EOL>objects = list_dicts_to_tabulate(objects)<EOL>if objects:<EOL><INDENT>Printer.print_header("<STR_LIT>")<EOL>objects.pop('<STR_LIT>', None)<EOL>dict_tabulate(objects, is_list_dict=True)<EOL><DEDENT>

List tensorboard jobs for this project.

    Uses [Caching](/references/polyaxon-cli/#caching)


user, project_name = get_project_or_local(ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>PolyaxonClient().project.unbookmark(user, project_name)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(user, project_name))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success("<STR_LIT>".format(user, project_name))<EOL>

Unbookmark project.

    Uses [Caching](/references/polyaxon-cli/#caching)


user, project_name = get_project_or_local(ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>response = PolyaxonClient().project.get_project(user, project_name)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(project_name))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>get_project_details(response)<EOL>

Get info for current project, by project_name, or user/project_name.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    To get current project:

    \b
    ```bash
    $ polyaxon project get
    ```

    To get a project by name

    \b
    ```bash
    $ polyaxon project get user/project
    ```


@project.command()<EOL>@click.option('<STR_LIT>', required=True, type=str,<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=str, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=str, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', is_flag=True, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', is_flag=True, help='<STR_LIT>')<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def create(ctx, name, description, tags, private, init):

try:<EOL><INDENT>tags = tags.split('<STR_LIT:U+002C>') if tags else None<EOL>project_dict = dict(name=name, description=description, is_public=not private, tags=tags)<EOL>project_config = ProjectConfig.from_dict(project_dict)<EOL><DEDENT>except ValidationError:<EOL><INDENT>Printer.print_error('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>try:<EOL><INDENT>_project = PolyaxonClient().project.create_project(project_config)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(name))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success("<STR_LIT>".format(_project.name))<EOL>if init:<EOL><INDENT>ctx.obj = {}<EOL>ctx.invoke(init_project, project=name)<EOL><DEDENT>

Create a new project.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Example:

    \b
    ```bash
    $ polyaxon project create --name=cats-vs-dogs --description="Image Classification with DL"
    ```


@bookmark.command()<EOL>@click.option('<STR_LIT>', type=int, help='<STR_LIT>')<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def builds(ctx, page):

user = get_username_or_local(ctx.obj.get('<STR_LIT:username>'))<EOL>page = page or <NUM_LIT:1><EOL>try:<EOL><INDENT>response = PolyaxonClient().bookmark.builds(username=user, page=page)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error(<EOL>'<STR_LIT>'.format(user))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>meta = get_meta_response(response)<EOL>if meta:<EOL><INDENT>Printer.print_header('<STR_LIT>'.format(user))<EOL>Printer.print_header('<STR_LIT>')<EOL>dict_tabulate(meta)<EOL><DEDENT>else:<EOL><INDENT>Printer.print_header('<STR_LIT>'.format(user))<EOL><DEDENT>objects = [Printer.add_status_color(o.to_light_dict(humanize_values=True))<EOL>for o in response['<STR_LIT>']]<EOL>objects = list_dicts_to_tabulate(objects)<EOL>if objects:<EOL><INDENT>Printer.print_header("<STR_LIT>")<EOL>dict_tabulate(objects, is_list_dict=True)<EOL><DEDENT>

List bookmarked builds for user.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon bookmark builds
    ```

    \b
    ```bash
    $ polyaxon bookmark -u adam builds
    ```


@click.group()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=str)<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def bookmark(ctx, username):

ctx.obj = ctx.obj or {}<EOL>ctx.obj['<STR_LIT:username>'] = username<EOL>


@bookmark.command()<EOL>@click.option('<STR_LIT>', type=int, help='<STR_LIT>')<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def groups(ctx, page):

user = get_username_or_local(ctx.obj.get('<STR_LIT:username>'))<EOL>page = page or <NUM_LIT:1><EOL>try:<EOL><INDENT>response = PolyaxonClient().bookmark.groups(username=user, page=page)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error(<EOL>'<STR_LIT>'.format(user))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>meta = get_meta_response(response)<EOL>if meta:<EOL><INDENT>Printer.print_header('<STR_LIT>'.format(user))<EOL>Printer.print_header('<STR_LIT>')<EOL>dict_tabulate(meta)<EOL><DEDENT>else:<EOL><INDENT>Printer.print_header('<STR_LIT>'.format(user))<EOL><DEDENT>objects = [Printer.add_status_color(o.to_light_dict(humanize_values=True))<EOL>for o in response['<STR_LIT>']]<EOL>objects = list_dicts_to_tabulate(objects)<EOL>if objects:<EOL><INDENT>Printer.print_header("<STR_LIT>")<EOL>dict_tabulate(objects, is_list_dict=True)<EOL><DEDENT>

List bookmarked experiment groups for user.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon bookmark groups
    ```

    \b
    ```bash
    $ polyaxon bookmark -u adam groups
    ```


user, project_name, _group = get_project_group_or_local(ctx.obj.get('<STR_LIT>'),<EOL>ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>response = PolyaxonClient().experiment_group.get_experiment_group(<EOL>user, project_name, _group)<EOL>cache.cache(config_manager=GroupManager, response=response)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_group))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>get_group_details(response)<EOL>

Get experiment group by uuid.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon group -g 13 get
    ```


@group.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>')<EOL>@click.option('<STR_LIT>', is_flag=True, default=False,<EOL>help='<STR_LIT>')<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def stop(ctx, yes, pending):

user, project_name, _group = get_project_group_or_local(ctx.obj.get('<STR_LIT>'),<EOL>ctx.obj.get('<STR_LIT>'))<EOL>if not yes and not click.confirm("<STR_LIT>"<EOL>"<STR_LIT>".format(_group)):<EOL><INDENT>click.echo('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>try:<EOL><INDENT>PolyaxonClient().experiment_group.stop(user, project_name, _group, pending=pending)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_group))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success("<STR_LIT>")<EOL>

Stop experiments in the group.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples: stop only pending experiments

    \b
    ```bash
    $ polyaxon group stop --pending
    ```

    Examples: stop all unfinished

    \b
    ```bash
    $ polyaxon group stop
    ```

    \b
    ```bash
    $ polyaxon group -g 2 stop
    ```


user, project_name, _group = get_project_group_or_local(ctx.obj.get('<STR_LIT>'),<EOL>ctx.obj.get('<STR_LIT>'))<EOL>try:<EOL><INDENT>PolyaxonClient().experiment_group.unbookmark(user, project_name, _group)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_group))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success("<STR_LIT>")<EOL>

Unbookmark group.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Examples:

    \b
    ```bash
    $ polyaxon group unbookmark
    ```

    \b
    ```bash
    $ polyaxon group -g 2 unbookmark
    ```


user, project_name, _group = get_project_group_or_local(ctx.obj.get('<STR_LIT>'),<EOL>ctx.obj.get('<STR_LIT>'))<EOL>if not click.confirm("<STR_LIT>".format(_group)):<EOL><INDENT>click.echo('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>try:<EOL><INDENT>response = PolyaxonClient().experiment_group.delete_experiment_group(<EOL>user, project_name, _group)<EOL>GroupManager.purge()<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_group))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if response.status_code == <NUM_LIT>:<EOL><INDENT>Printer.print_success("<STR_LIT>".format(_group))<EOL><DEDENT>

Delete experiment group.

    Uses [Caching](/references/polyaxon-cli/#caching)


@group.command()<EOL>@click.option('<STR_LIT>', type=str,<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=str, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=str, help='<STR_LIT>')<EOL>@click.pass_context<EOL>@clean_outputs<EOL>def update(ctx, name, description, tags):

user, project_name, _group = get_project_group_or_local(ctx.obj.get('<STR_LIT>'),<EOL>ctx.obj.get('<STR_LIT>'))<EOL>update_dict = {}<EOL>if name:<EOL><INDENT>update_dict['<STR_LIT:name>'] = name<EOL><DEDENT>if description:<EOL><INDENT>update_dict['<STR_LIT:description>'] = description<EOL><DEDENT>tags = validate_tags(tags)<EOL>if tags:<EOL><INDENT>update_dict['<STR_LIT>'] = tags<EOL><DEDENT>if not update_dict:<EOL><INDENT>Printer.print_warning('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>try:<EOL><INDENT>response = PolyaxonClient().experiment_group.update_experiment_group(<EOL>user, project_name, _group, update_dict)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(_group))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>Printer.print_success("<STR_LIT>")<EOL>get_group_details(response)<EOL>

Update experiment group.

    Uses [Caching](/references/polyaxon-cli/#caching)

    Example:

    \b
    ```bash
    $ polyaxon group -g 2 update --description="new description for this group"
    ```

    \b
    ```bash
    $ polyaxon update --tags="foo, bar"
    ```


Grant superuser role to a user.

    Example:

    \b
    ```bash
    $ polyaxon superuser grant david
    ```


@click.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=int, help='<STR_LIT>')<EOL>@clean_outputs<EOL>def cluster(node):

cluster_client = PolyaxonClient().cluster<EOL>if node:<EOL><INDENT>try:<EOL><INDENT>node_config = cluster_client.get_node(node)<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>'.format(node))<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>get_node_info(node_config)<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>cluster_config = cluster_client.get_cluster()<EOL><DEDENT>except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:<EOL><INDENT>Printer.print_error('<STR_LIT>')<EOL>Printer.print_error('<STR_LIT>'.format(e))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>get_cluster_info(cluster_config)<EOL><DEDENT>


globals()[defn.__name__] = defn<EOL>__all__.append(defn.__name__)<EOL>return defn<EOL>

Decorator to explicitly mark functions that are exposed in a lib.


try:<EOL><INDENT>filep, pathname, description = imp.find_module(link_type, sys.path)<EOL>link_type_module = imp.load_module(link_type, filep, pathname,<EOL>description)<EOL><DEDENT>except ImportError:<EOL><INDENT>return None<EOL><DEDENT>finally:<EOL><INDENT>if filep:<EOL><INDENT>filep.close()<EOL><DEDENT><DEDENT>return link_type_module<EOL>

Given a string for a given module, attempt to load it.


res = __get_ll_type__(ll_type)<EOL>if res:<EOL><INDENT>return res[<NUM_LIT:3>]<EOL><DEDENT>else:<EOL><INDENT>return res<EOL><DEDENT>

Given an ll_type, retrieve the linklayer constructor to decode
the packets.


res = [llt for llt in __LL_TYPES__<EOL>if llt[<NUM_LIT:1>] == ll_type]<EOL>assert len(res) < <NUM_LIT:2>, '<STR_LIT>'<EOL>if res:<EOL><INDENT>return res[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>

Given an lltype value, retrieve its definition.


res = __get_ll_type__(ll_type)<EOL>if res:<EOL><INDENT>return res[<NUM_LIT:2>]<EOL><DEDENT>else:<EOL><INDENT>return res<EOL><DEDENT>

Given an ll_type, retrieve the short name for the link layer.


def _generate_packets(file_h, header, layers=<NUM_LIT:0>):

hdrp = ctypes.pointer(header)<EOL>while True:<EOL><INDENT>pkt = _read_a_packet(file_h, hdrp, layers)<EOL>if pkt:<EOL><INDENT>yield pkt<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>

Read packets one by one from the capture file. Expects the file
handle to point to the location immediately after the header (24
bytes).


self.capfile = savefile.load_savefile(open('<STR_LIT>', '<STR_LIT:r>'),<EOL>layers=layers)<EOL>


Print a start message when loading the test suite.


tfile = create_pcap()<EOL>self.capfile = savefile.load_savefile(tfile, layers=layers)<EOL>tfile.close()<EOL>if os.path.exists(tfile.name):<EOL><INDENT>os.unlink(tfile.name)<EOL><DEDENT>


tfile = tempfile.NamedTemporaryFile()<EOL>if sys.version_info[<NUM_LIT:0>] >= <NUM_LIT:3>:  <EOL><INDENT>capture = pickle.loads(base64.b64decode(fixture.TESTPCAP3))<EOL><DEDENT>else:  <EOL><INDENT>capture = pickle.loads(fixture.TESTPCAP2.decode('<STR_LIT>'))<EOL><DEDENT>with open(tfile.name, '<STR_LIT:wb>') as f:<EOL><INDENT>f.write(capture)<EOL><DEDENT>return tfile<EOL>

Create a capture file from the test fixtures.


<EOL>if not self.capfile:<EOL><INDENT>self.init_capfile()<EOL><DEDENT>


raw = struct.pack('<STR_LIT:I>', address)<EOL>octets = struct.unpack('<STR_LIT>', raw)[::-<NUM_LIT:1>]<EOL>ipv4 = b'<STR_LIT:.>'.join([('<STR_LIT>' % o).encode('<STR_LIT:ascii>') for o in bytearray(octets)])<EOL>return ipv4<EOL>

Given a raw IPv4 address (i.e. as an unsigned integer), return it in
dotted quad notation.


if ethertype == <NUM_LIT>:<EOL><INDENT>from pcapfile.protocols.network.ip import IP<EOL>return (IP, '<STR_LIT>')<EOL>

Returns the appropriate payload constructor based on the supplied
EtherType.


llc = {}<EOL>snap = <NUM_LIT><EOL>llc_dsap = struct.unpack('<STR_LIT:B>', self._packet[idx:idx + <NUM_LIT:1>])[<NUM_LIT:0>]<EOL>llc['<STR_LIT>'] = llc_dsap >> <NUM_LIT:1><EOL>llc['<STR_LIT>'] = llc_dsap & <NUM_LIT><EOL>idx += <NUM_LIT:1><EOL>llc_ssap = struct.unpack('<STR_LIT:B>', self._packet[idx:idx + <NUM_LIT:1>])[<NUM_LIT:0>]<EOL>llc['<STR_LIT>'] = llc_ssap >> <NUM_LIT:1><EOL>llc['<STR_LIT>'] = llc_ssap & <NUM_LIT><EOL>idx += <NUM_LIT:1><EOL>if llc_dsap == snap and llc_ssap == snap:<EOL><INDENT>llc_control = struct.unpack('<STR_LIT:B>', self._packet[idx:idx + <NUM_LIT:1>])[<NUM_LIT:0>]<EOL>llc['<STR_LIT>'] = llc_control >> <NUM_LIT:2><EOL>llc['<STR_LIT>'] = llc_control & <NUM_LIT><EOL>idx += <NUM_LIT:1><EOL>llc['<STR_LIT>'] = self._packet[idx:idx + <NUM_LIT:3>]<EOL>idx += <NUM_LIT:3><EOL>llc['<STR_LIT:type>'] = self._packet[idx:idx + <NUM_LIT:2>]<EOL>return <NUM_LIT:8>, llc<EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:4>, llc<EOL><DEDENT>

strip(4 or 8 byte) logical link control headers
        :return: int
            number of processed bytes
        :return: dict
            llc information
        see -> http://www.wildpackets.com/resources/compendium/ethernet/frame_snap_iee8023
        ABBRVS.
        ssap: source service access point
        dsap: destination service access point
        SNAP(Subnetwork Acess Protocol)


idx = Radiotap.align(idx, <NUM_LIT:1>)<EOL>dbm_tx_power, = struct.unpack_from('<STR_LIT>', self._rtap, idx)<EOL>return idx + <NUM_LIT:1>, dbm_tx_power<EOL>

strip(1 byte) dbm_tx_power
        :return: int
            idx
        :return: int


def __init__(self, frame, no_rtap=False):

Wifi.__init__(self, frame, no_rtap)<EOL>self.tagged_params = []<EOL>self._raw_tagged_params = None<EOL>self.timestamp = None<EOL>self.interval = None<EOL>self.fixed_capabils = None<EOL>

Constructor Method
        :frame: ctypes.Structure
        :subtype: int


rx_flags = collections.namedtuple('<STR_LIT>', ['<STR_LIT>', '<STR_LIT>'])<EOL>idx = Radiotap.align(idx, <NUM_LIT:2>)<EOL>flags, = struct.unpack_from('<STR_LIT>', self._rtap, idx)<EOL>flag_bits = format(flags, '<STR_LIT>')[::-<NUM_LIT:1>]<EOL>rx_flags.reserved = int(flag_bits[<NUM_LIT:0>])<EOL>rx_flags.badplcp = int(flag_bits[<NUM_LIT:1>])<EOL>return idx + <NUM_LIT:2>, rx_flags<EOL>

strip(2 byte) radiotap.rxflags
        :idx: int
        :return: int
            idx
        :return: collections.namedtuple


qos_idx, seq_idx = <NUM_LIT:0>, <NUM_LIT:0><EOL>sa, ta, ra, da, bssid = None, None, None, None, None<EOL>if self.to_ds == <NUM_LIT:1> and self.from_ds == <NUM_LIT:1>:<EOL><INDENT>(ra, ta, da) = struct.unpack('<STR_LIT>', self._packet[<NUM_LIT:4>:<NUM_LIT>])<EOL>sa = struct.unpack('<STR_LIT>', self._packet[<NUM_LIT>:<NUM_LIT:30>])[<NUM_LIT:0>]<EOL>qos_idx = <NUM_LIT:30><EOL>seq_idx = <NUM_LIT><EOL><DEDENT>elif self.to_ds == <NUM_LIT:0> and self.from_ds == <NUM_LIT:1>:<EOL><INDENT>(ra, ta, sa) = struct.unpack('<STR_LIT>', self._packet[<NUM_LIT:4>:<NUM_LIT>])<EOL>qos_idx = <NUM_LIT><EOL>seq_idx = <NUM_LIT><EOL><DEDENT>elif self.to_ds == <NUM_LIT:1> and self.from_ds == <NUM_LIT:0>:<EOL><INDENT>(ra, ta, da) = struct.unpack('<STR_LIT>', self._packet[<NUM_LIT:4>:<NUM_LIT>])<EOL>qos_idx = <NUM_LIT><EOL>seq_idx = <NUM_LIT><EOL><DEDENT>elif self.to_ds == <NUM_LIT:0> and self.from_ds == <NUM_LIT:0>:<EOL><INDENT>(ra, ta, bssid) = struct.unpack('<STR_LIT>', self._packet[<NUM_LIT:4>:<NUM_LIT>])<EOL>qos_idx = <NUM_LIT><EOL>seq_idx = <NUM_LIT><EOL><DEDENT>if ta is not None:<EOL><INDENT>ta = Wifi.get_mac_addr(ta)<EOL><DEDENT>if ra is not None:<EOL><INDENT>ra = Wifi.get_mac_addr(ra)<EOL><DEDENT>if sa is not None:<EOL><INDENT>sa = Wifi.get_mac_addr(sa)<EOL><DEDENT>if da is not None:<EOL><INDENT>da = Wifi.get_mac_addr(da)<EOL><DEDENT>if bssid is not None:<EOL><INDENT>bssid = Wifi.get_mac_addr(bssid)<EOL><DEDENT>return seq_idx, qos_idx, sa, ta, ra, da, bssid<EOL>

strip mac address(each 6 byte) information.
        (wlan.ta, wlan.ra, wlan.sa, wlan.da)
        (transmitter, receiver, source, destination)
        :return: int
            index of sequence control
        :return: int
            index after mac addresses
        :return: str
            source address (sa)
        :return: str
            transmitter address (ta)
        :return: str
            receiver address (ra)
        :return: str
            destination address (da)
        :return: str
            basic service sed identifier (bssid)


super(Radiotap, self).__init__()<EOL>self._raw = {}   <EOL>self._bits = {}  <EOL>idx = <NUM_LIT:0><EOL>self._rtap = rtap_bytes<EOL>self.vers = Radiotap.strip_vers(self._rtap[idx:idx + <NUM_LIT:1>])<EOL>idx += <NUM_LIT:1><EOL>self.pad = Radiotap.strip_pad(self._rtap[idx:idx + <NUM_LIT:1>])<EOL>idx += <NUM_LIT:1><EOL>self.len = Radiotap.strip_len(self._rtap[idx:idx + <NUM_LIT:2>])<EOL>idx += <NUM_LIT:2><EOL>self.present, self.present_bits = Radiotap.strip_present(self._rtap[idx:idx + <NUM_LIT:4>])<EOL>idx += <NUM_LIT:4><EOL>if self.present.tsft:  <EOL><INDENT>idx, self.mactime = self.strip_tsft(idx)<EOL><DEDENT>if self.present.flags:  <EOL><INDENT>idx, self.flags = self.strip_flags(idx)<EOL><DEDENT>if self.present.rate:  <EOL><INDENT>idx, self.rate = self.strip_rate(idx)<EOL><DEDENT>if self.present.channel:  <EOL><INDENT>idx, self.chan = self.strip_chan(idx)<EOL><DEDENT>if self.present.fhss:  <EOL><INDENT>idx, self.fhss = self.strip_fhss(idx)<EOL><DEDENT>if self.present.dbm_antsignal:  <EOL><INDENT>idx, self.dbm_antsignal = self.strip_dbm_antsignal(idx)<EOL><DEDENT>if self.present.dbm_antnoise:  <EOL><INDENT>idx, self.dbm_antnoise = self.strip_dbm_antnoise(idx)<EOL><DEDENT>if self.present.lock_quality:  <EOL><INDENT>idx, self.lock_quality = self.strip_lock_quality(idx)<EOL><DEDENT>if self.present.tx_attenuation:  <EOL><INDENT>idx, self.tx_attenuation = self.strip_tx_attenuation(idx)<EOL><DEDENT>if self.present.db_tx_attenuation:  <EOL><INDENT>idx, self.db_tx_attenuation = self.strip_db_tx_attenuation(idx)<EOL><DEDENT>if self.present.dbm_tx_power:  <EOL><INDENT>idx, self.dbm_tx_power = self.strip_dbm_tx_power(idx)<EOL><DEDENT>if self.present.antenna:  <EOL><INDENT>idx, self.antenna = self.strip_antenna(idx)<EOL><DEDENT>if self.present.db_antsignal:  <EOL><INDENT>idx, self.db_antsignal = self.strip_db_antsignal(idx)<EOL><DEDENT>if self.present.db_antnoise:  <EOL><INDENT>idx, self.db_antnoise = self.strip_db_antnoise(idx)<EOL><DEDENT>if self.present.rxflags:  <EOL><INDENT>idx, self.rxflags = self.strip_rx_flags(idx)<EOL><DEDENT>if self.present.txflags:  <EOL><INDENT>idx, self.txflags = self.strip_tx_flags(idx)<EOL><DEDENT>if self.present.rts_retries:  <EOL><INDENT>idx, self.rts_retries = self.strip_rts_retries(idx)<EOL><DEDENT>if self.present.data_retries:  <EOL><INDENT>idx, self.data_retries = self.strip_data_retries(idx)<EOL><DEDENT>if self.present.xchannel:  <EOL><INDENT>idx, self.xchannel = self.strip_xchannel(idx)<EOL><DEDENT>if self.present.mcs:  <EOL><INDENT>idx, self.mcs = self.strip_mcs(idx)<EOL><DEDENT>if self.present.ampdu:  <EOL><INDENT>idx, self.ampdu = self.strip_ampdu(idx)<EOL><DEDENT>if self.present.vht:  <EOL><INDENT>idx, self.vht = self.strip_vht(idx)<EOL><DEDENT>self.prot_type = self.extract_protocol()<EOL>

Constructor method.
        :rtap_bytes: ctypes.Structure


cntrl = struct.unpack('<STR_LIT:H>', payload)[<NUM_LIT:0>]<EOL>cntrl_bits = format(cntrl, '<STR_LIT>')[::-<NUM_LIT:1>]<EOL>ackpolicy = int(cntrl_bits[<NUM_LIT:0>])<EOL>multitid = int(cntrl_bits[<NUM_LIT:1>])<EOL>return ackpolicy, multitid<EOL>

strip(2 byte) wlan.ba.control
        :payload: ctypes.structure
        :return: int
            multitid (tid: traffic indicator)
        :return: int
            ackpolicy


rts_retries, = struct.unpack_from('<STR_LIT>', self._rtap, idx)<EOL>return idx + <NUM_LIT:1>, rts_retries<EOL>

strip(1 byte) rts_retries
        :idx: int
        :return: int
            idx
        :return: int


Control.__init__(self, frame, no_rtap)<EOL>(ra_mac, ta_mac) = struct.unpack('<STR_LIT>', self._packet[<NUM_LIT:4>:<NUM_LIT:16>])<EOL>self.ra = self.ta = None<EOL>self.ackpolicy = self.multitid = None<EOL>self.ssc_frag = self.ssc_seq = None<EOL>self.bitmap_str = None<EOL>self.acked_seqs = []<EOL>self.ra = Wifi.get_mac_addr(ra_mac)<EOL>self.ta = Wifi.get_mac_addr(ta_mac)<EOL>idx = <NUM_LIT:16><EOL>payload = self._packet[idx:idx + <NUM_LIT:2>]<EOL>self.ackpolicy, self.multitid = BACK.strip_cntrl(payload)<EOL>idx += <NUM_LIT:2><EOL>payload = self._packet[idx:idx + <NUM_LIT:2>]<EOL>self.ssc_seq, self.ssc_frag = BACK.strip_ssc(payload)<EOL>idx += <NUM_LIT:2><EOL>payload = self._packet[idx:idx + <NUM_LIT:8>]<EOL>self.bitmap_str = BACK.strip_bitmap_str(payload)<EOL>idx += <NUM_LIT:8><EOL>self.acked_seqs = BACK.extract_acked_seqs(self.bitmap_str, self.ssc_seq)<EOL>

Constructor method.
        :frame: ctypes.Structure


ccmp_extiv = None<EOL>if len(self._packet[idx:]) >= <NUM_LIT:8>:<EOL><INDENT>raw_bytes = self._packet[idx:idx + <NUM_LIT:8>]<EOL>ccmp_extiv, = struct.unpack_from('<STR_LIT>', raw_bytes, <NUM_LIT:0>)<EOL><DEDENT>return <NUM_LIT:8>, ccmp_extiv<EOL>

strip(8 byte) wlan.ccmp.extiv
        CCMP Extended Initialization Vector
        :return: int
            number of processed bytes
        :return: ctypes.raw
            ccmp vector


xchannel = collections.namedtuple(<EOL>'<STR_LIT>', ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>flags = collections.namedtuple(<EOL>'<STR_LIT>', ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>idx = Radiotap.align(idx, <NUM_LIT:2>)<EOL>flag_val, freq, channel, max_power = struct.unpack_from('<STR_LIT>', self._rtap, idx)<EOL>xchannel.freq = freq<EOL>xchannel.channel = channel<EOL>xchannel.max_power = max_power<EOL>bits = format(flag_val, '<STR_LIT>')[::-<NUM_LIT:1>]<EOL>flags.turbo = int(bits[<NUM_LIT:4>])<EOL>flags.cck = int(bits[<NUM_LIT:5>])<EOL>flags.ofdm = int(bits[<NUM_LIT:6>])<EOL>flags.two_g = int(bits[<NUM_LIT:7>])<EOL>flags.five_g = int(bits[<NUM_LIT:8>])<EOL>flags.passive = int(bits[<NUM_LIT:9>])<EOL>flags.dynamic = int(bits[<NUM_LIT:10>])<EOL>flags.gfsk = int(bits[<NUM_LIT:11>])<EOL>flags.gsm = int(bits[<NUM_LIT:12>])<EOL>flags.sturbo = int(bits[<NUM_LIT>])<EOL>flags.half = int(bits[<NUM_LIT>])<EOL>flags.quarter = int(bits[<NUM_LIT:15>])<EOL>flags.ht_20 = int(bits[<NUM_LIT:16>])<EOL>flags.ht_40u = int(bits[<NUM_LIT>])<EOL>flags.ht_40d = int(bits[<NUM_LIT>])<EOL>xchannel.flags = flags<EOL>return idx + <NUM_LIT:8>, xchannel<EOL>

strip(7 bytes) radiotap.xchannel.channel(1 byte),
        radiotap.xchannel.freq(2 bytes) and radiotap.xchannel.flags(4 bytes)
        :idx: int
        :return: int
            idx
        :return: collections.namedtuple


flags = collections.namedtuple(<EOL>'<STR_LIT>', ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>val, = struct.unpack_from('<STR_LIT>', self._rtap, idx)<EOL>bits = format(val, '<STR_LIT>')[::-<NUM_LIT:1>]<EOL>flags.cfp = int(bits[<NUM_LIT:0>])<EOL>flags.preamble = int(bits[<NUM_LIT:1>])<EOL>flags.wep = int(bits[<NUM_LIT:2>])<EOL>flags.fragmentation = int(bits[<NUM_LIT:3>])<EOL>flags.fcs = int(bits[<NUM_LIT:4>])<EOL>flags.datapad = int(bits[<NUM_LIT:5>])<EOL>flags.badfcs = int(bits[<NUM_LIT:6>])<EOL>flags.shortgi = int(bits[<NUM_LIT:7>])<EOL>return idx + <NUM_LIT:1>, flags<EOL>

strip(1 byte) radiotap.flags
        :idx: int
        :return: int
            idx
        :return: collections.namedtuple


return (val + align - <NUM_LIT:1>) & ~(align - <NUM_LIT:1>)<EOL>


present = collections.namedtuple(<EOL>'<STR_LIT>', ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>val = struct.unpack('<STR_LIT>', payload)[<NUM_LIT:0>]<EOL>bits = format(val, '<STR_LIT>')[::-<NUM_LIT:1>]<EOL>present.tsft = int(bits[<NUM_LIT:0>])               <EOL>present.flags = int(bits[<NUM_LIT:1>])              <EOL>present.rate = int(bits[<NUM_LIT:2>])               <EOL>present.channel = int(bits[<NUM_LIT:3>])            <EOL>present.fhss = int(bits[<NUM_LIT:4>])               <EOL>present.dbm_antsignal = int(bits[<NUM_LIT:5>])      <EOL>present.dbm_antnoise = int(bits[<NUM_LIT:6>])       <EOL>present.lock_quality = int(bits[<NUM_LIT:7>])       <EOL>present.tx_attenuation = int(bits[<NUM_LIT:8>])     <EOL>present.db_tx_attenuation = int(bits[<NUM_LIT:9>])  <EOL>present.dbm_tx_power = int(bits[<NUM_LIT:10>])      <EOL>present.antenna = int(bits[<NUM_LIT:11>])           <EOL>present.db_antsignal = int(bits[<NUM_LIT:12>])      <EOL>present.db_antnoise = int(bits[<NUM_LIT>])       <EOL>present.rxflags = int(bits[<NUM_LIT>])           <EOL>present.txflags = int(bits[<NUM_LIT:15>])           <EOL>present.rts_retries = int(bits[<NUM_LIT:16>])       <EOL>present.data_retries = int(bits[<NUM_LIT>])      <EOL>present.xchannel = int(bits[<NUM_LIT>])          <EOL>present.mcs = int(bits[<NUM_LIT>])               <EOL>present.ampdu = int(bits[<NUM_LIT:20>])             <EOL>present.vht = int(bits[<NUM_LIT>])               <EOL>present.rtap_ns = int(bits[<NUM_LIT>])           <EOL>present.ven_ns = int(bits[<NUM_LIT:30>])            <EOL>present.ext = int(bits[<NUM_LIT>])               <EOL>return present, bits<EOL>

strip(4 byte) radiotap.present. Those are flags that
        identify existence of incoming radiotap meta-data.
        :idx: int
        :return: str
        :return: namedtuple


Management.__init__(self, frame, no_rtap)<EOL>idx = <NUM_LIT:0><EOL>self.timestamp = self.interval = None<EOL>self.ta = self.ra = self.bssid = None<EOL>self.seq_num = self.frag_num = None<EOL>self.ess = self.ibss = None<EOL>self.privacy = None<EOL>self.priv = self.short_preamble = self.pbcc = self.chan_agility = None<EOL>self.spec_man = self.short_slot = self.apsd = self.radio_meas = None<EOL>self.dss_ofdm = self.del_back = self.imm_back = None<EOL>seq_idx, _, _, self.ta, self.ra, _, self.bssid = self.strip_mac_addrs()<EOL>idx = seq_idx<EOL>self.seq_num, self.frag_num = self.strip_seq_cntrl(idx)<EOL>idx += <NUM_LIT:2><EOL>payload = self._packet[idx:idx + <NUM_LIT:12>]<EOL>timestamp, interval, fixed_capabils = self.strip_fixed_params(payload)<EOL>if all([timestamp, interval, fixed_capabils]):<EOL><INDENT>self.timestamp = timestamp<EOL>self.interval = interval<EOL>self.set_fixed_capabils(fixed_capabils)<EOL>idx += <NUM_LIT:12><EOL><DEDENT>else:<EOL><INDENT>logging.warning("<STR_LIT>")<EOL>return<EOL><DEDENT>if idx < len(self._packet):<EOL><INDENT>self._raw_tagged_params = self._packet[idx:]<EOL>is_out_bound, tagged_params = self.parse_tagged_params(self._raw_tagged_params)<EOL>if len(tagged_params):<EOL><INDENT>self.tagged_params = tagged_params<EOL><DEDENT>if is_out_bound:<EOL><INDENT>logging.warning("<STR_LIT>")<EOL><DEDENT><DEDENT>


def get_vendor_ies(self, mac_block=None, oui_type=None):

vendor_ies = []<EOL>if mac_block is not None:<EOL><INDENT>if Management.is_valid_mac_oui(mac_block):<EOL><INDENT>mac_block = mac_block.upper()<EOL>if '<STR_LIT::>' in mac_block:<EOL><INDENT>mac_block.replace('<STR_LIT::>', '<STR_LIT:->')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>logging.warning("<STR_LIT>")<EOL>return None<EOL><DEDENT><DEDENT>for elem in self.tagged_params:<EOL><INDENT>tag_num = elem['<STR_LIT>']<EOL>if MNGMT_TAGS[tag_num] == '<STR_LIT>':<EOL><INDENT>if mac_block is None:<EOL><INDENT>vendor_ies.append(elem)<EOL><DEDENT>elif elem['<STR_LIT>']['<STR_LIT>'] == mac_block.encode('<STR_LIT:ascii>'):<EOL><INDENT>if oui_type is None:<EOL><INDENT>vendor_ies.append(elem)<EOL><DEDENT>elif elem['<STR_LIT>']['<STR_LIT>'] == oui_type:<EOL><INDENT>vendor_ies.append(elem)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return vendor_ies<EOL>

vendor information element querying
        :mac_block: str
            first 3 bytes of mac addresses in format of
            00-11-22 or 00:11:22 or 001122
        :oui_type: int
            vendors ie type
        :return: int
            is valid mac_block  format
            -1 is unknown
        :return: dict[]
            list of oui information elements
            -1 on error (invalid v


<EOL>padding = <NUM_LIT:0><EOL>len_payload = <NUM_LIT:0><EOL>msdu = {<EOL>'<STR_LIT>': {},<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': <NUM_LIT:0><EOL>}<EOL>(da_mac, sa_mac) = struct.unpack('<STR_LIT>', self._packet[idx:idx + <NUM_LIT:12>])<EOL>msdu['<STR_LIT>'] = Wifi.get_mac_addr(da_mac)<EOL>msdu['<STR_LIT>'] = Wifi.get_mac_addr(sa_mac)<EOL>idx += <NUM_LIT:12><EOL>msdu['<STR_LIT>'] = struct.unpack('<STR_LIT>', self._packet[idx:idx + <NUM_LIT:2>])[<NUM_LIT:0>]<EOL>idx += <NUM_LIT:2><EOL>offset, msdu['<STR_LIT>'] = self.strip_llc(idx)<EOL>idx += offset<EOL>len_payload = msdu['<STR_LIT>'] - offset<EOL>msdu['<STR_LIT>'] = self._packet[idx:idx + len_payload]<EOL>padding = <NUM_LIT:4> - (len_payload % <NUM_LIT:4>)<EOL>return msdu, msdu['<STR_LIT>'] + padding + <NUM_LIT:12><EOL>

strip single mac servis data unit(msdu)
        see -> https://mrncciew.com/2014/11/01/cwap-802-11-data-frame-aggregation/
        :idx: int
        :return: dict
            msdu
        :return: int
            number of processed bytes


fhss = collections.namedtuple('<STR_LIT>', ['<STR_LIT>', '<STR_LIT>'])<EOL>fhss.hopset, fhss.pattern, = struct.unpack_from('<STR_LIT>', self._rtap, idx)<EOL>return idx + <NUM_LIT:2>, fhss<EOL>

strip (2 byte) radiotap.fhss.hopset(1 byte) and
        radiotap.fhss.pattern(1 byte)
        :idx: int
        :return: int
            idx
        :return: collections.namedtuple


idx = Radiotap.align(idx, <NUM_LIT:2>)<EOL>tx_attenuation, = struct.unpack_from('<STR_LIT>', self._rtap, idx)<EOL>return idx + <NUM_LIT:2>, tx_attenuation<EOL>

strip(1 byte) tx_attenuation
        :idx: int
        :return: int
            idx
        :return: int


if len(payload) != <NUM_LIT:2>:<EOL><INDENT>return None<EOL><DEDENT>interval = struct.unpack('<STR_LIT:H>', payload)[<NUM_LIT:0>]<EOL>return interval<EOL>

strip wlan_mgt.fixed.beacoN(2 bytes)
        beacon interval
        :payload: ctypes.structure
        :return: int
            None on error


if self.present.mcs:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>if self.present.vht:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>if self.present.channel and hasattr(self, '<STR_LIT>'):<EOL><INDENT>if self.chan.five_g:<EOL><INDENT>if self.chan.ofdm:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT><DEDENT>elif self.chan.two_g:<EOL><INDENT>if self.chan.cck:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>elif self.chan.ofdm or self.chan.dynamic:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT><DEDENT><DEDENT>return '<STR_LIT:None>'<EOL>

extract 802.11 protocol from radiotap.channel.flags
        :return: str
            protocol name
            one of below in success
            [.11a, .11b, .11g, .11n, .11ac]
            None in fail


acked_seqs = []<EOL>for idx, val in enumerate(bitmap):<EOL><INDENT>if int(val) == <NUM_LIT:1>:<EOL><INDENT>seq = (ssc_seq + idx) % <NUM_LIT><EOL>acked_seqs.append(seq)<EOL><DEDENT><DEDENT>return acked_seqs<EOL>

extracts acknowledged sequences from bitmap and
        starting sequence number.
        :bitmap: str
        :ssc_seq: int
        :return: int[]
            acknowledged sequence numbers


data_retries, = struct.unpack_from('<STR_LIT>', self._rtap, idx)<EOL>return idx + <NUM_LIT:1>, data_retries<EOL>

strip(1 byte) data_retries
        :idx: int
        :return: int
            idx
        :return: int


Wifi.__init__(self, frame, no_rtap)<EOL>

Constructor method.
        :packet: ctypes.Structure
        :no_rtap: Bool
            shall parse radiotap headers


idx = Radiotap.align(idx, <NUM_LIT:2>)<EOL>db_tx_attenuation, = struct.unpack_from('<STR_LIT>', self._rtap, idx)<EOL>return idx + <NUM_LIT:2>, db_tx_attenuation<EOL>

strip(1 byte) db_tx_attenuation
        :return: int
            idx
        :return: int


def strip_qos_cntrl(self, idx, prot_type):

qos_cntrl, = struct.unpack('<STR_LIT:H>', self._packet[idx:idx + <NUM_LIT:2>])<EOL>qos_cntrl_bits = format(qos_cntrl, '<STR_LIT>')[::-<NUM_LIT:1>]<EOL>qos_pri = qos_cntrl & <NUM_LIT><EOL>qos_bit = int(qos_cntrl_bits[<NUM_LIT:5>])<EOL>qos_ack = int(qos_cntrl_bits[<NUM_LIT:6>:<NUM_LIT:8>], <NUM_LIT:2>)<EOL>amsdupresent = <NUM_LIT:0><EOL>if prot_type == '<STR_LIT>':<EOL><INDENT>amsdupresent = int(qos_cntrl_bits[<NUM_LIT:7>])<EOL><DEDENT>return <NUM_LIT:2>, qos_pri, qos_bit, qos_ack, amsdupresent<EOL>

strip(2 byte) wlan.qos
        :idx: int
        :prot_type: string
            802.11 protocol type(.11ac, .11a, .11n, etc)
        :return: int
            number of processed bytes
        :return: int
            qos priority
        :return: int
            qos bit
        :return: int
            qos acknowledgement
        :return: int
            amsdupresent(aggregated mac service data unit)


pack = None<EOL>try:<EOL><INDENT>pack = WiHelper.get_wifi_packet(frame, no_rtap)<EOL><DEDENT>except Exception as e:<EOL><INDENT>logging.exception(e)<EOL><DEDENT>return pack<EOL>

calls wifi packet discriminator and constructor.
    :frame: ctypes.Structure
    :no_rtap: Bool
    :return: packet object in success
    :return: int
        -1 on known error
    :return: int
        -2 on unknown error


vht = collections.namedtuple(<EOL>'<STR_LIT>', ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>user = collections.namedtuple('<STR_LIT:user>', ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>idx = Radiotap.align(idx, <NUM_LIT:2>)<EOL>known, flags, bw = struct.unpack_from('<STR_LIT>', self._rtap, idx)<EOL>mcs_nss_0, mcs_nss_1, mcs_nss_2, mcs_nss_3 = struct.unpack_from('<STR_LIT>', self._rtap, idx + <NUM_LIT:4>)<EOL>coding, group_id, partial_id = struct.unpack_from('<STR_LIT>', self._rtap, idx + <NUM_LIT:8>)<EOL>known_bits = format(known, '<STR_LIT>')[::-<NUM_LIT:1>]<EOL>vht.known_bits = known_bits<EOL>vht.have_stbc = int(known_bits[<NUM_LIT:0>])         <EOL>vht.have_txop_ps = int(known_bits[<NUM_LIT:1>])      <EOL>vht.have_gi = int(known_bits[<NUM_LIT:2>])           <EOL>vht.have_sgi_nsym_da = int(known_bits[<NUM_LIT:3>])  <EOL>vht.have_ldpc_extra = int(known_bits[<NUM_LIT:4>])   <EOL>vht.have_beamformed = int(known_bits[<NUM_LIT:5>])   <EOL>vht.have_bw = int(known_bits[<NUM_LIT:6>])           <EOL>vht.have_gid = int(known_bits[<NUM_LIT:7>])          <EOL>vht.have_paid = int(known_bits[<NUM_LIT:8>])         <EOL>flag_bits = format(flags, '<STR_LIT>')[::-<NUM_LIT:1>]<EOL>vht.flag_bits = flag_bits<EOL>vht.stbc = int(flag_bits[<NUM_LIT:0>])<EOL>vht.txop_ps = int(flag_bits[<NUM_LIT:1>])<EOL>vht.gi = int(flag_bits[<NUM_LIT:2>])<EOL>vht.sgi_nysm_da = int(flag_bits[<NUM_LIT:3>])<EOL>vht.ldpc_extra = int(flag_bits[<NUM_LIT:4>])<EOL>vht.beamformed = int(flag_bits[<NUM_LIT:5>])<EOL>vht.group_id = group_id<EOL>vht.partial_id = partial_id<EOL>vht.bw = bw<EOL>vht.user_0 = user(None, None, None)<EOL>vht.user_1 = user(None, None, None)<EOL>vht.user_2 = user(None, None, None)<EOL>vht.user_3 = user(None, None, None)<EOL>for (i, mcs_nss) in enumerate([mcs_nss_0, mcs_nss_1, mcs_nss_2, mcs_nss_3]):<EOL><INDENT>if mcs_nss:<EOL><INDENT>nss = mcs_nss & <NUM_LIT> >> <NUM_LIT:4><EOL>mcs = (mcs_nss & <NUM_LIT>) >> <NUM_LIT:4><EOL>coding = (coding & <NUM_LIT:2>**i) >> i<EOL>if i == <NUM_LIT:0>:<EOL><INDENT>vht.user_0 = user(nss, mcs, coding)<EOL><DEDENT>elif i == <NUM_LIT:1>:<EOL><INDENT>vht.user_1 = user(nss, mcs, coding)<EOL><DEDENT>elif i == <NUM_LIT:2>:<EOL><INDENT>vht.user_2 = user(nss, mcs, coding)<EOL><DEDENT>elif i == <NUM_LIT:3>:<EOL><INDENT>vht.user_3 = user(nss, mcs, coding)<EOL><DEDENT><DEDENT><DEDENT>return idx + <NUM_LIT:12>, vht<EOL>

strip(12 byte) radiotap.vht
        :idx: int
        :return: int
            idx
        :return: collections.namedtuple


Control.__init__(self, frame, no_rtap)<EOL>ra_mac = struct.unpack('<STR_LIT>', self._packet[<NUM_LIT:4>:<NUM_LIT:10>])[<NUM_LIT:0>]<EOL>self.ra = Wifi.get_mac_addr(ra_mac)<EOL>

Constructor method.
        :frame: ctypes.Structure


self.ess = capabils['<STR_LIT>']<EOL>self.ibss = capabils['<STR_LIT>']<EOL>self.priv = capabils['<STR_LIT>']<EOL>self.short_preamble = capabils['<STR_LIT>']<EOL>self.pbcc = capabils['<STR_LIT>']<EOL>self.chan_agility = capabils['<STR_LIT>']<EOL>self.spec_man = capabils['<STR_LIT>']<EOL>self.short_slot = capabils['<STR_LIT>']<EOL>self.apsd = capabils['<STR_LIT>']<EOL>self.radio_meas = capabils['<STR_LIT>']<EOL>self.dss_ofdm = capabils['<STR_LIT>']<EOL>self.del_back = capabils['<STR_LIT>']<EOL>self.imm_back = capabils['<STR_LIT>']<EOL>

set keys of capabils into fields of object
        :capabils: dict


def __init__(self, frame, no_rtap=False, parse_amsdu=True):

Data.__init__(self, frame, no_rtap)<EOL>idx = <NUM_LIT:0><EOL>self.sa = self.ta = self.ra = self.da = None<EOL>self.seq_num = self.frag_num = None<EOL>self.qos_pri = self.qos_bit = self.qos_ack = None<EOL>self.ccmp_extiv = None<EOL>self.payload = []<EOL>seq_idx, qos_idx, self.sa, self.ta, self.ra, self.da, _ = self.strip_mac_addrs()<EOL>self.seq_num, self.frag_num = self.strip_seq_cntrl(seq_idx)<EOL>idx = qos_idx<EOL>incr, self.qos_pri, self.qos_bit, self.qos_ack, self.amsdupresent =self.strip_qos_cntrl(idx, self.radiotap.prot_type)<EOL>idx += incr<EOL>if self.wep == <NUM_LIT:1>:<EOL><INDENT>incr, self.ccmp_extiv = self.strip_ccmp(idx)<EOL>idx += incr<EOL><DEDENT>if parse_amsdu:<EOL><INDENT>if self.amsdupresent != <NUM_LIT:0> and self.wep == <NUM_LIT:0>:<EOL><INDENT>while idx < len(self._packet):<EOL><INDENT>msdu, offset = self.strip_msdu(idx)<EOL>self.payload.append(msdu)<EOL>idx += offset<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if self.wep == <NUM_LIT:0>:<EOL><INDENT>msdu = {}<EOL>offset, llc = self.strip_llc(idx)<EOL>msdu['<STR_LIT>'] = llc<EOL>msdu['<STR_LIT>'] = self._packet[idx + offset:]<EOL>self.payload.append(msdu)<EOL><DEDENT>else:<EOL><INDENT>self.payload.append({'<STR_LIT>': self._packet[idx:]})<EOL><DEDENT><DEDENT><DEDENT>

Constructor method.
        :frame: ctypes.Structure
        :parse_amsdu: Bool
            shall parse aggregated mac service data unit


return struct.unpack('<STR_LIT:H>', payload)[<NUM_LIT:0>]<EOL>

strip(2 byte) radiotap.length
        :payload: ctypes.Structure
        :return: int


mcs = collections.namedtuple(<EOL>'<STR_LIT>', ['<STR_LIT>', '<STR_LIT:index>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>'])<EOL>idx = Radiotap.align(idx, <NUM_LIT:1>)<EOL>known, flags, index = struct.unpack_from('<STR_LIT>', self._rtap, idx)<EOL>bits = format(flags, '<STR_LIT>')[::-<NUM_LIT:1>]<EOL>mcs.known = known               <EOL>mcs.index = index               <EOL>mcs.have_bw = int(bits[<NUM_LIT:0>])      <EOL>mcs.have_mcs = int(bits[<NUM_LIT:1>])     <EOL>mcs.have_gi = int(bits[<NUM_LIT:2>])      <EOL>mcs.have_format = int(bits[<NUM_LIT:3>])  <EOL>mcs.have_fec = int(bits[<NUM_LIT:4>])     <EOL>mcs.have_stbc = int(bits[<NUM_LIT:5>])    <EOL>mcs.have_ness = int(bits[<NUM_LIT:6>])    <EOL>mcs.ness_bit1 = int(bits[<NUM_LIT:7>])    <EOL>return idx + <NUM_LIT:3>, mcs<EOL>

strip(3 byte) radiotap.mcs which contains 802.11n bandwidth,
        mcs(modulation and coding scheme) and stbc(space time block coding)
        information.
        :idx: int
        :return: int
            idx
        :return: collections.namedtuple


mac_addr = bytearray(mac_addr)<EOL>mac = b'<STR_LIT::>'.join([('<STR_LIT>' % o).encode('<STR_LIT:ascii>') for o in mac_addr])<EOL>return mac<EOL>

converts bytes to mac addr format
        :mac_addr: ctypes.structure
        :return: str
            mac addr in format
            11:22:33:aa:bb:cc


tags = ['<STR_LIT:\\>', '<STR_LIT:|>', '<STR_LIT:/>', '<STR_LIT:->']<EOL>for i in range(wait):<EOL><INDENT>time.sleep(<NUM_LIT>)<EOL>sys.stdout.write("<STR_LIT>" % {<EOL>'<STR_LIT:message>': message,<EOL>'<STR_LIT>': tags[i % <NUM_LIT:4>]<EOL>})<EOL>sys.stdout.flush()<EOL>pass<EOL><DEDENT>sys.stdout.write("<STR_LIT>" % message)<EOL>sys.stdout.flush()<EOL>pass<EOL>

print loading message on screen

.. note::

    loading message only write to `sys.stdout`

:param int wait: seconds to wait
:param str message: message to print
:return: None


return self.warn_message(*args, **kwargs)<EOL>


def warn_message(self, message, fh=None, prefix="<STR_LIT>", suffix="<STR_LIT>"):

msg = prefix + message + suffix<EOL>fh = fh or sys.stdout<EOL>if fh is sys.stdout:<EOL><INDENT>termcolor.cprint(msg, color="<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>fh.write(msg)<EOL><DEDENT>pass<EOL>

print warn type message,
if file handle is `sys.stdout`, print color message

:param str message: message to print
:param file fh: file handle,default is `sys.stdout`
:param str prefix: message prefix,default is `[warn]`
:param str suffix: message suffix ,default is `...`
:return: None


def print_message(self, message, fh=None):

return self.parser._print_message(message + "<STR_LIT:\n>", fh)<EOL>

print message on screen

:param str message:
:param file fh: file handle,default is None
:return: None


return [<EOL>(('<STR_LIT>',), dict(help='<STR_LIT>')),<EOL>(('<STR_LIT:name>',), dict(nargs='<STR_LIT:?>', default='<STR_LIT>', help='<STR_LIT>')),<EOL>(('<STR_LIT>',),<EOL>dict(action='<STR_LIT:store_true>', help='<STR_LIT>')),<EOL>(('<STR_LIT>',),<EOL>dict(action='<STR_LIT:store_true>', help='<STR_LIT>')),<EOL>]<EOL>pass<EOL>

Create project.

By default cliez find github first,
if not found,then try to search bitbucket

if user define `--local` option. search local path first.

if user define `--bitbucket`, search bitbucket first,
then search github.


def render(self, match_string, new_string):

current_dir = self.options.dir<EOL>if os.path.expanduser(current_dir) in ['<STR_LIT:/>', os.path.expanduser("<STR_LIT>")]:<EOL><INDENT>self.error("<STR_LIT>", -<NUM_LIT:1>)<EOL>pass<EOL><DEDENT>def match_directory(path):<EOL><INDENT>"""<STR_LIT>"""<EOL>skip = False<EOL>for include_dir in ['<STR_LIT>' % s for s in<EOL>self.exclude_directories]:<EOL><INDENT>if path.find(include_dir) > -<NUM_LIT:1>:<EOL><INDENT>skip = True<EOL>break<EOL><DEDENT>pass<EOL><DEDENT>return skip<EOL><DEDENT>for v in os.walk(current_dir):<EOL><INDENT>if os.path.basename(v[<NUM_LIT:0>]) in self.exclude_directories:<EOL><INDENT>continue<EOL><DEDENT>if match_directory(v[<NUM_LIT:0>]):<EOL><INDENT>continue<EOL><DEDENT>for base_name in v[<NUM_LIT:2>]:<EOL><INDENT>file_name = os.path.join(v[<NUM_LIT:0>], base_name)<EOL>try:<EOL><INDENT>with open(file_name, '<STR_LIT:r>') as fh:<EOL><INDENT>buffer = fh.read()<EOL>buffer = buffer.replace(match_string, new_string)<EOL>pass<EOL><DEDENT>with open(file_name, '<STR_LIT:w>') as fh:<EOL><INDENT>fh.write(buffer)<EOL>pass<EOL><DEDENT><DEDENT>except UnicodeDecodeError:<EOL><INDENT>continue<EOL><DEDENT>pass<EOL><DEDENT>pass<EOL><DEDENT>redo_directories = []<EOL>redo_files = []<EOL>for v in os.walk(current_dir):<EOL><INDENT>if os.path.basename(v[<NUM_LIT:0>]) in self.exclude_directories:<EOL><INDENT>continue<EOL><DEDENT>if match_directory(v[<NUM_LIT:0>]):<EOL><INDENT>continue<EOL><DEDENT>for sub_dir in v[<NUM_LIT:1>]:<EOL><INDENT>if match_string in sub_dir:<EOL><INDENT>redo_directories.append(os.path.join(v[<NUM_LIT:0>], sub_dir))<EOL>pass<EOL><DEDENT><DEDENT>for f in v[<NUM_LIT:2>]:<EOL><INDENT>if match_string in f:<EOL><INDENT>redo_files.append(os.path.join(v[<NUM_LIT:0>], f))<EOL>pass<EOL><DEDENT><DEDENT>pass<EOL><DEDENT>redo_directories.reverse()<EOL>redo_files.reverse()<EOL>for v in redo_files:<EOL><INDENT>dir_name = os.path.dirname(v)<EOL>file_name = os.path.basename(v)<EOL>shutil.move(v, os.path.join(<EOL>dir_name,<EOL>file_name.replace(match_string, new_string)))<EOL>pass<EOL><DEDENT>for v in redo_directories:<EOL><INDENT>shutil.move(v, v.replace(match_string, new_string))<EOL>pass<EOL><DEDENT>pass<EOL>

render template string to user string
:param str match_string: template string,syntax: '___VAR___'
:param str new_string: user string
:return:


self.logger.debug("<STR_LIT>")<EOL>depends = ['<STR_LIT>']<EOL>nil_tools = []<EOL>self.logger.info("<STR_LIT>", depends)<EOL>for v in depends:<EOL><INDENT>real_path = shutil.which(v)<EOL>if real_path:<EOL><INDENT>self.print_message("<STR_LIT>"<EOL>"<STR_LIT>".format(v,<EOL>real_path,<EOL>termcolor.colored(<EOL>'<STR_LIT>',<EOL>color='<STR_LIT>')))<EOL><DEDENT>else:<EOL><INDENT>nil_tools.append(v)<EOL>self.error_message(<EOL>'<STR_LIT>'.format(v, '<STR_LIT>'), prefix='<STR_LIT>',<EOL>suffix='<STR_LIT>')<EOL><DEDENT>pass<EOL><DEDENT>if nil_tools:<EOL><INDENT>self.print_message('<STR_LIT>')<EOL>self.error("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>self.print_message("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>self.logger.debug("<STR_LIT>")<EOL>pass<EOL><DEDENT>pass<EOL>

.. todo::

    check network connection

:param Namespace options: parse result from argparse
:return:


new_name = '<STR_LIT>'<EOL>pos = <NUM_LIT:0><EOL>for c in name:<EOL><INDENT>if pos == <NUM_LIT:0>:<EOL><INDENT>new_name = c.lower()<EOL><DEDENT>elif <NUM_LIT> <= ord(c) <= <NUM_LIT>:<EOL><INDENT>new_name += '<STR_LIT:_>' + c.lower()<EOL>pass<EOL><DEDENT>else:<EOL><INDENT>new_name += c<EOL><DEDENT>pos += <NUM_LIT:1><EOL>pass<EOL><DEDENT>return new_name<EOL>

Convert Hump style to underscore

:param name: Hump Character
:return: str


def include_file(filename, global_vars=None, local_vars=None):

if global_vars is None:<EOL><INDENT>global_vars = sys._getframe(<NUM_LIT:1>).f_globals<EOL><DEDENT>if local_vars is None:<EOL><INDENT>local_vars = sys._getframe(<NUM_LIT:1>).f_locals<EOL><DEDENT>with open(filename, '<STR_LIT:r>') as f:<EOL><INDENT>code = compile(f.read(), os.path.basename(filename), '<STR_LIT>')<EOL>exec(code, global_vars, local_vars)<EOL>pass<EOL><DEDENT>

.. deprecated 2.1::
    Don't use this any more.

    It's not pythonic.

include file like php include.

include is very useful when we need to split large config file


if path:<EOL><INDENT>Settings.bind(path, with_path=with_path)<EOL><DEDENT>return Settings._wrapped<EOL>

Get or set `Settings._wrapped`

:param str path: a python module file,
    if user set it,write config to `Settings._wrapped`
:param str with_path: search path
:return: A instance of `Settings`


if self.options.exclusive_mode:<EOL><INDENT>import psutil<EOL>current_pid = os.getpid()<EOL>current = psutil.Process(current_pid).cmdline()<EOL>for pid in psutil.pids():<EOL><INDENT>p = psutil.Process(pid)<EOL>try:<EOL><INDENT>if current_pid != pid and current == p.cmdline():<EOL><INDENT>self.error_message(<EOL>"<STR_LIT>".format(p.pid))<EOL>sys.exit(-<NUM_LIT:1>)<EOL>pass<EOL><DEDENT><DEDENT>except psutil.ZombieProcess:<EOL><INDENT>pass<EOL><DEDENT>except psutil.AccessDenied:<EOL><INDENT>pass<EOL><DEDENT>pass<EOL><DEDENT>pass<EOL><DEDENT>pass<EOL>

检查是否是独占模式

参数顺序必须一致,也就是说如果参数顺序不一致,则判定为是两个不同的进程
这么设计是考虑到:

- 一般而言,排他模式的服务启动都是crontab等脚本来完成的,不存在顺序变更的可能
- 这在调试的时候可以帮助我们不需要结束原有进程就可以继续调试

:return:


self.set_signal()<EOL>self.check_exclusive_mode()<EOL>slot = self.Handle(self)<EOL>i = <NUM_LIT:0><EOL>while i < options.threads:<EOL><INDENT>t = threading.Thread(target=self.worker, args=[slot])<EOL>if options.once is True or options.no_daemon is True:<EOL><INDENT>t.daemon = False<EOL><DEDENT>else:<EOL><INDENT>t.daemon = True<EOL><DEDENT>t.start()<EOL>i += <NUM_LIT:1><EOL><DEDENT>if options.once is False:<EOL><INDENT>while True:<EOL><INDENT>if threading.active_count() > <NUM_LIT:1>:<EOL><INDENT>sleep(<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>if threading.current_thread().name == "<STR_LIT>":<EOL><INDENT>sys.exit(<NUM_LIT:0>)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>pass<EOL>

In general, you don't need to overwrite this method.

:param options:
:return:


return (data.get('<STR_LIT:type>') == '<STR_LIT:message>' and<EOL>self.full_name in data.get('<STR_LIT:text>', '<STR_LIT>'))<EOL>


return json.loads(msg.data)<EOL>

Unpack the data from the message.

        Arguments:
          msg (:py:class:`aiohttp.websocket.Message`): The message to
            unpack.

        Returns:
          :py:class:`dict`: The loaded data.

        Raises:
          :py:class:`AttributeError`: If there is no data attribute.
          :py:class:`json.JSONDecodeError`: If the data isn't valid
            JSON.


data = cls._unpack_message(msg)<EOL>logger.debug(data)<EOL>if data != cls.RTM_HANDSHAKE:<EOL><INDENT>raise SlackApiError('<STR_LIT>'.format(data))<EOL><DEDENT>logger.info('<STR_LIT>')<EOL>

Check the first message matches the expected handshake.

        Note:
          The handshake is provided as :py:attr:`RTM_HANDSHAKE`.

        Arguments:
          msg (:py:class:`aiohttp.Message`): The message to validate.

        Raises:
          :py:class:`SlackApiError`: If the data doesn't match the
            expected handshake.


return (data.get('<STR_LIT:type>') == '<STR_LIT:message>' and<EOL>data.get('<STR_LIT:text>', '<STR_LIT>').startswith(self.address_as))<EOL>


self.text = data.get('<STR_LIT:text>')<EOL>return True<EOL>

Whether the handler should handle the current message.

        Args:
          data: The data representing the current message.

        Returns:
          :py:class:`bool`: Whether it should be handled.