text_prompt stringlengths 157 13.1k | code_prompt stringlengths 7 19.8k ⌀ |
|---|---|
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def resume(self, unique_id, configs=None):
""" Issues a sigcont for the specified process :Parameter unique_id: the name of the process """ |
self._send_signal(unique_id, signal.SIGCONT,configs) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def terminate(self, unique_id, configs=None):
""" Issues a kill -15 to the specified process :Parameter unique_id: the name of the process """ |
self._send_signal(unique_id, signal.SIGTERM, configs) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def hangup(self, unique_id, configs=None):
""" Issue a signal to hangup the specified process :Parameter unique_id: the name of the process """ |
self._send_signal(unique_id, signal.SIGHUP, configs) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_NONE):
"""deprecated name for fetch_logs""" |
self.fetch_logs(unique_id, logs, directory, pattern) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def fetch_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_NONE):
""" Copies logs from the remote host that the process is running on t... |
hostname = self.processes[unique_id].hostname
install_path = self.processes[unique_id].install_path
self.fetch_logs_from_host(hostname, install_path, unique_id, logs, directory, pattern) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def fetch_logs_from_host(hostname, install_path, prefix, logs, directory, pattern):
""" Static method Copies logs from specified host on the specified install pa... |
if hostname is not None:
with get_sftp_client(hostname, username=runtime.get_username(), password=runtime.get_password()) as ftp:
for f in logs:
try:
mode = ftp.stat(f).st_mode
except IOError, e:
if e.errno == errno.ENOENT:
logger.error("Log f... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_pid(self, unique_id, configs=None):
"""Gets the pid of the process with `unique_id`. If the deployer does not know of a process with `unique_id` then it ... |
RECV_BLOCK_SIZE = 16
# the following is necessay to set the configs for this function as the combination of the
# default configurations and the parameter with the parameter superceding the defaults but
# not modifying the defaults
if configs is None:
configs = {}
tmp = self.default_confi... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_host(self, unique_id):
"""Gets the host of the process with `unique_id`. If the deployer does not know of a process with `unique_id` then it should retur... |
if unique_id in self.processes:
return self.processes[unique_id].hostname
logger.error("{0} not a known process".format(unique_id))
raise NameError("{0} not a known process".format(unique_id)) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def kill_all_process(self):
""" Terminates all the running processes. By default it is set to false. Users can set to true in config once the method to get_pid i... |
if (runtime.get_active_config("cleanup_pending_process",False)):
for process in self.get_processes():
self.terminate(process.unique_id) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def string_to_level(log_level):
""" Converts a string to the corresponding log level """ |
if (log_level.strip().upper() == "DEBUG"):
return logging.DEBUG
if (log_level.strip().upper() == "INFO"):
return logging.INFO
if (log_level.strip().upper() == "WARNING"):
return logging.WARNING
if (log_level.strip().upper() == "ERROR"):
return logging.ERROR |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def execute ( self, conn, dataset, dataset_access_type, transaction=False ):
""" for a given file """ |
if not conn:
dbsExceptionHandler("dbsException-failed-connect2host", "Oracle/Dataset/UpdateType. Expects db connection from upper layer.", self.logger.exception)
binds = { "dataset" : dataset , "dataset_access_type" : dataset_access_type ,"myuser": dbsUtils().getCreateBy(), "mydate": dbsUt... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def validateStringInput(input_key,input_data, read=False):
""" To check if a string has the required format. This is only used for POST APIs. """ |
log = clog.error_log
func = None
if '*' in input_data or '%' in input_data:
func = validationFunctionWildcard.get(input_key)
if func is None:
func = searchstr
elif input_key == 'migration_input' :
if input_data.find('#') != -1 : func = block
else : func = dat... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def jsonstreamer(func):
"""JSON streamer decorator""" |
def wrapper (self, *args, **kwds):
gen = func (self, *args, **kwds)
yield "["
firstItem = True
for item in gen:
if not firstItem:
yield ","
else:
firstItem = False
yield cjson.encode(item)
yield "]"
re... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listDatasetAccessTypes(self, dataset_access_type=""):
""" List dataset access types """ |
if isinstance(dataset_access_type, basestring):
try:
dataset_access_type = str(dataset_access_type)
except:
dbsExceptionHandler('dbsException-invalid-input', 'dataset_access_type given is not valid : %s' %dataset_access_type)
else:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def block_before(self):
""" Check the current request and block it if the IP address it's coming from is blacklisted. """ |
# To avoid unnecessary database queries, ignore the IP check for
# requests for static files
if request.path.startswith(url_for('static', filename='')):
return
# Some static files might be served from the root path (e.g.
# favicon.ico, robots.txt, etc.). Ignore the ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def matches_ip(self, ip):
"""Return True if the given IP is blacklisted, False otherwise.""" |
# Check the cache if caching is enabled
if self.cache is not None:
matches_ip = self.cache.get(ip)
if matches_ip is not None:
return matches_ip
# Query MongoDB to see if the IP is blacklisted
matches_ip = IPNetwork.matches_ip(
ip, re... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def processDatasetBlocks(self, url, conn, inputdataset, order_counter):
""" Utility function, that comapares blocks of a dataset at source and dst and returns an... |
ordered_dict = {}
srcblks = self.getSrcBlocks(url, dataset=inputdataset)
if len(srcblks) < 0:
e = "DBSMigration: No blocks in the required dataset %s found at source %s."%(inputdataset, url)
dbsExceptionHandler('dbsException-invalid-input2', e, self.logger.exception, e)
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def removeMigrationRequest(self, migration_rqst):
""" Method to remove pending or failed migration request from the queue. """ |
conn = self.dbi.connection()
try:
tran = conn.begin()
self.mgrremove.execute(conn, migration_rqst)
tran.commit()
except dbsException as he:
if conn: conn.close()
raise
except Exception as ex:
if conn: conn.close()
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listMigrationBlocks(self, migration_request_id=""):
""" get eveything of block that is has status = 0 and migration_request_id as specified. """ |
conn = self.dbi.connection()
try:
return self.mgrblklist.execute(conn, migration_request_id=migration_request_id)
finally:
if conn: conn.close() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def getSrcBlocks(self, url, dataset="", block=""):
""" Need to list all blocks of the dataset and its parents starting from the top For now just list the blocks ... |
if block:
params={'block_name':block, 'open_for_writing':0}
elif dataset:
params={'dataset':dataset, 'open_for_writing':0}
else:
m = 'DBSMigration: Invalid input. Either block or dataset name has to be provided'
e = 'DBSMigrate/getSrcBlocks: Inva... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def executeSingle( self, conn, daoinput, tablename, transaction = False):
"""build dynamic sql based on daoinput""" |
sql1 = " insert into %s%s( " %(self.owner, tablename)
sql2 =" values("
"Now loop over all the input keys. We need to check if all the keys are valid !!!"
for key in daoinput:
sql1 += "%s," %key.upper()
sql2 += ":%s," %key.lower()
sql = sql1.strip(',') + ') ' + sql2.s... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def parse_requirements(requirements_file):
""" Create a list for the 'install_requires' component of the setup function by parsing a requirements file """ |
if os.path.exists(requirements_file):
# return a list that contains each line of the requirements file
return open(requirements_file, 'r').read().splitlines()
else:
print("ERROR: requirements file " + requirements_file + " not found.")
sys.exit(1) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def execute(self, conn, dsType = "", dataset="", transaction = False):
""" Lists all primary dataset types if no user input is provided. """ |
sql = self.sql
binds={}
if not dsType and not dataset:
pass
elif dsType and dataset in ("", None, '%'):
op = ("=", "like")["%" in dsType]
sql += "WHERE PDT.PRIMARY_DS_TYPE %s :primdstype"%op
binds = {"primdstype":dsType}
elif dataset an... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listReleaseVersions(self, release_version="", dataset='', logical_file_name=''):
""" List release versions """ |
if dataset and ('%' in dataset or '*' in dataset):
dbsExceptionHandler('dbsException-invalid-input',
" DBSReleaseVersion/listReleaseVersions. No wildcards are" +
" allowed in dataset.\n.")
if logical_file_name and ('%' in logical_file_name or '*' in logical_... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def __search_ca_path(self):
""" Get CA Path to check the validity of the server host certificate on the client side """ |
if "X509_CERT_DIR" in os.environ:
self._ca_path = os.environ['X509_CERT_DIR']
elif os.path.exists('/etc/grid-security/certificates'):
self._ca_path = '/etc/grid-security/certificates'
else:
raise ClientAuthException("Could not find a valid CA path") |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def authInsert(user, role, group, site):
""" Authorization function for general insert """ |
if not role: return True
for k, v in user['roles'].iteritems():
for g in v['group']:
if k in role.get(g, '').split(':'):
return True
return False |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listDatasetParents(self, dataset=""):
""" takes required dataset parameter returns only parent dataset name """ |
if( dataset == "" ):
dbsExceptionHandler("dbsException-invalid-input", "DBSDataset/listDatasetParents. Child Dataset name is required.")
conn = self.dbi.connection()
try:
result = self.datasetparentlist.execute(conn, dataset)
return result
finally:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listDatasetChildren(self, dataset):
""" takes required dataset parameter returns only children dataset name """ |
if( dataset == "" ):
dbsExceptionHandler("dbsException-invalid-input", "DBSDataset/listDatasetChildren. Parent Dataset name is required.")
conn = self.dbi.connection()
try:
result = self.datasetchildlist.execute(conn, dataset)
return result
finally:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listDatasets(self, dataset="", parent_dataset="", is_dataset_valid=1, release_version="", pset_hash="", app_name="", output_module_label="", global_tag="", pr... |
if(logical_file_name and logical_file_name.find("%")!=-1):
dbsExceptionHandler('dbsException-invalid-input', 'DBSDataset/listDatasets API requires \
fullly qualified logical_file_name. NO wildcard is allowed in logical_file_name.')
if(dataset and dataset.find("/%/%/%")!=-1):... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def execute(self, conn, block_name, origin_site_name, transaction=False):
""" Update origin_site_name for a given block_name """ |
if not conn:
dbsExceptionHandler("dbsException-failed-connect2host", "Oracle/Block/UpdateStatus. \
Expects db connection from upper layer.", self.logger.exception)
binds = {"block_name": block_name, "origin_site_name": origin_site_name, "mtime": dbsUtils().getTime(),
"myuse... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def increment(self, conn, seqName, transaction = False, incCount=1):
""" increments the sequence `seqName` by default `Incremented by one` and returns its value ... |
try:
seqTable = "%sS" %seqName
tlock = "lock tables %s write" %seqTable
self.dbi.processData(tlock, [], conn, transaction)
sql = "select ID from %s" % seqTable
result = self.dbi.processData(sql, [], conn, transaction)
resultlist = self.formatDict(result)
newSeq = resultlist[0]['id']... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listRuns(self, run_num=-1, logical_file_name="", block_name="", dataset=""):
""" List run known to DBS. """ |
if( '%' in logical_file_name or '%' in block_name or '%' in dataset ):
dbsExceptionHandler('dbsException-invalid-input',
" DBSDatasetRun/listRuns. No wildcards are allowed in logical_file_name, block_name or dataset.\n.")
conn = self.dbi.connection()
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def insertPrimaryDataset(self):
""" API to insert A primary dataset in DBS :param primaryDSObj: primary dataset object :type primaryDSObj: dict :key primary_ds_t... |
try :
body = request.body.read()
indata = cjson.decode(body)
indata = validateJSONInputNoCopy("primds", indata)
indata.update({"creation_date": dbsUtils().getTime(), "create_by": dbsUtils().getCreateBy() })
self.dbsPrimaryDataset.insertPrimaryDataset(... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def insertBlock(self):
""" API to insert a block into DBS :param blockObj: Block object :type blockObj: dict :key open_for_writing: Open For Writing (1/0) (Optio... |
try:
body = request.body.read()
indata = cjson.decode(body)
indata = validateJSONInputNoCopy("block", indata)
self.dbsBlock.insertBlock(indata)
except cjson.DecodeError as dc:
dbsExceptionHandler("dbsException-invalid-input2", "Wrong format/da... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def updateFile(self, logical_file_name=[], is_file_valid=1, lost=0, dataset=''):
""" API to update file status :param logical_file_name: logical_file_name to upd... |
if lost in [1, True, 'True', 'true', '1', 'y', 'yes']:
lost = 1
if is_file_valid in [1, True, 'True', 'true', '1', 'y', 'yes']:
dbsExceptionHandler("dbsException-invalid-input2", dbsExceptionCode["dbsException-invalid-input2"], self.logger.exception,\
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def qs_for_ip(cls, ip_str):
""" Returns a queryset with matching IPNetwork objects for the given IP. """ |
ip = int(netaddr.IPAddress(ip_str))
# ignore IPv6 addresses for now (4294967295 is 0xffffffff, aka the
# biggest 32-bit number)
if ip > 4294967295:
return cls.objects.none()
ip_range_query = {
'start__lte': ip,
'stop__gte': ip
}
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def matches_ip(cls, ip_str, read_preference=None):
""" Return True if provided IP exists in the blacklist and doesn't exist in the whitelist. Otherwise, return F... |
qs = cls.qs_for_ip(ip_str).only('whitelist')
if read_preference:
qs = qs.read_preference(read_preference)
# Return True if any docs match the IP and none of them represent
# a whitelist
return bool(qs) and not any(obj.whitelist for obj in qs) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def dbsExceptionHandler(eCode='', message='', logger=None , serverError=''):
""" This utility function handles all dbs exceptions. It will log , raise exception ... |
if logger:
#HTTP Error
if eCode == "dbsException-invalid-input":
#logger(eCode + ": " + serverError)
raise HTTPError(400, message)
elif eCode == "dbsException-missing-data":
logger( time.asctime(time.gmtime()) + " " + eCode + ": " + serverError)
#p... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def configure_proxy(self, curl_object):
"""configure pycurl proxy settings""" |
curl_object.setopt(curl_object.PROXY, self._proxy_hostname)
curl_object.setopt(curl_object.PROXYPORT, self._proxy_port)
curl_object.setopt(curl_object.PROXYTYPE, curl_object.PROXYTYPE_SOCKS5)
if self._proxy_user and self._proxy_passwd:
curl_object.setopt(curl_object.PROXYUSE... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def execute(self, conn, acquisition_era_name,end_date, transaction = False):
""" for a given block_id """ |
if not conn:
dbsExceptionHandler("dbsException-failed-connect2host", "dbs/dao/Oracle/AcquisitionEra/updateEndDate expects db connection from upper layer.", self.logger.exception)
binds = { "acquisition_era_name" :acquisition_era_name , "end_date" : end_date }
result = self.dbi.processData(self... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def updateStatus(self, block_name="", open_for_writing=0):
""" Used to toggle the status of a block open_for_writing=1, open for writing, open_for_writing=0, clo... |
if open_for_writing not in [1, 0, '1', '0']:
msg = "DBSBlock/updateStatus. open_for_writing can only be 0 or 1 : passed %s."\
% open_for_writing
dbsExceptionHandler('dbsException-invalid-input', msg)
conn = self.dbi.connection()
trans = conn.begin()
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def updateSiteName(self, block_name, origin_site_name):
""" Update the origin_site_name for a given block name """ |
if not origin_site_name:
dbsExceptionHandler('dbsException-invalid-input',
"DBSBlock/updateSiteName. origin_site_name is mandatory.")
conn = self.dbi.connection()
trans = conn.begin()
try:
self.updatesitename.execute(conn, block_na... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listBlocks(self, dataset="", block_name="", data_tier_name="", origin_site_name="", logical_file_name="", run_num=-1, min_cdate=0, max_cdate=0, min_ldate=0, m... |
if (not dataset) or re.search("['%','*']", dataset):
if (not block_name) or re.search("['%','*']", block_name):
if (not logical_file_name) or re.search("['%','*']", logical_file_name):
if not data_tier_name or re.search("['%','*']", data_tier_name):
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def execute(self, conn, site_name= "", transaction = False):
""" Lists all sites types if site_name is not provided. """ |
sql = self.sql
if site_name == "":
result = self.dbi.processData(sql, conn=conn, transaction=transaction)
else:
sql += "WHERE S.SITE_NAME = :site_name"
binds = { "site_name" : site_name }
result = self.dbi.processData(sql, binds, conn, transactio... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def getBlocks(self):
""" Get the blocks that need to be migrated """ |
try:
conn = self.dbi.connection()
result = self.buflistblks.execute(conn)
return result
finally:
if conn:
conn.close() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def getBufferedFiles(self, block_id):
""" Get some files from the insert buffer """ |
try:
conn = self.dbi.connection()
result = self.buflist.execute(conn, block_id)
return result
finally:
if conn:
conn.close() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def execute(self, conn, data_tier_name='', transaction = False, cache=None):
""" returns id for a given datatier name """ |
if cache:
ret=cache.get("DATA_TIERS")
if not ret==None:
return ret
sql = self.sql
binds={}
if data_tier_name:
op = ('=', 'like')['%' in data_tier_name]
sql += "WHERE DT.DATA_TIER_NAME %s :datatier" %op
binds = {"datatier":data_tier_name}
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def execute(self, conn, migration_url="", migration_input="", create_by="", migration_request_id="", transaction=False):
""" Lists the oldest request queued """ |
binds = {}
result = self.dbi.processData(self.sql, binds, conn, transaction)
result = self.formatDict(result)
if len(result) == 0 :
return []
if result[0]["migration_request_id"] in ('', None) :
return []
return result |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listProcessingEras(self, processing_version=''):
""" Returns all processing eras in dbs """ |
conn = self.dbi.connection()
try:
result = self.pelst.execute(conn, processing_version)
return result
finally:
if conn:
conn.close() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listPhysicsGroups(self, physics_group_name=""):
""" Returns all physics groups if physics group names are not passed. """ |
if not isinstance(physics_group_name, basestring):
dbsExceptionHandler('dbsException-invalid-input',
'physics group name given is not valid : %s' %
physics_group_name)
else:
try:
physics_group_name = str(physics_group_name)
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def getServices(self):
""" Simple method that returs list of all know DBS instances, instances known to this registry """ |
try:
conn = self.dbi.connection()
result = self.serviceslist.execute(conn)
return result
except Exception as ex:
msg = (("%s DBSServicesRegistry/getServices." +
" %s\n. Exception trace: \n %s") %
(DBSEXCEPTIONS['dbs... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def addService(self):
""" Add a service to service registry """ |
conn = self.dbi.connection()
tran = conn.begin()
try:
body = request.body.read()
service = cjson.decode(body)
addthis = {}
addthis['service_id'] = self.sm.increment(conn, "SEQ_RS", tran)
addthis['name'] = service.get('NAM... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def execute(self, conn, migration_url="", migration_input="", create_by="", migration_request_id="", oldest= False, transaction=False):
""" Lists all requests if... |
sql = self.sql
binds = {}
if migration_request_id:
sql += " WHERE MR.MIGRATION_REQUEST_ID=:migration_request_id"
binds['migration_request_id']=migration_request_id
elif oldest:
#FIXME: Need to write the sql.YG
#current_date = dbsUtils().getTime()
#... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listPrimaryDatasets(self, primary_ds_name="", primary_ds_type=""):
""" Returns all primary dataset if primary_ds_name or primary_ds_type are not passed. """ |
conn = self.dbi.connection()
try:
result = self.primdslist.execute(conn, primary_ds_name, primary_ds_type)
if conn: conn.close()
return result
finally:
if conn:
conn.close() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listPrimaryDSTypes(self, primary_ds_type="", dataset=""):
""" Returns all primary dataset types if dataset or primary_ds_type are not passed. """ |
conn = self.dbi.connection()
try:
result = self.primdstypeList.execute(conn, primary_ds_type, dataset)
if conn: conn.close()
return result
finally:
if conn:
conn.close() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def execute(self, conn, name='', transaction = False):
""" returns id for a given physics group name """ |
binds={}
if name:
op = ('=', 'like')['%' in name]
sql = self.sql + " WHERE pg.physics_group_name %s :physicsgroup" % (op)
binds = {"physicsgroup": name}
else:
sql = self.sql
self.logger.debug(sql)
result = self.dbi.processData... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def getHelp(self, call=""):
""" API to get a list of supported REST APIs. In the case a particular API is specified, the docstring of that API is displayed. :par... |
if call:
params = self.methods['GET'][call]['args']
doc = self.methods['GET'][call]['call'].__doc__
return dict(params=params, doc=doc)
else:
return self.methods['GET'].keys() |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listPrimaryDatasets(self, primary_ds_name="", primary_ds_type=""):
""" API to list primary datasets :param primary_ds_type: List primary datasets with primar... |
primary_ds_name = primary_ds_name.replace("*", "%")
primary_ds_type = primary_ds_type.replace("*", "%")
try:
return self.dbsPrimaryDataset.listPrimaryDatasets(primary_ds_name, primary_ds_type)
except dbsException as de:
dbsExceptionHandler(de.eCode, de.message, s... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listDatasetArray(self):
""" API to list datasets in DBS. To be called by datasetlist url with post call. :param dataset: list of datasets [dataset1,dataset2,... |
ret = []
try :
body = request.body.read()
if body:
data = cjson.decode(body)
data = validateJSONInputNoCopy("dataset", data, read=True)
#Because CMSWEB has a 300 seconds responding time. We have to limit the array siz to make sure ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listDataTiers(self, data_tier_name=""):
""" API to list data tiers known to DBS. :param data_tier_name: List details on that data tier (Optional) :type data_... |
data_tier_name = data_tier_name.replace("*", "%")
try:
conn = self.dbi.connection()
return self.dbsDataTierListDAO.execute(conn, data_tier_name.upper())
except dbsException as de:
dbsExceptionHandler(de.eCode, de.message, self.logger.exception, de.message)
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listBlockOrigin(self, origin_site_name="", dataset="", block_name=""):
""" API to list blocks first generated in origin_site_name. :param origin_site_name: O... |
try:
return self.dbsBlock.listBlocksOrigin(origin_site_name, dataset, block_name)
except dbsException as de:
dbsExceptionHandler(de.eCode, de.message, self.logger.exception, de.serverError)
except Exception as ex:
sError = "DBSReaderModel/listBlocks. %s\n. Ex... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listBlocksParents(self):
""" API to list block parents of multiple blocks. To be called by blockparents url with post call. :type block_names: list """ |
try :
body = request.body.read()
data = cjson.decode(body)
data = validateJSONInputNoCopy("block", data, read=True)
#Because CMSWEB has a 300 seconds responding time. We have to limit the array siz to make sure that
#the API can be finished in 300 sec... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listBlockChildren(self, block_name=""):
""" API to list block children. :param block_name: name of block who's children needs to be found (Required) :type bl... |
block_name = block_name.replace("*", "%")
try:
return self.dbsBlock.listBlockChildren(block_name)
except dbsException as de:
dbsExceptionHandler(de.eCode, de.message, self.logger.exception, de.serverError)
except Exception as ex:
sError = "DBSReaderMo... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listBlockSummaries(self, block_name="", dataset="", detail=False):
""" API that returns summary information like total size and total number of events in a d... |
if bool(dataset)+bool(block_name)!=1:
dbsExceptionHandler("dbsException-invalid-input2",
dbsExceptionCode["dbsException-invalid-input2"],
self.logger.exception,
"Dataset or block_names must be specified ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listDatasetParents(self, dataset=''):
""" API to list A datasets parents in DBS. :param dataset: dataset (Required) :type dataset: str :returns: List of dict... |
try:
return self.dbsDataset.listDatasetParents(dataset)
except dbsException as de:
dbsExceptionHandler(de.eCode, de.message, self.logger.exception, de.serverError)
except Exception as ex:
sError = "DBSReaderModel/listDatasetParents. %s\n. Exception trace: \n ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listOutputConfigs(self, dataset="", logical_file_name="", release_version="", pset_hash="", app_name="", output_module_label="", block_id=0, global_tag=''):
... |
release_version = release_version.replace("*", "%")
pset_hash = pset_hash.replace("*", "%")
app_name = app_name.replace("*", "%")
output_module_label = output_module_label.replace("*", "%")
try:
return self.dbsOutputConfig.listOutputConfigs(dataset,
l... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listFileParents(self, logical_file_name='', block_id=0, block_name=''):
""" API to list file parents :param logical_file_name: logical_file_name of file (Req... |
try:
r = self.dbsFile.listFileParents(logical_file_name, block_id, block_name)
for item in r:
yield item
except HTTPError as he:
raise he
except dbsException as de:
dbsExceptionHandler(de.eCode, de.message, self.logger.exception, de.serverError)
exce... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listFileChildren(self, logical_file_name='', block_name='', block_id=0):
""" API to list file children. One of the parameters in mandatory. :param logical_fi... |
if isinstance(logical_file_name, list):
for f in logical_file_name:
if '*' in f or '%' in f:
dbsExceptionHandler("dbsException-invalid-input2", dbsExceptionCode["dbsException-invalid-input2"], self.logger.exception, "No \
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listFileLumis(self, logical_file_name="", block_name="", run_num=-1, validFileOnly=0):
""" API to list Lumi for files. Either logical_file_name or block_name... |
# run_num=1 caused full table scan and CERN DBS reported some of the queries ran more than 50 hours
# We will disbale all the run_num=1 calls in DBS. Run_num=1 will be OK when logical_file_name is given.
# YG Jan. 16 2019
if (run_num != -1 and logical_file_name ==''):
for r... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listRuns(self, run_num=-1, logical_file_name="", block_name="", dataset=""):
""" API to list all runs in DBS. At least one parameter is mandatory. :param log... |
# run_num=1 caused full table scan and CERN DBS reported some of the queries ran more than 50 hours
# We will disbale all the run_num=1 calls in DBS. Run_num=1 will be OK when logical_file_name is given.
# YG Jan. 16 2019
if (run_num != -1 and logical_file_name ==''):
for r... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def dumpBlock(self, block_name):
""" API the list all information related with the block_name :param block_name: Name of block to be dumped (Required) :type bloc... |
try:
return self.dbsBlock.dumpBlock(block_name)
except HTTPError as he:
raise he
except dbsException as de:
dbsExceptionHandler(de.eCode, de.message, self.logger.exception, de.serverError)
except Exception as ex:
sError = "DBSReaderModel/d... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listAcquisitionEras(self, acquisition_era_name=''):
""" API to list all Acquisition Eras in DBS. :param acquisition_era_name: Acquisition era name (Optional,... |
try:
acquisition_era_name = acquisition_era_name.replace('*', '%')
return self.dbsAcqEra.listAcquisitionEras(acquisition_era_name)
except dbsException as de:
dbsExceptionHandler(de.eCode, de.message, self.logger.exception, de.serverError)
except Exception as... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listProcessingEras(self, processing_version=0):
""" API to list all Processing Eras in DBS. :param processing_version: Processing Version (Optional). If prov... |
try:
#processing_version = processing_version.replace("*", "%")
return self.dbsProcEra.listProcessingEras(processing_version)
except dbsException as de:
dbsExceptionHandler(de.eCode, de.message, self.logger.exception, de.serverError)
except Exception as ex:
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listReleaseVersions(self, release_version='', dataset='', logical_file_name=''):
""" API to list all release versions in DBS :param release_version: List onl... |
if release_version:
release_version = release_version.replace("*", "%")
try:
return self.dbsReleaseVersion.listReleaseVersions(release_version, dataset, logical_file_name )
except dbsException as de:
dbsExceptionHandler(de.eCode, de.message, self.logger.excep... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listDatasetAccessTypes(self, dataset_access_type=''):
""" API to list dataset access types. :param dataset_access_type: List that dataset access type (Option... |
if dataset_access_type:
dataset_access_type = dataset_access_type.replace("*", "%")
try:
return self.dbsDatasetAccessType.listDatasetAccessTypes(dataset_access_type)
except dbsException as de:
dbsExceptionHandler(de.eCode, de.message, self.logger.exception, d... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listPhysicsGroups(self, physics_group_name=''):
""" API to list all physics groups. :param physics_group_name: List that specific physics group (Optional) :t... |
if physics_group_name:
physics_group_name = physics_group_name.replace('*', '%')
try:
return self.dbsPhysicsGroup.listPhysicsGroups(physics_group_name)
except dbsException as de:
dbsExceptionHandler(de.eCode, de.message, self.logger.exception, de.serverError)... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listRunSummaries(self, dataset="", run_num=-1):
""" API to list run summaries, like the maximal lumisection in a run. :param dataset: dataset name (Optional)... |
if run_num==-1:
dbsExceptionHandler("dbsException-invalid-input",
"The run_num parameter is mandatory",
self.logger.exception)
if re.search('[*,%]', dataset):
dbsExceptionHandler("dbsException-invalid-input",
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def list():
""" List all events """ |
entries = lambder.list_events()
for e in entries:
click.echo(str(e)) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def add(name, function_name, cron):
""" Create an event """ |
lambder.add_event(name=name, function_name=function_name, cron=cron) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def load(file):
""" Load events from a json file """ |
with open(file, 'r') as f:
contents = f.read()
lambder.load_events(contents) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def functions(context):
""" Manage AWS Lambda functions """ |
# find lambder.json in CWD
config_file = "./lambder.json"
if os.path.isfile(config_file):
context.obj = FunctionConfig(config_file)
pass |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def list():
""" List lambder functions """ |
functions = lambder.list_functions()
output = json.dumps(
functions,
sort_keys=True,
indent=4,
separators=(',', ':')
)
click.echo(output) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def new( name, bucket, timeout, memory, description, subnet_ids, security_group_ids ):
""" Create a new lambda project """ |
config = {}
if timeout:
config['timeout'] = timeout
if memory:
config['memory'] = memory
if description:
config['description'] = description
if subnet_ids:
config['subnet_ids'] = subnet_ids
if security_group_ids:
config['security_group_ids'] = security_gr... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def rm(config, name, bucket):
""" Delete lambda function, role, and zipfile """ |
# options should override config if it is there
myname = name or config.name
mybucket = bucket or config.bucket
click.echo('Deleting {} from {}'.format(myname, mybucket))
lambder.delete_function(myname, mybucket) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def invoke(config, name, input):
""" Invoke function in AWS """ |
# options should override config if it is there
myname = name or config.name
click.echo('Invoking ' + myname)
output = lambder.invoke_function(myname, input)
click.echo(output) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def putBlock(self, blockcontent, migration=False):
""" Insert the data in sereral steps and commit when each step finishes or rollback if there is a problem. """ |
#YG
try:
#1 insert configuration
self.logger.debug("insert configuration")
configList = self.insertOutputModuleConfig(
blockcontent['dataset_conf_list'], migration)
#2 insert dataset
self.logger.debug("insert datase... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listSites(self, block_name="", site_name=""):
""" Returns sites. """ |
try:
conn = self.dbi.connection()
if block_name:
result = self.blksitelist.execute(conn, block_name)
else:
result = self.sitelist.execute(conn, site_name)
return result
finally:
if conn:
conn.clo... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def checkInputParameter(method, parameters, validParameters, requiredParameters=None):
""" Helper function to check input by using before sending to the server :... |
for parameter in parameters:
if parameter not in validParameters:
raise dbsClientException("Invalid input",
"API %s does not support parameter %s. Supported parameters are %s" \
% (method, parameter, validParameters))
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def split_calls(func):
""" Decorator to split up server calls for methods using url parameters, due to the lenght limitation of the URI in Apache. By default 819... |
def wrapper(*args, **kwargs):
#The size limit is 8190 bytes minus url and api to call
#For example (https://cmsweb-testbed.cern.ch:8443/dbs/prod/global/filechildren), so 192 bytes should be safe.
size_limit = 8000
encoded_url = urllib.urlencode(kwargs)
if len(encoded_url) > ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def __callServer(self, method="", params={}, data={}, callmethod='GET', content='application/json'):
""" A private method to make HTTP call to the DBS Server :ty... |
UserID = os.environ['USER']+'@'+socket.gethostname()
try:
UserAgent = "DBSClient/"+os.environ['DBS3_CLIENT_VERSION']+"/"+ self.userAgent
except:
UserAgent = "DBSClient/Unknown"+"/"+ self.userAgent
request_headers = {"Content-Type": content, "Accept": content, "U... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def __parseForException(self, http_error):
""" An internal method, should not be used by clients :param httperror: Thrown httperror by the server """ |
data = http_error.body
try:
if isinstance(data, str):
data = cjson.decode(data)
except:
raise http_error
if isinstance(data, dict) and 'exception' in data:# re-raise with more details
raise HTTPError(http_error.url, data['exception'],... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def requestTimingInfo(self):
""" Returns the time needed to process the request by the frontend server in microseconds and the EPOC timestamp of the request in m... |
try:
return tuple(item.split('=')[1] for item in self.http_response.header.get('CMS-Server-Time').split())
except AttributeError:
return None, None |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listFileParentsByLumi(self, **kwargs):
""" API to list file parents using lumi section info. :param block_name: name of block that has files who's parents ne... |
validParameters = ['block_name', 'logical_file_name']
requiredParameters = {'forced': ['block_name']}
checkInputParameter(method="listFileParentsByLumi", parameters=kwargs.keys(), validParameters=validParameters,
requiredParameters=requiredParameters)
return... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listBlockParents(self, **kwargs):
""" API to list block parents. :param block_name: name of block who's parents needs to be found (Required) :type block_name... |
validParameters = ['block_name']
requiredParameters = {'forced': validParameters}
checkInputParameter(method="listBlockParents", parameters=kwargs.keys(), validParameters=validParameters,
requiredParameters=requiredParameters)
if isinstance(kwargs["block_nam... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listDatasetArray(self, **kwargs):
""" API to list datasets in DBS. :param dataset: list of datasets [dataset1,dataset2,..,dataset n] (Required if dataset_id ... |
validParameters = ['dataset', 'dataset_access_type', 'detail', 'dataset_id']
requiredParameters = {'multiple': ['dataset', 'dataset_id']}
checkInputParameter(method="listDatasetArray", parameters=kwargs.keys(), validParameters=validParameters,
requiredParameters=requiredPa... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def find_devices():
"""Return a list of dictionaries. Each dictionary represents one device. The dictionary contains the following keys: port, unique_id and in_u... |
# first fetch the number of attached devices, so we can create a buffer
# with the exact amount of entries. api expects array of u16
num_devices = api.py_aa_find_devices(0, array.array('H'))
_raise_error_if_negative(num_devices)
# return an empty list if no device is connected
if num_devices ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def i2c_bitrate(self):
"""I2C bitrate in kHz. Not every bitrate is supported by the host adapter. Therefore, the actual bitrate may be less than the value which ... |
ret = api.py_aa_i2c_bitrate(self.handle, 0)
_raise_error_if_negative(ret)
return ret |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def i2c_pullups(self):
"""Setting this to `True` will enable the I2C pullup resistors. If set to `False` the pullup resistors will be disabled. Raises an :exc:`I... |
ret = api.py_aa_i2c_pullup(self.handle, I2C_PULLUP_QUERY)
_raise_error_if_negative(ret)
return ret |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def i2c_bus_timeout(self):
"""I2C bus lock timeout in ms. Minimum value is 10 ms and the maximum value is 450 ms. Not every value can be set and will be rounded ... |
ret = api.py_aa_i2c_bus_timeout(self.handle, 0)
_raise_error_if_negative(ret)
return ret |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def i2c_master_write(self, i2c_address, data, flags=I2C_NO_FLAGS):
"""Make an I2C write access. The given I2C device is addressed and data given as a string is w... |
data = array.array('B', data)
status, _ = api.py_aa_i2c_write_ext(self.handle, i2c_address, flags,
len(data), data)
_raise_i2c_status_code_error_if_failure(status) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.