rattail.commands.batch
¶
Batch-related commands
- class rattail.commands.batch.AutoReceiveBatch(*args, **kwargs)[source]¶
Auto-receive all items in a receiving batch
- class rattail.commands.batch.BatchAction(*args, **kwargs)[source]¶
Base class for commands which invoke a handler to act on a single batch.
- class rattail.commands.batch.BatchHandlerCommand(*args, **kwargs)[source]¶
Base class for commands which invoke a batch handler.
Note that if such a command fails to run its action, the error will be written to STDOUT as a simple message string. If the full traceback is needed, logs must be consulted. This is done for sake of letting the caller capture output for display to the user when something goes wrong.
- get_handler(args)[source]¶
Must return the batch handler to use, per the given
args
object.Default logic assumes that
args
has abatch_type
attribute, which determines which batch handler should be used. That is figured out by callingget_batch_handler()
on the app handler.- Parameters:
args¶ – Reference to the
argparse.Namespace
instance, which was the result of parsing the command line args.- Returns:
Must return the batch handler. This will be an instance of some class which derives from
BatchHandler
.
- run(args)[source]¶
Run the subcommand logic. Subclass should override this.
- Parameters:
args¶ – Reference to the
argparse.Namespace
object, as returned by the subcommand arg parser.
The
args
should have values for everything setup inadd_args()
. For example if you added the--foo
arg then here inrun()
you can do:print("foo value is:", args.foo)
Usually of course this method is invoked by way of command line. But if you need to run it programmatically, you should not try to invoke this method directly. Instead create the
Command
object and invoke itsrun()
method.For a command line like
bin/poser hello --foo=baz
then, you might do this:from poser.commands import PoserCommand cmd = PoserCommand() assert cmd.name == 'poser' cmd.run('hello', '--foo=baz')
- class rattail.commands.batch.PopulateBatch(*args, **kwargs)[source]¶
Populate initial data for a batch
- class rattail.commands.batch.PurgeBatches(*args, **kwargs)[source]¶
Purge old batches from the database
- run(args)[source]¶
Run the subcommand logic. Subclass should override this.
- Parameters:
args¶ – Reference to the
argparse.Namespace
object, as returned by the subcommand arg parser.
The
args
should have values for everything setup inadd_args()
. For example if you added the--foo
arg then here inrun()
you can do:print("foo value is:", args.foo)
Usually of course this method is invoked by way of command line. But if you need to run it programmatically, you should not try to invoke this method directly. Instead create the
Command
object and invoke itsrun()
method.For a command line like
bin/poser hello --foo=baz
then, you might do this:from poser.commands import PoserCommand cmd = PoserCommand() assert cmd.name == 'poser' cmd.run('hello', '--foo=baz')