INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Start the capture process creating all necessary files and directories as well as ingesting the captured files if no backup mode is configured. | def start_capture(upcoming_event):
'''Start the capture process, creating all necessary files and directories
as well as ingesting the captured files if no backup mode is configured.
'''
logger.info('Start recording')
# First move event to recording_event table
db = get_session()
event = db... |
Start a capture process but make sure to catch any errors during this process log them but otherwise ignore them. | def safe_start_capture(event):
'''Start a capture process but make sure to catch any errors during this
process, log them but otherwise ignore them.
'''
try:
start_capture(event)
except Exception:
logger.error('Recording failed')
logger.error(traceback.format_exc())
#... |
Run the actual command to record the a/ v material. | def recording_command(event):
'''Run the actual command to record the a/v material.
'''
conf = config('capture')
# Prepare command line
cmd = conf['command']
cmd = cmd.replace('{{time}}', str(event.remaining_duration(timestamp())))
cmd = cmd.replace('{{dir}}', event.directory())
cmd = cm... |
Main loop of the capture agent retrieving and checking the schedule as well as starting the capture process if necessry. | def control_loop():
'''Main loop of the capture agent, retrieving and checking the schedule as
well as starting the capture process if necessry.
'''
set_service_status(Service.CAPTURE, ServiceStatus.IDLE)
notify.notify('READY=1')
notify.notify('STATUS=Waiting')
while not terminate():
... |
Returns a simple fragment | def render_to_fragment(self, request, **kwargs):
"""
Returns a simple fragment
"""
fragment = Fragment(TEST_HTML)
fragment.add_javascript(TEST_JS)
fragment.add_css(TEST_CSS)
return fragment |
Returns list of unique FragmentResource s by order of first appearance. | def resources(self):
"""
Returns list of unique `FragmentResource`s by order of first appearance.
"""
seen = set()
# seen.add always returns None, so 'not seen.add(x)' is always True,
# but will only be called if the value is not already in seen (because
# 'and' s... |
Returns the fragment in a dictionary representation. | def to_dict(self):
"""
Returns the fragment in a dictionary representation.
"""
return {
'content': self.content,
'resources': [r._asdict() for r in self.resources], # pylint: disable=W0212
'js_init_fn': self.js_init_fn,
'js_init_version':... |
Returns a new Fragment from a dictionary representation. | def from_dict(cls, pods):
"""
Returns a new Fragment from a dictionary representation.
"""
frag = cls()
frag.content = pods['content']
frag._resources = [FragmentResource(**d) for d in pods['resources']] # pylint: disable=protected-access
frag.js_init_fn = pods['... |
Add content to this fragment. | def add_content(self, content):
"""
Add content to this fragment.
`content` is a Unicode string, HTML to append to the body of the
fragment. It must not contain a ``<body>`` tag, or otherwise assume
that it is the only content on the page.
"""
assert isinstance(... |
Add a resource needed by this Fragment. | def add_resource(self, text, mimetype, placement=None):
"""
Add a resource needed by this Fragment.
Other helpers, such as :func:`add_css` or :func:`add_javascript` are
more convenient for those common types of resource.
`text`: the actual text of this resource, as a unicode st... |
Add a resource by URL needed by this Fragment. | def add_resource_url(self, url, mimetype, placement=None):
"""
Add a resource by URL needed by this Fragment.
Other helpers, such as :func:`add_css_url` or
:func:`add_javascript_url` are more convenent for those common types of
resource.
`url`: the URL to the resource.
... |
Register a Javascript function to initialize the Javascript resources. | def initialize_js(self, js_func, json_args=None):
"""
Register a Javascript function to initialize the Javascript resources.
`js_func` is the name of a Javascript function defined by one of the
Javascript resources. As part of setting up the browser's runtime
environment, the f... |
Get some resource HTML for this Fragment. | def resources_to_html(self, placement):
"""
Get some resource HTML for this Fragment.
`placement` is "head" or "foot".
Returns a unicode string, the HTML for the head or foot of the page.
"""
# - non url js could be wrapped in an anonymous function
# - non url c... |
Returns resource wrapped in the appropriate html tag for it s mimetype. | def resource_to_html(resource):
"""
Returns `resource` wrapped in the appropriate html tag for it's mimetype.
"""
if resource.mimetype == "text/css":
if resource.kind == "text":
return u"<style type='text/css'>\n%s\n</style>" % resource.data
elif r... |
Render a fragment to HTML or return JSON describing it based on the request. | def get(self, request, *args, **kwargs):
"""
Render a fragment to HTML or return JSON describing it, based on the request.
"""
fragment = self.render_to_fragment(request, **kwargs)
response_format = request.GET.get('format') or request.POST.get('format') or 'html'
if resp... |
Renders a standalone page as a response for the specified fragment. | def render_standalone_response(self, request, fragment, **kwargs): # pylint: disable=unused-argument
"""
Renders a standalone page as a response for the specified fragment.
"""
if fragment is None:
return HttpResponse(status=204)
html = self.render_to_standalone_htm... |
Render the specified fragment to HTML for a standalone page. | def render_to_standalone_html(self, request, fragment, **kwargs): # pylint: disable=unused-argument
"""
Render the specified fragment to HTML for a standalone page.
"""
template = get_template(STANDALONE_TEMPLATE_NAME)
context = {
'head_html': fragment.head_html(),
... |
meaning pvalues presorted i descending order | def calc(pvalues, lamb):
""" meaning pvalues presorted i descending order"""
m = len(pvalues)
pi0 = (pvalues > lamb).sum() / ((1 - lamb)*m)
pFDR = np.ones(m)
print("pFDR y Pr fastPow")
for i in range(m):
y = pvalues[i]
Pr = max(1, m - i) / float(m)
pFDR[i]... |
You can not call methods with multiprocessing but free functions If you want to call inst. method ( arg0 arg1 ) | def unwrap_self_for_multiprocessing(arg):
""" You can not call methods with multiprocessing, but free functions,
If you want to call inst.method(arg0, arg1),
unwrap_self_for_multiprocessing(inst, "method", (arg0, arg1))
does the trick.
"""
(inst, method_name, args) = arg
r... |
Converts list or flattens n - dim array to 1 - dim array if possible | def to_one_dim_array(values, as_type=None):
""" Converts list or flattens n-dim array to 1-dim array if possible """
if isinstance(values, (list, tuple)):
values = np.array(values, dtype=np.float32)
elif isinstance(values, pd.Series):
values = values.values
values = values.flatten()
... |
Find matching q - value for each score in scores | def lookup_values_from_error_table(scores, err_df):
""" Find matching q-value for each score in 'scores' """
ix = find_nearest_matches(np.float32(err_df.cutoff.values), np.float32(scores))
return err_df.pvalue.iloc[ix].values, err_df.svalue.iloc[ix].values, err_df.pep.iloc[ix].values, err_df.qvalue.iloc[ix]... |
Compute posterior probabilities for each chromatogram | def posterior_chromatogram_hypotheses_fast(experiment, prior_chrom_null):
""" Compute posterior probabilities for each chromatogram
For each chromatogram (each group_id / peptide precursor), all hypothesis of all peaks
being correct (and all others false) as well as the h0 (all peaks are
false) are com... |
[ P ( X > pi mu sigma ) for pi in pvalues ] for normal distributed stat with expectation value mu and std deviation sigma | def pnorm(stat, stat0):
""" [P(X>pi, mu, sigma) for pi in pvalues] for normal distributed stat with
expectation value mu and std deviation sigma """
mu, sigma = mean_and_std_dev(stat0)
stat = to_one_dim_array(stat, np.float64)
args = (stat - mu) / sigma
return 1-(0.5 * (1.0 + scipy.special.erf... |
Computes empirical values identically to bioconductor/ qvalue empPvals | def pemp(stat, stat0):
""" Computes empirical values identically to bioconductor/qvalue empPvals """
assert len(stat0) > 0
assert len(stat) > 0
stat = np.array(stat)
stat0 = np.array(stat0)
m = len(stat)
m0 = len(stat0)
statc = np.concatenate((stat, stat0))
v = np.array([True] * ... |
Estimate pi0 according to bioconductor/ qvalue | def pi0est(p_values, lambda_ = np.arange(0.05,1.0,0.05), pi0_method = "smoother", smooth_df = 3, smooth_log_pi0 = False):
""" Estimate pi0 according to bioconductor/qvalue """
# Compare to bioconductor/qvalue reference implementation
# import rpy2
# import rpy2.robjects as robjects
# from rpy2.robj... |
Estimate local FDR/ posterior error probability from p - values according to bioconductor/ qvalue | def lfdr(p_values, pi0, trunc = True, monotone = True, transf = "probit", adj = 1.5, eps = np.power(10.0,-8)):
""" Estimate local FDR / posterior error probability from p-values according to bioconductor/qvalue """
p = np.array(p_values)
# Compare to bioconductor/qvalue reference implementation
# impor... |
Create artificial cutoff sample points from given range of cutoff values in df number of sample points is num_cut_offs | def final_err_table(df, num_cut_offs=51):
""" Create artificial cutoff sample points from given range of cutoff
values in df, number of sample points is 'num_cut_offs' """
cutoffs = df.cutoff.values
min_ = min(cutoffs)
max_ = max(cutoffs)
# extend max_ and min_ by 5 % of full range
margin =... |
Summary error table for some typical q - values | def summary_err_table(df, qvalues=[0, 0.01, 0.02, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5]):
""" Summary error table for some typical q-values """
qvalues = to_one_dim_array(qvalues)
# find best matching fows in df for given qvalues:
ix = find_nearest_matches(np.float32(df.qvalue.values), qvalues)
# extract ... |
Takes list of decoy and target scores and creates error statistics for target values | def error_statistics(target_scores, decoy_scores, parametric, pfdr, pi0_lambda, pi0_method = "smoother", pi0_smooth_df = 3, pi0_smooth_log_pi0 = False, compute_lfdr = False, lfdr_trunc = True, lfdr_monotone = True, lfdr_transf = "probit", lfdr_adj = 1.5, lfdr_eps = np.power(10.0,-8)):
""" Takes list of decoy and ta... |
Finds cut off target score for specified false discovery rate fdr | def find_cutoff(tt_scores, td_scores, cutoff_fdr, parametric, pfdr, pi0_lambda, pi0_method, pi0_smooth_df, pi0_smooth_log_pi0):
""" Finds cut off target score for specified false discovery rate fdr """
error_stat, pi0 = error_statistics(tt_scores, td_scores, parametric, pfdr, pi0_lambda, pi0_method, pi0_smooth... |
Conduct semi - supervised learning and error - rate estimation for MS1 MS2 and transition - level data. | def score(infile, outfile, classifier, xgb_autotune, apply_weights, xeval_fraction, xeval_num_iter, ss_initial_fdr, ss_iteration_fdr, ss_num_iter, ss_main_score, group_id, parametric, pfdr, pi0_lambda, pi0_method, pi0_smooth_df, pi0_smooth_log_pi0, lfdr_truncate, lfdr_monotone, lfdr_transformation, lfdr_adj, lfdr_eps, ... |
Infer peptidoforms after scoring of MS1 MS2 and transition - level data. | def ipf(infile, outfile, ipf_ms1_scoring, ipf_ms2_scoring, ipf_h0, ipf_grouped_fdr, ipf_max_precursor_pep, ipf_max_peakgroup_pep, ipf_max_precursor_peakgroup_pep, ipf_max_transition_pep):
"""
Infer peptidoforms after scoring of MS1, MS2 and transition-level data.
"""
if outfile is None:
outfile... |
Infer peptides and conduct error - rate estimation in different contexts. | def peptide(infile, outfile, context, parametric, pfdr, pi0_lambda, pi0_method, pi0_smooth_df, pi0_smooth_log_pi0, lfdr_truncate, lfdr_monotone, lfdr_transformation, lfdr_adj, lfdr_eps):
"""
Infer peptides and conduct error-rate estimation in different contexts.
"""
if outfile is None:
outfile ... |
Infer proteins and conduct error - rate estimation in different contexts. | def protein(infile, outfile, context, parametric, pfdr, pi0_lambda, pi0_method, pi0_smooth_df, pi0_smooth_log_pi0, lfdr_truncate, lfdr_monotone, lfdr_transformation, lfdr_adj, lfdr_eps):
"""
Infer proteins and conduct error-rate estimation in different contexts.
"""
if outfile is None:
outfile ... |
Subsample OpenSWATH file to minimum for integrated scoring | def subsample(infile, outfile, subsample_ratio, test):
"""
Subsample OpenSWATH file to minimum for integrated scoring
"""
if outfile is None:
outfile = infile
else:
outfile = outfile
subsample_osw(infile, outfile, subsample_ratio, test) |
Reduce scored PyProphet file to minimum for global scoring | def reduce(infile, outfile):
"""
Reduce scored PyProphet file to minimum for global scoring
"""
if outfile is None:
outfile = infile
else:
outfile = outfile
reduce_osw(infile, outfile) |
Merge multiple OSW files and ( for large experiments it is recommended to subsample first ). | def merge(infiles, outfile, same_run, templatefile):
"""
Merge multiple OSW files and (for large experiments, it is recommended to subsample first).
"""
if len(infiles) < 1:
raise click.ClickException("At least one PyProphet input file needs to be provided.")
merge_osw(infiles, outfile, te... |
Backpropagate multi - run peptide and protein scores to single files | def backpropagate(infile, outfile, apply_scores):
"""
Backpropagate multi-run peptide and protein scores to single files
"""
if outfile is None:
outfile = infile
else:
outfile = outfile
backpropagate_oswr(infile, outfile, apply_scores) |
Export TSV/ CSV tables | def export(infile, outfile, format, outcsv, transition_quantification, max_transition_pep, ipf, ipf_max_peptidoform_pep, max_rs_peakgroup_qvalue, peptide, max_global_peptide_qvalue, protein, max_global_protein_qvalue):
"""
Export TSV/CSV tables
"""
if format == "score_plots":
export_score_plots(... |
Export Compound TSV/ CSV tables | def export_compound(infile, outfile, format, outcsv, max_rs_peakgroup_qvalue):
"""
Export Compound TSV/CSV tables
"""
if format == "score_plots":
export_score_plots(infile)
else:
if outfile is None:
if outcsv:
outfile = infile.split(".osw")[0] + ".csv"
... |
Filter sqMass files | def filter(sqmassfiles, infile, max_precursor_pep, max_peakgroup_pep, max_transition_pep):
"""
Filter sqMass files
"""
filter_sqmass(sqmassfiles, infile, max_precursor_pep, max_peakgroup_pep, max_transition_pep) |
Returns a list of restclients. GroupReference objects matching the passed parameters. Valid parameters are: name: parts_of_name name may include the wild - card ( * ) character. stem: group_stem member: member netid owner: admin netid instructor: instructor netid stem = course will be set when this parameter is passed.... | def search_groups(self, **kwargs):
"""
Returns a list of restclients.GroupReference objects matching the
passed parameters. Valid parameters are:
name: parts_of_name
name may include the wild-card (*) character.
stem: group_stem
member: member ... |
Returns a restclients. Group object for the group identified by the passed group ID. | def get_group_by_id(self, group_id):
"""
Returns a restclients.Group object for the group identified by the
passed group ID.
"""
self._valid_group_id(group_id)
url = "{}/group/{}".format(self.API, group_id)
data = self._get_resource(url)
return self._gr... |
Creates a group from the passed restclients. Group object. | def create_group(self, group):
"""
Creates a group from the passed restclients.Group object.
"""
self._valid_group_id(group.id)
body = {"data": group.json_data()}
url = "{}/group/{}".format(self.API, group.name)
data = self._put_resource(url, headers={}, body=bo... |
Deletes the group identified by the passed group ID. | def delete_group(self, group_id):
"""
Deletes the group identified by the passed group ID.
"""
self._valid_group_id(group_id)
url = "{}/group/{}".format(self.API, group_id)
self._delete_resource(url)
return True |
Returns a list of restclients. GroupMember objects for the group identified by the passed group ID. | def get_members(self, group_id):
"""
Returns a list of restclients.GroupMember objects for the group
identified by the passed group ID.
"""
self._valid_group_id(group_id)
url = "{}/group/{}/member".format(self.API, group_id)
data = self._get_resource(url)
... |
Updates the membership of the group represented by the passed group id. Returns a list of members not found. | def update_members(self, group_id, members):
"""
Updates the membership of the group represented by the passed group id.
Returns a list of members not found.
"""
self._valid_group_id(group_id)
body = {"data": [m.json_data() for m in members]}
headers = {"If-Match... |
Returns a count of effective members for the group identified by the passed group ID. | def get_effective_member_count(self, group_id):
"""
Returns a count of effective members for the group identified by the
passed group ID.
"""
self._valid_group_id(group_id)
url = "{}/group/{}/effective_member?view=count".format(self.API,
... |
Returns True if the netid is in the group False otherwise. | def is_effective_member(self, group_id, netid):
"""
Returns True if the netid is in the group, False otherwise.
"""
self._valid_group_id(group_id)
# GWS doesn't accept EPPNs on effective member checks, for UW users
netid = re.sub('@washington.edu', '', netid)
ur... |
pip install redbaron | def modify_conf():
"""
pip install redbaron
"""
import redbaron
import ubelt as ub
conf_path = 'docs/conf.py'
source = ub.readfrom(conf_path)
red = redbaron.RedBaron(source)
# Insert custom extensions
extra_extensions = [
'"sphinxcontrib.napoleon"'
]
ext_node =... |
Statically parse the version number from __init__. py | def parse_version():
""" Statically parse the version number from __init__.py """
from os.path import dirname, join
import ast
modname = setupkw['name']
init_fpath = join(dirname(__file__), modname, '__init__.py')
with open(init_fpath) as file_:
sourcecode = file_.read()
pt = ast.par... |
Create 3 datasets in a group to represent the sparse array. | def create_dataset(self, name, shape=None, dtype=None, data=None,
sparse_format=None, indptr_dtype=np.int64, indices_dtype=np.int32,
**kwargs):
"""Create 3 datasets in a group to represent the sparse array.
Parameters
----------
sparse_forma... |
Decrypts context. io_manager s stdin and sends that to context. io_manager s stdout. | def cli_decrypt(context, key):
"""
Decrypts context.io_manager's stdin and sends that to
context.io_manager's stdout.
See :py:mod:`swiftly.cli.decrypt` for context usage information.
See :py:class:`CLIDecrypt` for more information.
"""
with context.io_manager.with_stdout() as stdout:
... |
Returns immediately to the caller and begins executing the func in the background. Use get_results and the ident given to retrieve the results of the func. If the func causes an exception this exception will be caught and the sys. exc_info () will be returned via get_results. | def spawn(self, ident, func, *args, **kwargs):
"""
Returns immediately to the caller and begins executing the
func in the background. Use get_results and the ident given
to retrieve the results of the func. If the func causes an
exception, this exception will be caught and the
... |
Returns a dict of the results currently available. The keys are the ident values given with the calls to spawn. The values are tuples of ( exc_type exc_value exc_tb result ) where: | def get_results(self):
"""
Returns a dict of the results currently available. The keys
are the ident values given with the calls to spawn. The
values are tuples of (exc_type, exc_value, exc_tb, result)
where:
========= ============================================
... |
Converts a client path into the operating system s path by replacing instances of/ with os. path. sep. | def client_path_to_os_path(self, client_path):
"""
Converts a client path into the operating system's path by
replacing instances of '/' with os.path.sep.
Note: If the client path contains any instances of
os.path.sep already, they will be replaced with '-'.
"""
... |
Converts an operating system path into a client path by replacing instances of os. path. sep with/. | def os_path_to_client_path(self, os_path):
"""
Converts an operating system path into a client path by
replacing instances of os.path.sep with '/'.
Note: If the client path contains any instances of '/'
already, they will be replaced with '-'.
"""
if os.path.sep ... |
Returns a stdin - suitable file - like object based on the optional os_path and optionally skipping any configured sub - command. | def get_stdin(self, os_path=None, skip_sub_command=False):
"""
Returns a stdin-suitable file-like object based on the
optional os_path and optionally skipping any configured
sub-command.
"""
sub_command = None if skip_sub_command else self.stdin_sub_command
inn, p... |
Returns a stdout - suitable file - like object based on the optional os_path and optionally skipping any configured sub - command. | def get_stdout(self, os_path=None, skip_sub_command=False):
"""
Returns a stdout-suitable file-like object based on the
optional os_path and optionally skipping any configured
sub-command.
"""
sub_command = None if skip_sub_command else self.stdout_sub_command
out... |
Returns a stderr - suitable file - like object based on the optional os_path and optionally skipping any configured sub - command. | def get_stderr(self, os_path=None, skip_sub_command=False):
"""
Returns a stderr-suitable file-like object based on the
optional os_path and optionally skipping any configured
sub-command.
"""
sub_command = None if skip_sub_command else self.stderr_sub_command
out... |
Returns a debug - output - suitable file - like object based on the optional os_path and optionally skipping any configured sub - command. | def get_debug(self, os_path=None, skip_sub_command=False):
"""
Returns a debug-output-suitable file-like object based on the
optional os_path and optionally skipping any configured
sub-command.
"""
sub_command = None if skip_sub_command else self.debug_sub_command
... |
A context manager yielding a stdin - suitable file - like object based on the optional os_path and optionally skipping any configured sub - command. | def with_stdin(self, os_path=None, skip_sub_command=False,
disk_closed_callback=None):
"""
A context manager yielding a stdin-suitable file-like object
based on the optional os_path and optionally skipping any
configured sub-command.
:param os_path: Optional p... |
A context manager yielding a stdout - suitable file - like object based on the optional os_path and optionally skipping any configured sub - command. | def with_stdout(self, os_path=None, skip_sub_command=False,
disk_closed_callback=None):
"""
A context manager yielding a stdout-suitable file-like object
based on the optional os_path and optionally skipping any
configured sub-command.
:param os_path: Optiona... |
A context manager yielding a stderr - suitable file - like object based on the optional os_path and optionally skipping any configured sub - command. | def with_stderr(self, os_path=None, skip_sub_command=False,
disk_closed_callback=None):
"""
A context manager yielding a stderr-suitable file-like object
based on the optional os_path and optionally skipping any
configured sub-command.
:param os_path: Optiona... |
A context manager yielding a debug - output - suitable file - like object based on the optional os_path and optionally skipping any configured sub - command. | def with_debug(self, os_path=None, skip_sub_command=False,
disk_closed_callback=None):
"""
A context manager yielding a debug-output-suitable file-like
object based on the optional os_path and optionally skipping
any configured sub-command.
:param os_path: Opt... |
Deletes all objects and containers in the account. | def cli_empty_account(context, yes_empty_account=False, until_empty=False):
"""
Deletes all objects and containers in the account.
You must set yes_empty_account to True to verify you really want to
do this.
By default, this will perform one pass at deleting all objects and
containers; so if o... |
Deletes all objects in the container. | def cli_empty_container(context, path, until_empty=False):
"""
Deletes all objects in the container.
By default, this will perform one pass at deleting all objects in
the container; so if objects revert to previous versions or if new
objects otherwise arise during the process, the container may not... |
Deletes the item ( account container or object ) at the path. | def cli_delete(context, path, body=None, recursive=False,
yes_empty_account=False, yes_delete_account=False,
until_empty=False):
"""
Deletes the item (account, container, or object) at the path.
See :py:mod:`swiftly.cli.delete` for context usage information.
See :py:class... |
Instance method decorator to convert an optional file keyword argument into an actual value whether it be a passed value a value obtained from an io_manager or sys. stdout. | def _stdout_filed(func):
"""
Instance method decorator to convert an optional file keyword
argument into an actual value, whether it be a passed value, a
value obtained from an io_manager, or sys.stdout.
"""
def wrapper(self, file=None):
if file:
return func(self, file=file)
... |
Instance method decorator to convert an optional file keyword argument into an actual value whether it be a passed value a value obtained from an io_manager or sys. stderr. | def _stderr_filed(func):
"""
Instance method decorator to convert an optional file keyword
argument into an actual value, whether it be a passed value, a
value obtained from an io_manager, or sys.stderr.
"""
def wrapper(self, msg, file=None):
if file:
return func(self, msg, f... |
Outputs the error msg to the file if specified or to the io_manager s stderr if available or to sys. stderr. | def error(self, msg, file=None):
"""
Outputs the error msg to the file if specified, or to the
io_manager's stderr if available, or to sys.stderr.
"""
self.error_encountered = True
file.write(self.error_prefix)
file.write(msg)
file.write('\n')
file... |
Immediately exits Python with the given status ( or 0 ) as the exit code and optionally outputs the msg using self. error. | def exit(self, status=0, msg=None):
"""
Immediately exits Python with the given status (or 0) as the
exit code and optionally outputs the msg using self.error.
"""
if msg:
self.error(msg)
sys.exit(status) |
Outputs help information to the file if specified or to the io_manager s stdout if available or to sys. stdout. | def print_help(self, file=None):
"""
Outputs help information to the file if specified, or to the
io_manager's stdout if available, or to sys.stdout.
"""
optparse.OptionParser.print_help(self, file)
if self.raw_epilog:
file.write(self.raw_epilog)
file.... |
Outputs usage information to the file if specified or to the io_manager s stdout if available or to sys. stdout. | def print_usage(self, file=None):
"""
Outputs usage information to the file if specified, or to the
io_manager's stdout if available, or to sys.stdout.
"""
optparse.OptionParser.print_usage(self, file)
file.flush() |
Outputs version information to the file if specified or to the io_manager s stdout if available or to sys. stdout. | def print_version(self, file=None):
"""
Outputs version information to the file if specified, or to
the io_manager's stdout if available, or to sys.stdout.
"""
optparse.OptionParser.print_version(self, file)
file.flush() |
Helper method that will parse the args into options and remaining args as well as create an initial: py: class: swiftly. cli. context. CLIContext. | def parse_args_and_create_context(self, args):
"""
Helper method that will parse the args into options and
remaining args as well as create an initial
:py:class:`swiftly.cli.context.CLIContext`.
The new context will be a copy of
:py:attr:`swiftly.cli.cli.CLI.context` wit... |
Helper function that will convert an options list into a dict of key/ values. | def options_list_to_lowered_dict(self, options_list):
"""
Helper function that will convert an options list into a dict
of key/values.
This is used for the quite common -hheader:value and
-qparameter=value command line options, like this::
context.headers = self.opt... |
Performs a direct HTTP request to the Swift service. | def request(self, method, path, contents, headers, decode_json=False,
stream=False, query=None, cdn=False):
"""
Performs a direct HTTP request to the Swift service.
:param method: The request method ('GET', 'HEAD', etc.)
:param path: The request path.
:param cont... |
HEADs the account and returns the results. Useful headers returned are: | def head_account(self, headers=None, query=None, cdn=False):
"""
HEADs the account and returns the results. Useful headers
returned are:
=========================== =================================
x-account-bytes-used Object storage used for the
... |
GETs the account and returns the results. This is done to list the containers for the account. Some useful headers are also returned: | def get_account(self, headers=None, prefix=None, delimiter=None,
marker=None, end_marker=None, limit=None, query=None,
cdn=False, decode_json=True):
"""
GETs the account and returns the results. This is done to list
the containers for the account. Some use... |
PUTs the account and returns the results. This is usually done with the extract - archive bulk upload request and has no other use I know of ( but the call is left open in case there ever is ). | def put_account(self, headers=None, query=None, cdn=False, body=None):
"""
PUTs the account and returns the results. This is usually
done with the extract-archive bulk upload request and has no
other use I know of (but the call is left open in case there
ever is).
:param... |
POSTs the account and returns the results. This is usually done to set X - Account - Meta - xxx headers. Note that any existing X - Account - Meta - xxx headers will remain untouched. To remove an X - Account - Meta - xxx header send the header with an empty string as its value. | def post_account(self, headers=None, query=None, cdn=False, body=None):
"""
POSTs the account and returns the results. This is usually
done to set X-Account-Meta-xxx headers. Note that any existing
X-Account-Meta-xxx headers will remain untouched. To remove an
X-Account-Meta-xxx ... |
Sends a DELETE request to the account and returns the results. | def delete_account(self, headers=None,
yes_i_mean_delete_the_account=False, query=None,
cdn=False, body=None):
"""
Sends a DELETE request to the account and returns the results.
With ``query['bulk-delete'] = ''`` this might mean a bulk
delet... |
HEADs the container and returns the results. Useful headers returned are: | def head_container(self, container, headers=None, query=None, cdn=False):
"""
HEADs the container and returns the results. Useful headers
returned are:
=========================== =================================
x-container-bytes-used Object storage used for the
... |
GETs the container and returns the results. This is done to list the objects for the container. Some useful headers are also returned: | def get_container(self, container, headers=None, prefix=None,
delimiter=None, marker=None, end_marker=None,
limit=None, query=None, cdn=False, decode_json=True):
"""
GETs the container and returns the results. This is done to
list the objects for the c... |
PUTs the container and returns the results. This is usually done to create new containers and can also be used to set X - Container - Meta - xxx headers. Note that if the container already exists any existing X - Container - Meta - xxx headers will remain untouched. To remove an X - Container - Meta - xxx header send t... | def put_container(self, container, headers=None, query=None, cdn=False,
body=None):
"""
PUTs the container and returns the results. This is usually
done to create new containers and can also be used to set
X-Container-Meta-xxx headers. Note that if the container
... |
HEADs the object and returns the results. | def head_object(self, container, obj, headers=None, query=None, cdn=False):
"""
HEADs the object and returns the results.
:param container: The name of the container.
:param obj: The name of the object.
:param headers: Additional headers to send with the request.
:param ... |
GETs the object and returns the results. | def get_object(self, container, obj, headers=None, stream=True, query=None,
cdn=False):
"""
GETs the object and returns the results.
:param container: The name of the container.
:param obj: The name of the object.
:param headers: Additional headers to send wit... |
PUTs the object and returns the results. This is used to create or overwrite objects. X - Object - Meta - xxx can optionally be sent to be stored with the object. Content - Type Content - Encoding and other standard HTTP headers can often also be set depending on the Swift cluster. | def put_object(self, container, obj, contents, headers=None, query=None,
cdn=False):
"""
PUTs the object and returns the results. This is used to
create or overwrite objects. X-Object-Meta-xxx can optionally
be sent to be stored with the object. Content-Type,
C... |
POSTs the object and returns the results. This is used to update the object s header values. Note that all headers must be sent with the POST unlike the account and container POSTs. With account and container POSTs existing headers are untouched. But with object POSTs any existing headers are removed. The full list of ... | def post_object(self, container, obj, headers=None, query=None, cdn=False,
body=None):
"""
POSTs the object and returns the results. This is used to
update the object's header values. Note that all headers must
be sent with the POST, unlike the account and container P... |
Performs a ping test. | def cli_ping(context, prefix):
"""
Performs a ping test.
See :py:mod:`swiftly.cli.ping` for context usage information.
See :py:class:`CLIPing` for more information.
:param context: The :py:class:`swiftly.cli.context.CLIContext` to
use.
:param prefix: The container name prefix to use. ... |
Performs a GET on the account as a listing request. | def cli_get_account_listing(context):
"""
Performs a GET on the account as a listing request.
See :py:mod:`swiftly.cli.get` for context usage information.
See :py:class:`CLIGet` for more information.
"""
limit = context.query.get('limit')
delimiter = context.query.get('delimiter')
pref... |
Performs a GET on the container as a listing request. | def cli_get_container_listing(context, path=None):
"""
Performs a GET on the container as a listing request.
See :py:mod:`swiftly.cli.get` for context usage information.
See :py:class:`CLIGet` for more information.
"""
path = path.strip('/') if path else None
if not path or '/' in path:
... |
Performs a GET on the item ( account container or object ). | def cli_get(context, path=None):
"""
Performs a GET on the item (account, container, or object).
See :py:mod:`swiftly.cli.get` for context usage information.
See :py:class:`CLIGet` for more information.
"""
path = path.lstrip('/') if path else None
if not path:
return cli_get_accou... |
See: py: func: swiftly. client. client. Client. request | def request(self, method, path, contents, headers, decode_json=False,
stream=False, query=None, cdn=False):
"""
See :py:func:`swiftly.client.client.Client.request`
"""
if cdn:
raise Exception('CDN not yet supported with LocalClient')
if isinstance(cont... |
Resolves an option value into options. | def _resolve_option(self, options, option_name, section_name):
"""Resolves an option value into options.
Sets options.<option_name> to a resolved value. Any value
already in options overrides a value in os.environ which
overrides self.context.conf.
:param options: The options i... |
Performs a POST on the item ( account container or object ). | def cli_post(context, path, body=None):
"""
Performs a POST on the item (account, container, or object).
See :py:mod:`swiftly.cli.post` for context usage information.
See :py:class:`CLIPost` for more information.
:param context: The :py:class:`swiftly.cli.context.CLIContext` to
use.
:... |
Returns a new CLIContext instance that is a shallow copy of the original much like dict s copy method. | def copy(self):
"""
Returns a new CLIContext instance that is a shallow copy of
the original, much like dict's copy method.
"""
context = CLIContext()
for item in dir(self):
if item[0] != '_' and item not in ('copy', 'write_headers'):
setattr(c... |
Convenience function to output headers in a formatted fashion to a file - like fp optionally muting any headers in the mute list. | def write_headers(self, fp, headers, mute=None):
"""
Convenience function to output headers in a formatted fashion
to a file-like fp, optionally muting any headers in the mute
list.
"""
if headers:
if not mute:
mute = []
fmt = '%%-%... |
See: py: func: swiftly. client. client. Client. request | def request(self, method, path, contents, headers, decode_json=False,
stream=False, query=None, cdn=False):
"""
See :py:func:`swiftly.client.client.Client.request`
"""
if query:
path += '?' + '&'.join(
('%s=%s' % (quote(k), quote(v)) if v else ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.