Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Predict the next line for this snippet: <|code_start|># 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. #...
def get_docker_run_args(self, dockernode):
Based on the snippet: <|code_start|> node_id, petition_id, daemons=['wpantund', 'otbr-agent'], rcp=False): self.thread_endpoint = ThreadSimPipe(node_id, petition_id, rcp) self.thread_endpoint.open() self.logger = CirqueLog.get_cirque_logger(self.__c...
'privileged': True,
Continue the code snippet: <|code_start|># Copyright 2020 Google LLC # # 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...
@property
Using the snippet: <|code_start|> self.logger.error('Fail to setup ipv6 external access in ip6tables') def __inspect_network_properties(self): ret = host_run(self.logger, ['docker', 'network', 'inspect', self.__name]) if ret.returncode != 0: self.logger.error('Failed to inspect home lan %s' % self...
self.logger, self.gateway, self.subnet, 'ACCEPT', add=False)
Based on the snippet: <|code_start|> ret = host_run(self.logger, ['docker', 'network', 'inspect', self.__name]) if ret.returncode != 0: self.logger.error('Failed to inspect home lan %s' % self.__name) return network_info = json.loads(ret.stdout.decode()) if not network_info: self.logger...
self.gateway = None
Predict the next line for this snippet: <|code_start|> def __init__(self, name, internal=False, ipv6=False): self.logger = CirqueLog.get_cirque_logger('lan_{}'.format(name)) self.__name = name self.__internal = internal self.__ipv6 = ipv6 self.subnet = None self.gateway = None if 'ipvlan' i...
if self.__ipv6:
Predict the next line after this snippet: <|code_start|># Copyright 2020 Google LLC # # 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 # # Unl...
def name(self):
Next line prediction: <|code_start|> service_pb2.ListCirqueHomeDevicesRequest(home_id=home_id)) device_ids = [ device.device_id for device in devices.devices if device.device_specification.device_type != 'wifi_ap' ] ssid, psk = [(device.device_description.ssid, device.device...
devices = self.stub.ListCirqueHomeDevices(
Given the code snippet: <|code_start|># Copyright 2020 Google LLC # # 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 ap...
host_path=os.path.abspath(os.path.relpath(__file__)),
Predict the next line after this snippet: <|code_start|> mount_capability = MountCapability() mount_capability.mount_pairs.append( MountPair( host_path=os.path.abspath(os.path.relpath(__file__)), target_path='/tmp/test')) device_0_id = stub.CreateCirqueDevice( service_...
logger.info('Waiting for device to fully launch')
Next line prediction: <|code_start|> len(os.listdir(self.X_SOCKET_PATH)) == 0: return 0 x_server_ids = glob.glob(os.path.join(self.X_SOCKET_PATH, 'X*')) x_server_ids = [int(os.path.basename(f)[1:]) for f in x_server_ids] return max(x_server_ids) + 1 @property def name(self): return 'Xvn...
if self.__xvnc_process:
Predict the next line for this snippet: <|code_start|># # 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 governi...
try:
Here is a snippet: <|code_start|> commands = [ "ip addr flush dev wlan0", "ip link set wlan0 down", "ip link set wlan0 name {}".format(docker_node.wlan_interface), ] for command in commands: ret = utils.netns_run(docker_node.logger, comm...
def is_mac80211_hwsim_loaded():
Predict the next line after this snippet: <|code_start|> docker_node.wlan_interface = interface self.logger.info("container {}: phy device {} interface {}".format( docker_node.name, docker_node.wlan_phy_device, docker_node.wlan_interface)) def __phy_namespace_setup(self, docker_node): try:...
sym_src = "/proc/{}/ns/net".format(pid)
Given the following code snippet before the placeholder: <|code_start|> @property def name(self): return "WiFi" def get_docker_run_args(self, docker_node): return { "privileged": True, } def enable_capability(self, docker_node): if not WiFiCapability.is_mac80211_hwsim_loaded(): Wi...
docker_node.name))
Predict the next line for this snippet: <|code_start|> devices = [(l1, l2.split()[-1]) for l1, l2 in zip(lines, lines[1:]) if l1.startswith("phy")] phy_device, interface = devices.pop() phy_device = "".join(phy_device.split("#")) docker_node.wlan_phy_device = phy_device ...
os.makedirs(self.RUNTIME_NAMESPACE)
Next line prediction: <|code_start|># # 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...
try:
Next line prediction: <|code_start|> def type(self): return self.node_type @property def base_image(self): return self.image_name @property def description(self): inspection = self.inspect() network_info = inspection['NetworkSettings']['Networks'] if network_info: network_name = nex...
if self.container is not None:
Given the following code snippet before the placeholder: <|code_start|> class TrafficControlCapability(BaseCapability): def __init__(self, latencyMs=0, loss=0): self.latencyMs = latencyMs self.loss = loss @property def name(self): return "TrafficControl" @property def description(self): ret...
command))
Predict the next line for this snippet: <|code_start|># Copyright 2016 Google LLC # # 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...
(?P<name>[^/]+) # initial letter, wordchars + allowed punc
Given the following code snippet before the placeholder: <|code_start|># Copyright 2021 Google LLC # # 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/LICEN...
_GAE_ENV_VARS = [_GAE_SERVICE_ENV, _GAE_VERSION_ENV, _GAE_INSTANCE_ENV]
Given the code snippet: <|code_start|># 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 ...
return "test flask trace" # pragma: NO COVER
Given the code snippet: <|code_start|> pre_commit(AddNumberOneTimePreCommitCallable(numbers_list=numbers_list, number=3)) assert_equal(len(numbers_list), 0) assert_equal(len(numbers_list), 0) assert_equal(numbers_list, [1]) def test_pre_commit_should_called_with...
TestSmartModel.objects.create(name='test')
Based on the snippet: <|code_start|> __all__ = ( 'TransactionsTestCase', ) def add_number(numbers_list, number): numbers_list.append(number) class TransactionsTestCase(TransactionTestCase): <|code_end|> , predict the immediate next line with the help of imports: from django.test import TransactionTes...
def test_pre_commit_without_atomic_should_be_called_immediately(self):
Continue the code snippet: <|code_start|> class AddNumberOneTimePreCommitCallable(UniquePreCommitCallable): def handle(self): self.kwargs_list[-1]['numbers_list'].append(3) with transaction.atomic(): for i in range(5): pre_commit(AddNumberOneTimeP...
with transaction.atomic():
Next line prediction: <|code_start|> super().__init__(*args, **kwargs) self.placeholder = currency class PriceField(DecimalField): widget = PriceNumberInput def __init__(self, *args, **kwargs): currency = kwargs.pop('currency', ugettext('CZK')) kwargs.setdefault('max_digits', ...
)
Here is a snippet: <|code_start|> attrs['min'] = self.min if self.max is not None: attrs['max'] = self.max return attrs class PriceNumberInput(forms.NumberInput): def __init__(self, currency, *args, **kwargs): super().__init__(*args, **kwargs) self.placehold...
allowed_content_types = kwargs.pop('allowed_content_types', None)
Based on the snippet: <|code_start|> class DecimalField(forms.DecimalField): def __init__(self, *args, **kwargs): self.step = kwargs.pop('step', 'any') self.min = kwargs.pop('min', None) self.max = kwargs.pop('max', None) super().__init__(*args, **kwargs) def widget_attrs(se...
class PriceField(DecimalField):
Continue the code snippet: <|code_start|> class S3StorageTestCase(TestCase): TEST_DATA = ( ('Hello, this is str content.', b'Hello, this is str content.', True), (b'Hello, this is bytes content.', b'Hello, this is bytes content.', False), ) @data_provider(TEST_DATA) def test_s3stora...
casted_content = result.read()
Using the snippet: <|code_start|> def create_test_smart_model_handler(instance, **kwargs): TestSmartModel.objects.create(name='name') def create_test_fields_model_handler(instance, **kwargs): TestFieldsModel.objects.create() def create_test_dispatchers_model_handler(instance, **kwargs): <|code_end|> , d...
TestDispatchersModel.objects.create()
Here is a snippet: <|code_start|> assert_equal(get_object_or_none(ShortcutsModel, name='test1'), obj) assert_is_none(get_object_or_none(ShortcutsModel, name='test3')) assert_is_none(get_object_or_none(ShortcutsModel, number='test3')) assert_is_none(get_object_or_none(ShortcutsModel, datet...
ShortcutsModel.objects.create(name='test1', datetime=timezone.now(), number=1)
Continue the code snippet: <|code_start|> ShortcutsModel.objects.create(name='test1', datetime=timezone.make_aware(datetime(2014, 1, 1, 12, 12), timezone.get_default_timezone()), number=1) ...
obj = DiffModel.objects.create(name='test', datetime=timezone.now(), number=2)
Using the snippet: <|code_start|> assert_equal(exclude_by_date(ShortcutsModel, datetime=date.today()).count(), 1) assert_equal(exclude_by_date(ShortcutsModel, datetime=date(2014, 1, 1)).count(), 2) def test_change(self): obj = ShortcutsModel.objects.create(name='test1', datetime=timezone.no...
def test_bulk_change_and_save(self):
Based on the snippet: <|code_start|> class ShortcutsTestCase(TestCase): def test_get_object_or_none(self): obj = ShortcutsModel.objects.create(name='test1', datetime=timezone.now(), number=1) ShortcutsModel.objects.create(name='test2', datetime=timezone.now(), number=2) ShortcutsModel....
ShortcutsModel.objects.create(name='test2', datetime=timezone.now(), number=3)
Using the snippet: <|code_start|> assert_is_none(get_object_or_none(ShortcutsModel, number='test3')) assert_is_none(get_object_or_none(ShortcutsModel, datetime='test3')) assert_raises(FieldError, get_object_or_none, ShortcutsModel, non_field='test2') assert_raises(MultipleObjectsReturned...
timezone.get_default_timezone()),
Based on the snippet: <|code_start|> ShortcutsModel.objects.create(name='test1', datetime=timezone.make_aware(datetime(2014, 1, 1, 12, 12), timezone.get_default_timezone()), number=1) as...
obj = DiffModel.objects.create(name='test', datetime=timezone.now(), number=2)
Given the code snippet: <|code_start|> ShortcutsModel.objects.create(name='test2', datetime=timezone.now(), number=3) assert_equal(get_object_or_none(ShortcutsModel, name='test1'), obj) assert_is_none(get_object_or_none(ShortcutsModel, name='test3')) assert_is_none(get_object_or_none(Sho...
def test_filter_and_exclude_by_date(self):
Continue the code snippet: <|code_start|> obj1 = ShortcutsModel.objects.create(name='test1', datetime=timezone.now(), number=1) obj2 = ShortcutsModel.objects.create(name='test2', datetime=timezone.now(), number=2) bulk_change_and_save([obj1, obj2], name='modified') assert_equal(obj1.name,...
assert_equal(obj1.name, 'modified')
Given snippet: <|code_start|> ShortcutsModel.objects.create(name='test2', datetime=timezone.now(), number=2) ShortcutsModel.objects.create(name='test2', datetime=timezone.now(), number=3) assert_equal(tuple(distinct_field(ShortcutsModel, 'name')), (('test1',), ('test2',))) assert_equal(li...
obj = DiffModel.objects.create(name='test', datetime=timezone.now(), number=2)
Given snippet: <|code_start|> setup( name='django-chamber', version=get_version(), description='Utilities library meant as a complement to django-is-core.', author='Lubos Matl, Oskar Hollmann', author_email='matllubos@gmail.com, oskar@hollmann.me', url='http://github.com/druids/django-chamber', ...
)
Given the code snippet: <|code_start|> class DatastructuresTestCase(TestCase): def test_enum_should_contain_only_defined_values(self): enum = Enum( 'A', 'B' ) assert_equal(enum.A, 'A') assert_equal(enum.B, 'B') assert_equal(list(enum), ['A', 'B']) asse...
assert_is_none(enum.get_name('C'))
Predict the next line after this snippet: <|code_start|> with assert_raises(AttributeError): enum.C # pylint: disable=W0104 assert_is_none(enum.get_name('f')) assert_in('c', enum) assert_in(enum.A, enum) assert_not_in('A', enum) def test_auto_gemerated_num_enum_s...
assert_equal(list(enum), [4, 2, 3])
Given snippet: <|code_start|> ChoicesNumEnum( ('A', 'label a', 'e'), ('B', 'label b', 2) ) def test_enum_key_should_have_right_format(self): with assert_raises(ValueError): Enum( 1, 2 ) with assert_raises(ValueError): ...
assert_equal(ordered_set, [5, 3, 9, 10])
Next line prediction: <|code_start|> ('B', 'label b', 2), ('C', 'label c') ) assert_equal(choices_num.A, 4) assert_equal(choices_num.B, 2) assert_equal(choices_num.C, 3) assert_equal(list(choices_num.choices), [(4, 'label a'), (2, 'label b'), (3, 'label c')...
def test_enum_key_should_have_right_format(self):
Here is a snippet: <|code_start|> ('A', 1), ('B', 1) ) def test_num_enum_same_generated_numbers_should_raise_exception(self): with assert_raises(ValueError): NumEnum( ('A', 3), ('B', 2), 'C' ) def test_num_enum_invalid_num_should_raise...
('B', 'label b', 'd'),
Predict the next line after this snippet: <|code_start|> class DispatchersTestCase(TransactionTestCase): def test_state_dispatcher(self): m = TestDispatchersModel.objects.create() # Moving TestDispatcher model to SECOND state should create new TestSmartModel instance assert_equal(Test...
assert_equal(TestFieldsModel.objects.count(), 0)
Next line prediction: <|code_start|> __all__ = ( 'FormFieldsTestCase', ) class FormFieldsTestCase(TransactionTestCase): def test_decimal_field_should_return_correct_widget_attrs(self): kwargs = { 'step': 0.5, 'min': 1.0, 'max': 10.0, } field = D...
for attr, value in kwargs.items():
Predict the next line after this snippet: <|code_start|> __all__ = ( 'FormFieldsTestCase', ) class FormFieldsTestCase(TransactionTestCase): def test_decimal_field_should_return_correct_widget_attrs(self): kwargs = { 'step': 0.5, 'min': 1.0, 'max': 10.0, ...
def test_restricted_file_field_should_raise_validation_error_for_invalid_files(self):
Predict the next line for this snippet: <|code_start|> singleton = SingletonObject() assert_equal(singleton.num_singletons, 1) singleton = SingletonObject() assert_equal(singleton.num_singletons, 1) def test_translation_activate_block(self): @translation_activate_block(langu...
with assert_raises(RuntimeError):
Given the following code snippet before the placeholder: <|code_start|> @classmethod def class_method_property(cls): return 1 @singleton class SingletonObject(object): num_singletons = 0 def __init__(self): self.num_singletons += 1 super(self.__class__, self).__init__() d...
def test_translation_activate_block(self):
Predict the next line for this snippet: <|code_start|> def get_count_singletons(self): return self.num_singletons class DecoratorsTestCase(TestCase): def test_class_property(self): assert_equal(ObjectWithClassProperty.class_method_property, 1) assert_equal(ObjectWithClassProperty().cla...
name='test',
Given snippet: <|code_start|> def test_singleton(self): singleton = SingletonObject() assert_equal(singleton.num_singletons, 1) singleton = SingletonObject() assert_equal(singleton.num_singletons, 1) def test_translation_activate_block(self): @translation_activate_block(...
def test_smart_atomic_should_be_to_use_as_a_context_manager(self):
Given the code snippet: <|code_start|> def skip_unreadable_post(record): if record.exc_info: exc_type, exc_value = record.exc_info[:2] if isinstance(exc_value, UnreadablePostError): return False return True class AppendExtraJSONHandler(logging.StreamHandler): DEFAULT_STREAM...
extra = {
Given the code snippet: <|code_start|> class GetUserMixin: def get_user(self, user_id): UserModel = get_user_class() try: return UserModel._default_manager.get(pk=user_id) except UserModel.DoesNotExist: <|code_end|> , generate the next line using the imports in this file: fro...
return None
Using the snippet: <|code_start|> assert_equal(get_domain(settings.FRONTEND_SITE_ID).name, 'frontend') assert_raises(ImproperlyConfigured, get_domain, 3) def test_get_domain_url(self): assert_equal(get_domain(settings.BACKEND_SITE_ID).url, 'http://localhost:8000') assert_equal(get_do...
protocol='https', hostname='localhost', port=80).url, 'https://localhost:80')
Predict the next line for this snippet: <|code_start|> assert_equal(Domain('testA', 'dj.backend_urls', 'test_chamber.BackendUser', protocol='http', hostname='localhost').port, 80) assert_equal(Domain('testB', 'dj.backend_urls', 'test_chamber.BackendUser', ...
'http://localhost:8000/current_time_backend/')
Based on the snippet: <|code_start|> class MultidomainsTestCase(TestCase): def test_get_domain_choices(self): choices = get_domain_choices() assert_equal(len(choices), 2) assert_equal(choices[0][1], 'backend') assert_equal(choices[1][1], 'frontend') assert_equal(choices[...
def test_get_domain_url(self):
Given the code snippet: <|code_start|> class MultidomainsTestCase(TestCase): def test_get_domain_choices(self): choices = get_domain_choices() assert_equal(len(choices), 2) assert_equal(choices[0][1], 'backend') assert_equal(choices[1][1], 'frontend') assert_equal(choice...
def test_get_domain_url(self):
Given the code snippet: <|code_start|> class MultidomainsTestCase(TestCase): def test_get_domain_choices(self): choices = get_domain_choices() assert_equal(len(choices), 2) assert_equal(choices[0][1], 'backend') assert_equal(choices[1][1], 'frontend') assert_equal(choice...
def test_get_domain_url(self):
Continue the code snippet: <|code_start|> self._waiters = [] # Export the lock's acquire() and release() methods self.acquire = lock.acquire self.release = lock.release # If the lock defines _release_save() and/or _acquire_restore(), # these override the default implement...
finally:
Based on the snippet: <|code_start|> class FooTimeout(Exception): pass class TimeoutTests(EvergreenTestCase): def test_with_timeout(self): def sleep(): with Timeout(0.01): evergreen.sleep(10) def func(): self.assertRaises(Timeout, sleep) ever...
self.loop.run()
Given snippet: <|code_start|># # This file is part of Evergreen. See the NOTICE for more information. # from __future__ import absolute_import __all__ = ['Empty', 'Full', 'Queue', 'PriorityQueue', 'LifoQueue'] Empty = __queue__.Empty Full = __queue__.Full <|code_end|> , continue by predicting the next line. Con...
class Queue(object):
Given the following code snippet before the placeholder: <|code_start|> assert not isinstance(func, Handler) obj = partial.__new__(cls, func, *args, **kw) obj._cancelled = False return obj def cancel(self): self._cancelled = True class Timer(Handler): def __new__(cls, ...
return obj
Continue the code snippet: <|code_start|> RUN_DEFAULT = 1 RUN_FOREVER = 2 class EventLoop(object): def __init__(self): if getattr(_tls, 'loop', None) is not None: raise RuntimeError('cannot instantiate more than one event loop per thread') _tls.loop = self self._loop = pyuv.Lo...
self._install_signal_checker()
Predict the next line for this snippet: <|code_start|> class LocalTests(EvergreenTestCase): def test_local(self): tls = local() tls.foo = 42 <|code_end|> with the help of current file imports: from common import unittest, EvergreenTestCase from evergreen.local import local import evergreen an...
def func(x):
Continue the code snippet: <|code_start|> class EventTests(EvergreenTestCase): def test_event_simple(self): ev = Event() def waiter(): self.assertTrue(ev.wait()) <|code_end|> . Use current file imports: from common import unittest, EvergreenTestCase from evergreen.event import Event...
evergreen.spawn(waiter)
Given snippet: <|code_start|># # This file is part of Evergreen. See the NOTICE for more information. # from __future__ import absolute_import __all__ = ['select', 'error'] __patched__ = ['select'] error = __select__.error def get_fileno(obj): # The purpose of this function is to exactly replicate # ...
else:
Predict the next line after this snippet: <|code_start|> def test_rlock(self): lock = locks.RLock() def func1(): lock.acquire() self.assertTrue(lock.acquire()) def func2(): self.assertFalse(lock.acquire(blocking=False)) evergreen.spawn(func1) ...
d = dummy()
Here is a snippet: <|code_start|> loop = evergreen.EventLoop() class EchoServer(tcp.TCPServer): @evergreen.task def handle_connection(self, connection): print('client connected from {}'.format(connection.peername)) while True: data = connection.read_until('\n') if no...
print ('listening on {}'.format(server.sockname))
Given the code snippet: <|code_start|># # This file is part of Evergreen. See the NOTICE for more information. # __all__ = ['Event'] class Event(object): def __init__(self): self._cond = Condition(Lock()) self._flag = False def is_set(self): return self._flag def set(self): ...
self._cond.notify_all()
Given the code snippet: <|code_start|># # This file is part of Evergreen. See the NOTICE for more information. # __all__ = ['Event'] class Event(object): def __init__(self): self._cond = Condition(Lock()) <|code_end|> , generate the next line using the imports in this file: from evergreen.locks import...
self._flag = False
Given the following code snippet before the placeholder: <|code_start|> def raise_(self): six.reraise(self.type, self.value, self.traceback) class Channel(object): def __init__(self): self._send_lock = Lock() self._recv_lock = Lock() self._new_data = Event() self._recv_...
data.raise_()
Using the snippet: <|code_start|> __all__ = ['Channel'] class _Bomb(object): def __init__(self, exp_type, exp_value=None, exp_traceback=None): self.type = exp_type self.value = exp_value if exp_value is not None else exp_type() self.traceback = exp_traceback def raise_(self): ...
self._recv_data.wait()
Given the following code snippet before the placeholder: <|code_start|># __all__ = ['UDPEndpoint', 'UDPError'] UDPError = pyuv.error.UDPError class UDPEndpoint(object): def __init__(self): loop = evergreen.current.loop self._handle = pyuv.UDP(loop._loop) self._closed = False ...
self._check_closed()
Next line prediction: <|code_start|> def bind(self, addr): self._check_closed() self._handle.bind(addr) def send(self, data, addr): self._check_closed() self._handle.send(addr, data, self.__send_cb) if self._pending_writes == 0: self._flush_event.clear() ...
raise UDPError('endpoint is closed')
Given the following code snippet before the placeholder: <|code_start|> def __init__(self): loop = evergreen.current.loop self._handle = pyuv.UDP(loop._loop) self._closed = False self._receive_result = Result() self._pending_writes = 0 self._flush_event = Event() ...
self._check_closed()
Predict the next line for this snippet: <|code_start|> return self._sockname def bind(self, addr): self._check_closed() self._handle.bind(addr) def send(self, data, addr): self._check_closed() self._handle.send(addr, data, self.__send_cb) if self._pending_writes ...
if self._closed:
Predict the next line after this snippet: <|code_start|> _counter = _counter + 1 return template % _counter class Task(Fiber): def __init__(self, target=None, name=None, args=(), kwargs={}): super(Task, self).__init__(target=self.__run, parent=evergreen.current.loop.task) self._name = str(...
raise RuntimeError('cannot join task before it is started')
Next line prediction: <|code_start|> if parsed_node: ndict['children'].append(gcdict) nlist.append(ndict) ndict = {} ndict['title'] = graph.node.name ndict['children'] = [] parsed_node.append(graph.no...
gdict['key'] = 'graph_%s' % (graph.pk)
Here is a snippet: <|code_start|> nlist.append(ndict) nlist.sort(key=lambda item: item['title'], reverse=False) grdict['children'] = nlist grlist.append(grdict) ndict['children'].append(gcdict) glist = json.dumps(grlist) cach...
grlist.append(gcdict)
Predict the next line after this snippet: <|code_start|> nodes = request.user.get_profile().nodes.all() graphs = graphs.filter(node__in=nodes) len_graphs = len(graphs) for index, graph in enumerate(graphs): if graph.graph.category.name not in parsed_graph_category: ...
ndict['title'] = graph.node.name
Continue the code snippet: <|code_start|># Copyright (C) 2010-2014 GRNET S.A. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later v...
def get_nodes(self):
Given the following code snippet before the placeholder: <|code_start|> if isinstance(node, tuple): MNODES.append(node) else: raise ImproperlyConfigured('Munin node should be a tupple') for node in MuninNodes.objects.all(): MNODES.append((node.name, node.as_dict())) ...
if html[html.find('version ') + 8] == '1':
Predict the next line after this snippet: <|code_start|>@login_required @never_cache def delete_search(request, search_id=None): try: savedsearch = SavedSearch.objects.get(pk=search_id) savedsearch.delete() response = json.dumps({"result": "Successfully deleted %s" % (savedsearch.description...
@never_cache
Continue the code snippet: <|code_start|> nodes = request.user.get_profile().nodes.all() except UserProfile.DoesNotExist: raise Http404 graphs.extend(["%s" % (i.pk) for i in savedsearches.graphs.filter(node__in=nodes)]) else: graphs.extend(["%s" % (i.pk) for i in saved...
'id': s.id,
Here is a snippet: <|code_start|># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. @login_required def home(reque...
@never_cache
Here is a snippet: <|code_start|> except UserProfile.DoesNotExist: raise Http404 graphs.extend(["%s" % (i.pk) for i in savedsearches.graphs.filter(node__in=nodes)]) else: graphs.extend(["%s" % (i.pk) for i in savedsearches.graphs.all()]) graphs = ','.join(graphs) result = ...
'description': s.description,
Predict the next line for this snippet: <|code_start|> def save(self, message='auto-save'): self.commit_thing(message + ' ' + str(time())) class WorldWrapper: # TODO: Merge this class with TextViewerWorldMixin. def __init__(self, world): self.world = world def do_lookup(self, name): ...
return stack[0]
Using the snippet: <|code_start|># def make_commit_thing(path, files): log = logging.getLogger('COMMIT') try: repo = Repo(path) except NotGitRepository: log.critical("%r isn't a repository!", path) raise ValueError("%r isn't a repository!" % (path,)) # Note that we bind the args as defaults rathe...
raise ValueError("%r doesn't exist!" % (path,))
Using the snippet: <|code_start|># evil INSTANCE_PRICES_FILENAME = '/tmp/aws-prices.json' INSTANCE_PRICES_URL_PREFIX="https://pricing.us-east-1.amazonaws.com/" OPERATING_SYSTEM="Linux" TENANCY='Shared' class InstancePricing(object): def __init__(self): if not os.path.isfile(INSTANCE_PRICES_FILENAME): ...
def get_spot_pricing(self, ec2, spot_instance_request_id):
Given snippet: <|code_start|> with open(INSTANCE_PRICES_FILENAME, 'w') as f: print(json.dumps(ec2_prices), file=f) @memoized def get_spot_pricing(self, ec2, spot_instance_request_id): # inefficient spot_instance_requests = ec2.get_all_spot_instance_requests(request_ids=[spot_...
print(InstancePricing().get_ondemand_pricing('ap-southeast-1', 'm1.small'))
Predict the next line for this snippet: <|code_start|>#!/usr/bin/python from __future__ import print_function # evil INSTANCE_PRICES_FILENAME = '/tmp/aws-prices.json' INSTANCE_PRICES_URL_PREFIX="https://pricing.us-east-1.amazonaws.com/" OPERATING_SYSTEM="Linux" TENANCY='Shared' class InstancePricing(object): ...
self.retrieve_pricing_file()
Based on the snippet: <|code_start|> name = get_host_name(i) archdomain = get_archdomain(i) env_tag = get_env_tag(i) if i.ip_address and i.private_ip_address and name: if i.spot_instance_request_id is not None: s...
if __name__=="__main__":
Based on the snippet: <|code_start|>#!/usr/bin/python from __future__ import print_function # region.name, name, instance_type, price, archdomain, env_tag, ip_address, private_ip_address ... def sanitize(value): if value is None or value == "": <|code_end|> , predict the immediate next line with the help of im...
return "unknown"
Given the code snippet: <|code_start|> @override_settings(USE_TZ=True) class CreateOrgTests(TestCase): fixtures = ["users.json", "orgs.json"] def setUp(self): self.user = User.objects.get(username="dave") def test_create_organization(self): acme = create_organization( self....
self.assertTrue(acme.owner.organization_user.is_admin)
Predict the next line for this snippet: <|code_start|> @override_settings(USE_TZ=True) class CreateOrgTests(TestCase): fixtures = ["users.json", "orgs.json"] def setUp(self): self.user = User.objects.get(username="dave") def test_create_organization(self): acme = create_organization( ...
self.assertTrue(isinstance(acme, Organization))
Given the following code snippet before the placeholder: <|code_start|>def extra_org_user(org_organization): new_user = User.objects.create(username="NotYou", email="not@you.com") org_organization.add_user(new_user) yield new_user @pytest.fixture def invitee_user(): yield User.objects.create_user( ...
class OrgUserReminderView(base.BaseOrganizationUserRemind):
Given the following code snippet before the placeholder: <|code_start|> @pytest.fixture def account_user(): yield User.objects.create(username="AccountUser", email="akjdkj@kjdk.com") @pytest.fixture def account_account(account_user): yield create_organization(account_user, "Acme", org_model=Account) @pyt...
org_organization.add_user(new_user)
Next line prediction: <|code_start|> @pytest.fixture def account_user(): yield User.objects.create(username="AccountUser", email="akjdkj@kjdk.com") @pytest.fixture def account_account(account_user): yield create_organization(account_user, "Acme", org_model=Account) <|code_end|> . Use current file imports...
@pytest.fixture
Given the code snippet: <|code_start|> @override_settings(USE_TZ=True) class BaseTests(TestCase): def test_generate_username(self): self.assertTrue(BaseBackend().get_username()) @override_settings( INSTALLED_APPS=[ "django.contrib.auth", "django.contrib.contenttypes", "djan...
USE_TZ=True,