Wrapper
KoshScriptWrapper
Bases: object
Source code in kosh/wrapper.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
__init__(executable)
Wrapper for scripts. Will inspect passed object at call time to construct command line and run script with appropriate parameters
Parameters:
Name | Type | Description | Default |
---|---|---|---|
executable |
str
|
path to executable/script, e.g. "python myscript.py" |
required |
Source code in kosh/wrapper.py
add_argument(parameter, feed_attribute=None, default='use_default', mapper=getattr, feed_pos=None)
Adds an argument to map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameter |
str | none
|
name of the parameter in the script (e.g --file or -f) use None to reflect positional argument |
required |
feed_attribute |
str
|
name of attribute to use on the feed object |
None
|
default |
default value to use if not affected by feed objects to let the store use its own default pass "use_default" |
'use_default'
|
|
mapper |
mapper to use defaults to gettattr, the function will receive the kosh_object and the kosh feed_attribute as arguments |
getattr
|
|
feed_pos |
int | None
|
index of the feed object fed to use to do the mapping -1 means as long as a feed object matches it will be used and will override any value already set. None means as soon as a feed object match that name it will be used and the search is over. |
None
|
Source code in kosh/wrapper.py
run(*kosh_objects, **updated_named_parameters)
Given a kosh object uses it to construct the appropriate command line
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kosh_object |
any
|
The object that will be used to get values for named parameters This object will also be the feed to any mapping function in |
required |
call_communicate |
bool
|
After creating the subprocess do we call communicate? |
required |
updated_named_parameters |
these keyword values will be used to override anything generated and be passed as is to the command line |
{}
|
Returns:
Type | Description |
---|---|
A tuple of the output and err streams from the commuicate call or The Popen process created if call_communicate is False |