Questions tagged [pyinvoke]

Python Invoke is a Python tool and library for task execution, similar to Make or Rake.

Invoke existed originally in Fabric 1.x, and it was extracted out after realizing that it made sense as dedicated tool dedicated to task execution that can also be used as a library.

http://www.pyinvoke.org

37 questions
2
votes
2 answers

Python Invoke and console output issue

I am using Invoke for task execution. The problem is, it hides most of the console output. Because of which I cannot see output from my app. I have a task that runs a shell. Invoke changes the behavior of default shell. Back key does not work. What…
learner010
  • 445
  • 5
  • 17
1
vote
1 answer

Can I tell pylint about a specific param a decorator requires and have it not apply unused-argument?

I use pyinvoke which has a task decorator that works like this: @task def mycommand( # MUST include context param even if its not used ctx: Context ): # Do stuff, but don't use ctx Even if I don't use ctx I must include it for pyinvoke…
red888
  • 27,709
  • 55
  • 204
  • 392
1
vote
1 answer

Python invoke: Get the flags from a parent command?

Given the following python invoke script: from invoke import task @task def pre(c): print("pre") @task(pre=[pre]) def command(c, flag): print(f"command flag={flag}") Called with the following shell command: inv command --flag I would like…
Philippe Hebert
  • 1,616
  • 2
  • 24
  • 51
1
vote
1 answer

How to use pyinvoke as a library and include the tasks in a single file?

I'd like to create a standalone python script that uses invoke and also includes the tasks to be executed. A minimal working example looks like: #!/usr/bin/env python3 from invoke import task, Program @task() def foo(c): …
cryptoplex
  • 1,235
  • 10
  • 14
1
vote
1 answer

Modifying the Config class for Invoke

I'm using the Invoke python command runner and I'm having a bit of trouble making some modifications to the Config object (which loads and exposes user created options). By default, Invoke will load a user profile with a prefix of ~/.invoke (so it…
Hector Villarreal
  • 822
  • 10
  • 20
1
vote
1 answer

Invoke vs Argparse for multi-task scripts

Invoke and Argparse are both python libraries for managing and executing python scripts. They both allow to deal with the case when the same script should be used in different ways (Argparse via add_subparsers, and Invoke via task). Eventually it…
kurtosis
  • 1,365
  • 2
  • 12
  • 27
0
votes
1 answer

How do I read the current output with asynchronous without waiting for the process to finish?

Also opened a GitHub issue: https://github.com/pyinvoke/invoke/issues/951 It's documented, but are there any complete examples and snippets for how to use asynchronous=True? I usually have to look through GitHub issues when trying to find full…
red888
  • 27,709
  • 55
  • 204
  • 392
0
votes
0 answers

python invoke throwing AttributeError: 'Argument' object has no attribute 'pre'

I'm seeing the following error when I run invoke prepare-bitbucket on one of my invoke functions: AttributeError: 'Argument' object has no attribute 'pre' here's the function responsible: @invoke.task def prepare_ssm(ctx): invoke.run("echo…
aphexlog
  • 1,503
  • 3
  • 16
  • 43
0
votes
0 answers

Does pyinvoke support defining "default" arguments that are injected into all tasks automatically?

I like how simple it is to create a cli runnable task like this: @task def my_command(ctx, myarg="abc"): ctx.run('some command') I really want to maintain that simplicity if possible, but I also want to define a default set of params ALL my…
red888
  • 27,709
  • 55
  • 204
  • 392
0
votes
0 answers

How to override Invoke configuration project-wide for Fabric?

I'm currently specifying a connection override per constructor call: fabric2.Connection(…, config=invoke.Config(overrides={"shell": "bash"})). How would I translate this to a configuration file, so that I don't have to configure it per call? Fabric…
l0b0
  • 55,365
  • 30
  • 138
  • 223
0
votes
1 answer

How to specify local shell for Fabric2/Paramiko/Invoke?

When trying to create a fabric2.Connection, Paramiko tries to invoke a local /bin/bash command: $ fab2 db-shell Traceback (most recent call last): File "/nix/store/m2iyj18cifr4a1rvpfgphg7kfgsf2pj2-python3.9-fabric2-2.7.1/bin/.fab2-wrapped", line…
l0b0
  • 55,365
  • 30
  • 138
  • 223
0
votes
0 answers

pyinvoke: pass any number and name of arguments not specified in task definition

I'd like to make a generic task, something like # tasks.py from invoke import task @task def do(context, **kwargs): print("Kwargs") print(kwargs) so I can pass any name and number of arguments to this task inv do inv do…
RAbraham
  • 5,956
  • 8
  • 45
  • 80
0
votes
1 answer

Got error from message.py - paramiko "object of type 'bool' has no len()" when executing fabric.Connection.run()

I use fabric 2.6.0, paramiko 2.9.2 and invoke 1.4.0 Is this bug or something incompatible I got an error like this. File "/usr/local/lib/python3.7/dist-packages/paramiko/message.py", line 274, in add_string self.add_int(len(s)) TypeError: object of…
dhentris
  • 198
  • 1
  • 2
  • 10
0
votes
0 answers

python fabric command stdout/stderr contains unencoded (garbage) symbols

I'm running some commands over an AWS ec2 instance using fabric. The output (in some parts) contains characters such as: [K 81% |██████████████████████████ | 142.9MB 161.0MB/s eta…
Cruizo
  • 1
  • 2
0
votes
1 answer

How to disable dependencies deduplication for one particular task

I have a task like this: @task(pre=[test_teardown, test_bootstrap], post=[test_teardown]) def test_do(c): pass test_teardown post-task will not run because of task deduplication, but I want it to run before and after the test_do task. I have…
SergiyKolesnikov
  • 7,369
  • 2
  • 26
  • 47