Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the following code snippet before the placeholder: <|code_start|> rel_ctx = MockRelationshipContext( type='cloudify.relationships.resources.reserve_list_item', target=tar_rel_subject_ctx ) # source src_ctx = MockCloudifyContext( node_id='test_it...
RESERVATIONS_PROPERTY in ctx.instance.runtime_properties)
Given snippet: <|code_start|> ctx.instance.runtime_properties[RESERVATIONS_PROPERTY], {} ) # when (delete) tasks.delete_list(ctx) # then (delete) self.assertEquals( ctx.instance.runtime_properties[RESOURCES_LIST_PROPERTY], [] ...
SINGLE_RESERVATION_PROPERTY in ctx.instance.runtime_properties)
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....
result = SecretsSDK(ctx.logger, get_rest_client(), **parameters).create(
Next line prediction: <|code_start|># See the License for the specific language governing permissions and # limitations under the License. class TestPlugin(unittest.TestCase): def test_execute_mock_sdk(self): _ctx = MockCloudifyContext('node_name', properties={'hosts'...
tasks.bunch_execute(templates=[{
Given the code 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 governing permissions and...
cfy_mock_client = MockCloudifyRestClient()
Based on the snippet: <|code_start|> ('registration_id', registration_id), ]), logging.INFO, device=device, ) if result.get('failure'): log_middleware_information( '{0} | Should remove {1} because {2}', ...
redis_cache = RedisClusterCache()
Given the following code snippet before the placeholder: <|code_start|> TYPE_CALL = 'call' TYPE_MESSAGE = 'message' def send_call_message(device, unique_key, phonenumber, caller_id, attempt): """ Function to send the call push notification. Args: device (Device): A Device object. unique_...
log_middleware_information(
Predict the next line for this snippet: <|code_start|> TYPE_CALL = 'call' TYPE_MESSAGE = 'message' def send_call_message(device, unique_key, phonenumber, caller_id, attempt): """ Function to send the call push notification. Args: device (Device): A Device object. unique_key (string): ...
elif device.app.platform == ANDROID_PLATFORM:
Given the following code snippet before the placeholder: <|code_start|> TYPE_CALL = 'call' TYPE_MESSAGE = 'message' def send_call_message(device, unique_key, phonenumber, caller_id, attempt): """ Function to send the call push notification. Args: device (Device): A Device object. uniq...
if device.app.platform == APNS_PLATFORM:
Using the snippet: <|code_start|> TYPE_CALL = 'call' TYPE_MESSAGE = 'message' def send_call_message(device, unique_key, phonenumber, caller_id, attempt): """ Function to send the call push notification. Args: device (Device): A Device object. unique_key (string): String with the uniqu...
elif device.app.platform == GCM_PLATFORM:
Using the snippet: <|code_start|> class RegisterDeviceTest(TestCase): def setUp(self): super(RegisterDeviceTest, self).setUp() self.client = APIClient() <|code_end|> , determine the next line of code. You have imports: from ast import literal_eval from datetime import datetime, timedelta from ...
self.ios_app, created = App.objects.get_or_create(platform='apns', app_id='com.voipgrid.vialer')
Here is a snippet: <|code_start|> def get_metrics_base_data(json_data): """ Function to parse the base metric data from JSON into a new dict. Args: json_data (dict): JSON dict containing the data from the app. Returns: dict: Dict in the format we can store in Redis. """ metric...
APP_VERSION_KEY: json_data.get(APP_VERSION_KEY),
Predict the next line for this snippet: <|code_start|> def get_metrics_base_data(json_data): """ Function to parse the base metric data from JSON into a new dict. Args: json_data (dict): JSON dict containing the data from the app. Returns: dict: Dict in the format we can store in Redi...
CONNECTION_TYPE_KEY: json_data.get(CONNECTION_TYPE_KEY),
Given the following code snippet before the placeholder: <|code_start|> def get_metrics_base_data(json_data): """ Function to parse the base metric data from JSON into a new dict. Args: json_data (dict): JSON dict containing the data from the app. Returns: dict: Dict in the format we ...
DIRECTION_KEY: json_data.get(DIRECTION_KEY),
Using the snippet: <|code_start|> def get_metrics_base_data(json_data): """ Function to parse the base metric data from JSON into a new dict. Args: json_data (dict): JSON dict containing the data from the app. Returns: dict: Dict in the format we can store in Redis. """ metric...
NETWORK_KEY: json_data.get(NETWORK_KEY),
Predict the next line for this snippet: <|code_start|> def get_metrics_base_data(json_data): """ Function to parse the base metric data from JSON into a new dict. Args: json_data (dict): JSON dict containing the data from the app. Returns: dict: Dict in the format we can store in Redi...
metrics_dict[NETWORK_OPERATOR_KEY] = json_data.get(NETWORK_OPERATOR_KEY)
Continue the code snippet: <|code_start|> def get_metrics_base_data(json_data): """ Function to parse the base metric data from JSON into a new dict. Args: json_data (dict): JSON dict containing the data from the app. Returns: dict: Dict in the format we can store in Redis. """ ...
OS_KEY: json_data.get(OS_KEY),
Predict the next line after this snippet: <|code_start|> def get_metrics_base_data(json_data): """ Function to parse the base metric data from JSON into a new dict. Args: json_data (dict): JSON dict containing the data from the app. Returns: dict: Dict in the format we can store in Re...
OS_VERSION_KEY: json_data.get(OS_VERSION_KEY),
Using the snippet: <|code_start|>#!/usr/bin/env python os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings') project_root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../../') sys.path.append(project_root) django.setup() # Middleware health metrics. MYSQL_HEALTH = Gauge('mysql_health', ...
REDIS_CLUSTER_CLIENT = RedisClusterCache()
Given the code snippet: <|code_start|> bool: True if we can read and write to Redis """ try: result = REDIS_CLUSTER_CLIENT.client.execute_command('PING') for key, value in result.items(): if value is False: return False except: return False retu...
platform=GCM_PLATFORM,
Given the following code snippet before the placeholder: <|code_start|> Returns: bool: True if we can read and write to Redis """ try: result = REDIS_CLUSTER_CLIENT.client.execute_command('PING') for key, value in result.items(): if value is False: return F...
response_log = ResponseLog.objects.create(
Continue the code snippet: <|code_start|> VIALER_MIDDLEWARE_PUSH_NOTIFICATION_SUCCESS_TOTAL.labels( direction=value_dict[DIRECTION_KEY], os=value_dict[OS_KEY], ).inc() # Trim the list, this means that the values that are outside # of the selected range are deleted. In thi...
action=value_dict[ACTION_KEY],
Continue the code snippet: <|code_start|> platform=GCM_PLATFORM, roundtrip_time=random_roundtrip, available=random_available, ) except DatabaseError: connection.close() raven_client.captureException() return False else: if response_log....
app_version=value_dict[APP_VERSION_KEY],
Predict the next line for this snippet: <|code_start|> roundtrip_time=random_roundtrip, available=random_available, ) except DatabaseError: connection.close() raven_client.captureException() return False else: if response_log.available == random_av...
codec=value_dict[CODEC_KEY],
Continue the code snippet: <|code_start|> available=random_available, ) except DatabaseError: connection.close() raven_client.captureException() return False else: if response_log.available == random_available and response_log.roundtrip_time == random_roundtri...
connection_type=value_dict[CONNECTION_TYPE_KEY],
Using the snippet: <|code_start|> ) except DatabaseError: connection.close() raven_client.captureException() return False else: if response_log.available == random_available and response_log.roundtrip_time == random_roundtrip: response_log.delete() ...
direction=value_dict[DIRECTION_KEY],
Given the code snippet: <|code_start|> mos=value_dict[MOS_KEY], network=value_dict[NETWORK_KEY], network_operator=value_dict.get(NETWORK_OPERATOR_KEY, ''), os=value_dict[OS_KEY], os_version=value_dict[OS_VERSION_KEY], ).inc() # Trim the list, this ...
failed_reason=value_dict[FAILED_REASON_KEY],
Given snippet: <|code_start|> failed_reason=value_dict[FAILED_REASON_KEY], network=value_dict[NETWORK_KEY], network_operator=value_dict.get(NETWORK_OPERATOR_KEY, ''), os=value_dict[OS_KEY], os_version=value_dict[OS_VERSION_KEY], ).inc() # Trim the ...
hangup_reason=value_dict[HANGUP_REASON_KEY],
Continue the code snippet: <|code_start|> except DatabaseError: connection.close() raven_client.captureException() return False else: if response_log.available == random_available and response_log.roundtrip_time == random_roundtrip: response_log.delete() r...
mos=value_dict[MOS_KEY],
Predict the next line for this snippet: <|code_start|> connection.close() raven_client.captureException() return False else: if response_log.available == random_available and response_log.roundtrip_time == random_roundtrip: response_log.delete() return True ...
network=value_dict[NETWORK_KEY],
Using the snippet: <|code_start|> raven_client.captureException() return False else: if response_log.available == random_available and response_log.roundtrip_time == random_roundtrip: response_log.delete() return True return False def increment_vialer_call_s...
network_operator=value_dict.get(NETWORK_OPERATOR_KEY, ''),
Given snippet: <|code_start|> raven_client.captureException() return False else: if response_log.available == random_available and response_log.roundtrip_time == random_roundtrip: response_log.delete() return True return False def increment_vialer_call_succes...
os=value_dict[OS_KEY],
Predict the next line after this snippet: <|code_start|> return False else: if response_log.available == random_available and response_log.roundtrip_time == random_roundtrip: response_log.delete() return True return False def increment_vialer_call_success_metric_coun...
os_version=value_dict[OS_VERSION_KEY],
Given snippet: <|code_start|> django.setup() # Middleware health metrics. MYSQL_HEALTH = Gauge('mysql_health', 'See if MySQL is still reachable through the ORM.') REDIS_CLUSTER_CLIENT = RedisClusterCache() REDIS_HEALTH = Gauge('redis_health', 'See if Redis is still reachable.') DOCKER_TAG = Counter('docker_tag', 'S...
VIALER_CALL_FAILURE_TOTAL_KEY,
Next line prediction: <|code_start|>#!/usr/bin/env python os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings') project_root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../../') sys.path.append(project_root) django.setup() # Middleware health metrics. MYSQL_HEALTH = Gauge('mysql_health...
VIALER_CALL_SUCCESS_TOTAL_KEY,
Predict the next line after this snippet: <|code_start|> 'The amount of successful calls that were made using the Vialer app', [ 'app_version', 'codec', 'connection_type', 'direction', 'mos', 'network', 'network_operator', 'os', 'os_version'...
VIALER_HANGUP_REASON_TOTAL_KEY,
Given the following code snippet before the placeholder: <|code_start|> 'app_version', 'connection_type', 'direction', 'hangup_reason', 'network', 'network_operator', 'os', 'os_version', ], ) VIALER_MIDDLEWARE_PUSH_NOTIFICATION_FAILED_TOTAL = Counter( ...
VIALER_MIDDLEWARE_INCOMING_CALL_FAILED_TOTAL_KEY,
Based on the snippet: <|code_start|>) VIALER_HANGUP_REASON_TOTAL = Counter( VIALER_HANGUP_REASON_TOTAL_KEY, 'The amount of why a call was ended for the Vialer app', [ 'app_version', 'connection_type', 'direction', 'hangup_reason', 'network', 'network_operator...
VIALER_MIDDLEWARE_INCOMING_CALL_SUCCESS_TOTAL_KEY,
Given the code snippet: <|code_start|> VIALER_CALL_FAILURE_TOTAL_KEY, 'The amount of calls that failed during setup using the Vialer app', [ 'app_version', 'connection_type', 'direction', 'failed_reason', 'network', 'network_operator', 'os', 'os...
VIALER_MIDDLEWARE_PUSH_NOTIFICATION_FAILED_TOTAL_KEY,
Given the code snippet: <|code_start|> 'failed_reason', 'network', 'network_operator', 'os', 'os_version', ], ) VIALER_HANGUP_REASON_TOTAL = Counter( VIALER_HANGUP_REASON_TOTAL_KEY, 'The amount of why a call was ended for the Vialer app', [ 'app_version', ...
VIALER_MIDDLEWARE_PUSH_NOTIFICATION_SUCCESS_TOTAL_KEY,
Given the following code snippet before the placeholder: <|code_start|> class IncomingCallPerformanceTest(TransactionTestCase): def setUp(self): super(IncomingCallPerformanceTest, self).setUp() self.client = APIClient() <|code_end|> , predict the next line using imports from the current file: ...
self.ios_app, created = App.objects.get_or_create(platform='apns', app_id='com.voipgrid.vialer')
Given snippet: <|code_start|> class IncomingCallPerformanceTest(TransactionTestCase): def setUp(self): super(IncomingCallPerformanceTest, self).setUp() self.client = APIClient() self.ios_app, created = App.objects.get_or_create(platform='apns', app_id='com.voipgrid.vialer') tw...
Device.objects.create(
Next line prediction: <|code_start|> class IncomingCallPerformanceTest(TransactionTestCase): def setUp(self): super(IncomingCallPerformanceTest, self).setUp() self.client = APIClient() self.ios_app, created = App.objects.get_or_create(platform='apns', app_id='com.voipgrid.vialer') ...
@mock.patch('app.push.send_apns_message', side_effect=mocked_send_apns_message)
Here is a snippet: <|code_start|> class IncomingCallPerformanceTest(TransactionTestCase): def setUp(self): super(IncomingCallPerformanceTest, self).setUp() self.client = APIClient() self.ios_app, created = App.objects.get_or_create(platform='apns', app_id='com.voipgrid.vialer') tw...
thread = ThreadWithReturn(target=self.client.post, args=('/api/incoming-call/', call_data))
Here is a snippet: <|code_start|> @threaded def task_incoming_call_notify(device, unique_key, phonenumber, caller_id, attempt): """ Threaded task to send a call push notification. """ send_call_message(device, unique_key, phonenumber, caller_id, attempt) @threaded def task_notify_old_token(device, ap...
ResponseLog.objects.create(
Continue the code snippet: <|code_start|> @threaded def task_incoming_call_notify(device, unique_key, phonenumber, caller_id, attempt): """ Threaded task to send a call push notification. """ <|code_end|> . Use current file imports: from .decorators import threaded from .models import ResponseLog from .pu...
send_call_message(device, unique_key, phonenumber, caller_id, attempt)
Based on the snippet: <|code_start|> @threaded def task_incoming_call_notify(device, unique_key, phonenumber, caller_id, attempt): """ Threaded task to send a call push notification. """ send_call_message(device, unique_key, phonenumber, caller_id, attempt) @threaded def task_notify_old_token(device,...
send_text_message(device, app, msg)
Predict the next line after this snippet: <|code_start|> """ name = serializers.CharField(max_length=255, allow_blank=True, required=False) os_version = serializers.CharField(max_length=255, allow_blank=True, required=False) client_version = serializers.CharField(max_length=255, allow_blank=True, require...
phonenumber = serializers.CharField(max_length=32, validators=[phone_number_validator])
Given snippet: <|code_start|> serializer = self.serializer(data=data) serializer.is_valid() sandbox = serializer.validated_data['sandbox'] self.assertFalse(sandbox) def test_sandbox_value(self): """ Test if sandbox is set to true when given. """ dat...
self.serializer = CallResponseSerializer
Using the snippet: <|code_start|> class TestSipUserIdSerializer(TestCase): def setUp(self): self.serializer = SipUserIdSerializer def test_required_fields(self): """ Test if the sip_user_id field is required. """ data = {'no_sip_user_id': '123456789'} self.asse...
self.serializer = DeviceSerializer
Here is a snippet: <|code_start|> """ Test if the unique_key and message_start_time fields are required. """ now = time.time() data = { 'no_unique_key': 'aghadgfagsdfjagsdjkfgakjdf', 'message_start_time': now, } self.assertFalse(self.seria...
self.serializer = IncomingCallSerializer
Predict the next line for this snippet: <|code_start|> class TestTokenSerializer(TestCase): def setUp(self): self.serializer = TokenSerializer def test_required_fields(self): """ Test if the token field is required. """ data = {'no_token': 'blaat'} self.assertF...
self.serializer = SipUserIdSerializer
Here is a snippet: <|code_start|>LOG_NONCE = 'nonce' LOG_USERNAME = 'username' LOG_EMAIL = 'email' LOGENTRIES_HANDLERS = {} django_logger = logging.getLogger('django') def get_metrics(start_date, end_date, platform): """ Function to get a dict with metrics for the given date range and platform. Args: ...
base_query = ResponseLog.objects.filter(
Given snippet: <|code_start|> class VoipgridAuthenticationTestCase(TestCase): """ Class to test the VG authentication. """ def setUp(self): """ Setup authentication class. """ super(VoipgridAuthenticationTestCase, self).setUp() <|code_end|> , continue by predicting the...
self.authentication = VoipgridAuthentication()
Given the following code snippet before the placeholder: <|code_start|> class VoipgridAuthenticationTestCase(TestCase): """ Class to test the VG authentication. """ def setUp(self): """ Setup authentication class. """ super(VoipgridAuthenticationTestCase, self).setUp() ...
with self.assertRaises(UnavailableException):
Predict the next line for this snippet: <|code_start|> ) # This raises a bad request response. raise ParseError(detail=None) # Get sip_user_id. sip_user_id = serializer.validated_data['sip_user_id'] # Created new headers with old auth data. headers = ...
device=Device.objects.get(sip_user_id=sip_user_id),
Predict the next line for this snippet: <|code_start|> ('data', request.data), ]), logging.INFO, ) # This raises a bad request response. raise ParseError(detail=None) # Get sip_user_id. sip_user_id = serializer.valid...
(LOG_EMAIL, json_response['email']),
Given the code snippet: <|code_start|> class VoipgridAuthentication(BaseAuthentication): """ Custom authentication. """ def _check_status_code(self, status_code): """ Function for checking the status code. Args: status_code(int): That status code of a response. ...
log_middleware_information(
Predict the next line for this snippet: <|code_start|> class VoipgridAuthentication(BaseAuthentication): """ Custom authentication. """ def _check_status_code(self, status_code): """ Function for checking the status code. Args: status_code(int): That status code o...
raise UnavailableException(detail=None)
Continue the code snippet: <|code_start|> elif status_code == 401: raise AuthenticationFailed(detail=None) elif status_code == 403: raise PermissionDenied(detail=None) else: # Temporarily unavailable. log_middleware_information( 'Uns...
serializer = SipUserIdSerializer(data=request.data)
Predict the next line after this snippet: <|code_start|> return new_urls + original_urls def last_day_of_month(self, any_day): """ Function to return the last day of the month. Args: any_date (date): Date of the month to determine to last day for. Returns: ...
get_metrics(start_date, end_date, APNS_PLATFORM),
Predict the next line for this snippet: <|code_start|> Returns: Date object with the last day of the month. """ next_month = any_day.replace(day=28) + datetime.timedelta(days=4) return next_month - datetime.timedelta(days=next_month.day) def view_metrics(self, request, **...
admin.site.register(Device, DeviceAdmin)
Predict the next line for this snippet: <|code_start|> def last_day_of_month(self, any_day): """ Function to return the last day of the month. Args: any_date (date): Date of the month to determine to last day for. Returns: Date object with the last day of th...
get_metrics(start_date, end_date, GCM_PLATFORM),
Predict the next line for this snippet: <|code_start|> return new_urls + original_urls def last_day_of_month(self, any_day): """ Function to return the last day of the month. Args: any_date (date): Date of the month to determine to last day for. Returns: ...
get_metrics(start_date, end_date, APNS_PLATFORM),
Based on the snippet: <|code_start|> log3 = ResponseLog.objects.create( platform=platform, roundtrip_time=2.5, available=True, ) log3.date = self.first_of_month.replace(day=3) log3.save() # Not available logs. log4 = ResponseLog.object...
self._create_entries(GCM_PLATFORM)
Predict the next line after this snippet: <|code_start|> class GetMetricsTestCase(TestCase): """ Test for the get_metrics utils function. """ def setUp(self): """ Setup start and end date. """ super(GetMetricsTestCase, self).setUp() self.first_of_month = datet...
log1 = ResponseLog.objects.create(
Using the snippet: <|code_start|> """ self._create_entries(GCM_PLATFORM) metrics = get_metrics(self.first_of_month, self.end_date, GCM_PLATFORM) self.assertEquals(metrics['total_count'], 5) self.assertEquals(metrics['available']['count'], 3) self.assertEquals(metrics['a...
log_statement = fill_log_statement(
Based on the snippet: <|code_start|> platform=platform, roundtrip_time=2.5, available=True, ) log3.date = self.first_of_month.replace(day=3) log3.save() # Not available logs. log4 = ResponseLog.objects.create( platform=platform, ...
metrics = get_metrics(self.first_of_month, self.end_date, GCM_PLATFORM)
Here is a snippet: <|code_start|> def silentremove(filename): '''Remove a file. If the file does not exist, stay silent.''' try: os.remove(filename) except OSError as e: if e.errno != errno.ENOENT: raise class CryptoTest(unittest.TestCase): ''' Test crypto functions....
cr.create_key()
Using the snippet: <|code_start|> now = datetime.datetime.now() next_year = now.replace(year=now.year + 1) last_year = now.replace(year=now.year - 1) class OrderBookTest(unittest.TestCase): def setUp(self): '''Clean the orderbook before every test.''' <|code_end|> , determine the next line of code. You...
ob.message_id = 0
Continue the code snippet: <|code_start|> now = datetime.datetime.now() next_year = now.replace(year=now.year + 1) last_year = now.replace(year=now.year - 1) class OrderBookTest(unittest.TestCase): def setUp(self): '''Clean the orderbook before every test.''' ob.message_id = 0 ob.offers...
self.public_id = get_public_bytestring()
Predict the next line for this snippet: <|code_start|> class CreateCommentResult(Result): def __init__(self, response): super(CreateCommentResult, self).__init__(response) self.comment_id = -1 if self.ok: serialized = response.json() if "id" in serialized: ...
cs = [RecordComment.deserialize(cd) for cd in self.raw_comments]
Given snippet: <|code_start|> class CreateCommentResult(Result): def __init__(self, response): super(CreateCommentResult, self).__init__(response) self.comment_id = -1 if self.ok: serialized = response.json() if "id" in serialized: self.comment_id = ...
c.mentions = [Mention.deserialize(m) for m in c.mentions]
Based on the snippet: <|code_start|> def serialize(f): return f if not isinstance(f, ff.BaseField) else f.serialize() targets = fields if isinstance(fields, (list, tuple)) else [fields] properties = {} for t in targets: st = serialize(t) if "code" in st and "type...
candidates = [e for e in list(FieldType) if e.value == field_name]
Using the snippet: <|code_start|> return r def create(self, comment, mentions=()): """ create comment :param comment: :param mentions: list of pair of code and type("USER", "GROUP", and so on) :return: """ data = { "app": self.app_id, ...
elif isinstance(m, Mention):
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- class TestAppModel(kintoneModel): def __init__(self): super(TestAppModel, self).__init__() self.my_key = "" self.stringField = "" self.numberField = 0 self.radio = "" self.checkbox = []...
self._property_details.append(PropertyDetail("time", FieldType.TIME))
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- class TestAppModel(kintoneModel): def __init__(self): super(TestAppModel, self).__init__() self.my_key = "" self.stringField = "" self.numberField = 0 self.radio = "" sel...
self._property_details.append(PropertyDetail("time", FieldType.TIME))
Based on the snippet: <|code_start|> if pn in properties: v, t = get_value_and_type(field) initial_value = getattr(instance, pn) value = instance._field_to_property(v, t, pd, initial_value) setattr(instance, pn, value) is_set = T...
value = ks.value_to_date(value)
Predict the next line after this snippet: <|code_start|> metadata: Sequence[Tuple[str, str]] = () ): """Instantiate the pager. Args: method (Callable): The method that was originally called, and which instantiated this pager. request (google.cloud.vide...
def __iter__(self) -> Iterator[resources.Job]:
Based on the 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 governing permissions and...
method: Callable[..., services.ListJobsResponse],
Continue the code snippet: <|code_start|>__protobuf__ = proto.module( package="google.cloud.video.transcoder.v1", manifest={ "CreateJobRequest", "ListJobsRequest", "GetJobRequest", "DeleteJobRequest", "ListJobsResponse", "CreateJobTemplateRequest", "ListJo...
job = proto.Field(proto.MESSAGE, number=2, message=resources.Job,)
Given the code snippet: <|code_start|> self.delete_job: gapic_v1.method.wrap_method( self.delete_job, default_timeout=60.0, client_info=client_info, ), self.create_job_template: gapic_v1.method.wrap_method( self.create_job_template, default_timeout=60.0...
[services.CreateJobRequest], Union[resources.Job, Awaitable[resources.Job]]
Given snippet: <|code_start|> self.delete_job: gapic_v1.method.wrap_method( self.delete_job, default_timeout=60.0, client_info=client_info, ), self.create_job_template: gapic_v1.method.wrap_method( self.create_job_template, default_timeout=60.0, client_...
[services.CreateJobRequest], Union[resources.Job, Awaitable[resources.Job]]
Here is a snippet: <|code_start|> def login_required(func): @functools.wraps(func) def wrapper(*args, **kw): act_name = kw.get('activity') act = check_acatvity(act_name) sid = session.get('{}_user'.format(act_name)) if sid: <|code_end|> . Write the next line using the current ...
member = Members.query.filter_by(sid=str(sid)).first()
Here is a snippet: <|code_start|> def login_required(func): @functools.wraps(func) def wrapper(*args, **kw): act_name = kw.get('activity') <|code_end|> . Write the next line using the current file imports: import functools from flask import session, flash, redirect, url_for, abort from web.Model.dat...
act = check_acatvity(act_name)
Here is a snippet: <|code_start|> def check_acatvity(name): act = Activities.query.filter_by(activity_name=name).first() if not act: abort(404) return act def check_user_exist(stucode, act_name): <|code_end|> . Write the next line using the current file imports: from flask import abort from web...
stu = Members.query.filter_by(stu_code=stucode, activity=act_name).first()
Continue the code snippet: <|code_start|> FileRequired(message='请选择文件'), FileAllowed(['zip', 'rar'], '请使用zip或rar压缩格式提交'), ], description="文件请打包压缩后上传,推荐使用ZIP格式~~") button = SubmitField('提交') class Login(Form): name = StringField('姓名', [validators.required()], description="就是你的名字"...
return list((o.activity_name, o.activity_name) for o in Activities.query.all())
Using the snippet: <|code_start|> TODO require_setting """ def __init__(self): """ Setting definitions in base_settings are indispensable """ self._callbacks = {} self.add_key_callback('LOGGERS', set_loggers) for i in dir(base_settings): if not i...
raise SettingsError('Key "%s" is not defined in settings' % key)
Here is a snippet: <|code_start|> by import torext module, a Settings object will be instanced and stored globally, then it can be involved in any place like this: >>> import torext >>> print torext.settings or >>> from torext import settings >>> print settings getting value from setting...
self.add_key_callback('LOGGERS', set_loggers)
Given snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- class ModuleSearcher(object): def __init__(self, label): assert settings['PROJECT'], 'you must set PROJECT first' self.import_path = settings['PROJECT'] + '.' + label self._handlers = [] def get_handlers(self)...
raise URLRouteError('Caught error when router was getting handlers from module: %s' % e)
Given snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- class ModuleSearcher(object): def __init__(self, label): assert settings['PROJECT'], 'you must set PROJECT first' self.import_path = settings['PROJECT'] + '.' + label self._handlers = [] def get_handlers(self)...
app_log.debug('got handlers from module %s' % self.import_path)
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- def test_logging(): msgs = [ '中文 utf8', '始める utf8', ] if PY2: msgs += [ u'中文 gbk'.encode('gbk'), u'中文 unicode', u'始める shift_jis'.encode('shift_ji...
set_logger('')
Using the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- def test_logging(): msgs = [ '中文 utf8', '始める utf8', ] <|code_end|> , determine the next line of code. You have imports: import logging from torext.log import set_logger from nose.tools import with_setup from torex...
if PY2:
Given snippet: <|code_start|> self.has_varargs = bool(spec.varargs) self.has_kwargs = bool(spec.keywords) if func.__doc__: doc = func.__doc__ if '\n' in doc: doc = ' '.join(i.strip() for i in doc.split('\n')) else: doc = "Command '%s' i...
raise CommandArgumentError(
Predict the next line after this snippet: <|code_start|> """ return log in unicode """ self._format_record(record) record_dict = {} for k, v in record.__dict__.items(): if isinstance(k, str): k = decode_(k, 'utf8') if isinstance(v, ...
_kwgs = split_kwargs(
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- try: except ImportError: MyMemoryHandler = None root_logger = logging.getLogger() app_log = logging.getLogger('torext.app') request_log = logging.getLogger('torext.request') # borrow from tornado.options._L...
return u_(''), u_('')
Given the code snippet: <|code_start|> # when oauth-parameters is generated, `all_args` contain `args` and `post_args` url = "http://api.twitter.com/1" + path + ".json" if access_token: all_args = {} all_args.update(args) all_args.update(post_args o...
key=settings['TWITTER']['consumer_key'],
Here is a snippet: <|code_start|> _OAUTH_REQUEST_TOKEN_URL = "http://api.twitter.com/oauth/request_token" _OAUTH_ACCESS_TOKEN_URL = "http://api.twitter.com/oauth/access_token" _OAUTH_AUTHORIZE_URL = "http://api.twitter.com/oauth/authorize" _OAUTH_AUTHENTICATE_URL = "http://api.twitter.com/oauth/authentic...
url += "?" + urlencode(args)
Here is a snippet: <|code_start|> def _oauth_consumer_token(self): return dict(key=settings.networks['weibo']['consumer_key'], secret=settings.networks['weibo']['consumer_secret']) def _oauth_get_user(self, access_token, callback): callback = self.async_callback(self._parse_u...
url = quote("http://" + self._OAUTH_API_DOMAIN + path, ':/')
Using the snippet: <|code_start|> if response.error and not response.body: logging.warning("Error response %s fetching %s", response.error, response.request.url) callback(None) return callback(response) return def _oauth_consum...
"next": urljoin(self.request.full_url(), callback_uri),