Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Here is a snippet: <|code_start|># vim: tabstop=4 shiftwidth=4 softtabstop=4
# -*- encoding: utf-8 -*-
# Copyright © 2012 New Dream Network, LLC (DreamHost)
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
auth_opts = [
cfg.StrOpt('auth_strategy',
default='noauth',
help='Method to use for auth: noauth or keystone.'),
]
CONF = cfg.CONF
<|code_end|>
. Write the next line using the current file imports:
from oslo.config import cfg
from tuskar.api import acl
from tuskar.api import config
from tuskar.api import hooks
from tuskar.api import renderers
import pecan
and context from other files:
# Path: tuskar/api/acl.py
# OPT_GROUP_NAME = 'keystone_authtoken'
# def register_opts(conf):
# def install(app, conf):
# def before(self, state):
# class AdminAuthHook(hooks.PecanHook):
#
# Path: tuskar/api/config.py
#
# Path: tuskar/api/hooks.py
# class ConfigHook(hooks.PecanHook):
# class DBHook(hooks.PecanHook):
# def before(self, state):
# def before(self, state):
#
# Path: tuskar/api/renderers.py
# class JSonRenderer(object):
# def __init__(self, path, extra_vars):
# def render(self, template_path, namespace):
, which may include functions, classes, or code. Output only the next line. | CONF.register_opts(auth_opts) |
Given snippet: <|code_start|> # Set up the pecan configuration
filename = config.__file__.replace('.pyc', '.py')
return pecan.configuration.conf_from_file(filename)
def setup_app(pecan_config=None, extra_hooks=None):
app_hooks = [hooks.ConfigHook(),
hooks.DBHook()]
if extra_hooks:
app_hooks.extend(extra_hooks)
if not pecan_config:
pecan_config = get_pecan_config()
if pecan_config.app.enable_acl:
app_hooks.append(acl.AdminAuthHook())
pecan.configuration.set_config(dict(pecan_config), overwrite=True)
# TODO(deva): add middleware.ParsableErrorMiddleware from Ceilometer
app = pecan.make_app(
pecan_config.app.root,
custom_renderers=dict(wsmejson=renderers.JSonRenderer),
static_root=pecan_config.app.static_root,
template_path=pecan_config.app.template_path,
debug=CONF.debug,
force_canonical=getattr(pecan_config.app, 'force_canonical', True),
hooks=app_hooks,
)
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from oslo.config import cfg
from tuskar.api import acl
from tuskar.api import config
from tuskar.api import hooks
from tuskar.api import renderers
import pecan
and context:
# Path: tuskar/api/acl.py
# OPT_GROUP_NAME = 'keystone_authtoken'
# def register_opts(conf):
# def install(app, conf):
# def before(self, state):
# class AdminAuthHook(hooks.PecanHook):
#
# Path: tuskar/api/config.py
#
# Path: tuskar/api/hooks.py
# class ConfigHook(hooks.PecanHook):
# class DBHook(hooks.PecanHook):
# def before(self, state):
# def before(self, state):
#
# Path: tuskar/api/renderers.py
# class JSonRenderer(object):
# def __init__(self, path, extra_vars):
# def render(self, template_path, namespace):
which might include code, classes, or functions. Output only the next line. | if pecan_config.app.enable_acl: |
Predict the next line for this snippet: <|code_start|># Copyright © 2012 New Dream Network, LLC (DreamHost)
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
auth_opts = [
cfg.StrOpt('auth_strategy',
default='noauth',
help='Method to use for auth: noauth or keystone.'),
]
CONF = cfg.CONF
CONF.register_opts(auth_opts)
def get_pecan_config():
# Set up the pecan configuration
filename = config.__file__.replace('.pyc', '.py')
<|code_end|>
with the help of current file imports:
from oslo.config import cfg
from tuskar.api import acl
from tuskar.api import config
from tuskar.api import hooks
from tuskar.api import renderers
import pecan
and context from other files:
# Path: tuskar/api/acl.py
# OPT_GROUP_NAME = 'keystone_authtoken'
# def register_opts(conf):
# def install(app, conf):
# def before(self, state):
# class AdminAuthHook(hooks.PecanHook):
#
# Path: tuskar/api/config.py
#
# Path: tuskar/api/hooks.py
# class ConfigHook(hooks.PecanHook):
# class DBHook(hooks.PecanHook):
# def before(self, state):
# def before(self, state):
#
# Path: tuskar/api/renderers.py
# class JSonRenderer(object):
# def __init__(self, path, extra_vars):
# def render(self, template_path, namespace):
, which may contain function names, class names, or code. Output only the next line. | return pecan.configuration.conf_from_file(filename) |
Continue the code snippet: <|code_start|>class ClientException(Exception):
"""This encapsulates some actual exception that is expected to be
hit by an RPC proxy object. Merely instantiating it records the
current exception information, which will be passed back to the
RPC client without exceptional logging."""
def __init__(self):
self._exc_info = sys.exc_info()
def catch_client_exception(exceptions, func, *args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as e:
if type(e) in exceptions:
raise ClientException()
else:
raise
def client_exceptions(*exceptions):
"""Decorator for manager methods that raise expected exceptions.
Marking a Manager method with this decorator allows the declaration
of expected exceptions that the RPC layer should not consider fatal,
and not log as if they were generated in a real error scenario. Note
that this will cause listed exceptions to be wrapped in a
ClientException, which is used internally by the RPC layer."""
def outer(func):
def inner(*args, **kwargs):
return catch_client_exception(exceptions, func, *args, **kwargs)
return inner
<|code_end|>
. Use current file imports:
import copy
import sys
import traceback
import six
from oslo.config import cfg
from tuskar.openstack.common.gettextutils import _
from tuskar.openstack.common import importutils
from tuskar.openstack.common import jsonutils
from tuskar.openstack.common import local
from tuskar.openstack.common import log as logging
and context (classes, functions, or code) from other files:
# Path: tuskar/openstack/common/gettextutils.py
# def _(msg):
# return _t.ugettext(msg)
#
# Path: tuskar/openstack/common/importutils.py
# def import_class(import_str):
# def import_object(import_str, *args, **kwargs):
# def import_object_ns(name_space, import_str, *args, **kwargs):
# def import_module(import_str):
# def try_import(import_str, default=None):
#
# Path: tuskar/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
# level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):
#
# Path: tuskar/openstack/common/local.py
# class WeakLocal(corolocal.local):
# def __getattribute__(self, attr):
# def __setattr__(self, attr, value):
#
# Path: tuskar/openstack/common/log.py
# _DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
# CONF = cfg.CONF
# LEVEL_COLORS = {
# logging.DEBUG: '\033[00;32m', # GREEN
# logging.INFO: '\033[00;36m', # CYAN
# logging.AUDIT: '\033[01;36m', # BOLD CYAN
# logging.WARN: '\033[01;33m', # BOLD YELLOW
# logging.ERROR: '\033[01;31m', # BOLD RED
# logging.CRITICAL: '\033[01;31m', # BOLD RED
# }
# class NullHandler(logging.Handler):
# class BaseLoggerAdapter(logging.LoggerAdapter):
# class LazyAdapter(BaseLoggerAdapter):
# class ContextAdapter(BaseLoggerAdapter):
# class JSONFormatter(logging.Formatter):
# class LogConfigError(Exception):
# class WritableLogger(object):
# class ContextFormatter(logging.Formatter):
# class ColorHandler(logging.StreamHandler):
# class DeprecatedConfig(Exception):
# def handle(self, record):
# def emit(self, record):
# def createLock(self):
# def _dictify_context(context):
# def _get_binary_name():
# def _get_log_file_path(binary=None):
# def audit(self, msg, *args, **kwargs):
# def __init__(self, name='unknown', version='unknown'):
# def logger(self):
# def __init__(self, logger, project_name, version_string):
# def handlers(self):
# def deprecated(self, msg, *args, **kwargs):
# def process(self, msg, kwargs):
# def __init__(self, fmt=None, datefmt=None):
# def formatException(self, ei, strip_newlines=True):
# def format(self, record):
# def _create_logging_excepthook(product_name):
# def logging_excepthook(type, value, tb):
# def __init__(self, log_config, err_msg):
# def __str__(self):
# def _load_log_config(log_config):
# def setup(product_name):
# def set_defaults(logging_context_format_string):
# def _find_facility_from_conf():
# def _setup_logging_from_conf():
# def getLogger(name='unknown', version='unknown'):
# def getLazyLogger(name='unknown', version='unknown'):
# def __init__(self, logger, level=logging.INFO):
# def write(self, msg):
# def format(self, record):
# def formatException(self, exc_info, record=None):
# def format(self, record):
# def __init__(self, msg):
. Output only the next line. | return outer |
Predict the next line for this snippet: <|code_start|> # convert the RpcContext back to its native RequestContext doing
# something like nova.context.RequestContext.from_dict(ctxt.to_dict())
context = self.deepcopy()
context.values['is_admin'] = True
context.values.setdefault('roles', [])
if 'admin' not in context.values['roles']:
context.values['roles'].append('admin')
if read_deleted is not None:
context.values['read_deleted'] = read_deleted
return context
class ClientException(Exception):
"""This encapsulates some actual exception that is expected to be
hit by an RPC proxy object. Merely instantiating it records the
current exception information, which will be passed back to the
RPC client without exceptional logging."""
def __init__(self):
self._exc_info = sys.exc_info()
def catch_client_exception(exceptions, func, *args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as e:
<|code_end|>
with the help of current file imports:
import copy
import sys
import traceback
import six
from oslo.config import cfg
from tuskar.openstack.common.gettextutils import _
from tuskar.openstack.common import importutils
from tuskar.openstack.common import jsonutils
from tuskar.openstack.common import local
from tuskar.openstack.common import log as logging
and context from other files:
# Path: tuskar/openstack/common/gettextutils.py
# def _(msg):
# return _t.ugettext(msg)
#
# Path: tuskar/openstack/common/importutils.py
# def import_class(import_str):
# def import_object(import_str, *args, **kwargs):
# def import_object_ns(name_space, import_str, *args, **kwargs):
# def import_module(import_str):
# def try_import(import_str, default=None):
#
# Path: tuskar/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
# level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):
#
# Path: tuskar/openstack/common/local.py
# class WeakLocal(corolocal.local):
# def __getattribute__(self, attr):
# def __setattr__(self, attr, value):
#
# Path: tuskar/openstack/common/log.py
# _DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
# CONF = cfg.CONF
# LEVEL_COLORS = {
# logging.DEBUG: '\033[00;32m', # GREEN
# logging.INFO: '\033[00;36m', # CYAN
# logging.AUDIT: '\033[01;36m', # BOLD CYAN
# logging.WARN: '\033[01;33m', # BOLD YELLOW
# logging.ERROR: '\033[01;31m', # BOLD RED
# logging.CRITICAL: '\033[01;31m', # BOLD RED
# }
# class NullHandler(logging.Handler):
# class BaseLoggerAdapter(logging.LoggerAdapter):
# class LazyAdapter(BaseLoggerAdapter):
# class ContextAdapter(BaseLoggerAdapter):
# class JSONFormatter(logging.Formatter):
# class LogConfigError(Exception):
# class WritableLogger(object):
# class ContextFormatter(logging.Formatter):
# class ColorHandler(logging.StreamHandler):
# class DeprecatedConfig(Exception):
# def handle(self, record):
# def emit(self, record):
# def createLock(self):
# def _dictify_context(context):
# def _get_binary_name():
# def _get_log_file_path(binary=None):
# def audit(self, msg, *args, **kwargs):
# def __init__(self, name='unknown', version='unknown'):
# def logger(self):
# def __init__(self, logger, project_name, version_string):
# def handlers(self):
# def deprecated(self, msg, *args, **kwargs):
# def process(self, msg, kwargs):
# def __init__(self, fmt=None, datefmt=None):
# def formatException(self, ei, strip_newlines=True):
# def format(self, record):
# def _create_logging_excepthook(product_name):
# def logging_excepthook(type, value, tb):
# def __init__(self, log_config, err_msg):
# def __str__(self):
# def _load_log_config(log_config):
# def setup(product_name):
# def set_defaults(logging_context_format_string):
# def _find_facility_from_conf():
# def _setup_logging_from_conf():
# def getLogger(name='unknown', version='unknown'):
# def getLazyLogger(name='unknown', version='unknown'):
# def __init__(self, logger, level=logging.INFO):
# def write(self, msg):
# def format(self, record):
# def formatException(self, exc_info, record=None):
# def format(self, record):
# def __init__(self, msg):
, which may contain function names, class names, or code. Output only the next line. | if type(e) in exceptions: |
Continue the code snippet: <|code_start|> local.store.context = self
def elevated(self, read_deleted=None, overwrite=False):
"""Return a version of this context with admin flag set."""
# TODO(russellb) This method is a bit of a nova-ism. It makes
# some assumptions about the data in the request context sent
# across rpc, while the rest of this class does not. We could get
# rid of this if we changed the nova code that uses this to
# convert the RpcContext back to its native RequestContext doing
# something like nova.context.RequestContext.from_dict(ctxt.to_dict())
context = self.deepcopy()
context.values['is_admin'] = True
context.values.setdefault('roles', [])
if 'admin' not in context.values['roles']:
context.values['roles'].append('admin')
if read_deleted is not None:
context.values['read_deleted'] = read_deleted
return context
class ClientException(Exception):
"""This encapsulates some actual exception that is expected to be
hit by an RPC proxy object. Merely instantiating it records the
current exception information, which will be passed back to the
RPC client without exceptional logging."""
<|code_end|>
. Use current file imports:
import copy
import sys
import traceback
import six
from oslo.config import cfg
from tuskar.openstack.common.gettextutils import _
from tuskar.openstack.common import importutils
from tuskar.openstack.common import jsonutils
from tuskar.openstack.common import local
from tuskar.openstack.common import log as logging
and context (classes, functions, or code) from other files:
# Path: tuskar/openstack/common/gettextutils.py
# def _(msg):
# return _t.ugettext(msg)
#
# Path: tuskar/openstack/common/importutils.py
# def import_class(import_str):
# def import_object(import_str, *args, **kwargs):
# def import_object_ns(name_space, import_str, *args, **kwargs):
# def import_module(import_str):
# def try_import(import_str, default=None):
#
# Path: tuskar/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
# level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):
#
# Path: tuskar/openstack/common/local.py
# class WeakLocal(corolocal.local):
# def __getattribute__(self, attr):
# def __setattr__(self, attr, value):
#
# Path: tuskar/openstack/common/log.py
# _DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
# CONF = cfg.CONF
# LEVEL_COLORS = {
# logging.DEBUG: '\033[00;32m', # GREEN
# logging.INFO: '\033[00;36m', # CYAN
# logging.AUDIT: '\033[01;36m', # BOLD CYAN
# logging.WARN: '\033[01;33m', # BOLD YELLOW
# logging.ERROR: '\033[01;31m', # BOLD RED
# logging.CRITICAL: '\033[01;31m', # BOLD RED
# }
# class NullHandler(logging.Handler):
# class BaseLoggerAdapter(logging.LoggerAdapter):
# class LazyAdapter(BaseLoggerAdapter):
# class ContextAdapter(BaseLoggerAdapter):
# class JSONFormatter(logging.Formatter):
# class LogConfigError(Exception):
# class WritableLogger(object):
# class ContextFormatter(logging.Formatter):
# class ColorHandler(logging.StreamHandler):
# class DeprecatedConfig(Exception):
# def handle(self, record):
# def emit(self, record):
# def createLock(self):
# def _dictify_context(context):
# def _get_binary_name():
# def _get_log_file_path(binary=None):
# def audit(self, msg, *args, **kwargs):
# def __init__(self, name='unknown', version='unknown'):
# def logger(self):
# def __init__(self, logger, project_name, version_string):
# def handlers(self):
# def deprecated(self, msg, *args, **kwargs):
# def process(self, msg, kwargs):
# def __init__(self, fmt=None, datefmt=None):
# def formatException(self, ei, strip_newlines=True):
# def format(self, record):
# def _create_logging_excepthook(product_name):
# def logging_excepthook(type, value, tb):
# def __init__(self, log_config, err_msg):
# def __str__(self):
# def _load_log_config(log_config):
# def setup(product_name):
# def set_defaults(logging_context_format_string):
# def _find_facility_from_conf():
# def _setup_logging_from_conf():
# def getLogger(name='unknown', version='unknown'):
# def getLazyLogger(name='unknown', version='unknown'):
# def __init__(self, logger, level=logging.INFO):
# def write(self, msg):
# def format(self, record):
# def formatException(self, exc_info, record=None):
# def format(self, record):
# def __init__(self, msg):
. Output only the next line. | def __init__(self): |
Predict the next line after this snippet: <|code_start|> return context
class ClientException(Exception):
"""This encapsulates some actual exception that is expected to be
hit by an RPC proxy object. Merely instantiating it records the
current exception information, which will be passed back to the
RPC client without exceptional logging."""
def __init__(self):
self._exc_info = sys.exc_info()
def catch_client_exception(exceptions, func, *args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as e:
if type(e) in exceptions:
raise ClientException()
else:
raise
def client_exceptions(*exceptions):
"""Decorator for manager methods that raise expected exceptions.
Marking a Manager method with this decorator allows the declaration
of expected exceptions that the RPC layer should not consider fatal,
and not log as if they were generated in a real error scenario. Note
that this will cause listed exceptions to be wrapped in a
ClientException, which is used internally by the RPC layer."""
def outer(func):
<|code_end|>
using the current file's imports:
import copy
import sys
import traceback
import six
from oslo.config import cfg
from tuskar.openstack.common.gettextutils import _
from tuskar.openstack.common import importutils
from tuskar.openstack.common import jsonutils
from tuskar.openstack.common import local
from tuskar.openstack.common import log as logging
and any relevant context from other files:
# Path: tuskar/openstack/common/gettextutils.py
# def _(msg):
# return _t.ugettext(msg)
#
# Path: tuskar/openstack/common/importutils.py
# def import_class(import_str):
# def import_object(import_str, *args, **kwargs):
# def import_object_ns(name_space, import_str, *args, **kwargs):
# def import_module(import_str):
# def try_import(import_str, default=None):
#
# Path: tuskar/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
# level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):
#
# Path: tuskar/openstack/common/local.py
# class WeakLocal(corolocal.local):
# def __getattribute__(self, attr):
# def __setattr__(self, attr, value):
#
# Path: tuskar/openstack/common/log.py
# _DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
# CONF = cfg.CONF
# LEVEL_COLORS = {
# logging.DEBUG: '\033[00;32m', # GREEN
# logging.INFO: '\033[00;36m', # CYAN
# logging.AUDIT: '\033[01;36m', # BOLD CYAN
# logging.WARN: '\033[01;33m', # BOLD YELLOW
# logging.ERROR: '\033[01;31m', # BOLD RED
# logging.CRITICAL: '\033[01;31m', # BOLD RED
# }
# class NullHandler(logging.Handler):
# class BaseLoggerAdapter(logging.LoggerAdapter):
# class LazyAdapter(BaseLoggerAdapter):
# class ContextAdapter(BaseLoggerAdapter):
# class JSONFormatter(logging.Formatter):
# class LogConfigError(Exception):
# class WritableLogger(object):
# class ContextFormatter(logging.Formatter):
# class ColorHandler(logging.StreamHandler):
# class DeprecatedConfig(Exception):
# def handle(self, record):
# def emit(self, record):
# def createLock(self):
# def _dictify_context(context):
# def _get_binary_name():
# def _get_log_file_path(binary=None):
# def audit(self, msg, *args, **kwargs):
# def __init__(self, name='unknown', version='unknown'):
# def logger(self):
# def __init__(self, logger, project_name, version_string):
# def handlers(self):
# def deprecated(self, msg, *args, **kwargs):
# def process(self, msg, kwargs):
# def __init__(self, fmt=None, datefmt=None):
# def formatException(self, ei, strip_newlines=True):
# def format(self, record):
# def _create_logging_excepthook(product_name):
# def logging_excepthook(type, value, tb):
# def __init__(self, log_config, err_msg):
# def __str__(self):
# def _load_log_config(log_config):
# def setup(product_name):
# def set_defaults(logging_context_format_string):
# def _find_facility_from_conf():
# def _setup_logging_from_conf():
# def getLogger(name='unknown', version='unknown'):
# def getLazyLogger(name='unknown', version='unknown'):
# def __init__(self, logger, level=logging.INFO):
# def write(self, msg):
# def format(self, record):
# def formatException(self, exc_info, record=None):
# def format(self, record):
# def __init__(self, msg):
. Output only the next line. | def inner(*args, **kwargs): |
Continue the code snippet: <|code_start|>
return context
class ClientException(Exception):
"""This encapsulates some actual exception that is expected to be
hit by an RPC proxy object. Merely instantiating it records the
current exception information, which will be passed back to the
RPC client without exceptional logging."""
def __init__(self):
self._exc_info = sys.exc_info()
def catch_client_exception(exceptions, func, *args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as e:
if type(e) in exceptions:
raise ClientException()
else:
raise
def client_exceptions(*exceptions):
"""Decorator for manager methods that raise expected exceptions.
Marking a Manager method with this decorator allows the declaration
of expected exceptions that the RPC layer should not consider fatal,
and not log as if they were generated in a real error scenario. Note
that this will cause listed exceptions to be wrapped in a
ClientException, which is used internally by the RPC layer."""
<|code_end|>
. Use current file imports:
import copy
import sys
import traceback
import six
from oslo.config import cfg
from tuskar.openstack.common.gettextutils import _
from tuskar.openstack.common import importutils
from tuskar.openstack.common import jsonutils
from tuskar.openstack.common import local
from tuskar.openstack.common import log as logging
and context (classes, functions, or code) from other files:
# Path: tuskar/openstack/common/gettextutils.py
# def _(msg):
# return _t.ugettext(msg)
#
# Path: tuskar/openstack/common/importutils.py
# def import_class(import_str):
# def import_object(import_str, *args, **kwargs):
# def import_object_ns(name_space, import_str, *args, **kwargs):
# def import_module(import_str):
# def try_import(import_str, default=None):
#
# Path: tuskar/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
# level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):
#
# Path: tuskar/openstack/common/local.py
# class WeakLocal(corolocal.local):
# def __getattribute__(self, attr):
# def __setattr__(self, attr, value):
#
# Path: tuskar/openstack/common/log.py
# _DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
# CONF = cfg.CONF
# LEVEL_COLORS = {
# logging.DEBUG: '\033[00;32m', # GREEN
# logging.INFO: '\033[00;36m', # CYAN
# logging.AUDIT: '\033[01;36m', # BOLD CYAN
# logging.WARN: '\033[01;33m', # BOLD YELLOW
# logging.ERROR: '\033[01;31m', # BOLD RED
# logging.CRITICAL: '\033[01;31m', # BOLD RED
# }
# class NullHandler(logging.Handler):
# class BaseLoggerAdapter(logging.LoggerAdapter):
# class LazyAdapter(BaseLoggerAdapter):
# class ContextAdapter(BaseLoggerAdapter):
# class JSONFormatter(logging.Formatter):
# class LogConfigError(Exception):
# class WritableLogger(object):
# class ContextFormatter(logging.Formatter):
# class ColorHandler(logging.StreamHandler):
# class DeprecatedConfig(Exception):
# def handle(self, record):
# def emit(self, record):
# def createLock(self):
# def _dictify_context(context):
# def _get_binary_name():
# def _get_log_file_path(binary=None):
# def audit(self, msg, *args, **kwargs):
# def __init__(self, name='unknown', version='unknown'):
# def logger(self):
# def __init__(self, logger, project_name, version_string):
# def handlers(self):
# def deprecated(self, msg, *args, **kwargs):
# def process(self, msg, kwargs):
# def __init__(self, fmt=None, datefmt=None):
# def formatException(self, ei, strip_newlines=True):
# def format(self, record):
# def _create_logging_excepthook(product_name):
# def logging_excepthook(type, value, tb):
# def __init__(self, log_config, err_msg):
# def __str__(self):
# def _load_log_config(log_config):
# def setup(product_name):
# def set_defaults(logging_context_format_string):
# def _find_facility_from_conf():
# def _setup_logging_from_conf():
# def getLogger(name='unknown', version='unknown'):
# def getLazyLogger(name='unknown', version='unknown'):
# def __init__(self, logger, level=logging.INFO):
# def write(self, msg):
# def format(self, record):
# def formatException(self, exc_info, record=None):
# def format(self, record):
# def __init__(self, msg):
. Output only the next line. | def outer(func): |
Here is a snippet: <|code_start|># Copyright 2012 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
CONF = cfg.CONF
class PolicyFixture(fixtures.Fixture):
def setUp(self):
super(PolicyFixture, self).setUp()
self.policy_dir = self.useFixture(fixtures.TempDir())
<|code_end|>
. Write the next line using the current file imports:
import os
import fixtures
from oslo.config import cfg
from tuskar.common import policy as tuskar_policy
from tuskar.openstack.common import policy as common_policy
from tuskar.tests import fake_policy
and context from other files:
# Path: tuskar/openstack/common/policy.py
# LOG = logging.getLogger(__name__)
# class Rules(dict):
# class BaseCheck(object):
# class FalseCheck(BaseCheck):
# class TrueCheck(BaseCheck):
# class Check(BaseCheck):
# class NotCheck(BaseCheck):
# class AndCheck(BaseCheck):
# class OrCheck(BaseCheck):
# class ParseStateMeta(type):
# class ParseState(object):
# class RuleCheck(Check):
# class RoleCheck(Check):
# class HttpCheck(Check):
# class GenericCheck(Check):
# def load_json(cls, data, default_rule=None):
# def __init__(self, rules=None, default_rule=None):
# def __missing__(self, key):
# def __str__(self):
# def set_rules(rules):
# def reset():
# def check(rule, target, creds, exc=None, *args, **kwargs):
# def __str__(self):
# def __call__(self, target, cred):
# def __str__(self):
# def __call__(self, target, cred):
# def __str__(self):
# def __call__(self, target, cred):
# def __init__(self, kind, match):
# def __str__(self):
# def __init__(self, rule):
# def __str__(self):
# def __call__(self, target, cred):
# def __init__(self, rules):
# def __str__(self):
# def __call__(self, target, cred):
# def add_check(self, rule):
# def __init__(self, rules):
# def __str__(self):
# def __call__(self, target, cred):
# def add_check(self, rule):
# def _parse_check(rule):
# def _parse_list_rule(rule):
# def _parse_tokenize(rule):
# def __new__(mcs, name, bases, cls_dict):
# def reducer(*tokens):
# def decorator(func):
# def __init__(self):
# def reduce(self):
# def shift(self, tok, value):
# def result(self):
# def _wrap_check(self, _p1, check, _p2):
# def _make_and_expr(self, check1, _and, check2):
# def _extend_and_expr(self, and_expr, _and, check):
# def _make_or_expr(self, check1, _or, check2):
# def _extend_or_expr(self, or_expr, _or, check):
# def _make_not_expr(self, _not, check):
# def _parse_text_rule(rule):
# def parse_rule(rule):
# def register(name, func=None):
# def decorator(func):
# def __call__(self, target, creds):
# def __call__(self, target, creds):
# def __call__(self, target, creds):
# def __call__(self, target, creds):
#
# Path: tuskar/tests/fake_policy.py
, which may include functions, classes, or code. Output only the next line. | self.policy_file_name = os.path.join(self.policy_dir.path, |
Next line prediction: <|code_start|>
# The module.Class to use for matchmaking.
cfg.StrOpt(
'rpc_zmq_matchmaker',
default=('tuskar.openstack.common.rpc.'
'matchmaker.MatchMakerLocalhost'),
help='MatchMaker driver',
),
# The following port is unassigned by IANA as of 2012-05-21
cfg.IntOpt('rpc_zmq_port', default=9501,
help='ZeroMQ receiver listening port'),
cfg.IntOpt('rpc_zmq_contexts', default=1,
help='Number of ZeroMQ contexts, defaults to 1'),
cfg.IntOpt('rpc_zmq_topic_backlog', default=None,
help='Maximum number of ingress messages to locally buffer '
'per topic. Default is unlimited.'),
cfg.StrOpt('rpc_zmq_ipc_dir', default='/var/run/openstack',
help='Directory for holding IPC sockets'),
cfg.StrOpt('rpc_zmq_host', default=socket.gethostname(),
help='Name of this node. Must be a valid hostname, FQDN, or '
'IP address. Must match "host" option, if running Nova.')
]
CONF = cfg.CONF
<|code_end|>
. Use current file imports:
(import os
import pprint
import re
import socket
import sys
import types
import uuid
import eventlet
import greenlet
from oslo.config import cfg
from tuskar.openstack.common import excutils
from tuskar.openstack.common.gettextutils import _
from tuskar.openstack.common import importutils
from tuskar.openstack.common import jsonutils
from tuskar.openstack.common import processutils as utils
from tuskar.openstack.common.rpc import common as rpc_common)
and context including class names, function names, or small code snippets from other files:
# Path: tuskar/openstack/common/excutils.py
# def save_and_reraise_exception():
#
# Path: tuskar/openstack/common/gettextutils.py
# def _(msg):
# return _t.ugettext(msg)
#
# Path: tuskar/openstack/common/importutils.py
# def import_class(import_str):
# def import_object(import_str, *args, **kwargs):
# def import_object_ns(name_space, import_str, *args, **kwargs):
# def import_module(import_str):
# def try_import(import_str, default=None):
#
# Path: tuskar/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
# level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):
#
# Path: tuskar/openstack/common/processutils.py
# LOG = logging.getLogger(__name__)
# _PIPE = subprocess.PIPE # pylint: disable=E1101
# class InvalidArgumentError(Exception):
# class UnknownArgumentError(Exception):
# class ProcessExecutionError(Exception):
# class NoRootWrapSpecified(Exception):
# def __init__(self, message=None):
# def __init__(self, message=None):
# def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
# description=None):
# def __init__(self, message=None):
# def _subprocess_setup():
# def execute(*cmd, **kwargs):
# def trycmd(*args, **kwargs):
# def ssh_execute(ssh, cmd, process_input=None,
# addl_env=None, check_exit_code=True):
#
# Path: tuskar/openstack/common/rpc/common.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# _RPC_ENVELOPE_VERSION = '2.0'
# _VERSION_KEY = 'oslo.version'
# _MESSAGE_KEY = 'oslo.message'
# SANITIZE = {'set_admin_password': [('args', 'new_pass')],
# 'run_instance': [('args', 'admin_password')],
# 'route_message': [('args', 'message', 'args', 'method_info',
# 'method_kwargs', 'password'),
# ('args', 'message', 'args', 'method_info',
# 'method_kwargs', 'admin_password')]}
# class RPCException(Exception):
# class RemoteError(RPCException):
# class Timeout(RPCException):
# class DuplicateMessageError(RPCException):
# class InvalidRPCConnectionReuse(RPCException):
# class UnsupportedRpcVersion(RPCException):
# class UnsupportedRpcEnvelopeVersion(RPCException):
# class RpcVersionCapError(RPCException):
# class Connection(object):
# class CommonRpcContext(object):
# class ClientException(Exception):
# def __init__(self, message=None, **kwargs):
# def __init__(self, exc_type=None, value=None, traceback=None):
# def __init__(self, info=None, topic=None, method=None):
# def close(self):
# def create_consumer(self, topic, proxy, fanout=False):
# def create_worker(self, topic, proxy, pool_name):
# def join_consumer_pool(self, callback, pool_name, topic, exchange_name):
# def consume_in_thread(self):
# def _safe_log(log_func, msg, msg_data):
# def serialize_remote_exception(failure_info, log_failure=True):
# def deserialize_remote_exception(conf, data):
# def __init__(self, **kwargs):
# def __getattr__(self, key):
# def to_dict(self):
# def from_dict(cls, values):
# def deepcopy(self):
# def update_store(self):
# def elevated(self, read_deleted=None, overwrite=False):
# def __init__(self):
# def catch_client_exception(exceptions, func, *args, **kwargs):
# def client_exceptions(*exceptions):
# def outer(func):
# def inner(*args, **kwargs):
# def version_is_compatible(imp_version, version):
# def serialize_msg(raw_msg):
# def deserialize_msg(msg):
. Output only the next line. | CONF.register_opts(zmq_opts) |
Given the following code snippet before the placeholder: <|code_start|># under the License.
zmq = importutils.try_import('eventlet.green.zmq')
# for convenience, are not modified.
pformat = pprint.pformat
Timeout = eventlet.timeout.Timeout
LOG = rpc_common.LOG
RemoteError = rpc_common.RemoteError
RPCException = rpc_common.RPCException
zmq_opts = [
cfg.StrOpt('rpc_zmq_bind_address', default='*',
help='ZeroMQ bind address. Should be a wildcard (*), '
'an ethernet interface, or IP. '
'The "host" option should point or resolve to this '
'address.'),
# The module.Class to use for matchmaking.
cfg.StrOpt(
'rpc_zmq_matchmaker',
default=('tuskar.openstack.common.rpc.'
'matchmaker.MatchMakerLocalhost'),
help='MatchMaker driver',
),
# The following port is unassigned by IANA as of 2012-05-21
<|code_end|>
, predict the next line using imports from the current file:
import os
import pprint
import re
import socket
import sys
import types
import uuid
import eventlet
import greenlet
from oslo.config import cfg
from tuskar.openstack.common import excutils
from tuskar.openstack.common.gettextutils import _
from tuskar.openstack.common import importutils
from tuskar.openstack.common import jsonutils
from tuskar.openstack.common import processutils as utils
from tuskar.openstack.common.rpc import common as rpc_common
and context including class names, function names, and sometimes code from other files:
# Path: tuskar/openstack/common/excutils.py
# def save_and_reraise_exception():
#
# Path: tuskar/openstack/common/gettextutils.py
# def _(msg):
# return _t.ugettext(msg)
#
# Path: tuskar/openstack/common/importutils.py
# def import_class(import_str):
# def import_object(import_str, *args, **kwargs):
# def import_object_ns(name_space, import_str, *args, **kwargs):
# def import_module(import_str):
# def try_import(import_str, default=None):
#
# Path: tuskar/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
# level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):
#
# Path: tuskar/openstack/common/processutils.py
# LOG = logging.getLogger(__name__)
# _PIPE = subprocess.PIPE # pylint: disable=E1101
# class InvalidArgumentError(Exception):
# class UnknownArgumentError(Exception):
# class ProcessExecutionError(Exception):
# class NoRootWrapSpecified(Exception):
# def __init__(self, message=None):
# def __init__(self, message=None):
# def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
# description=None):
# def __init__(self, message=None):
# def _subprocess_setup():
# def execute(*cmd, **kwargs):
# def trycmd(*args, **kwargs):
# def ssh_execute(ssh, cmd, process_input=None,
# addl_env=None, check_exit_code=True):
#
# Path: tuskar/openstack/common/rpc/common.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# _RPC_ENVELOPE_VERSION = '2.0'
# _VERSION_KEY = 'oslo.version'
# _MESSAGE_KEY = 'oslo.message'
# SANITIZE = {'set_admin_password': [('args', 'new_pass')],
# 'run_instance': [('args', 'admin_password')],
# 'route_message': [('args', 'message', 'args', 'method_info',
# 'method_kwargs', 'password'),
# ('args', 'message', 'args', 'method_info',
# 'method_kwargs', 'admin_password')]}
# class RPCException(Exception):
# class RemoteError(RPCException):
# class Timeout(RPCException):
# class DuplicateMessageError(RPCException):
# class InvalidRPCConnectionReuse(RPCException):
# class UnsupportedRpcVersion(RPCException):
# class UnsupportedRpcEnvelopeVersion(RPCException):
# class RpcVersionCapError(RPCException):
# class Connection(object):
# class CommonRpcContext(object):
# class ClientException(Exception):
# def __init__(self, message=None, **kwargs):
# def __init__(self, exc_type=None, value=None, traceback=None):
# def __init__(self, info=None, topic=None, method=None):
# def close(self):
# def create_consumer(self, topic, proxy, fanout=False):
# def create_worker(self, topic, proxy, pool_name):
# def join_consumer_pool(self, callback, pool_name, topic, exchange_name):
# def consume_in_thread(self):
# def _safe_log(log_func, msg, msg_data):
# def serialize_remote_exception(failure_info, log_failure=True):
# def deserialize_remote_exception(conf, data):
# def __init__(self, **kwargs):
# def __getattr__(self, key):
# def to_dict(self):
# def from_dict(cls, values):
# def deepcopy(self):
# def update_store(self):
# def elevated(self, read_deleted=None, overwrite=False):
# def __init__(self):
# def catch_client_exception(exceptions, func, *args, **kwargs):
# def client_exceptions(*exceptions):
# def outer(func):
# def inner(*args, **kwargs):
# def version_is_compatible(imp_version, version):
# def serialize_msg(raw_msg):
# def deserialize_msg(msg):
. Output only the next line. | cfg.IntOpt('rpc_zmq_port', default=9501, |
Predict the next line after this snippet: <|code_start|># for convenience, are not modified.
pformat = pprint.pformat
Timeout = eventlet.timeout.Timeout
LOG = rpc_common.LOG
RemoteError = rpc_common.RemoteError
RPCException = rpc_common.RPCException
zmq_opts = [
cfg.StrOpt('rpc_zmq_bind_address', default='*',
help='ZeroMQ bind address. Should be a wildcard (*), '
'an ethernet interface, or IP. '
'The "host" option should point or resolve to this '
'address.'),
# The module.Class to use for matchmaking.
cfg.StrOpt(
'rpc_zmq_matchmaker',
default=('tuskar.openstack.common.rpc.'
'matchmaker.MatchMakerLocalhost'),
help='MatchMaker driver',
),
# The following port is unassigned by IANA as of 2012-05-21
cfg.IntOpt('rpc_zmq_port', default=9501,
help='ZeroMQ receiver listening port'),
cfg.IntOpt('rpc_zmq_contexts', default=1,
help='Number of ZeroMQ contexts, defaults to 1'),
cfg.IntOpt('rpc_zmq_topic_backlog', default=None,
<|code_end|>
using the current file's imports:
import os
import pprint
import re
import socket
import sys
import types
import uuid
import eventlet
import greenlet
from oslo.config import cfg
from tuskar.openstack.common import excutils
from tuskar.openstack.common.gettextutils import _
from tuskar.openstack.common import importutils
from tuskar.openstack.common import jsonutils
from tuskar.openstack.common import processutils as utils
from tuskar.openstack.common.rpc import common as rpc_common
and any relevant context from other files:
# Path: tuskar/openstack/common/excutils.py
# def save_and_reraise_exception():
#
# Path: tuskar/openstack/common/gettextutils.py
# def _(msg):
# return _t.ugettext(msg)
#
# Path: tuskar/openstack/common/importutils.py
# def import_class(import_str):
# def import_object(import_str, *args, **kwargs):
# def import_object_ns(name_space, import_str, *args, **kwargs):
# def import_module(import_str):
# def try_import(import_str, default=None):
#
# Path: tuskar/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
# level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):
#
# Path: tuskar/openstack/common/processutils.py
# LOG = logging.getLogger(__name__)
# _PIPE = subprocess.PIPE # pylint: disable=E1101
# class InvalidArgumentError(Exception):
# class UnknownArgumentError(Exception):
# class ProcessExecutionError(Exception):
# class NoRootWrapSpecified(Exception):
# def __init__(self, message=None):
# def __init__(self, message=None):
# def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
# description=None):
# def __init__(self, message=None):
# def _subprocess_setup():
# def execute(*cmd, **kwargs):
# def trycmd(*args, **kwargs):
# def ssh_execute(ssh, cmd, process_input=None,
# addl_env=None, check_exit_code=True):
#
# Path: tuskar/openstack/common/rpc/common.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# _RPC_ENVELOPE_VERSION = '2.0'
# _VERSION_KEY = 'oslo.version'
# _MESSAGE_KEY = 'oslo.message'
# SANITIZE = {'set_admin_password': [('args', 'new_pass')],
# 'run_instance': [('args', 'admin_password')],
# 'route_message': [('args', 'message', 'args', 'method_info',
# 'method_kwargs', 'password'),
# ('args', 'message', 'args', 'method_info',
# 'method_kwargs', 'admin_password')]}
# class RPCException(Exception):
# class RemoteError(RPCException):
# class Timeout(RPCException):
# class DuplicateMessageError(RPCException):
# class InvalidRPCConnectionReuse(RPCException):
# class UnsupportedRpcVersion(RPCException):
# class UnsupportedRpcEnvelopeVersion(RPCException):
# class RpcVersionCapError(RPCException):
# class Connection(object):
# class CommonRpcContext(object):
# class ClientException(Exception):
# def __init__(self, message=None, **kwargs):
# def __init__(self, exc_type=None, value=None, traceback=None):
# def __init__(self, info=None, topic=None, method=None):
# def close(self):
# def create_consumer(self, topic, proxy, fanout=False):
# def create_worker(self, topic, proxy, pool_name):
# def join_consumer_pool(self, callback, pool_name, topic, exchange_name):
# def consume_in_thread(self):
# def _safe_log(log_func, msg, msg_data):
# def serialize_remote_exception(failure_info, log_failure=True):
# def deserialize_remote_exception(conf, data):
# def __init__(self, **kwargs):
# def __getattr__(self, key):
# def to_dict(self):
# def from_dict(cls, values):
# def deepcopy(self):
# def update_store(self):
# def elevated(self, read_deleted=None, overwrite=False):
# def __init__(self):
# def catch_client_exception(exceptions, func, *args, **kwargs):
# def client_exceptions(*exceptions):
# def outer(func):
# def inner(*args, **kwargs):
# def version_is_compatible(imp_version, version):
# def serialize_msg(raw_msg):
# def deserialize_msg(msg):
. Output only the next line. | help='Maximum number of ingress messages to locally buffer ' |
Based on the snippet: <|code_start|>
zmq = importutils.try_import('eventlet.green.zmq')
# for convenience, are not modified.
pformat = pprint.pformat
Timeout = eventlet.timeout.Timeout
LOG = rpc_common.LOG
RemoteError = rpc_common.RemoteError
RPCException = rpc_common.RPCException
zmq_opts = [
cfg.StrOpt('rpc_zmq_bind_address', default='*',
help='ZeroMQ bind address. Should be a wildcard (*), '
'an ethernet interface, or IP. '
'The "host" option should point or resolve to this '
'address.'),
# The module.Class to use for matchmaking.
cfg.StrOpt(
'rpc_zmq_matchmaker',
default=('tuskar.openstack.common.rpc.'
'matchmaker.MatchMakerLocalhost'),
help='MatchMaker driver',
),
# The following port is unassigned by IANA as of 2012-05-21
cfg.IntOpt('rpc_zmq_port', default=9501,
help='ZeroMQ receiver listening port'),
<|code_end|>
, predict the immediate next line with the help of imports:
import os
import pprint
import re
import socket
import sys
import types
import uuid
import eventlet
import greenlet
from oslo.config import cfg
from tuskar.openstack.common import excutils
from tuskar.openstack.common.gettextutils import _
from tuskar.openstack.common import importutils
from tuskar.openstack.common import jsonutils
from tuskar.openstack.common import processutils as utils
from tuskar.openstack.common.rpc import common as rpc_common
and context (classes, functions, sometimes code) from other files:
# Path: tuskar/openstack/common/excutils.py
# def save_and_reraise_exception():
#
# Path: tuskar/openstack/common/gettextutils.py
# def _(msg):
# return _t.ugettext(msg)
#
# Path: tuskar/openstack/common/importutils.py
# def import_class(import_str):
# def import_object(import_str, *args, **kwargs):
# def import_object_ns(name_space, import_str, *args, **kwargs):
# def import_module(import_str):
# def try_import(import_str, default=None):
#
# Path: tuskar/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
# level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):
#
# Path: tuskar/openstack/common/processutils.py
# LOG = logging.getLogger(__name__)
# _PIPE = subprocess.PIPE # pylint: disable=E1101
# class InvalidArgumentError(Exception):
# class UnknownArgumentError(Exception):
# class ProcessExecutionError(Exception):
# class NoRootWrapSpecified(Exception):
# def __init__(self, message=None):
# def __init__(self, message=None):
# def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
# description=None):
# def __init__(self, message=None):
# def _subprocess_setup():
# def execute(*cmd, **kwargs):
# def trycmd(*args, **kwargs):
# def ssh_execute(ssh, cmd, process_input=None,
# addl_env=None, check_exit_code=True):
#
# Path: tuskar/openstack/common/rpc/common.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# _RPC_ENVELOPE_VERSION = '2.0'
# _VERSION_KEY = 'oslo.version'
# _MESSAGE_KEY = 'oslo.message'
# SANITIZE = {'set_admin_password': [('args', 'new_pass')],
# 'run_instance': [('args', 'admin_password')],
# 'route_message': [('args', 'message', 'args', 'method_info',
# 'method_kwargs', 'password'),
# ('args', 'message', 'args', 'method_info',
# 'method_kwargs', 'admin_password')]}
# class RPCException(Exception):
# class RemoteError(RPCException):
# class Timeout(RPCException):
# class DuplicateMessageError(RPCException):
# class InvalidRPCConnectionReuse(RPCException):
# class UnsupportedRpcVersion(RPCException):
# class UnsupportedRpcEnvelopeVersion(RPCException):
# class RpcVersionCapError(RPCException):
# class Connection(object):
# class CommonRpcContext(object):
# class ClientException(Exception):
# def __init__(self, message=None, **kwargs):
# def __init__(self, exc_type=None, value=None, traceback=None):
# def __init__(self, info=None, topic=None, method=None):
# def close(self):
# def create_consumer(self, topic, proxy, fanout=False):
# def create_worker(self, topic, proxy, pool_name):
# def join_consumer_pool(self, callback, pool_name, topic, exchange_name):
# def consume_in_thread(self):
# def _safe_log(log_func, msg, msg_data):
# def serialize_remote_exception(failure_info, log_failure=True):
# def deserialize_remote_exception(conf, data):
# def __init__(self, **kwargs):
# def __getattr__(self, key):
# def to_dict(self):
# def from_dict(cls, values):
# def deepcopy(self):
# def update_store(self):
# def elevated(self, read_deleted=None, overwrite=False):
# def __init__(self):
# def catch_client_exception(exceptions, func, *args, **kwargs):
# def client_exceptions(*exceptions):
# def outer(func):
# def inner(*args, **kwargs):
# def version_is_compatible(imp_version, version):
# def serialize_msg(raw_msg):
# def deserialize_msg(msg):
. Output only the next line. | cfg.IntOpt('rpc_zmq_contexts', default=1, |
Given the following code snippet before the placeholder: <|code_start|> 'address.'),
# The module.Class to use for matchmaking.
cfg.StrOpt(
'rpc_zmq_matchmaker',
default=('tuskar.openstack.common.rpc.'
'matchmaker.MatchMakerLocalhost'),
help='MatchMaker driver',
),
# The following port is unassigned by IANA as of 2012-05-21
cfg.IntOpt('rpc_zmq_port', default=9501,
help='ZeroMQ receiver listening port'),
cfg.IntOpt('rpc_zmq_contexts', default=1,
help='Number of ZeroMQ contexts, defaults to 1'),
cfg.IntOpt('rpc_zmq_topic_backlog', default=None,
help='Maximum number of ingress messages to locally buffer '
'per topic. Default is unlimited.'),
cfg.StrOpt('rpc_zmq_ipc_dir', default='/var/run/openstack',
help='Directory for holding IPC sockets'),
cfg.StrOpt('rpc_zmq_host', default=socket.gethostname(),
help='Name of this node. Must be a valid hostname, FQDN, or '
'IP address. Must match "host" option, if running Nova.')
]
<|code_end|>
, predict the next line using imports from the current file:
import os
import pprint
import re
import socket
import sys
import types
import uuid
import eventlet
import greenlet
from oslo.config import cfg
from tuskar.openstack.common import excutils
from tuskar.openstack.common.gettextutils import _
from tuskar.openstack.common import importutils
from tuskar.openstack.common import jsonutils
from tuskar.openstack.common import processutils as utils
from tuskar.openstack.common.rpc import common as rpc_common
and context including class names, function names, and sometimes code from other files:
# Path: tuskar/openstack/common/excutils.py
# def save_and_reraise_exception():
#
# Path: tuskar/openstack/common/gettextutils.py
# def _(msg):
# return _t.ugettext(msg)
#
# Path: tuskar/openstack/common/importutils.py
# def import_class(import_str):
# def import_object(import_str, *args, **kwargs):
# def import_object_ns(name_space, import_str, *args, **kwargs):
# def import_module(import_str):
# def try_import(import_str, default=None):
#
# Path: tuskar/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
# level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):
#
# Path: tuskar/openstack/common/processutils.py
# LOG = logging.getLogger(__name__)
# _PIPE = subprocess.PIPE # pylint: disable=E1101
# class InvalidArgumentError(Exception):
# class UnknownArgumentError(Exception):
# class ProcessExecutionError(Exception):
# class NoRootWrapSpecified(Exception):
# def __init__(self, message=None):
# def __init__(self, message=None):
# def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
# description=None):
# def __init__(self, message=None):
# def _subprocess_setup():
# def execute(*cmd, **kwargs):
# def trycmd(*args, **kwargs):
# def ssh_execute(ssh, cmd, process_input=None,
# addl_env=None, check_exit_code=True):
#
# Path: tuskar/openstack/common/rpc/common.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# _RPC_ENVELOPE_VERSION = '2.0'
# _VERSION_KEY = 'oslo.version'
# _MESSAGE_KEY = 'oslo.message'
# SANITIZE = {'set_admin_password': [('args', 'new_pass')],
# 'run_instance': [('args', 'admin_password')],
# 'route_message': [('args', 'message', 'args', 'method_info',
# 'method_kwargs', 'password'),
# ('args', 'message', 'args', 'method_info',
# 'method_kwargs', 'admin_password')]}
# class RPCException(Exception):
# class RemoteError(RPCException):
# class Timeout(RPCException):
# class DuplicateMessageError(RPCException):
# class InvalidRPCConnectionReuse(RPCException):
# class UnsupportedRpcVersion(RPCException):
# class UnsupportedRpcEnvelopeVersion(RPCException):
# class RpcVersionCapError(RPCException):
# class Connection(object):
# class CommonRpcContext(object):
# class ClientException(Exception):
# def __init__(self, message=None, **kwargs):
# def __init__(self, exc_type=None, value=None, traceback=None):
# def __init__(self, info=None, topic=None, method=None):
# def close(self):
# def create_consumer(self, topic, proxy, fanout=False):
# def create_worker(self, topic, proxy, pool_name):
# def join_consumer_pool(self, callback, pool_name, topic, exchange_name):
# def consume_in_thread(self):
# def _safe_log(log_func, msg, msg_data):
# def serialize_remote_exception(failure_info, log_failure=True):
# def deserialize_remote_exception(conf, data):
# def __init__(self, **kwargs):
# def __getattr__(self, key):
# def to_dict(self):
# def from_dict(cls, values):
# def deepcopy(self):
# def update_store(self):
# def elevated(self, read_deleted=None, overwrite=False):
# def __init__(self):
# def catch_client_exception(exceptions, func, *args, **kwargs):
# def client_exceptions(*exceptions):
# def outer(func):
# def inner(*args, **kwargs):
# def version_is_compatible(imp_version, version):
# def serialize_msg(raw_msg):
# def deserialize_msg(msg):
. Output only the next line. | CONF = cfg.CONF |
Given the code snippet: <|code_start|> cfg.StrOpt('rpc_zmq_bind_address', default='*',
help='ZeroMQ bind address. Should be a wildcard (*), '
'an ethernet interface, or IP. '
'The "host" option should point or resolve to this '
'address.'),
# The module.Class to use for matchmaking.
cfg.StrOpt(
'rpc_zmq_matchmaker',
default=('tuskar.openstack.common.rpc.'
'matchmaker.MatchMakerLocalhost'),
help='MatchMaker driver',
),
# The following port is unassigned by IANA as of 2012-05-21
cfg.IntOpt('rpc_zmq_port', default=9501,
help='ZeroMQ receiver listening port'),
cfg.IntOpt('rpc_zmq_contexts', default=1,
help='Number of ZeroMQ contexts, defaults to 1'),
cfg.IntOpt('rpc_zmq_topic_backlog', default=None,
help='Maximum number of ingress messages to locally buffer '
'per topic. Default is unlimited.'),
cfg.StrOpt('rpc_zmq_ipc_dir', default='/var/run/openstack',
help='Directory for holding IPC sockets'),
cfg.StrOpt('rpc_zmq_host', default=socket.gethostname(),
help='Name of this node. Must be a valid hostname, FQDN, or '
<|code_end|>
, generate the next line using the imports in this file:
import os
import pprint
import re
import socket
import sys
import types
import uuid
import eventlet
import greenlet
from oslo.config import cfg
from tuskar.openstack.common import excutils
from tuskar.openstack.common.gettextutils import _
from tuskar.openstack.common import importutils
from tuskar.openstack.common import jsonutils
from tuskar.openstack.common import processutils as utils
from tuskar.openstack.common.rpc import common as rpc_common
and context (functions, classes, or occasionally code) from other files:
# Path: tuskar/openstack/common/excutils.py
# def save_and_reraise_exception():
#
# Path: tuskar/openstack/common/gettextutils.py
# def _(msg):
# return _t.ugettext(msg)
#
# Path: tuskar/openstack/common/importutils.py
# def import_class(import_str):
# def import_object(import_str, *args, **kwargs):
# def import_object_ns(name_space, import_str, *args, **kwargs):
# def import_module(import_str):
# def try_import(import_str, default=None):
#
# Path: tuskar/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
# level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):
#
# Path: tuskar/openstack/common/processutils.py
# LOG = logging.getLogger(__name__)
# _PIPE = subprocess.PIPE # pylint: disable=E1101
# class InvalidArgumentError(Exception):
# class UnknownArgumentError(Exception):
# class ProcessExecutionError(Exception):
# class NoRootWrapSpecified(Exception):
# def __init__(self, message=None):
# def __init__(self, message=None):
# def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
# description=None):
# def __init__(self, message=None):
# def _subprocess_setup():
# def execute(*cmd, **kwargs):
# def trycmd(*args, **kwargs):
# def ssh_execute(ssh, cmd, process_input=None,
# addl_env=None, check_exit_code=True):
#
# Path: tuskar/openstack/common/rpc/common.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# _RPC_ENVELOPE_VERSION = '2.0'
# _VERSION_KEY = 'oslo.version'
# _MESSAGE_KEY = 'oslo.message'
# SANITIZE = {'set_admin_password': [('args', 'new_pass')],
# 'run_instance': [('args', 'admin_password')],
# 'route_message': [('args', 'message', 'args', 'method_info',
# 'method_kwargs', 'password'),
# ('args', 'message', 'args', 'method_info',
# 'method_kwargs', 'admin_password')]}
# class RPCException(Exception):
# class RemoteError(RPCException):
# class Timeout(RPCException):
# class DuplicateMessageError(RPCException):
# class InvalidRPCConnectionReuse(RPCException):
# class UnsupportedRpcVersion(RPCException):
# class UnsupportedRpcEnvelopeVersion(RPCException):
# class RpcVersionCapError(RPCException):
# class Connection(object):
# class CommonRpcContext(object):
# class ClientException(Exception):
# def __init__(self, message=None, **kwargs):
# def __init__(self, exc_type=None, value=None, traceback=None):
# def __init__(self, info=None, topic=None, method=None):
# def close(self):
# def create_consumer(self, topic, proxy, fanout=False):
# def create_worker(self, topic, proxy, pool_name):
# def join_consumer_pool(self, callback, pool_name, topic, exchange_name):
# def consume_in_thread(self):
# def _safe_log(log_func, msg, msg_data):
# def serialize_remote_exception(failure_info, log_failure=True):
# def deserialize_remote_exception(conf, data):
# def __init__(self, **kwargs):
# def __getattr__(self, key):
# def to_dict(self):
# def from_dict(cls, values):
# def deepcopy(self):
# def update_store(self):
# def elevated(self, read_deleted=None, overwrite=False):
# def __init__(self):
# def catch_client_exception(exceptions, func, *args, **kwargs):
# def client_exceptions(*exceptions):
# def outer(func):
# def inner(*args, **kwargs):
# def version_is_compatible(imp_version, version):
# def serialize_msg(raw_msg):
# def deserialize_msg(msg):
. Output only the next line. | 'IP address. Must match "host" option, if running Nova.') |
Continue the code snippet: <|code_start|># Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
CONF = cfg.CONF
def notify(_context, message):
"""Notifies the recipient of the desired event given the model.
Log notifications using openstack's default logging system"""
priority = message.get('priority',
CONF.default_notification_level)
priority = priority.lower()
logger = logging.getLogger(
<|code_end|>
. Use current file imports:
from oslo.config import cfg
from tuskar.openstack.common import jsonutils
from tuskar.openstack.common import log as logging
and context (classes, functions, or code) from other files:
# Path: tuskar/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
# level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):
#
# Path: tuskar/openstack/common/log.py
# _DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
# CONF = cfg.CONF
# LEVEL_COLORS = {
# logging.DEBUG: '\033[00;32m', # GREEN
# logging.INFO: '\033[00;36m', # CYAN
# logging.AUDIT: '\033[01;36m', # BOLD CYAN
# logging.WARN: '\033[01;33m', # BOLD YELLOW
# logging.ERROR: '\033[01;31m', # BOLD RED
# logging.CRITICAL: '\033[01;31m', # BOLD RED
# }
# class NullHandler(logging.Handler):
# class BaseLoggerAdapter(logging.LoggerAdapter):
# class LazyAdapter(BaseLoggerAdapter):
# class ContextAdapter(BaseLoggerAdapter):
# class JSONFormatter(logging.Formatter):
# class LogConfigError(Exception):
# class WritableLogger(object):
# class ContextFormatter(logging.Formatter):
# class ColorHandler(logging.StreamHandler):
# class DeprecatedConfig(Exception):
# def handle(self, record):
# def emit(self, record):
# def createLock(self):
# def _dictify_context(context):
# def _get_binary_name():
# def _get_log_file_path(binary=None):
# def audit(self, msg, *args, **kwargs):
# def __init__(self, name='unknown', version='unknown'):
# def logger(self):
# def __init__(self, logger, project_name, version_string):
# def handlers(self):
# def deprecated(self, msg, *args, **kwargs):
# def process(self, msg, kwargs):
# def __init__(self, fmt=None, datefmt=None):
# def formatException(self, ei, strip_newlines=True):
# def format(self, record):
# def _create_logging_excepthook(product_name):
# def logging_excepthook(type, value, tb):
# def __init__(self, log_config, err_msg):
# def __str__(self):
# def _load_log_config(log_config):
# def setup(product_name):
# def set_defaults(logging_context_format_string):
# def _find_facility_from_conf():
# def _setup_logging_from_conf():
# def getLogger(name='unknown', version='unknown'):
# def getLazyLogger(name='unknown', version='unknown'):
# def __init__(self, logger, level=logging.INFO):
# def write(self, msg):
# def format(self, record):
# def formatException(self, exc_info, record=None):
# def format(self, record):
# def __init__(self, msg):
. Output only the next line. | 'tuskar.openstack.common.notification.%s' % |
Based on the snippet: <|code_start|> cache_data = {"data": 1123, "mtime": 1}
data = utils.read_cached_file("/this/is/a/fake", cache_data)
self.assertEqual(cache_data["data"], data)
def test_read_modified_cached_file(self):
self.mox.StubOutWithMock(os.path, "getmtime")
self.mox.StubOutWithMock(__builtin__, 'open')
os.path.getmtime(mox.IgnoreArg()).AndReturn(2)
fake_contents = "lorem ipsum"
fake_file = self.mox.CreateMockAnything()
fake_file.read().AndReturn(fake_contents)
fake_context_manager = self.mox.CreateMockAnything()
fake_context_manager.__enter__().AndReturn(fake_file)
fake_context_manager.__exit__(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg())
__builtin__.open(mox.IgnoreArg()).AndReturn(fake_context_manager)
self.mox.ReplayAll()
cache_data = {"data": 1123, "mtime": 1}
self.reload_called = False
def test_reload(reloaded_data):
self.assertEqual(reloaded_data, fake_contents)
self.reload_called = True
data = utils.read_cached_file("/this/is/a/fake", cache_data,
reload_func=test_reload)
<|code_end|>
, predict the immediate next line with the help of imports:
import __builtin__
import os
import os.path
import mox
from tuskar.common import utils
from tuskar.tests import base
and context (classes, functions, sometimes code) from other files:
# Path: tuskar/common/utils.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# class LazyPluggable(object):
# def __init__(self, pivot, config_group=None, **backends):
# def __get_backend(self):
# def __getattr__(self, key):
# def is_int_like(val):
# def read_cached_file(filename, cache_info, reload_func=None):
#
# Path: tuskar/tests/base.py
# CONF = cfg.CONF
# _DB_CACHE = None
# _DB_CACHE = Database(session, migration,
# sql_connection=CONF.database.connection,
# sqlite_db=CONF.sqlite_db,
# sqlite_clean_db=CONF.sqlite_clean_db)
# class Database(fixtures.Fixture):
# class ReplaceModule(fixtures.Fixture):
# class MoxStubout(fixtures.Fixture):
# class TestingException(Exception):
# class TestCase(testtools.TestCase):
# class TimeOverride(fixtures.Fixture):
# def __init__(self, db_session, db_migrate, sql_connection,
# sqlite_db, sqlite_clean_db):
# def setUp(self):
# def post_migrations(self):
# def __init__(self, name, new_value):
# def _restore(self, old_value):
# def setUp(self):
# def setUp(self):
# def setUp(self):
# def _clear_attrs(self):
# def config(self, **kw):
# def path_get(self, project_file=None):
# def setUp(self):
. Output only the next line. | self.assertEqual(data, fake_contents) |
Predict the next line for this snippet: <|code_start|> self.mox.StubOutWithMock(os.path, "getmtime")
os.path.getmtime(mox.IgnoreArg()).AndReturn(1)
self.mox.ReplayAll()
cache_data = {"data": 1123, "mtime": 1}
data = utils.read_cached_file("/this/is/a/fake", cache_data)
self.assertEqual(cache_data["data"], data)
def test_read_modified_cached_file(self):
self.mox.StubOutWithMock(os.path, "getmtime")
self.mox.StubOutWithMock(__builtin__, 'open')
os.path.getmtime(mox.IgnoreArg()).AndReturn(2)
fake_contents = "lorem ipsum"
fake_file = self.mox.CreateMockAnything()
fake_file.read().AndReturn(fake_contents)
fake_context_manager = self.mox.CreateMockAnything()
fake_context_manager.__enter__().AndReturn(fake_file)
fake_context_manager.__exit__(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg())
__builtin__.open(mox.IgnoreArg()).AndReturn(fake_context_manager)
self.mox.ReplayAll()
cache_data = {"data": 1123, "mtime": 1}
self.reload_called = False
def test_reload(reloaded_data):
self.assertEqual(reloaded_data, fake_contents)
<|code_end|>
with the help of current file imports:
import __builtin__
import os
import os.path
import mox
from tuskar.common import utils
from tuskar.tests import base
and context from other files:
# Path: tuskar/common/utils.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# class LazyPluggable(object):
# def __init__(self, pivot, config_group=None, **backends):
# def __get_backend(self):
# def __getattr__(self, key):
# def is_int_like(val):
# def read_cached_file(filename, cache_info, reload_func=None):
#
# Path: tuskar/tests/base.py
# CONF = cfg.CONF
# _DB_CACHE = None
# _DB_CACHE = Database(session, migration,
# sql_connection=CONF.database.connection,
# sqlite_db=CONF.sqlite_db,
# sqlite_clean_db=CONF.sqlite_clean_db)
# class Database(fixtures.Fixture):
# class ReplaceModule(fixtures.Fixture):
# class MoxStubout(fixtures.Fixture):
# class TestingException(Exception):
# class TestCase(testtools.TestCase):
# class TimeOverride(fixtures.Fixture):
# def __init__(self, db_session, db_migrate, sql_connection,
# sqlite_db, sqlite_clean_db):
# def setUp(self):
# def post_migrations(self):
# def __init__(self, name, new_value):
# def _restore(self, old_value):
# def setUp(self):
# def setUp(self):
# def setUp(self):
# def _clear_attrs(self):
# def config(self, **kw):
# def path_get(self, project_file=None):
# def setUp(self):
, which may contain function names, class names, or code. Output only the next line. | self.reload_called = True |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
_LXC_NETWORK = """\
lxc.network.type=veth
<|code_end|>
using the current file's imports:
from revolver import contextmanager as ctx
from revolver import file, package, core
and any relevant context from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | lxc.network.link=vbr-%(name)s |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
_LXC_NETWORK = """\
lxc.network.type=veth
lxc.network.link=vbr-%(name)s
<|code_end|>
. Use current file imports:
(from revolver import contextmanager as ctx
from revolver import file, package, core)
and context including class names, function names, or small code snippets from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | lxc.network.flags=up |
Continue the code snippet: <|code_start|>
def test_revolver_is_just_a_wrapper():
assert ctx.cd == fabric_ctx.cd
assert ctx.hide == fabric_ctx.hide
assert ctx.lcd == fabric_ctx.lcd
assert ctx.path == fabric_ctx.path
assert ctx.prefix == fabric_ctx.prefix
assert ctx.settings == fabric_ctx.settings
assert ctx.show == fabric_ctx.show
def test_sudo_changes_env_flag():
with ctx.sudo():
assert env.sudo_forced
def test_sudo_without_user_does_not_change_sudo_env_user():
old_user = env.sudo_user
with ctx.sudo():
assert env.sudo_user == old_user
def test_sudo_with_user_change_sudo_env_user():
with ctx.sudo("foo"):
assert env.sudo_user == "foo"
<|code_end|>
. Use current file imports:
from fabric import context_managers as fabric_ctx
from fudge import patch
from revolver import contextmanager as ctx
from revolver.core import env
and context (classes, functions, or code) from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | def test_sudo_restores_previous_settings(): |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def test_revolver_is_just_a_wrapper():
assert ctx.cd == fabric_ctx.cd
assert ctx.hide == fabric_ctx.hide
assert ctx.lcd == fabric_ctx.lcd
assert ctx.path == fabric_ctx.path
assert ctx.prefix == fabric_ctx.prefix
assert ctx.settings == fabric_ctx.settings
assert ctx.show == fabric_ctx.show
def test_sudo_changes_env_flag():
with ctx.sudo():
assert env.sudo_forced
def test_sudo_without_user_does_not_change_sudo_env_user():
old_user = env.sudo_user
with ctx.sudo():
assert env.sudo_user == old_user
<|code_end|>
, predict the immediate next line with the help of imports:
from fabric import context_managers as fabric_ctx
from fudge import patch
from revolver import contextmanager as ctx
from revolver.core import env
and context (classes, functions, sometimes code) from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | def test_sudo_with_user_change_sudo_env_user(): |
Here is a snippet: <|code_start|>
def test_revolver_is_just_a_wrapper():
assert decorator.hosts == fabric.decorators.hosts
assert decorator.needs_host == fabric.network.needs_host
assert decorator.parallel == fabric.decorators.parallel
assert decorator.roles == fabric.decorators.roles
assert decorator.runs_once == fabric.decorators.runs_once
assert decorator.serial == fabric.decorators.serial
assert decorator.task == fabric.decorators.task
assert decorator.with_settings == fabric.decorators.with_settings
def test_multiargs():
stack = []
def dummy(*args, **kwargs):
stack.append((args, kwargs))
decorator.multiargs(dummy)([1, 2, 3])
print stack
assert stack == [((1,), {}), ((2,), {}), ((3,), {})]
def test_multiargs_no_argumetns():
stack = []
def dummy(*args, **kwargs):
<|code_end|>
. Write the next line using the current file imports:
import fabric
from revolver import contextmanager as ctx
from revolver import decorator, core
and context from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/decorator.py
# def sudo(func):
# def wrapper(*args, **kwargs):
# def multiargs(func):
# def wrapper(*args, **kwargs):
# def inject_use_sudo(func):
# def inject_wrapper(*args, **kwargs):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
, which may include functions, classes, or code. Output only the next line. | stack.append((args, kwargs)) |
Next line prediction: <|code_start|> stack = []
def dummy(*args, **kwargs):
stack.append((args, kwargs))
decorator.multiargs(dummy)("foo", bar="baz")
assert stack == [(("foo",), {"bar": "baz"})]
def _sudo_dummy(sudo=None):
return sudo
def test_sudo_dummy():
assert _sudo_dummy() is None
assert _sudo_dummy(True)
assert not _sudo_dummy(False)
def test_inject_sudo_with_forced_sudo():
with ctx.sudo():
assert decorator.inject_use_sudo(_sudo_dummy)()
def test_inject_sudo_does_nothing_if_argument_given():
assert decorator.inject_use_sudo(_sudo_dummy)(sudo=True)
assert not decorator.inject_use_sudo(_sudo_dummy)(sudo=False)
def _use_sudo_dummy(use_sudo=None):
<|code_end|>
. Use current file imports:
(import fabric
from revolver import contextmanager as ctx
from revolver import decorator, core)
and context including class names, function names, or small code snippets from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/decorator.py
# def sudo(func):
# def wrapper(*args, **kwargs):
# def multiargs(func):
# def wrapper(*args, **kwargs):
# def inject_use_sudo(func):
# def inject_wrapper(*args, **kwargs):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | return use_sudo |
Given the code snippet: <|code_start|>def test_multiargs_no_list():
stack = []
def dummy(*args, **kwargs):
stack.append((args, kwargs))
decorator.multiargs(dummy)("foo", bar="baz")
assert stack == [(("foo",), {"bar": "baz"})]
def _sudo_dummy(sudo=None):
return sudo
def test_sudo_dummy():
assert _sudo_dummy() is None
assert _sudo_dummy(True)
assert not _sudo_dummy(False)
def test_inject_sudo_with_forced_sudo():
with ctx.sudo():
assert decorator.inject_use_sudo(_sudo_dummy)()
def test_inject_sudo_does_nothing_if_argument_given():
assert decorator.inject_use_sudo(_sudo_dummy)(sudo=True)
assert not decorator.inject_use_sudo(_sudo_dummy)(sudo=False)
<|code_end|>
, generate the next line using the imports in this file:
import fabric
from revolver import contextmanager as ctx
from revolver import decorator, core
and context (functions, classes, or occasionally code) from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/decorator.py
# def sudo(func):
# def wrapper(*args, **kwargs):
# def multiargs(func):
# def wrapper(*args, **kwargs):
# def inject_use_sudo(func):
# def inject_wrapper(*args, **kwargs):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | def _use_sudo_dummy(use_sudo=None): |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install(version, _update=True):
# Without this we would build python without the bz2 package
package.ensure("libbz2-dev")
pythonbrew.ensure()
status = run("pythonbrew switch %s; true" % version)
<|code_end|>
, predict the immediate next line with the help of imports:
from revolver.core import run
from revolver import package
from revolver.tool import pythonbrew
and context (classes, functions, sometimes code) from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/tool/pythonbrew.py
# def install():
# def ensure():
. Output only the next line. | if status.find("not installed") != -1 or _update: |
Here is a snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install(version, _update=True):
# Without this we would build python without the bz2 package
package.ensure("libbz2-dev")
pythonbrew.ensure()
status = run("pythonbrew switch %s; true" % version)
if status.find("not installed") != -1 or _update:
run("pythonbrew install --no-test %s" % version)
run("pythonbrew cleanup")
run("pythonbrew switch %s" % version)
run("pip install virtualenv")
run("pip install virtualenvwrapper")
<|code_end|>
. Write the next line using the current file imports:
from revolver.core import run
from revolver import package
from revolver.tool import pythonbrew
and context from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/tool/pythonbrew.py
# def install():
# def ensure():
, which may include functions, classes, or code. Output only the next line. | def ensure(version): |
Given snippet: <|code_start|>from __future__ import absolute_import, division, with_statement
def temp_local():
return mkdtemp()
def temp(mode=None, owner=None, group=None):
path = core.run('mktemp --directory').stdout
attributes(path, mode=mode, owner=owner, group=group)
return path
def remove(location, recursive=False, force=True):
recursive = recursive and '-r' or ''
force = force and '-f' or ''
core.run('rm %s %s %s' % (force, recursive, location))
def create(path, recursive=False, mode=None, owner=None, group=None):
recursive = recursive and '-p' or ''
if exists(path):
return
core.run('mkdir %s %s' % (recursive, path))
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from tempfile import mkdtemp
from cuisine import dir_attribs as attributes
from cuisine import dir_ensure as ensure
from cuisine import dir_exists as exists
from cuisine import file_attribs_get as attributes_get
from cuisine import file_is_link as is_link
from revolver import core
and context:
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
which might include code, classes, or functions. Output only the next line. | attributes(path, mode=mode, owner=owner, group=group) |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure(["git-core", "libssl-dev", "curl", "build-essential"])
if not dir.exists(".nvm"):
run("git clone git://github.com/creationix/nvm.git .nvm")
<|code_end|>
, generate the next line using the imports in this file:
from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import package
and context (functions, classes, or occasionally code) from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
. Output only the next line. | else: |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure(["git-core", "libssl-dev", "curl", "build-essential"])
if not dir.exists(".nvm"):
run("git clone git://github.com/creationix/nvm.git .nvm")
else:
with ctx.cd(".nvm"):
run("git pull")
_ensure_autoload(".bashrc")
_ensure_autoload(".zshrc")
def ensure():
if not dir.exists(".nvm"):
<|code_end|>
using the current file's imports:
from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import package
and any relevant context from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
. Output only the next line. | install() |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure(["git-core", "libssl-dev", "curl", "build-essential"])
if not dir.exists(".nvm"):
run("git clone git://github.com/creationix/nvm.git .nvm")
<|code_end|>
, predict the immediate next line with the help of imports:
from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import package
and context (classes, functions, sometimes code) from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
. Output only the next line. | else: |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure("curl")
if not command.exists("pythonbrew"):
<|code_end|>
. Use current file imports:
from revolver import command, package
from revolver.core import run
and context (classes, functions, or code) from other files:
# Path: revolver/command.py
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
. Output only the next line. | url = "https://raw.github.com" \ |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure("curl")
if not command.exists("pythonbrew"):
url = "https://raw.github.com" \
+ "/utahta/pythonbrew/master/pythonbrew-install"
run("curl -s %s | bash" % url)
<|code_end|>
using the current file's imports:
from revolver import command, package
from revolver.core import run
and any relevant context from other files:
# Path: revolver/command.py
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
. Output only the next line. | else: |
Given the following code snippet before the placeholder: <|code_start|> run.expects_call().returns(run_result("path"))
(attributes.expects_call()
.with_args("path", mode=None, owner=None, group=None))
file.touch("path")
@patch("revolver.core.run")
@patch("revolver.file.attributes")
def test_touch_passes_attributes(run, attributes):
run.expects_call().returns(run_result("path"))
(attributes.expects_call()
.with_args("path", mode="foo", owner="bar", group="baz"))
file.touch("path", "foo", "bar", "baz")
@patch("revolver.core.run")
def test_remove_defaults(run):
run.expects_call().with_args("rm -f path")
file.remove("path")
@patch("revolver.core.run")
def test_remove_recusrive(run):
run.expects_call().with_args("rm -f path")
file.remove("path", recursive=False)
run.expects_call().with_args("rm -f -r path")
file.remove("path", recursive=True)
<|code_end|>
, predict the next line using imports from the current file:
from fudge import patch
from fabric.contrib import files as fabric_files
from revolver import file
from .utils import assert_contain_function_wrapped, run_result
import cuisine
import fabric
and context including class names, function names, and sometimes code from other files:
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/test/utils.py
# def assert_contain_function_wrapped(haystack, needle):
# assert haystack.__module__ == needle.__module__
# assert haystack.__name__ == needle.__name__
#
# def run_result(stdout="", stderr="", return_code=0):
# result = fabric.operations._AttributeString(stdout)
# result.stderr = stderr
# result.return_code = return_code
# result.failed = return_code != 0
# result.succeeded = return_code == 0
# return result
. Output only the next line. | @patch("revolver.core.run") |
Here is a snippet: <|code_start|>@patch("revolver.core.run")
def test_remove_recusrive(run):
run.expects_call().with_args("rm -f path")
file.remove("path", recursive=False)
run.expects_call().with_args("rm -f -r path")
file.remove("path", recursive=True)
@patch("revolver.core.run")
def test_remove_force(run):
run.expects_call().with_args("rm path")
file.remove("path", force=False)
run.expects_call().with_args("rm -f path")
file.remove("path", force=True)
@patch("revolver.core.run")
def test_copy(run):
run.expects_call().with_args("cp -f src dst")
file.copy("src", "dst")
@patch("revolver.core.run")
def test_copy_force_false(run):
run.expects_call().with_args("cp src dst")
file.copy("src", "dst", force=False)
<|code_end|>
. Write the next line using the current file imports:
from fudge import patch
from fabric.contrib import files as fabric_files
from revolver import file
from .utils import assert_contain_function_wrapped, run_result
import cuisine
import fabric
and context from other files:
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/test/utils.py
# def assert_contain_function_wrapped(haystack, needle):
# assert haystack.__module__ == needle.__module__
# assert haystack.__name__ == needle.__name__
#
# def run_result(stdout="", stderr="", return_code=0):
# result = fabric.operations._AttributeString(stdout)
# result.stderr = stderr
# result.return_code = return_code
# result.failed = return_code != 0
# result.succeeded = return_code == 0
# return result
, which may include functions, classes, or code. Output only the next line. | @patch("revolver.core.run") |
Using the snippet: <|code_start|>@patch("revolver.core.run")
def test_touch(run):
run.expects_call().with_args("touch path")
file.touch("path")
@patch("revolver.core.run")
@patch("revolver.file.attributes")
def test_touch_default_attributes(run, attributes):
run.expects_call().returns(run_result("path"))
(attributes.expects_call()
.with_args("path", mode=None, owner=None, group=None))
file.touch("path")
@patch("revolver.core.run")
@patch("revolver.file.attributes")
def test_touch_passes_attributes(run, attributes):
run.expects_call().returns(run_result("path"))
(attributes.expects_call()
.with_args("path", mode="foo", owner="bar", group="baz"))
file.touch("path", "foo", "bar", "baz")
@patch("revolver.core.run")
def test_remove_defaults(run):
run.expects_call().with_args("rm -f path")
file.remove("path")
<|code_end|>
, determine the next line of code. You have imports:
from fudge import patch
from fabric.contrib import files as fabric_files
from revolver import file
from .utils import assert_contain_function_wrapped, run_result
import cuisine
import fabric
and context (class names, function names, or code) available:
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/test/utils.py
# def assert_contain_function_wrapped(haystack, needle):
# assert haystack.__module__ == needle.__module__
# assert haystack.__name__ == needle.__name__
#
# def run_result(stdout="", stderr="", return_code=0):
# result = fabric.operations._AttributeString(stdout)
# result.stderr = stderr
# result.return_code = return_code
# result.failed = return_code != 0
# result.succeeded = return_code == 0
# return result
. Output only the next line. | @patch("revolver.core.run") |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure(["curl", "git-core"])
if not dir.exists(".php-build"):
core.run("git clone git://github.com/CHH/php-build .php-build")
with ctx.cd(".php-build"):
core.run("git pull")
dir.create("versions")
dir.create("tmp")
_ensure_autoload(".bashrc")
_ensure_autoload(".zshrc")
<|code_end|>
. Use current file imports:
(from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import package, file, core)
and context including class names, function names, or small code snippets from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | def ensure(): |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure(["curl", "git-core"])
if not dir.exists(".php-build"):
core.run("git clone git://github.com/CHH/php-build .php-build")
with ctx.cd(".php-build"):
core.run("git pull")
dir.create("versions")
dir.create("tmp")
_ensure_autoload(".bashrc")
_ensure_autoload(".zshrc")
def ensure():
if not dir.exists(".php-build"):
install()
<|code_end|>
, determine the next line of code. You have imports:
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import package, file, core
and context (class names, function names, or code) available:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | def _ensure_autoload(filename): |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure(["curl", "git-core"])
if not dir.exists(".php-build"):
core.run("git clone git://github.com/CHH/php-build .php-build")
with ctx.cd(".php-build"):
core.run("git pull")
dir.create("versions")
dir.create("tmp")
<|code_end|>
, predict the immediate next line with the help of imports:
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import package, file, core
and context (classes, functions, sometimes code) from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | _ensure_autoload(".bashrc") |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def timezone(zone='UTC'):
from_file = '/usr/share/zoneinfo/%s' % zone
<|code_end|>
, determine the next line of code. You have imports:
from cuisine import system_uuid as uuid
from revolver import contextmanager as ctx
from revolver import file, core
and context (class names, function names, or code) available:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | to_file = '/etc/localtime' |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure(["curl", "git-core"])
url = "https://raw.github.com/CHH/phpenv/master/bin/phpenv-install.sh"
if not dir.exists(".phpenv"):
run("curl -s %s | bash" % url)
else:
run("curl -s %s | UPDATE=yes bash" % url)
dir.create(".phpenv/versions")
_ensure_autoload(".bashrc")
_ensure_autoload(".zshrc")
<|code_end|>
using the current file's imports:
from revolver.core import run
from revolver import directory as dir
from revolver import package, file
and any relevant context from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
. Output only the next line. | def ensure(): |
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure(["curl", "git-core"])
<|code_end|>
, predict the next line using imports from the current file:
from revolver.core import run
from revolver import directory as dir
from revolver import package, file
and context including class names, function names, and sometimes code from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
. Output only the next line. | url = "https://raw.github.com/CHH/phpenv/master/bin/phpenv-install.sh" |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure(["curl", "git-core"])
url = "https://raw.github.com/CHH/phpenv/master/bin/phpenv-install.sh"
if not dir.exists(".phpenv"):
run("curl -s %s | bash" % url)
else:
run("curl -s %s | UPDATE=yes bash" % url)
dir.create(".phpenv/versions")
_ensure_autoload(".bashrc")
_ensure_autoload(".zshrc")
def ensure():
if not dir.exists(".phpenv"):
install()
<|code_end|>
using the current file's imports:
from revolver.core import run
from revolver import directory as dir
from revolver import package, file
and any relevant context from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
. Output only the next line. | def _ensure_autoload(filename): |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def test_revolver_is_just_a_wrapper():
assert user.get == cuisine.user_check
assert user.create == cuisine.user_create
assert user.ensure == cuisine.user_ensure
assert user.remove == cuisine.user_remove
@patch("revolver.user.get")
def test_exists(get):
get.expects_call().with_args("user").returns(None)
assert not user.exists("user")
get.expects_call().with_args("user").returns({})
assert user.exists("user")
@patch("revolver.user.get")
def test_shell(get):
get.expects_call().with_args("user").returns({"shell": "bar"})
assert user.shell("user") == "bar"
@patch("revolver.user.get")
<|code_end|>
using the current file's imports:
from fudge import patch
from revolver import user
import cuisine
and any relevant context from other files:
# Path: revolver/user.py
# def _get_with_abort(username):
# def exists(username):
# def home_directory(username):
# def shell(username):
. Output only the next line. | @patch("revolver.log.abort") |
Given the code snippet: <|code_start|>def sudo(username=None, login=False):
old_forced = env.sudo_forced
old_user = env.sudo_user
old_shell = env.shell
env.sudo_forced = True
env.sudo_user = username
if login:
with sudo():
user_shell = user.shell(username)
env.shell = "-i %s -i -c" % user_shell
yield
env.sudo_forced = old_forced
env.sudo_user = old_user
env.shell = old_shell
@contextmanager
def unpatched_state():
old_shell = env.shell
old_sudo_forced = env.sudo_forced
old_sudo_user = env.sudo_user
env.shell = "/bin/bash -l -c"
env.sudo_forced = False
env.sudo_user = None
<|code_end|>
, generate the next line using the imports in this file:
from contextlib import contextmanager
from fabric.context_managers import cd, hide, lcd, path, prefix, settings, show
from revolver import user
from revolver.core import env
and context (functions, classes, or occasionally code) from other files:
# Path: revolver/user.py
# def _get_with_abort(username):
# def exists(username):
# def home_directory(username):
# def shell(username):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | yield |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def inside():
return dir.exists("/vagrant") and user.exists("vagrant")
def is_running():
with ctx.settings(warn_only=True):
command = "vagrant status | egrep -o 'running$'"
vm_running = core.local(command, capture=True)
if vm_running is None or vm_running == "":
return False
<|code_end|>
with the help of current file imports:
import os
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import log, user, core
and context from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/log.py
#
# Path: revolver/user.py
# def _get_with_abort(username):
# def exists(username):
# def home_directory(username):
# def shell(username):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
, which may contain function names, class names, or code. Output only the next line. | return True |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def inside():
return dir.exists("/vagrant") and user.exists("vagrant")
def is_running():
with ctx.settings(warn_only=True):
<|code_end|>
with the help of current file imports:
import os
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import log, user, core
and context from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/log.py
#
# Path: revolver/user.py
# def _get_with_abort(username):
# def exists(username):
# def home_directory(username):
# def shell(username):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
, which may contain function names, class names, or code. Output only the next line. | command = "vagrant status | egrep -o 'running$'" |
Given snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def inside():
return dir.exists("/vagrant") and user.exists("vagrant")
def is_running():
with ctx.settings(warn_only=True):
command = "vagrant status | egrep -o 'running$'"
vm_running = core.local(command, capture=True)
if vm_running is None or vm_running == "":
return False
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import os
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import log, user, core
and context:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/log.py
#
# Path: revolver/user.py
# def _get_with_abort(username):
# def exists(username):
# def home_directory(username):
# def shell(username):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
which might include code, classes, or functions. Output only the next line. | return True |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def inside():
return dir.exists("/vagrant") and user.exists("vagrant")
def is_running():
with ctx.settings(warn_only=True):
<|code_end|>
. Use current file imports:
import os
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import log, user, core
and context (classes, functions, or code) from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/log.py
#
# Path: revolver/user.py
# def _get_with_abort(username):
# def exists(username):
# def home_directory(username):
# def shell(username):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | command = "vagrant status | egrep -o 'running$'" |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def test_revolver_is_just_a_wrapper():
assert directory.attributes == cuisine.dir_attribs
assert directory.attributes_get == cuisine.file_attribs_get
assert directory.ensure == cuisine.dir_ensure
assert directory.exists == cuisine.dir_exists
assert directory.is_link == cuisine.file_is_link
@patch("revolver.directory.mkdtemp")
<|code_end|>
using the current file's imports:
from fudge import patch
from revolver import directory
from .utils import run_result
import cuisine
and any relevant context from other files:
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/test/utils.py
# def run_result(stdout="", stderr="", return_code=0):
# result = fabric.operations._AttributeString(stdout)
# result.stderr = stderr
# result.return_code = return_code
# result.failed = return_code != 0
# result.succeeded = return_code == 0
# return result
. Output only the next line. | def test_temp_local(mkdtemp): |
Next line prediction: <|code_start|>
@patch("revolver.core.run")
@patch("revolver.directory.attributes")
def test_temp_passes_attributes(run, attributes):
run.expects_call().returns(run_result("path"))
(attributes.expects_call()
.with_args("path", mode="foo", owner="bar", group="baz"))
directory.temp("foo", "bar", "baz")
@patch("revolver.core.run")
def test_remove_defaults(run):
run.expects_call().with_args("rm -f path")
directory.remove("path")
@patch("revolver.core.run")
def test_remove_recusrive(run):
run.expects_call().with_args("rm -f path")
directory.remove("path", recursive=False)
run.expects_call().with_args("rm -f -r path")
directory.remove("path", recursive=True)
@patch("revolver.core.run")
def test_remove_force(run):
run.expects_call().with_args("rm path")
directory.remove("path", force=False)
<|code_end|>
. Use current file imports:
(from fudge import patch
from revolver import directory
from .utils import run_result
import cuisine)
and context including class names, function names, or small code snippets from other files:
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/test/utils.py
# def run_result(stdout="", stderr="", return_code=0):
# result = fabric.operations._AttributeString(stdout)
# result.stderr = stderr
# result.return_code = return_code
# result.failed = return_code != 0
# result.succeeded = return_code == 0
# return result
. Output only the next line. | run.expects_call().with_args("rm -f path") |
Given the following code snippet before the placeholder: <|code_start|> if file.exists(upstart_file):
cmd = "%s %s" % (command, name)
elif file.exists(initd_file):
cmd = "%s %s" % (initd_file, command)
else:
cmd = "false"
with ctx.unpatched_state():
core.sudo(cmd)
def start(name):
command(name, "start")
def stop(name):
command(name, "stop")
def restart(name):
command(name, "restart")
def reload(name):
command(name, "reload")
def is_running(name):
with ctx.settings(warn_only=True):
res = core.sudo("/etc/init.d/%s status" % name)
<|code_end|>
, predict the next line using imports from the current file:
from revolver import contextmanager as ctx
from revolver import core, file
and context including class names, function names, and sometimes code from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
. Output only the next line. | return res.succeeded |
Based on the snippet: <|code_start|>
with ctx.sudo():
with ctx.unpatched_state():
file.write(upstart_file, content)
def command(name, command):
initd_file = "/etc/init.d/%s" % name
upstart_file = "/etc/init/%s.conf" % name
if file.exists(upstart_file):
cmd = "%s %s" % (command, name)
elif file.exists(initd_file):
cmd = "%s %s" % (initd_file, command)
else:
cmd = "false"
with ctx.unpatched_state():
core.sudo(cmd)
def start(name):
command(name, "start")
def stop(name):
command(name, "stop")
def restart(name):
<|code_end|>
, predict the immediate next line with the help of imports:
from revolver import contextmanager as ctx
from revolver import core, file
and context (classes, functions, sometimes code) from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
. Output only the next line. | command(name, "restart") |
Given snippet: <|code_start|>
def add_upstart(name, content):
if name.endswith(".conf"):
name = name[:-5]
upstart_file = "/etc/init/%s.conf" % name
with ctx.sudo():
with ctx.unpatched_state():
file.write(upstart_file, content)
def command(name, command):
initd_file = "/etc/init.d/%s" % name
upstart_file = "/etc/init/%s.conf" % name
if file.exists(upstart_file):
cmd = "%s %s" % (command, name)
elif file.exists(initd_file):
cmd = "%s %s" % (initd_file, command)
else:
cmd = "false"
with ctx.unpatched_state():
core.sudo(cmd)
def start(name):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from revolver import contextmanager as ctx
from revolver import core, file
and context:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
which might include code, classes, or functions. Output only the next line. | command(name, "start") |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure(["curl", "git-core"])
<|code_end|>
. Use current file imports:
from revolver.core import sudo
from revolver import command, package
and context (classes, functions, or code) from other files:
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# Path: revolver/command.py
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
. Output only the next line. | url = "https://raw.github.com" \ |
Given the code snippet: <|code_start|> try:
core.put(tmp_tar, "deploy.tar.gz")
core.run("tar -xzf deploy.tar.gz")
file.remove("deploy.tar.gz")
with ctx.unpatched_state():
file.write("VERSION", git.revparse(self.revision))
finally:
core.local("rm -rf %s" % tmp_tar)
def _cleanup(self):
with ctx.cd(self.folders["releases"]):
core.run("ls -1 | sort -V | head -n-%s | xargs -l1 rm -rf"
% self.releases_to_keep)
def _activate(self):
file.link(self.folders["releases.current"], self.folders["current"])
class BaseHook(object):
def set_deployinator(self, deployinator):
self.deployinator = deployinator
def __getattr__(self, name):
if name.startswith("on_"):
return None
return getattr(self.deployinator, name)
class UnicornUpstartHook(BaseHook):
<|code_end|>
, generate the next line using the imports in this file:
from datetime import datetime
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import file, git, core, command, service
import posixpath
and context (functions, classes, or occasionally code) from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/git.py
# def repository_name():
# def create_archive(revision):
# def revparse(revision):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
#
# Path: revolver/command.py
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
. Output only the next line. | _template = """\ |
Predict the next line after this snippet: <|code_start|>
class Deployinator(object):
def __init__(self, cwd=None, name=None):
self.cwd = cwd or core.run("pwd").stdout
self.name = name or git.repository_name()
self.releases_to_keep = 15
self.revision = "HEAD"
self._hooks = []
self._init_folders()
def add_hook(self, hook):
hook.set_deployinator(self)
self._hooks.append(hook)
def dispatch_hook(self, name):
for hook in self._hooks:
method = getattr(hook, "on_%s" % name)
if method:
method()
def run(self):
self.dispatch_hook("init")
self.dispatch_hook("before_layout")
try:
self._layout()
self.dispatch_hook("after_layout")
with ctx.cd(self.folders["releases.current"]):
self.dispatch_hook("before_upload")
<|code_end|>
using the current file's imports:
from datetime import datetime
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import file, git, core, command, service
import posixpath
and any relevant context from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/git.py
# def repository_name():
# def create_archive(revision):
# def revparse(revision):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
#
# Path: revolver/command.py
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
. Output only the next line. | self._upload() |
Given the code snippet: <|code_start|> core.local("rm -rf %s" % tmp_tar)
def _cleanup(self):
with ctx.cd(self.folders["releases"]):
core.run("ls -1 | sort -V | head -n-%s | xargs -l1 rm -rf"
% self.releases_to_keep)
def _activate(self):
file.link(self.folders["releases.current"], self.folders["current"])
class BaseHook(object):
def set_deployinator(self, deployinator):
self.deployinator = deployinator
def __getattr__(self, name):
if name.startswith("on_"):
return None
return getattr(self.deployinator, name)
class UnicornUpstartHook(BaseHook):
_template = """\
description "Unicorn application server for {name}"
author "Revolver UnicornUpstartHook"
version "1.0"
start on runlevel [2]
stop on runlevel [016]
<|code_end|>
, generate the next line using the imports in this file:
from datetime import datetime
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import file, git, core, command, service
import posixpath
and context (functions, classes, or occasionally code) from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/git.py
# def repository_name():
# def create_archive(revision):
# def revparse(revision):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
#
# Path: revolver/command.py
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
. Output only the next line. | console owner |
Predict the next line after this snippet: <|code_start|>
class Deployinator(object):
def __init__(self, cwd=None, name=None):
self.cwd = cwd or core.run("pwd").stdout
self.name = name or git.repository_name()
self.releases_to_keep = 15
self.revision = "HEAD"
self._hooks = []
self._init_folders()
def add_hook(self, hook):
hook.set_deployinator(self)
self._hooks.append(hook)
def dispatch_hook(self, name):
for hook in self._hooks:
method = getattr(hook, "on_%s" % name)
if method:
method()
def run(self):
self.dispatch_hook("init")
self.dispatch_hook("before_layout")
try:
self._layout()
self.dispatch_hook("after_layout")
with ctx.cd(self.folders["releases.current"]):
self.dispatch_hook("before_upload")
<|code_end|>
using the current file's imports:
from datetime import datetime
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import file, git, core, command, service
import posixpath
and any relevant context from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/git.py
# def repository_name():
# def create_archive(revision):
# def revparse(revision):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
#
# Path: revolver/command.py
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
. Output only the next line. | self._upload() |
Here is a snippet: <|code_start|> self._layout()
self.dispatch_hook("after_layout")
with ctx.cd(self.folders["releases.current"]):
self.dispatch_hook("before_upload")
self._upload()
self.dispatch_hook("after_upload")
self.dispatch_hook("before_cleanup")
self._cleanup()
self.dispatch_hook("after_cleanup")
self.dispatch_hook("before_activate")
self._activate()
except:
dir.remove(self.folders["releases.current"], recursive=True)
raise
with ctx.cd(self.folders["releases.current"]):
self.dispatch_hook("after_activate")
def _init_folders(self):
project = posixpath.join(self.cwd, self.name)
deploy = datetime.utcnow().strftime("%Y%m%dT%H%M%SZ")
join = posixpath.join
self.folders = {
"project": project,
"current": join(project, "current"),
"releases": join(project, "releases"),
<|code_end|>
. Write the next line using the current file imports:
from datetime import datetime
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import file, git, core, command, service
import posixpath
and context from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/git.py
# def repository_name():
# def create_archive(revision):
# def revparse(revision):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
#
# Path: revolver/command.py
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
, which may include functions, classes, or code. Output only the next line. | "releases.current": join(project, "releases", deploy), |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
append = inject_use_sudo(append)
comment = inject_use_sudo(comment)
contains = inject_use_sudo(contains)
sed = inject_use_sudo(sed)
uncomment = inject_use_sudo(uncomment)
write = inject_use_sudo(write)
def temp(mode=None, owner=None, group=None):
path = core.run('mktemp').stdout
attributes(path, mode=mode, owner=owner, group=group)
return path
def remove(location, recursive=False, force=True):
force = force and '-f' or ''
recursive = recursive and '-r' or ''
core.run('rm %s %s %s' % (force, recursive, location))
<|code_end|>
using the current file's imports:
from cuisine import file_attribs as attributes
from cuisine import file_attribs_get as attributes_get
from cuisine import file_ensure as ensure
from cuisine import file_is_file as exists
from cuisine import file_is_link as is_link
from cuisine import file_link as link
from cuisine import file_local_read as read_local
from cuisine import file_read as read
from cuisine import file_update as update
from cuisine import file_write as write
from fabric.contrib.files import append, comment, contains, sed, uncomment
from revolver import core
from revolver.decorator import inject_use_sudo
and any relevant context from other files:
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
#
# Path: revolver/decorator.py
# def inject_use_sudo(func):
# @wraps(func)
# def inject_wrapper(*args, **kwargs):
# func_args = func.func_code.co_varnames[:func.func_code.co_argcount]
#
# # Fabric
# if "use_sudo" not in kwargs and "use_sudo" in func_args:
# kwargs["use_sudo"] = env.sudo_forced
#
# # Cuisine
# if "sudo" not in kwargs and "sudo" in func_args:
# kwargs["sudo"] = env.sudo_forced
#
# return func(*args, **kwargs)
# return inject_wrapper
. Output only the next line. | def touch(location, mode=None, owner=None, group=None): |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
append = inject_use_sudo(append)
comment = inject_use_sudo(comment)
contains = inject_use_sudo(contains)
sed = inject_use_sudo(sed)
uncomment = inject_use_sudo(uncomment)
write = inject_use_sudo(write)
def temp(mode=None, owner=None, group=None):
path = core.run('mktemp').stdout
attributes(path, mode=mode, owner=owner, group=group)
<|code_end|>
, determine the next line of code. You have imports:
from cuisine import file_attribs as attributes
from cuisine import file_attribs_get as attributes_get
from cuisine import file_ensure as ensure
from cuisine import file_is_file as exists
from cuisine import file_is_link as is_link
from cuisine import file_link as link
from cuisine import file_local_read as read_local
from cuisine import file_read as read
from cuisine import file_update as update
from cuisine import file_write as write
from fabric.contrib.files import append, comment, contains, sed, uncomment
from revolver import core
from revolver.decorator import inject_use_sudo
and context (class names, function names, or code) available:
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
#
# Path: revolver/decorator.py
# def inject_use_sudo(func):
# @wraps(func)
# def inject_wrapper(*args, **kwargs):
# func_args = func.func_code.co_varnames[:func.func_code.co_argcount]
#
# # Fabric
# if "use_sudo" not in kwargs and "use_sudo" in func_args:
# kwargs["use_sudo"] = env.sudo_forced
#
# # Cuisine
# if "sudo" not in kwargs and "sudo" in func_args:
# kwargs["sudo"] = env.sudo_forced
#
# return func(*args, **kwargs)
# return inject_wrapper
. Output only the next line. | return path |
Next line prediction: <|code_start|>
def test_revolver_is_just_a_wrapper():
assert server.uuid == cuisine.system_uuid
@patch("revolver.file.copy")
def test_timezone_default(copy):
copy.expects_call().with_args("/usr/share/zoneinfo/UTC", "/etc/localtime")
server.timezone()
@patch("revolver.file.copy")
def test_timezone(copy):
copy.expects_call().with_args("/usr/share/zoneinfo/FOO", "/etc/localtime")
server.timezone("FOO")
@patch("revolver.core.run")
def test_version(run):
(run.expects_call()
.with_args("lsb_release --release --short")
.returns(run_result("foo")))
assert server.version() == "foo"
@patch("revolver.core.run")
def test_codename(run):
<|code_end|>
. Use current file imports:
(from fudge import patch
from revolver import server
from .utils import run_result
import cuisine)
and context including class names, function names, or small code snippets from other files:
# Path: revolver/server.py
# def timezone(zone='UTC'):
# def version():
# def codename():
#
# Path: revolver/test/utils.py
# def run_result(stdout="", stderr="", return_code=0):
# result = fabric.operations._AttributeString(stdout)
# result.stderr = stderr
# result.return_code = return_code
# result.failed = return_code != 0
# result.succeeded = return_code == 0
# return result
. Output only the next line. | (run.expects_call() |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def test_revolver_is_just_a_wrapper():
assert server.uuid == cuisine.system_uuid
@patch("revolver.file.copy")
def test_timezone_default(copy):
copy.expects_call().with_args("/usr/share/zoneinfo/UTC", "/etc/localtime")
server.timezone()
@patch("revolver.file.copy")
def test_timezone(copy):
<|code_end|>
, determine the next line of code. You have imports:
from fudge import patch
from revolver import server
from .utils import run_result
import cuisine
and context (class names, function names, or code) available:
# Path: revolver/server.py
# def timezone(zone='UTC'):
# def version():
# def codename():
#
# Path: revolver/test/utils.py
# def run_result(stdout="", stderr="", return_code=0):
# result = fabric.operations._AttributeString(stdout)
# result.stderr = stderr
# result.return_code = return_code
# result.failed = return_code != 0
# result.succeeded = return_code == 0
# return result
. Output only the next line. | copy.expects_call().with_args("/usr/share/zoneinfo/FOO", "/etc/localtime") |
Based on the snippet: <|code_start|> (exists
.expects_call()
.returns(False)
.next_call()
.with_args("/etc/init.d/foo")
.returns(True))
sudo.expects_call().with_args("/etc/init.d/foo method")
service.command("foo", "method")
@patch("revolver.service.command")
def test_start(command):
command.expects_call().with_args("foo", "start")
service.start("foo")
@patch("revolver.service.command")
def test_stop(command):
command.expects_call().with_args("foo", "stop")
service.stop("foo")
@patch("revolver.service.command")
def test_restart(command):
command.expects_call().with_args("foo", "restart")
service.restart("foo")
@patch("revolver.service.command")
def test_reload(command):
<|code_end|>
, predict the immediate next line with the help of imports:
from fudge import patch
from revolver import service
import fabric
and context (classes, functions, sometimes code) from other files:
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
. Output only the next line. | command.expects_call().with_args("foo", "reload") |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def repository_name():
command = "grep 'url' .git/config | cut -d':' -f2"
name = core.local(command, capture=True)
# Get the basename (e.g. github/repo => repo)
name = name.split("/")[-1]
# Also strip the sometimes optional .git extension
<|code_end|>
, determine the next line of code. You have imports:
import os
from revolver import directory as dir
from revolver import core
and context (class names, function names, or code) available:
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | if name.endswith(".git"): |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def repository_name():
command = "grep 'url' .git/config | cut -d':' -f2"
name = core.local(command, capture=True)
# Get the basename (e.g. github/repo => repo)
name = name.split("/")[-1]
# Also strip the sometimes optional .git extension
if name.endswith(".git"):
name = name[:-4]
return name
def create_archive(revision):
tmp_folder = dir.temp_local()
tmp_tar = os.path.join(tmp_folder, 'repo.tar.gz')
core.local(
'git archive --format=tar %(rev)s | gzip > %(tar)s'
% {'rev': revision, 'tar': tmp_tar}
)
<|code_end|>
. Use current file imports:
import os
from revolver import directory as dir
from revolver import core
and context (classes, functions, or code) from other files:
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
. Output only the next line. | return tmp_tar |
Next line prediction: <|code_start|> prefix = "$HOME/.phpenv/versions/%s" % version
# Force the usage of pear because pyrus is unable to install APC
# See https://github.com/CHH/php-build/blob/master/man/php-build.1.ronn#L79
pear_path = "%s/pear" % prefix
pear = configure("--with-pear=%s" % pear_path)
dir.ensure(pear_path, recursive=True)
# We only support this two configuration options! Why?
# - Xdebug is already integrated into php-build
# - FPM is a very common flag
#
# But if you want to configure php even further? Own definition files!
# See https://github.com/CHH/php-build/blob/master/man/php-build.1.ronn#L54
fpm = (fpm and configure("--enable-fpm")) or "true"
xdebug = (xdebug and "true") or 'export PHP_BUILD_XDEBUG_ENABLE="off"'
with ctx.prefix(pear):
with ctx.prefix(xdebug):
with ctx.prefix(fpm):
run("php-build %s %s" % (version, prefix))
# Some executables (like php-fpm) aren't available through phpenv without
# this symlinks
with ctx.cd(prefix):
run('find sbin/ -type f -exec ln -sf "$(pwd)/{}" -t "$(pwd)/bin" \;')
def _install_apc():
installed = run("pecl list | grep -i apc; true")
<|code_end|>
. Use current file imports:
(from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import file, package
from revolver.tool import php_build, php_phpenv)
and context including class names, function names, or small code snippets from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/tool/php_build.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
#
# Path: revolver/tool/php_phpenv.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
. Output only the next line. | if installed: |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install(version, fpm=False, xdebug=False):
php_build.ensure()
php_phpenv.ensure()
switched = run("phpenv global %s; true" % version)
if not switched == "":
_install_php(version, fpm, xdebug)
run("phpenv global %s" % version)
run("phpenv rehash")
_install_apc()
_install_composer()
def _install_php(version, fpm, xdebug):
package.ensure([
<|code_end|>
, determine the next line of code. You have imports:
from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import file, package
from revolver.tool import php_build, php_phpenv
and context (class names, function names, or code) available:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/tool/php_build.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
#
# Path: revolver/tool/php_phpenv.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
. Output only the next line. | "build-essential", "lemon", "libbz2-dev", "libpcre3-dev", |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install(version, fpm=False, xdebug=False):
php_build.ensure()
php_phpenv.ensure()
switched = run("phpenv global %s; true" % version)
if not switched == "":
_install_php(version, fpm, xdebug)
run("phpenv global %s" % version)
run("phpenv rehash")
_install_apc()
_install_composer()
def _install_php(version, fpm, xdebug):
package.ensure([
"build-essential", "lemon", "libbz2-dev", "libpcre3-dev",
<|code_end|>
. Use current file imports:
(from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import file, package
from revolver.tool import php_build, php_phpenv)
and context including class names, function names, or small code snippets from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/tool/php_build.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
#
# Path: revolver/tool/php_phpenv.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
. Output only the next line. | "libc-client2007e-dev", "libcurl4-gnutls-dev", "libexpat1-dev", |
Given snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install(version, fpm=False, xdebug=False):
php_build.ensure()
php_phpenv.ensure()
switched = run("phpenv global %s; true" % version)
if not switched == "":
_install_php(version, fpm, xdebug)
run("phpenv global %s" % version)
run("phpenv rehash")
_install_apc()
_install_composer()
def _install_php(version, fpm, xdebug):
package.ensure([
"build-essential", "lemon", "libbz2-dev", "libpcre3-dev",
"libc-client2007e-dev", "libcurl4-gnutls-dev", "libexpat1-dev",
"libfreetype6-dev", "libgmp3-dev", "libicu-dev", "libjpeg8-dev",
"libltdl-dev", "libmcrypt-dev", "libmhash-dev", "libpng12-dev",
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import file, package
from revolver.tool import php_build, php_phpenv
and context:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/tool/php_build.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
#
# Path: revolver/tool/php_phpenv.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
which might include code, classes, or functions. Output only the next line. | "libreadline-dev", "libssl1.0.0", "libssl-dev", "libt1-dev", |
Given snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install(version, fpm=False, xdebug=False):
php_build.ensure()
php_phpenv.ensure()
switched = run("phpenv global %s; true" % version)
if not switched == "":
_install_php(version, fpm, xdebug)
run("phpenv global %s" % version)
run("phpenv rehash")
_install_apc()
_install_composer()
def _install_php(version, fpm, xdebug):
package.ensure([
"build-essential", "lemon", "libbz2-dev", "libpcre3-dev",
"libc-client2007e-dev", "libcurl4-gnutls-dev", "libexpat1-dev",
"libfreetype6-dev", "libgmp3-dev", "libicu-dev", "libjpeg8-dev",
"libltdl-dev", "libmcrypt-dev", "libmhash-dev", "libpng12-dev",
"libreadline-dev", "libssl1.0.0", "libssl-dev", "libt1-dev",
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import file, package
from revolver.tool import php_build, php_phpenv
and context:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/tool/php_build.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
#
# Path: revolver/tool/php_phpenv.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
which might include code, classes, or functions. Output only the next line. | "libtidy-dev", "libxml2-dev", "libxslt1-dev", "re2c", "zlib1g-dev" |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install(version, fpm=False, xdebug=False):
php_build.ensure()
php_phpenv.ensure()
switched = run("phpenv global %s; true" % version)
<|code_end|>
, determine the next line of code. You have imports:
from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import file, package
from revolver.tool import php_build, php_phpenv
and context (class names, function names, or code) available:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/tool/php_build.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
#
# Path: revolver/tool/php_phpenv.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
. Output only the next line. | if not switched == "": |
Given snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def test_revolver_is_just_a_wrapper():
# TODO Check the decorator stack (multiargs and sudo)
assert_contain_function_wrapped(package.ensure, cuisine.package_ensure)
assert_contain_function_wrapped(package.install, cuisine.package_install)
assert_contain_function_wrapped(package.update, cuisine.package_update)
assert_contain_function_wrapped(package.upgrade, cuisine.package_upgrade)
@patch("revolver.core.run")
def test_is_installed(run):
(run.expects_call()
.with_args("dpkg -s foo")
.returns("Status: foo installed"))
assert package.is_installed("foo")
@patch("revolver.core.run")
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from fudge import patch
from revolver import package, decorator
from .utils import assert_contain_function_wrapped
import cuisine
and context:
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/decorator.py
# def sudo(func):
# def wrapper(*args, **kwargs):
# def multiargs(func):
# def wrapper(*args, **kwargs):
# def inject_use_sudo(func):
# def inject_wrapper(*args, **kwargs):
#
# Path: revolver/test/utils.py
# def assert_contain_function_wrapped(haystack, needle):
# assert haystack.__module__ == needle.__module__
# assert haystack.__name__ == needle.__name__
which might include code, classes, or functions. Output only the next line. | def test_is_not_installed_without_status(run): |
Given the following code snippet before the placeholder: <|code_start|>
def test_revolver_is_just_a_wrapper():
# TODO Check the decorator stack (multiargs and sudo)
assert_contain_function_wrapped(package.ensure, cuisine.package_ensure)
assert_contain_function_wrapped(package.install, cuisine.package_install)
assert_contain_function_wrapped(package.update, cuisine.package_update)
assert_contain_function_wrapped(package.upgrade, cuisine.package_upgrade)
@patch("revolver.core.run")
def test_is_installed(run):
(run.expects_call()
.with_args("dpkg -s foo")
.returns("Status: foo installed"))
assert package.is_installed("foo")
@patch("revolver.core.run")
def test_is_not_installed_without_status(run):
(run.expects_call()
.with_args("dpkg -s foo")
.returns("foo installed"))
assert not package.is_installed("foo")
@patch("revolver.package.ensure")
@patch("revolver.server.codename")
@patch("revolver.file.exists")
@patch("revolver.core.sudo")
<|code_end|>
, predict the next line using imports from the current file:
from fudge import patch
from revolver import package, decorator
from .utils import assert_contain_function_wrapped
import cuisine
and context including class names, function names, and sometimes code from other files:
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/decorator.py
# def sudo(func):
# def wrapper(*args, **kwargs):
# def multiargs(func):
# def wrapper(*args, **kwargs):
# def inject_use_sudo(func):
# def inject_wrapper(*args, **kwargs):
#
# Path: revolver/test/utils.py
# def assert_contain_function_wrapped(haystack, needle):
# assert haystack.__module__ == needle.__module__
# assert haystack.__name__ == needle.__name__
. Output only the next line. | @patch("revolver.package.update") |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
already_installed = package.is_installed('nginx')
if server.version == '10.04':
package.install_ppa('nginx/stable')
package.install('nginx')
if not already_installed:
<|code_end|>
using the current file's imports:
from revolver.core import sudo
from revolver import command, file, package, server, service
from revolver import contextmanager as ctx
from revolver import directory as dir
and any relevant context from other files:
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# Path: revolver/command.py
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/server.py
# def timezone(zone='UTC'):
# def version():
# def codename():
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
. Output only the next line. | site_disable('default') |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
already_installed = package.is_installed('nginx')
if server.version == '10.04':
package.install_ppa('nginx/stable')
package.install('nginx')
<|code_end|>
with the help of current file imports:
from revolver.core import sudo
from revolver import command, file, package, server, service
from revolver import contextmanager as ctx
from revolver import directory as dir
and context from other files:
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# Path: revolver/command.py
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/server.py
# def timezone(zone='UTC'):
# def version():
# def codename():
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
, which may contain function names, class names, or code. Output only the next line. | if not already_installed: |
Using the snippet: <|code_start|> www_owner = 'www-data'
if not dir.exists(www_dir):
with ctx.sudo():
dir.create(www_dir)
dir.attributes(www_dir, owner=www_owner, group=www_owner)
restart()
def ensure():
if not command.exists('nginx'):
install()
def restart():
service.restart('nginx')
def reload():
service.reload('nginx')
def site_disable(site):
with ctx.sudo():
with ctx.cd('/etc/nginx/sites-enabled'):
file.remove(site)
reload()
def site_enable(site):
<|code_end|>
, determine the next line of code. You have imports:
from revolver.core import sudo
from revolver import command, file, package, server, service
from revolver import contextmanager as ctx
from revolver import directory as dir
and context (class names, function names, or code) available:
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# Path: revolver/command.py
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/server.py
# def timezone(zone='UTC'):
# def version():
# def codename():
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
. Output only the next line. | site_available = '/etc/nginx/sites-available/%s' % site |
Here is a snippet: <|code_start|>
restart()
def ensure():
if not command.exists('nginx'):
install()
def restart():
service.restart('nginx')
def reload():
service.reload('nginx')
def site_disable(site):
with ctx.sudo():
with ctx.cd('/etc/nginx/sites-enabled'):
file.remove(site)
reload()
def site_enable(site):
site_available = '/etc/nginx/sites-available/%s' % site
site_enabled = '/etc/nginx/sites-enabled/%s' % site
with ctx.sudo():
file.link(site_available, site_enabled)
<|code_end|>
. Write the next line using the current file imports:
from revolver.core import sudo
from revolver import command, file, package, server, service
from revolver import contextmanager as ctx
from revolver import directory as dir
and context from other files:
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# Path: revolver/command.py
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/server.py
# def timezone(zone='UTC'):
# def version():
# def codename():
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
, which may include functions, classes, or code. Output only the next line. | reload() |
Continue the code snippet: <|code_start|>
from __future__ import absolute_import, division, with_statement
def install():
already_installed = package.is_installed('nginx')
if server.version == '10.04':
package.install_ppa('nginx/stable')
package.install('nginx')
if not already_installed:
site_disable('default')
www_dir = '/var/www'
www_owner = 'www-data'
if not dir.exists(www_dir):
with ctx.sudo():
dir.create(www_dir)
dir.attributes(www_dir, owner=www_owner, group=www_owner)
restart()
def ensure():
if not command.exists('nginx'):
install()
<|code_end|>
. Use current file imports:
from revolver.core import sudo
from revolver import command, file, package, server, service
from revolver import contextmanager as ctx
from revolver import directory as dir
and context (classes, functions, or code) from other files:
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# Path: revolver/command.py
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/server.py
# def timezone(zone='UTC'):
# def version():
# def codename():
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
. Output only the next line. | def restart(): |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
already_installed = package.is_installed('nginx')
if server.version == '10.04':
package.install_ppa('nginx/stable')
package.install('nginx')
if not already_installed:
<|code_end|>
using the current file's imports:
from revolver.core import sudo
from revolver import command, file, package, server, service
from revolver import contextmanager as ctx
from revolver import directory as dir
and any relevant context from other files:
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# Path: revolver/command.py
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/server.py
# def timezone(zone='UTC'):
# def version():
# def codename():
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
. Output only the next line. | site_disable('default') |
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
already_installed = package.is_installed('nginx')
if server.version == '10.04':
package.install_ppa('nginx/stable')
package.install('nginx')
<|code_end|>
, predict the next line using imports from the current file:
from revolver.core import sudo
from revolver import command, file, package, server, service
from revolver import contextmanager as ctx
from revolver import directory as dir
and context including class names, function names, and sometimes code from other files:
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# Path: revolver/command.py
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/server.py
# def timezone(zone='UTC'):
# def version():
# def codename():
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
. Output only the next line. | if not already_installed: |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install(version, _update=True):
ruby_rbenv.ensure()
ruby_build.ensure()
status = run("rbenv global %s; true" % version)
if not status == "" or _update:
run("rbenv install %s" % version)
run("rbenv global %s" % version)
run("rbenv rehash")
run("gem install --no-ri --no-rdoc bundler")
def ensure(version):
<|code_end|>
. Use current file imports:
(from revolver.core import run
from revolver.tool import ruby_build, ruby_rbenv)
and context including class names, function names, or small code snippets from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/tool/ruby_build.py
# def install():
# def ensure():
#
# Path: revolver/tool/ruby_rbenv.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
. Output only the next line. | install(version, _update=False) |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install(version, _update=True):
ruby_rbenv.ensure()
ruby_build.ensure()
status = run("rbenv global %s; true" % version)
if not status == "" or _update:
run("rbenv install %s" % version)
run("rbenv global %s" % version)
run("rbenv rehash")
run("gem install --no-ri --no-rdoc bundler")
def ensure(version):
<|code_end|>
. Use current file imports:
(from revolver.core import run
from revolver.tool import ruby_build, ruby_rbenv)
and context including class names, function names, or small code snippets from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/tool/ruby_build.py
# def install():
# def ensure():
#
# Path: revolver/tool/ruby_rbenv.py
# def install():
# def ensure():
# def _ensure_autoload(filename):
. Output only the next line. | install(version, _update=False) |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure(["curl", "git-core", "make"])
<|code_end|>
. Use current file imports:
(from revolver.core import sudo
from revolver import command, package)
and context including class names, function names, or small code snippets from other files:
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# Path: revolver/command.py
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
. Output only the next line. | url = "https://raw.github.com/visionmedia/git-extras/master/bin/git-extras" |
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure(["curl", "git-core", "make"])
url = "https://raw.github.com/visionmedia/git-extras/master/bin/git-extras"
sudo("curl -s %s | INSTALL=y sh" % url)
def ensure():
if not command.exists("git-extras"):
<|code_end|>
, predict the next line using imports from the current file:
from revolver.core import sudo
from revolver import command, package
and context including class names, function names, and sometimes code from other files:
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# Path: revolver/command.py
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
. Output only the next line. | install() |
Predict the next line after this snippet: <|code_start|> assert fabric.operations.sudo == core.sudo
def test_patch_cuisine():
assert cuisine.run == core.run
assert cuisine.sudo == core.sudo
def test_original_methods_are_available_but_private():
assert core._run.__module__ == "fabric.operations"
assert core._sudo.__module__ == "fabric.operations"
@patch("revolver.core.sudo")
def test_force_sudo_via_env(sudo):
sudo.expects_call().with_args("foo")
core.env.sudo_forced = True
core.run("foo")
core.env.sudo_forced = False
@patch("revolver.core._sudo")
def test_inject_user_for_sudo_via_env(_sudo):
_sudo.expects_call().with_args("foo", user="bar")
core.env.sudo_user = "bar"
core.sudo("foo")
core.env.sudo_user = None
@patch("revolver.core._put")
<|code_end|>
using the current file's imports:
from fudge import patch
from revolver import core
from .utils import assert_contain_function_wrapped
import cuisine
import fabric
and any relevant context from other files:
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
#
# Path: revolver/test/utils.py
# def assert_contain_function_wrapped(haystack, needle):
# assert haystack.__module__ == needle.__module__
# assert haystack.__name__ == needle.__name__
. Output only the next line. | def test_put_does_not_pass_any_default_args(_put): |
Here is a snippet: <|code_start|>
from __future__ import absolute_import, division, with_statement
def sudo(func):
@wraps(func)
def wrapper(*args, **kwargs):
with ctx.sudo():
func(*args, **kwargs)
return wrapper
def multiargs(func):
@wraps(func)
def wrapper(*args, **kwargs):
if len(args) == 0:
return func()
arg = args[0]
args = args[1:]
if type(arg) in (tuple, list):
return map(lambda _: func(_, *args, **kwargs), arg)
else:
return func(arg, *args, **kwargs)
return wrapper
def inject_use_sudo(func):
<|code_end|>
. Write the next line using the current file imports:
from functools import wraps
from fabric.decorators import (task, hosts, roles, runs_once, serial,
parallel, with_settings)
from fabric.network import needs_host
from revolver.core import env
from revolver import contextmanager as ctx
and context from other files:
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
, which may include functions, classes, or code. Output only the next line. | @wraps(func) |
Given snippet: <|code_start|>
def sudo(func):
@wraps(func)
def wrapper(*args, **kwargs):
with ctx.sudo():
func(*args, **kwargs)
return wrapper
def multiargs(func):
@wraps(func)
def wrapper(*args, **kwargs):
if len(args) == 0:
return func()
arg = args[0]
args = args[1:]
if type(arg) in (tuple, list):
return map(lambda _: func(_, *args, **kwargs), arg)
else:
return func(arg, *args, **kwargs)
return wrapper
def inject_use_sudo(func):
@wraps(func)
def inject_wrapper(*args, **kwargs):
func_args = func.func_code.co_varnames[:func.func_code.co_argcount]
# Fabric
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from functools import wraps
from fabric.decorators import (task, hosts, roles, runs_once, serial,
parallel, with_settings)
from fabric.network import needs_host
from revolver.core import env
from revolver import contextmanager as ctx
and context:
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
which might include code, classes, or functions. Output only the next line. | if "use_sudo" not in kwargs and "use_sudo" in func_args: |
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def _preseed_server(root_password):
seed_config = """# Mysql preseed generated by revolver
mysql-server mysql-server/root_password password %(root_password)s
mysql-server mysql-server/root_password_again password %(root_password)s
<|code_end|>
, predict the next line using imports from the current file:
import random
import string
from revolver.core import sudo
from revolver import command, package, file, service
from revolver import contextmanager as ctx
from revolver import directory as dir
and context including class names, function names, and sometimes code from other files:
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# Path: revolver/command.py
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
. Output only the next line. | mysql-server mysql-server/start_on_boot boolean true |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def _preseed_server(root_password):
seed_config = """# Mysql preseed generated by revolver
<|code_end|>
. Use current file imports:
(import random
import string
from revolver.core import sudo
from revolver import command, package, file, service
from revolver import contextmanager as ctx
from revolver import directory as dir)
and context including class names, function names, or small code snippets from other files:
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# Path: revolver/command.py
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
. Output only the next line. | mysql-server mysql-server/root_password password %(root_password)s |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def _preseed_server(root_password):
seed_config = """# Mysql preseed generated by revolver
<|code_end|>
, predict the immediate next line with the help of imports:
import random
import string
from revolver.core import sudo
from revolver import command, package, file, service
from revolver import contextmanager as ctx
from revolver import directory as dir
and context (classes, functions, sometimes code) from other files:
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# Path: revolver/command.py
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
#
# Path: revolver/service.py
# def add_upstart(name, content):
# def command(name, command):
# def start(name):
# def stop(name):
# def restart(name):
# def reload(name):
# def is_running(name):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
. Output only the next line. | mysql-server mysql-server/root_password password %(root_password)s |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure("git-core")
if not dir.exists(".rbenv"):
run("git clone git://github.com/sstephenson/rbenv.git .rbenv")
else:
with ctx.cd(".rbenv"):
run("git pull")
_ensure_autoload(".bashrc")
_ensure_autoload(".zshrc")
<|code_end|>
with the help of current file imports:
from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import package, file
and context from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
, which may contain function names, class names, or code. Output only the next line. | def ensure(): |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure("git-core")
if not dir.exists(".rbenv"):
run("git clone git://github.com/sstephenson/rbenv.git .rbenv")
else:
with ctx.cd(".rbenv"):
run("git pull")
_ensure_autoload(".bashrc")
_ensure_autoload(".zshrc")
<|code_end|>
, determine the next line of code. You have imports:
from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import package, file
and context (class names, function names, or code) available:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
. Output only the next line. | def ensure(): |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure("git-core")
if not dir.exists(".rbenv"):
run("git clone git://github.com/sstephenson/rbenv.git .rbenv")
else:
with ctx.cd(".rbenv"):
run("git pull")
<|code_end|>
with the help of current file imports:
from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import package, file
and context from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
, which may contain function names, class names, or code. Output only the next line. | _ensure_autoload(".bashrc") |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
def install():
package.ensure("git-core")
if not dir.exists(".rbenv"):
run("git clone git://github.com/sstephenson/rbenv.git .rbenv")
else:
with ctx.cd(".rbenv"):
run("git pull")
_ensure_autoload(".bashrc")
_ensure_autoload(".zshrc")
def ensure():
if not dir.exists(".rbenv"):
install()
<|code_end|>
. Use current file imports:
(from revolver.core import run
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver import package, file)
and context including class names, function names, or small code snippets from other files:
# Path: revolver/core.py
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
. Output only the next line. | def _ensure_autoload(filename): |
Based on the snippet: <|code_start|>VERSION = '0.0.5'
env.sudo_forced = False
env.sudo_user = None
@inject_use_sudo
def put(*args, **kwargs):
with _ctx.unpatched_state():
return _put(*args, **kwargs)
def run(*args, **kwargs):
if not env.sudo_forced:
return _run(*args, **kwargs)
return sudo(*args, **kwargs)
def sudo(*args, **kwargs):
if env.sudo_user:
kwargs['user'] = env.sudo_user
return _sudo(*args, **kwargs)
# Monkeypatch sudo/run into fabric/cuisine
# TODO Added fabric.contrib.files because it was still wrong. Do we need to
# patch even more places? Wrong import-order used? Investigate here!
for module in ("fabric.api", "fabric.contrib.files",
<|code_end|>
, predict the immediate next line with the help of imports:
import sys
import cuisine
from fabric.api import run as _run
from fabric.api import sudo as _sudo
from fabric.api import put as _put
from fabric.api import local, get, env
from revolver import contextmanager as _ctx
from revolver.decorator import inject_use_sudo
from fabric.contrib import files as _files
and context (classes, functions, sometimes code) from other files:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/decorator.py
# def inject_use_sudo(func):
# @wraps(func)
# def inject_wrapper(*args, **kwargs):
# func_args = func.func_code.co_varnames[:func.func_code.co_argcount]
#
# # Fabric
# if "use_sudo" not in kwargs and "use_sudo" in func_args:
# kwargs["use_sudo"] = env.sudo_forced
#
# # Cuisine
# if "sudo" not in kwargs and "sudo" in func_args:
# kwargs["sudo"] = env.sudo_forced
#
# return func(*args, **kwargs)
# return inject_wrapper
. Output only the next line. | "fabric.operations", "cuisine"): |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
VERSION = '0.0.5'
env.sudo_forced = False
env.sudo_user = None
@inject_use_sudo
def put(*args, **kwargs):
with _ctx.unpatched_state():
return _put(*args, **kwargs)
def run(*args, **kwargs):
if not env.sudo_forced:
return _run(*args, **kwargs)
return sudo(*args, **kwargs)
def sudo(*args, **kwargs):
<|code_end|>
, determine the next line of code. You have imports:
import sys
import cuisine
from fabric.api import run as _run
from fabric.api import sudo as _sudo
from fabric.api import put as _put
from fabric.api import local, get, env
from revolver import contextmanager as _ctx
from revolver.decorator import inject_use_sudo
from fabric.contrib import files as _files
and context (class names, function names, or code) available:
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/decorator.py
# def inject_use_sudo(func):
# @wraps(func)
# def inject_wrapper(*args, **kwargs):
# func_args = func.func_code.co_varnames[:func.func_code.co_argcount]
#
# # Fabric
# if "use_sudo" not in kwargs and "use_sudo" in func_args:
# kwargs["use_sudo"] = env.sudo_forced
#
# # Cuisine
# if "sudo" not in kwargs and "sudo" in func_args:
# kwargs["sudo"] = env.sudo_forced
#
# return func(*args, **kwargs)
# return inject_wrapper
. Output only the next line. | if env.sudo_user: |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
_VERSION = '2.4'
_OPTIONS = ''
<|code_end|>
using the current file's imports:
from revolver import command, package
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver.core import sudo, run
and any relevant context from other files:
# Path: revolver/command.py
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
. Output only the next line. | def install(version=_VERSION, options=_OPTIONS): |
Given snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, with_statement
_VERSION = '2.4'
_OPTIONS = ''
def install(version=_VERSION, options=_OPTIONS):
package.ensure(['git-core', 'build-essential'])
tmpdir = dir.temp()
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from revolver import command, package
from revolver import contextmanager as ctx
from revolver import directory as dir
from revolver.core import sudo, run
and context:
# Path: revolver/command.py
#
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
#
# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
#
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
#
# Path: revolver/core.py
# def sudo(*args, **kwargs):
# if env.sudo_user:
# kwargs['user'] = env.sudo_user
#
# return _sudo(*args, **kwargs)
#
# def run(*args, **kwargs):
# if not env.sudo_forced:
# return _run(*args, **kwargs)
#
# return sudo(*args, **kwargs)
which might include code, classes, or functions. Output only the next line. | try: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.