Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the code snippet: <|code_start|> urlpatterns = patterns('', # NOQA url(r'^$', PizzaListView.as_view(), name='list'), url(r'^create/$', PizzaCreateView.as_view(), name='create'), url(r'^created/$', TemplateView.as_view( template_name='pizzagigi/pizza_created.html'), name='created'), url(...
url(r'^deleted/$', TemplateView.as_view(
Predict the next line for this snippet: <|code_start|> urlpatterns = patterns('', # NOQA url(r'^$', PizzaListView.as_view(), name='list'), url(r'^create/$', PizzaCreateView.as_view(), name='create'), <|code_end|> with the help of current file imports: from django.conf.urls import patterns, url from django....
url(r'^created/$', TemplateView.as_view(
Predict the next line for this snippet: <|code_start|> urlpatterns = patterns('', # NOQA url(r'^$', PizzaListView.as_view(), name='list'), url(r'^create/$', PizzaCreateView.as_view(), name='create'), url(r'^created/$', TemplateView.as_view( <|code_end|> with the help of current file imports: from djang...
template_name='pizzagigi/pizza_created.html'), name='created'),
Next line prediction: <|code_start|> urlpatterns = patterns('', # NOQA url(r'^$', PizzaListView.as_view(), name='list'), url(r'^create/$', PizzaCreateView.as_view(), name='create'), <|code_end|> . Use current file imports: (from django.conf.urls import patterns, url from django.views.generic import Template...
url(r'^created/$', TemplateView.as_view(
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class MyMigrationTestCase(SouthMigrationTestCase): start_migration = '0001_initial' dest_migration = '0002_auto__add_field_chickenballs_dips' django_application = 'suthern' def tes...
order.save()
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals try: except ImportError: def deconstructible(x): return x @deconstructible class MaxChoicesValidator(validators.BaseValidator): message = ungettext_lazy( <|code_end|> . Write the next line using the cu...
'Ensure this value has at most %(limit_value)d choice (it has %(show_value)d).', # NOQA
Continue the code snippet: <|code_start|> reverse('pizza:create'), urlencode(MultiValueDict(data), doseq=True), content_type='application/x-www-form-urlencoded' ) self.assertEqual(response.status_code, 302) self.assertRedirects( response, ...
self.pizza.save()
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class PizzaListViewTestCase(TestCase): def test_no_pizzas(self): p = Pizza.objects.all() self.assertEqual(len(p), 0, 'Test requires no pizzas') response = self.client.get(reverse('p...
self.assertEqual(len(pizzas), NUM_PIZZAS, 'Test requires pizzas')
Predict the next line after this snippet: <|code_start|> response, 'http://testserver' + reverse('ftw:created')) p = ChickenWings.objects.all()[0] self.assertIn(ChickenWings.JERK, p.flavour) def test_creation_two_choices(self): data = { 'flavour': [Chicken...
self.assertEqual(response.status_code, 200)
Next line prediction: <|code_start|> p = ChickenWings.objects.all() self.assertEqual(len(p), 0, 'Test requires no wings') response = self.client.get(reverse('ftw:list')) self.assertEqual(response.status_code, 200) self.assertTrue( 'No chicken wings found' in response.c...
}
Given the code snippet: <|code_start|>#-*- coding: utf-8 -*- class UdpServer(threading.Thread): RECV_SIZE = 262144 def __init__(self, port, ip="0.0.0.0"): threading.Thread.__init__(self) self.stopflag = False self.ip, self.port = ip, port self.sock = socket.socket(sock...
self.remoteAddr = None
Given the following code snippet before the placeholder: <|code_start|> def getSockType(self): return socktypes.UDP_SERVER def isConnected(self): return self.remoteAddr def sendall(self, data): if not self.remoteAddr: logger.warning("no remote udp client") ...
def run(self):
Given snippet: <|code_start|>#-*- coding: utf-8 -*- class UdpServer(threading.Thread): RECV_SIZE = 262144 def __init__(self, port, ip="0.0.0.0"): threading.Thread.__init__(self) self.stopflag = False self.ip, self.port = ip, port self.sock = socket.socket(socket.AF_INE...
self._id = id(self.sock)
Given the code snippet: <|code_start|>#-*- coding: utf-8 -*- class TcpServerManager(ServerManager): def __init__(self): ServerManager.__init__(self) <|code_end|> , generate the next line using the imports in this file: from log import logger from ServerManager import ServerManager from net impor...
def create(self, ip, port):
Given the following code snippet before the placeholder: <|code_start|>#-*- coding: utf-8 -*- class TcpServerManager(ServerManager): def __init__(self): ServerManager.__init__(self) <|code_end|> , predict the next line using imports from the current file: from log import logger from ServerManage...
def create(self, ip, port):
Given the following code snippet before the placeholder: <|code_start|>#-*- coding: utf-8 -*- class ServerManager(object): def __init__(self): self.serverDict = {} def create_(self, ip, port, sockType): # Check ip and port server = None if sockType == socktypes.TCP_SER...
return 0, ""
Predict the next line for this snippet: <|code_start|> def __init__(self): self.serverDict = {} def create_(self, ip, port, sockType): # Check ip and port server = None if sockType == socktypes.TCP_SERVER: server = TcpServer(port, ip) elif sockType == sock...
if server is None:
Continue the code snippet: <|code_start|> return self.getBaseItemBySocketType(socktypes.TCP_SERVER) def getBaseTcpClientItem(self): return self.getBaseItemBySocketType(socktypes.TCP_CLIENT_LOCAL) def addSocketItem(self, _id, address, sockType, icon): parentItem = self.getBaseItem...
parentItem = self.getSockItemById(serverId)
Using the snippet: <|code_start|> if not parentItem: logger.error("parent sock item is None") return item = SockTreeItem(sockType, address, _id, icon) self.sockItemDict[_id] = item parentItem.addChild(item) self.setItemExpanded(parentItem, True...
parentItem.addChild(item)
Given snippet: <|code_start|>#-*- coding: utf-8 -*- class CreateTcpServerDialog(CreateDialog): def __init__(self, parent=None): CreateDialog.__init__(self) self.okSig = signals.SIG_CREATE_TCP_SERVER self.ui = Ui_CreateTcpServerForm() self.ui.setupUi(self) self.initIpList()...
self.setModal(True)
Continue the code snippet: <|code_start|> QWidget.__init__(self, parent) self.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog) self.ui = Ui_TipPupup() self.ui.setupUi(self) self.timer = QTimer() self.timer.timeout.connect(self.__onTimeout) self.queue = Q...
self.show()
Given snippet: <|code_start|>#-*- coding: utf-8 -*- class SockClient(): RECV_SIZE = 262144 def __init__(self, parentId, sock, addr, sockType): self.parentId = parentId self._id = id(self) self.sockType = sockType self.conFlag = sockType == socktypes.TCP_CLIENT_REMOTE ...
def createSockByType(self, sockType):
Given the code snippet: <|code_start|> else: return -1 def getSockType(self): return self.sockType def isConnected(self): return self.conFlag def connect(self): try: if self.sock is None: self.createSockByType(...
def getId(self):
Given the code snippet: <|code_start|>#-*- coding: utf-8 -*- class SockClient(): RECV_SIZE = 262144 def __init__(self, parentId, sock, addr, sockType): self.parentId = parentId self._id = id(self) self.sockType = sockType self.conFlag = sockType == socktypes.TCP_CLIENT...
return "%s:%d" % (self.ip, self.port)
Predict the next line for this snippet: <|code_start|>#-*- coding: utf-8 -*- class UdpServerManager(ServerManager): def __init__(self): ServerManager.__init__(self) def create(self, ip, port): _id, address = self.create_(ip, port, socktypes.UDP_SERVER) return self.serverDict.g...
udpServerManager = UdpServerManager()
Given snippet: <|code_start|> SNDBUF_SIZE = 262144 BACKLOG = 10 def __init__(self, port, ip="0.0.0.0"): threading.Thread.__init__(self) self.ip, self.port = ip, port self.tcpClients = {} self.stopflag = False self.sock = socket.socket(socket.AF_INET, ...
except socket.error:
Based on the snippet: <|code_start|>#-*- coding: utf-8 -*- class TcpServer(threading.Thread): RCVBUF_SIZE = 262144 SNDBUF_SIZE = 262144 BACKLOG = 10 def __init__(self, port, ip="0.0.0.0"): threading.Thread.__init__(self) self.ip, self.port = ip, port <|code_end|> ...
self.tcpClients = {}
Using the snippet: <|code_start|> sockCls = self.sockClientClsDict.get(sockType) if not sockCls: return None, -1, "" sockClient = sockCls(0, None, (ip, port), sockType) if connect: if not sockClient.connect(): logger.error("fai...
def removeAllClient(self):
Predict the next line after this snippet: <|code_start|>#-*- coding: utf-8 -*- class SockClientManager(object): def __init__(self): self.clientDict = {} self.sockClientClsDict = { socktypes.UDP_CLIENT_LOCAL: UdpClient, socktypes.TCP_CLIENT_LOCAL: TcpClient} ...
def removeClient(self, _id):
Continue the code snippet: <|code_start|> MEMSQL_LOADER_DB = 'memsql_loader.db' def get_loader_db_path(): return os.path.join(paths.get_data_dir(), MEMSQL_LOADER_DB) # IMPORTANT NOTE: This class cannot be shared across forked processes unless # you use fork_wrapper. class LoaderStorage(APSWStorage): _instanc...
if os.path.isfile(get_loader_db_path() + '-shm'):
Next line prediction: <|code_start|> cls, *args, **kwargs) cls._initialized = False return cls._instance @classmethod def drop_database(cls): with cls._instance_lock: if os.path.isfile(get_loader_db_path()): os.remove(get_loader...
gc.collect(2)
Using the snippet: <|code_start|> if self._running_steps() != 0: raise StepRunning() if self.finished is not None: raise AlreadyFinished() with self.storage.cursor() as cursor: affected_row = apsw_helpers.get(cursor, ''' SELECT * from %s ...
result=NULL
Given the code snippet: <|code_start|> self.data = None self.result = None # NOTE: These fields are specific to the memsql-loader use case; # they are not necessary for the queue functionality. self.job_id = None self.file_id = None self.md5 = None self.by...
AND execution_id = :execution_id
Using the snippet: <|code_start|> self.steps = self._load_steps(json.loads(row.steps)) self.started = row.started self.finished = row.finished def _load_steps(self, raw_steps): """ load steps -> basically load all the datetime isoformats into datetimes """ for step in raw_ste...
AND last_contact > datetime(:now, 'unixepoch', '-%s second')
Predict the next line after this snippet: <|code_start|> self.job_id = row.job_id self.file_id = row.file_id self.md5 = row.md5 self.bytes_total = row.bytes_total self.bytes_downloaded = row.bytes_downloaded self.download_rate = row.download_rate self.steps = self....
bytes_downloaded=:bytes_downloaded,
Based on the snippet: <|code_start|> def valid(self): """ Check to see if we are still active. """ if self.finished is not None: return False with self.storage.cursor() as cursor: row = apsw_helpers.get(cursor, ''' SELECT (last_contact > datetime(:now...
AND execution_id = :execution_id
Based on the snippet: <|code_start|> return bool(row is not None and row.valid) def ping(self): """ Notify the queue that this task is still active. """ if self.finished is not None: raise AlreadyFinished() with self.storage.cursor() as cursor: affected_row =...
AND execution_id = :execution_id
Predict the next line for this snippet: <|code_start|> execution_id=self.execution_id) return bool(row is not None and row.valid) def ping(self): """ Notify the queue that this task is still active. """ if self.finished is not None: raise AlreadyFinished() ...
WHERE
Given snippet: <|code_start|> if self._running_steps() != 0: raise StepRunning() if self.finished is not None: raise AlreadyFinished() self._save(finished=datetime.utcnow(), result=result) def requeue(self): if self._running_steps() != 0: raise St...
UPDATE %s
Given the following code snippet before the placeholder: <|code_start|> MODELS = { 'jobs': jobs.Jobs, 'tasks': tasks.Tasks } def check_bootstrapped(): loader_storage = storage.LoaderStorage() with loader_storage.cursor() as cursor: rows = apsw_helpers.query( cursor, 'SELECT name FROM sqlite...
def bootstrap(force=False):
Continue the code snippet: <|code_start|> MODELS = { 'jobs': jobs.Jobs, 'tasks': tasks.Tasks } def check_bootstrapped(): loader_storage = storage.LoaderStorage() with loader_storage.cursor() as cursor: rows = apsw_helpers.query( cursor, 'SELECT name FROM sqlite_master WHERE type = "table"')...
for Model in MODELS.values():
Here is a snippet: <|code_start|> MODELS = { 'jobs': jobs.Jobs, 'tasks': tasks.Tasks } def check_bootstrapped(): loader_storage = storage.LoaderStorage() with loader_storage.cursor() as cursor: rows = apsw_helpers.query( cursor, 'SELECT name FROM sqlite_master WHERE type = "table"') tab...
write_log('Table', Model.__name__, 'Ready.')
Based on the snippet: <|code_start|> MODELS = { 'jobs': jobs.Jobs, 'tasks': tasks.Tasks } def check_bootstrapped(): loader_storage = storage.LoaderStorage() with loader_storage.cursor() as cursor: rows = apsw_helpers.query( cursor, 'SELECT name FROM sqlite_master WHERE type = "table"') ...
if not instance.ready():
Next line prediction: <|code_start|> MODELS = { 'jobs': jobs.Jobs, 'tasks': tasks.Tasks } def check_bootstrapped(): loader_storage = storage.LoaderStorage() with loader_storage.cursor() as cursor: rows = apsw_helpers.query( cursor, 'SELECT name FROM sqlite_master WHERE type = "table"') ...
def bootstrap(force=False):
Given the following code snippet before the placeholder: <|code_start|> elif columns is None and len(data) > 0: self.data = data self.columns = data[0].keys() else: self.data = [] self.columns = [] self.align = align self.sort_by = sort_by ...
elif self.tablefmt == TableFormat.HTML:
Here is a snippet: <|code_start|> class Tasks(Api): SORTABLE_COLUMNS = ['id', 'key_name', 'created', 'started', 'finished', 'state', 'error_msg'] validate = V.Schema({ V.Required('job_id'): basestring, 'state': listor(validate_enum(shared.TaskState)), V.Required('order', default=shared....
SELECT COUNT(*) AS count
Given the code snippet: <|code_start|> 'state': listor(validate_enum(shared.TaskState)), V.Required('order', default=shared.SortDirection.ASC): validate_enum(shared.SortDirection), V.Required('order_by', default='id'): V.Any(*SORTABLE_COLUMNS), 'page_size': V.Range(1, 100000), V.R...
%(paging)s
Based on the snippet: <|code_start|> class Tasks(Api): SORTABLE_COLUMNS = ['id', 'key_name', 'created', 'started', 'finished', 'state', 'error_msg'] validate = V.Schema({ V.Required('job_id'): basestring, 'state': listor(validate_enum(shared.TaskState)), V.Required('order', default=shar...
WHERE %(job_id_predicate)s
Predict the next line for this snippet: <|code_start|> class Tasks(Api): SORTABLE_COLUMNS = ['id', 'key_name', 'created', 'started', 'finished', 'state', 'error_msg'] validate = V.Schema({ V.Required('job_id'): basestring, 'state': listor(validate_enum(shared.TaskState)), V.Required('or...
tasks.*,
Continue the code snippet: <|code_start|> V.Required('job_id'): basestring, 'state': listor(validate_enum(shared.TaskState)), V.Required('order', default=shared.SortDirection.ASC): validate_enum(shared.SortDirection), V.Required('order_by', default='id'): V.Any(*SORTABLE_COLUMNS), ...
ORDER BY %(order_by)s %(order)s
Predict the next line for this snippet: <|code_start|> class Tasks(Api): SORTABLE_COLUMNS = ['id', 'key_name', 'created', 'started', 'finished', 'state', 'error_msg'] validate = V.Schema({ V.Required('job_id'): basestring, 'state': listor(validate_enum(shared.TaskState)), V.Required('or...
tasks.*,
Next line prediction: <|code_start|> class Command(object): def __init__(self, options): self.options = options self.ensure_bootstrapped() self.run() @staticmethod def configure(parser, subparsers): raise NotImplemented('Every command needs a static configure(...) method') ...
def run():
Given the code snippet: <|code_start|> class TableDefinition(object): def __init__(self, table_name, sql, index_columns=None): self.table_name = table_name <|code_end|> , generate the next line using the imports in this file: from memsql_loader.util import apsw_helpers and context (functions, classes, or ...
self.sql = sql
Given the following code snippet before the placeholder: <|code_start|> class DownloadMetrics(object): def __init__(self, total_size): self._total_size = total_size self._current_size = 0 self._last_snapshot = 0 self._last_change = time.time() self._snapshots = [] sel...
if diff > 10:
Predict the next line for this snippet: <|code_start|> DOWNLOAD_TIMEOUT = 30 SCRIPT_EXIT_TIMEOUT = 30 class DownloadMetrics(object): def __init__(self, total_size): self._total_size = total_size self._current_size = 0 self._last_snapshot = 0 self._last_change = time.time() ...
current = self._current_size
Based on the snippet: <|code_start|> # check that script hasn't errored before downloading # NOTE: we wait here so that we can check if a script exits prematurely # if this is the case, we fail the job without requeueing time...
status_code = curl.getinfo(pycurl.HTTP_CODE)
Continue the code snippet: <|code_start|> # emit a KILL QUERY due to fifo.open() # if we are piping through a script, the fifo should block # because the downloader is polling the script's stdin instead # of the fifo blocking = self.job.spe...
curl.setopt(pycurl.NOPROGRESS, 0)
Predict the next line after this snippet: <|code_start|> # HTTP client errors will cause task failure (no retry) if status_code >= 400 and status_code < 500: raise WorkerException('HTTP status code %s for file %s' % (status_code, self.key.name))...
self.script_proc.kill()
Given the code snippet: <|code_start|> if diff > 10: self.ping() self._snapshots.append(diff) if len(self._snapshots) > self._avg_len: self._snapshots = self._snapshots[(-1 * self._avg_len):] self._last_snapshot = current def get_stats(self): if self...
self._should_exit = False
Predict the next line after this snippet: <|code_start|> if log_path is not None: # mark that we are joining the file log try: with open(log_path, 'a') as logfile: logfile.write('Log file opened by %s\n' % os.getpid()) _file_handler = logging.FileHandler(file...
_disable_stdout = True
Given the following code snippet before the placeholder: <|code_start|> def validate_file_id_column(conn, database, table, col_name): # Load id column isn't required if col_name is None: return True col = conn.get("SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA=%s AND TABLE_...
if errno != errorcodes.ER_NO_SUCH_THREAD:
Predict the next line for this snippet: <|code_start|> class Api(object): name = None def __init__(self): self.logger = log.get_logger(self.name or 'api') self.storage = LoaderStorage() def query(self, params): assert 'validate' in dir(self), '`validate` must be defined' re...
def _execute(self, params):
Based on the snippet: <|code_start|> class Api(object): name = None def __init__(self): self.logger = log.get_logger(self.name or 'api') self.storage = LoaderStorage() def query(self, params): assert 'validate' in dir(self), '`validate` must be defined' return self._execute...
return callback(cursor)
Based on the snippet: <|code_start|> class Api(object): name = None def __init__(self): self.logger = log.get_logger(self.name or 'api') self.storage = LoaderStorage() def query(self, params): assert 'validate' in dir(self), '`validate` must be defined' return self._execute...
def _db_custom_query(self, callback):
Predict the next line after this snippet: <|code_start|> class Log(Command): @staticmethod def configure(parser, subparsers): subparser = subparsers.add_parser('log', help='Tail the MemSQL Loader log file or print out it\'s path.') subparser.set_defaults(command=Log) <|code_end|> using the cu...
subparser.add_argument('-p', '--path', default=False, action='store_true',
Continue the code snippet: <|code_start|> class Log(Command): @staticmethod def configure(parser, subparsers): <|code_end|> . Use current file imports: import sys import os from memsql_loader.util.command import Command from memsql_loader.util import log and context (classes, functions, or code) from other f...
subparser = subparsers.add_parser('log', help='Tail the MemSQL Loader log file or print out it\'s path.')
Next line prediction: <|code_start|> class Task(Api): validate = V.Schema({ V.Required('task_id'): int }) def _execute(self, params): generated_sql, query_params = self._generate_sql(params) task_row = self._db_get(''' <|code_end|> . Use current file imports: (from memsql_loader.a...
SELECT *, %(state_projection)s AS state
Using the snippet: <|code_start|> class Task(Api): validate = V.Schema({ V.Required('task_id'): int }) def _execute(self, params): generated_sql, query_params = self._generate_sql(params) task_row = self._db_get(''' SELECT *, %(state_projection)s AS state FR...
%(task_id_predicate)s
Based on the snippet: <|code_start|> class Task(Api): validate = V.Schema({ V.Required('task_id'): int }) <|code_end|> , predict the immediate next line with the help of imports: from memsql_loader.api.base import Api from memsql_loader.api import exceptions from memsql_loader.api.validation import V ...
def _execute(self, params):
Predict the next line for this snippet: <|code_start|> class Task(Api): validate = V.Schema({ V.Required('task_id'): int }) def _execute(self, params): generated_sql, query_params = self._generate_sql(params) task_row = self._db_get(''' SELECT *, %(state_projection)s AS...
LIMIT 1
Given the following code snippet before the placeholder: <|code_start|> class Job(Api): name = 'Job' validate = V.Schema({ V.Required('job_id'): basestring }) def _execute(self, params): <|code_end|> , predict the next line using imports from the current file: from memsql_loader.api.base impo...
generated_sql, query_params = self._generate_sql(params)
Given the code snippet: <|code_start|> class Job(Api): name = 'Job' validate = V.Schema({ V.Required('job_id'): basestring }) def _execute(self, params): generated_sql, query_params = self._generate_sql(params) row = self._db_query(""" SELECT id, ...
SELECT
Given snippet: <|code_start|> validate = V.Schema({ V.Required('job_id'): basestring }) def _execute(self, params): generated_sql, query_params = self._generate_sql(params) row = self._db_query(""" SELECT id, created, spec,...
CAST(SUM(%(error_cond)s) AS SIGNED) AS tasks_errored,
Using the snippet: <|code_start|> class Job(Api): name = 'Job' validate = V.Schema({ V.Required('job_id'): basestring }) def _execute(self, params): generated_sql, query_params = self._generate_sql(params) row = self._db_query(""" SELECT id, ...
IFNULL(tasks_total, 0) AS tasks_total,
Given snippet: <|code_start|> class CancelTask(Command): @staticmethod def configure(parser, subparsers): subparser = subparsers.add_parser('cancel-task', help='Cancel a specific task') subparser.set_defaults(command=CancelTask) subparser.add_argument('task_id', type=int, h...
rows_affected = self.tasks.bulk_finish(extra_predicate=('id = :task_id', { 'task_id': self.options.task_id }))
Here is a snippet: <|code_start|> class CancelTask(Command): @staticmethod def configure(parser, subparsers): subparser = subparsers.add_parser('cancel-task', help='Cancel a specific task') subparser.set_defaults(command=CancelTask) subparser.add_argument('task_id', type=int, ...
plural = not rows_affected == 1
Using the snippet: <|code_start|> class CancelTask(Command): @staticmethod def configure(parser, subparsers): subparser = subparsers.add_parser('cancel-task', help='Cancel a specific task') subparser.set_defaults(command=CancelTask) subparser.add_argument('task_id', type=int, ...
print 'Cancelled', rows_affected, 'task%s.' % ('s' if plural else '')
Here is a snippet: <|code_start|> V.Required("file_id_column", default=None): V.Any(basestring, None), V.Required("non_local_load", default=False): bool, V.Required("duplicate_key_method", default="error"): V.Any("error", "replace", "ignore"), V.Required("script", default=None): V.Any(bas...
})
Predict the next line after this snippet: <|code_start|> class InvalidKeyException(Exception): pass class LoadPath(object): def __init__(self, path): self.path = path parsed = urlparse.urlparse(path) self.bucket = None if parsed.scheme == 's3': self.scheme = 's3' ...
raise V.Invalid("OR (|) operators are not supported in file patterns", path=[ 'source', 'paths' ])
Continue the code snippet: <|code_start|> class Task(Command): @staticmethod def configure(parser, subparsers): subparser = subparsers.add_parser('task', help='Show information about a single task') subparser.set_defaults(command=Task) subparser.add_argument('task_id', type=int, <|co...
help='The ID of the task to lookup')
Here is a snippet: <|code_start|> class Task(Command): @staticmethod def configure(parser, subparsers): subparser = subparsers.add_parser('task', help='Show information about a single task') subparser.set_defaults(command=Task) subparser.add_argument('task_id', type=int, ...
try:
Given the following code snippet before the placeholder: <|code_start|> class Task(Command): @staticmethod def configure(parser, subparsers): subparser = subparsers.add_parser('task', help='Show information about a single task') subparser.set_defaults(command=Task) subparser.add_argu...
print e.message
Predict the next line after this snippet: <|code_start|>def delete_pid_file(): try: os.remove(get_pid_file_path()) except Exception: pass def write_pid_file(): atexit.register(delete_pid_file) with open(get_pid_file_path(), 'w') as f: f.write("%s\n" % os.getpid()) def get_serv...
except OSError as e:
Continue the code snippet: <|code_start|> TASKS_TTL = 120 class TaskState(SuperEnum): QUEUED = SuperEnum.E RUNNING = SuperEnum.E SUCCESS = SuperEnum.E <|code_end|> . Use current file imports: import re from datetime import datetime from dateutil import parser from clark.super_enum import SuperEnum from ...
ERROR = SuperEnum.E
Predict the next line after this snippet: <|code_start|> TASKS_TTL = 120 class TaskState(SuperEnum): QUEUED = SuperEnum.E RUNNING = SuperEnum.E SUCCESS = SuperEnum.E ERROR = SuperEnum.E CANCELLED = SuperEnum.E SUCCESS_CONDITION = 'tasks.result = \'success\'' ERROR_CONDITION = 'tasks.resu...
PROJECTION = re.sub(r'\s+', ' ', """
Here is a snippet: <|code_start|> SORTABLE_COLUMNS = [ 'id', 'created', 'last_contact', 'state', 'tasks_queued', 'tasks_running', 'tasks_cancelled', 'tasks_errored', 'tasks_finished', 'tasks_total' ] name = 'Jobs' validate = V.Schema({ 'state': listor(validate_enum(shared.JobState)), V.Requ...
bytes_total,
Using the snippet: <|code_start|> name = 'Jobs' validate = V.Schema({ 'state': listor(validate_enum(shared.JobState)), V.Required('order', default=shared.SortDirection.DESC): validate_enum(shared.SortDirection), V.Required('order_by', default='created'): V.Any(*SORTABLE_COLUMNS), ...
download_rate,
Based on the snippet: <|code_start|> created, last_contact, spec, IFNULL(tasks_total, 0) AS tasks_total, IFNULL(tasks_cancelled, 0) AS tasks_cancelled, ...
CAST(SUM(%(finished_cond)s) AS SIGNED) AS tasks_finished,
Next line prediction: <|code_start|> -- Tasks that are cancelled count as finished also -- It is always true that if one is null, all are null IFNULL(tasks_total - tasks_queued - tasks_finished, 0) AS tasks_running, IFNULL(tasks_finished, 0) ...
CAST(SUM(tasks.download_rate) AS SIGNED) AS download_rate
Next line prediction: <|code_start|> %(state_projection)s AS state, bytes_total, bytes_downloaded, download_rate, first_task_start FROM jobs LEFT JOIN( ...
%(where_expr)s
Predict the next line after this snippet: <|code_start|> urlpatterns = patterns( '', url(r'^$', FeedListView.as_view(), name='feeds_list'), url(r'^new/$', FeedCreateView.as_view(), name='feeds_create'), url(r'^edit/(?P<pk>[\w]+)/$', FeedUpdateView.as_view(), name='feeds_update'), url(r'^delete/(?P...
)
Continue the code snippet: <|code_start|> urlpatterns = patterns( '', url(r'^$', FeedListView.as_view(), name='feeds_list'), url(r'^new/$', FeedCreateView.as_view(), name='feeds_create'), url(r'^edit/(?P<pk>[\w]+)/$', FeedUpdateView.as_view(), name='feeds_update'), url(r'^delete/(?P<pk>[\w]+)/$', ...
)
Next line prediction: <|code_start|> class KipptUserBackend(ModelBackend): def authenticate(self, username=None, api_token=None): try: return KipptUser.objects.get(username=username, api_token=api_token) except KipptUser.DoesNotExist: return None <|code_end|> . Use current...
def get_user(self, user_id):
Predict the next line after this snippet: <|code_start|> class KipptUserAdmin(UserAdmin): list_display = ( 'username', 'first_name', 'last_name', 'email', 'is_active', 'is_staff', 'is_superuser') list_filter = ('is_staff', 'is_superuser', 'is_active') search_fields = ['username', 'email', ...
('Other info', {
Here is a snippet: <|code_start|> class ConnectView(CreateView): model = KipptUser form_class = KipptUserConnectForm def get_context_data(self, **kwargs): context = super(ConnectView, self).get_context_data(**kwargs) feeds_create = self.request.build_absolute_uri(reverse('feeds_create'))...
return redirect(reverse_lazy('feeds_list'))
Using the snippet: <|code_start|> class ConnectView(CreateView): model = KipptUser form_class = KipptUserConnectForm def get_context_data(self, **kwargs): context = super(ConnectView, self).get_context_data(**kwargs) feeds_create = self.request.build_absolute_uri(reverse('feeds_create'))...
def form_valid(self, form):
Predict the next line after this snippet: <|code_start|>class ConnectView(CreateView): model = KipptUser form_class = KipptUserConnectForm def get_context_data(self, **kwargs): context = super(ConnectView, self).get_context_data(**kwargs) feeds_create = self.request.build_absolute_uri(rever...
return redirect(redirect_to)
Next line prediction: <|code_start|> class FeedAdmin(admin.ModelAdmin): list_display = ('feed_url', 'created_by') class FeedEntryAdmin(admin.ModelAdmin): <|code_end|> . Use current file imports: (from django.contrib import admin from .models import Feed, FeedEntry) and context including class names, function ...
list_display = ('title', 'link', 'feed',
Given the following code snippet before the placeholder: <|code_start|> class FeedAdmin(admin.ModelAdmin): list_display = ('feed_url', 'created_by') class FeedEntryAdmin(admin.ModelAdmin): <|code_end|> , predict the next line using imports from the current file: from django.contrib import admin from .models im...
list_display = ('title', 'link', 'feed',
Using the snippet: <|code_start|> class FeedCreateForm(forms.ModelForm): list_id = forms.ChoiceField(label='List (optional)', required=False) class Meta: model = Feed fields = ('feed_url', 'list_id') def __init__(self, user, *args, **kwargs): super(FeedCreateForm, self).__init__...
feed = feedparser.parse(feed_url)