Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def ikey(self, value):
if value == self._defaults['iKey'] and 'iKey' in self._values:
del self._values['iKey']
else:
self._values['iKey'] = value | [
"The ikey property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def tags(self):
if 'tags' in self._values:
return self._values['tags']
self._values['tags'] = copy.deepcopy(self._defaults['tags'])
return self._values['tags'] | [
"The tags property.\n \n Returns:\n (hash). the property value. (defaults to: {})\n "
] |
Please provide a description of the function:def tags(self, value):
if value == self._defaults['tags'] and 'tags' in self._values:
del self._values['tags']
else:
self._values['tags'] = value | [
"The tags property.\n \n Args:\n value (hash). the property value.\n "
] |
Please provide a description of the function:def data(self, value):
if value == self._defaults['data'] and 'data' in self._values:
del self._values['data']
else:
self._values['data'] = value | [
"The data property.\n \n Args:\n value (object). the property value.\n "
] |
Please provide a description of the function:def account_id(self, value):
if value == self._defaults['ai.user.accountId'] and 'ai.user.accountId' in self._values:
del self._values['ai.user.accountId']
else:
self._values['ai.user.accountId'] = value | [
"The account_id property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def auth_user_id(self, value):
if value == self._defaults['ai.user.authUserId'] and 'ai.user.authUserId' in self._values:
del self._values['ai.user.authUserId']
else:
self._values['ai.user.authUserId'] = value | [
"The auth_user_id property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def sdk_version(self, value):
if value == self._defaults['ai.internal.sdkVersion'] and 'ai.internal.sdkVersion' in self._values:
del self._values['ai.internal.sdkVersion']
else:
self._values['ai.internal.sdkVersion'] = value | [
"The sdk_version property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def agent_version(self, value):
if value == self._defaults['ai.internal.agentVersion'] and 'ai.internal.agentVersion' in self._values:
del self._values['ai.internal.agentVersion']
else:
self._values['ai.internal.agentVersion']... | [
"The agent_version property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def node_name(self, value):
if value == self._defaults['ai.internal.nodeName'] and 'ai.internal.nodeName' in self._values:
del self._values['ai.internal.nodeName']
else:
self._values['ai.internal.nodeName'] = value | [
"The node_name property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def start(self):
with self._lock_send_remaining_time:
if self._send_remaining_time <= 0.0:
local_send_interval = self._send_interval
if self._send_interval < 0.1:
local_send_interval = 0.1
... | [
"Starts a new sender thread if none is not already there\n "
] |
Please provide a description of the function:def source(self, value):
if value == self._defaults['source'] and 'source' in self._values:
del self._values['source']
else:
self._values['source'] = value | [
"The source property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def name(self, value):
if value == self._defaults['name'] and 'name' in self._values:
del self._values['name']
else:
self._values['name'] = value | [
"The name property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def url(self, value):
if value == self._defaults['url'] and 'url' in self._values:
del self._values['url']
else:
self._values['url'] = value | [
"The url property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def device_initialize(self):
existing_device_initialize(self)
self.type = 'Other'
self.id = platform.node()
self.os_version = platform.version()
self.locale = locale.getdefaultlocale()[0] | [
" The device initializer used to assign special properties to all device context objects"
] |
Please provide a description of the function:def ns(self, value):
if value == self._defaults['ns'] and 'ns' in self._values:
del self._values['ns']
else:
self._values['ns'] = value | [
"The ns property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def kind(self, value):
if value == self._defaults['kind'] and 'kind' in self._values:
del self._values['kind']
else:
self._values['kind'] = value | [
"The kind property.\n \n Args:\n value (:class:`DataPointType.measurement`). the property value.\n "
] |
Please provide a description of the function:def count(self, value):
if value == self._defaults['count'] and 'count' in self._values:
del self._values['count']
else:
self._values['count'] = value | [
"The count property.\n \n Args:\n value (int). the property value.\n "
] |
Please provide a description of the function:def min(self, value):
if value == self._defaults['min'] and 'min' in self._values:
del self._values['min']
else:
self._values['min'] = value | [
"The min property.\n \n Args:\n value (float). the property value.\n "
] |
Please provide a description of the function:def max(self, value):
if value == self._defaults['max'] and 'max' in self._values:
del self._values['max']
else:
self._values['max'] = value | [
"The max property.\n \n Args:\n value (float). the property value.\n "
] |
Please provide a description of the function:def std_dev(self, value):
if value == self._defaults['stdDev'] and 'stdDev' in self._values:
del self._values['stdDev']
else:
self._values['stdDev'] = value | [
"The std_dev property.\n \n Args:\n value (float). the property value.\n "
] |
Please provide a description of the function:def perf_total(self, value):
if value == self._defaults['perfTotal'] and 'perfTotal' in self._values:
del self._values['perfTotal']
else:
self._values['perfTotal'] = value | [
"The perf_total property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def duration(self, value):
if value == self._defaults['duration'] and 'duration' in self._values:
del self._values['duration']
else:
self._values['duration'] = value | [
"The duration property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def network_connect(self, value):
if value == self._defaults['networkConnect'] and 'networkConnect' in self._values:
del self._values['networkConnect']
else:
self._values['networkConnect'] = value | [
"The network_connect property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def sent_request(self, value):
if value == self._defaults['sentRequest'] and 'sentRequest' in self._values:
del self._values['sentRequest']
else:
self._values['sentRequest'] = value | [
"The sent_request property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def received_response(self, value):
if value == self._defaults['receivedResponse'] and 'receivedResponse' in self._values:
del self._values['receivedResponse']
else:
self._values['receivedResponse'] = value | [
"The received_response property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def dom_processing(self, value):
if value == self._defaults['domProcessing'] and 'domProcessing' in self._values:
del self._values['domProcessing']
else:
self._values['domProcessing'] = value | [
"The dom_processing property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def referrer_uri(self, value):
if value == self._defaults['referrerUri'] and 'referrerUri' in self._values:
del self._values['referrerUri']
else:
self._values['referrerUri'] = value | [
"The referrer_uri property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def outer_id(self, value):
if value == self._defaults['outerId'] and 'outerId' in self._values:
del self._values['outerId']
else:
self._values['outerId'] = value | [
"The outer_id property.\n \n Args:\n value (int). the property value.\n "
] |
Please provide a description of the function:def has_full_stack(self, value):
if value == self._defaults['hasFullStack'] and 'hasFullStack' in self._values:
del self._values['hasFullStack']
else:
self._values['hasFullStack'] = value | [
"The has_full_stack property.\n \n Args:\n value (bool). the property value.\n "
] |
Please provide a description of the function:def stack(self, value):
if value == self._defaults['stack'] and 'stack' in self._values:
del self._values['stack']
else:
self._values['stack'] = value | [
"The stack property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def parsed_stack(self):
if 'parsedStack' in self._values:
return self._values['parsedStack']
self._values['parsedStack'] = copy.deepcopy(self._defaults['parsedStack'])
return self._values['parsedStack'] | [
"The parsed_stack property.\n \n Returns:\n (list). the property value. (defaults to: [])\n "
] |
Please provide a description of the function:def parsed_stack(self, value):
if value == self._defaults['parsedStack'] and 'parsedStack' in self._values:
del self._values['parsedStack']
else:
self._values['parsedStack'] = value | [
"The parsed_stack property.\n \n Args:\n value (list). the property value.\n "
] |
Please provide a description of the function:def result_code(self, value):
if value == self._defaults['resultCode'] and 'resultCode' in self._values:
del self._values['resultCode']
else:
self._values['resultCode'] = value | [
"The result_code property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def success(self, value):
if value == self._defaults['success'] and 'success' in self._values:
del self._values['success']
else:
self._values['success'] = value | [
"The success property.\n \n Args:\n value (bool). the property value.\n "
] |
Please provide a description of the function:def target(self, value):
if value == self._defaults['target'] and 'target' in self._values:
del self._values['target']
else:
self._values['target'] = value | [
"The target property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def type(self, value):
if value == self._defaults['type'] and 'type' in self._values:
del self._values['type']
else:
self._values['type'] = value | [
"The type property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def assembly(self, value):
if value == self._defaults['assembly'] and 'assembly' in self._values:
del self._values['assembly']
else:
self._values['assembly'] = value | [
"The assembly property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def file_name(self, value):
if value == self._defaults['fileName'] and 'fileName' in self._values:
del self._values['fileName']
else:
self._values['fileName'] = value | [
"The file_name property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def line(self, value):
if value == self._defaults['line'] and 'line' in self._values:
del self._values['line']
else:
self._values['line'] = value | [
"The line property.\n \n Args:\n value (int). the property value.\n "
] |
Please provide a description of the function:def is_first(self, value):
if value == self._defaults['ai.session.isFirst'] and 'ai.session.isFirst' in self._values:
del self._values['ai.session.isFirst']
else:
self._values['ai.session.isFirst'] = value | [
"The is_first property.\n \n Args:\n value (string). the property value.\n "
] |
Please provide a description of the function:def from_bytes(cls, xbytes: bytes) -> 'BlsEntity':
logger = logging.getLogger(__name__)
logger.debug("BlsEntity::from_bytes: >>>")
c_instance = c_void_p()
do_call(cls.from_bytes_handler, xbytes, len(xbytes), byref(c_instance))
... | [
"\n Creates and Bls entity from bytes representation.\n :param xbytes: Bytes representation of Bls entity\n :return: BLS entity intance\n "
] |
Please provide a description of the function:def as_bytes(self) -> bytes:
logger = logging.getLogger(__name__)
logger.debug("BlsEntity.as_bytes: >>> self: %r", self)
xbytes = POINTER(c_ubyte)()
xbytes_len = c_size_t()
do_call(self.as_bytes_handler, self.c_instance, byr... | [
"\n Returns BLS entity bytes representation.\n :return: BLS entity bytes representation\n "
] |
Please provide a description of the function:def new(cls) -> 'Generator':
logger = logging.getLogger(__name__)
logger.debug("Generator::new: >>>")
c_instance = c_void_p()
do_call(cls.new_handler, byref(c_instance))
res = cls(c_instance)
logger.debug("Generator... | [
"\n Creates and returns random generator point that satisfy BLS algorithm requirements.\n :return: BLS generator\n "
] |
Please provide a description of the function:def new(cls, seed: Optional[bytes]) -> 'SignKey':
logger = logging.getLogger(__name__)
logger.debug("SignKey::new: >>>")
c_instance = c_void_p()
do_call(cls.new_handler, seed, len(seed) if seed is not None else 0, byref(c_instance))
... | [
"\n Creates and returns random (or seeded from seed) BLS sign key.\n :param: seed - Optional seed.\n :return: BLS sign key\n "
] |
Please provide a description of the function:def new(cls, gen: Generator, sign_key: SignKey) -> 'VerKey':
logger = logging.getLogger(__name__)
logger.debug("VerKey::new: >>>")
c_instance = c_void_p()
do_call(cls.new_handler, gen.c_instance, sign_key.c_instance, byref(c_instance... | [
"\n Creates and returns BLS ver key that corresponds to the given generator and sign key.\n :param: gen - Generator\n :param: sign_key - Sign Key\n :return: BLS verification key\n "
] |
Please provide a description of the function:def new(cls, ver_key: VerKey, sign_key: SignKey) -> 'ProofOfPossession':
logger = logging.getLogger(__name__)
logger.debug("ProofOfPossession::new: >>>")
c_instance = c_void_p()
do_call(cls.new_handler, ver_key.c_instance, sign_key.c... | [
"\n Creates and returns BLS proof of possession that corresponds to the given ver key and sign key.\n :param: ver_key - Ver Key\n :param: sign_key - Sign Key\n :return: BLS proof of possession\n "
] |
Please provide a description of the function:def new(cls, signatures: [Signature]) -> 'MultiSignature':
logger = logging.getLogger(__name__)
logger.debug("MultiSignature::new: >>>")
# noinspection PyCallingNonCallable,PyTypeChecker
signature_c_instances = (c_void_p * len(signat... | [
"\n Creates and returns BLS multi signature that corresponds to the given signatures list.\n :param: signature - List of signatures\n :return: BLS multi signature\n "
] |
Please provide a description of the function:def sign(message: bytes, sign_key: SignKey) -> Signature:
logger = logging.getLogger(__name__)
logger.debug("Bls::sign: >>> message: %r, sign_key: %r", message, sign_key)
c_instance = c_void_p()
do_call('indy_crypto_bls_sign',
... | [
"\n Signs the message and returns signature.\n\n :param: message - Message to sign\n :param: sign_key - Sign key\n :return: Signature\n "
] |
Please provide a description of the function:def verify(signature: Signature, message: bytes, ver_key: VerKey, gen: Generator) -> bool:
logger = logging.getLogger(__name__)
logger.debug("Bls::verify: >>> signature: %r, message: %r, ver_key: %r, gen: %r", signature, message, ver_key,
... | [
"\n Verifies the message signature and returns true - if signature valid or false otherwise.\n\n :param: signature - Signature to verify\n :param: message - Message to verify\n :param: ver_key - Verification key\n :param: gen - Generator point\n :return: true if signature v... |
Please provide a description of the function:def verify_pop(pop: ProofOfPossession, ver_key: VerKey, gen: Generator) -> bool:
logger = logging.getLogger(__name__)
logger.debug("Bls::verify_pop: >>> pop: %r, ver_key: %r, gen: %r",
pop,
ver_key,
... | [
"\n Verifies the proof of possession and returns true - if signature valid or false otherwise.\n\n :param: pop - Proof of possession\n :param: ver_key - Verification key\n :param: gen - Generator point\n :return: true if signature valid\n "
] |
Please provide a description of the function:def verify_multi_sig(multi_sig: MultiSignature, message: bytes, ver_keys: [VerKey], gen: Generator) -> bool:
logger = logging.getLogger(__name__)
logger.debug("Bls::verify_multi_sig: >>> multi_sig: %r, message: %r, ver_keys: %r, gen: %r",
... | [
"\n Verifies the message multi signature and returns true - if signature valid or false otherwise.\n\n :param: multi_sig - Multi signature to verify\n :param: message - Message to verify\n :param: ver_keys - List of verification keys\n :param: gen - Generator point\n :retur... |
Please provide a description of the function:def handle_error(self, request: Any, status: int = 500, exc: Any = None, message: Optional[str] = None) -> web.Response:
if self.transport is None:
# client has been disconnected during writing.
if self._access_log:
re... | [
"Handle errors.\n\n Returns HTTP response with specific status code. Logs additional\n information. It always closes current connection."
] |
Please provide a description of the function:def get_meta_attribute(self, param):
return self._get_meta_value(param, getattr(self.app_config, param)) or '' | [
"\n Retrieves django-meta attributes from apphook config instance\n :param param: django-meta attribute passed as key\n "
] |
Please provide a description of the function:def make_published(self, request, queryset):
cnt1 = queryset.filter(
date_published__isnull=True,
publish=False,
).update(date_published=timezone.now(), publish=True)
cnt2 = queryset.filter(
date_published_... | [
" Bulk action to mark selected posts as published. If\n the date_published field is empty the current time is\n saved as date_published.\n queryset must not be empty (ensured by DjangoCMS).\n "
] |
Please provide a description of the function:def make_unpublished(self, request, queryset):
updates = queryset.filter(publish=True)\
.update(publish=False)
messages.add_message(
request, messages.INFO,
__('%(updates)d entry unpublished.',
'%(u... | [
" Bulk action to mark selected posts as UNpublished.\n queryset must not be empty (ensured by DjangoCMS).\n "
] |
Please provide a description of the function:def get_urls(self):
urls = [
url(r'^publish/([0-9]+)/$', self.admin_site.admin_view(self.publish_post),
name='djangocms_blog_publish_article'),
]
urls.extend(super(PostAdmin, self).get_urls())
return urls | [
"\n Customize the modeladmin urls\n "
] |
Please provide a description of the function:def publish_post(self, request, pk):
language = get_language_from_request(request, check_path=True)
try:
post = Post.objects.get(pk=int(pk))
post.publish = True
post.save()
return HttpResponseRedirect(p... | [
"\n Admin view to publish a single post\n\n :param request: request\n :param pk: primary key of the post to publish\n :return: Redirect to the post itself (if found) or fallback urls\n "
] |
Please provide a description of the function:def has_restricted_sites(self, request):
sites = self.get_restricted_sites(request)
return sites and sites.count() == 1 | [
"\n Whether the current user has permission on one site only\n\n :param request: current request\n :return: boolean: user has permission on only one site\n "
] |
Please provide a description of the function:def get_restricted_sites(self, request):
try:
return request.user.get_sites()
except AttributeError: # pragma: no cover
return Site.objects.none() | [
"\n The sites on which the user has permission on.\n\n To return the permissions, the method check for the ``get_sites``\n method on the user instance (e.g.: ``return request.user.get_sites()``)\n which must return the queryset of enabled sites.\n If the attribute does not exists,... |
Please provide a description of the function:def get_fieldsets(self, request, obj=None):
app_config_default = self._app_config_select(request, obj)
if app_config_default is None and request.method == 'GET':
return super(PostAdmin, self).get_fieldsets(request, obj)
if not obj... | [
"\n Customize the fieldsets according to the app settings\n\n :param request: request\n :param obj: post\n :return: fieldsets configuration\n "
] |
Please provide a description of the function:def get_fieldsets(self, request, obj=None):
return [
(None, {
'fields': ('type', 'namespace', 'app_title', 'object_name')
}),
(_('Generic'), {
'fields': (
'config.default... | [
"\n Fieldsets configuration\n "
] |
Please provide a description of the function:def save_model(self, request, obj, form, change):
if 'config.menu_structure' in form.changed_data:
from menus.menu_pool import menu_pool
menu_pool.clear(all=True)
return super(BlogConfigAdmin, self).save_model(request, obj, fo... | [
"\n Clear menu cache when changing menu structure\n "
] |
Please provide a description of the function:def clean_slug(self):
source = self.cleaned_data.get('slug', '')
lang_choice = self.language_code
if not source:
source = slugify(self.cleaned_data.get('title', ''))
qs = Post._default_manager.active_translations(lang_choi... | [
"\n Generate a valid slug, in case the given one is taken\n "
] |
Please provide a description of the function:def get_nodes(self, request):
nodes = []
language = get_language_from_request(request, check_path=True)
current_site = get_current_site(request)
page_site = self.instance.node.site
if self.instance and page_site != current_s... | [
"\n Generates the nodelist\n\n :param request:\n :return: list of nodes\n "
] |
Please provide a description of the function:def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
app = None
config = None
if getattr(request, 'current_page', None) and request.current_page.application_urls:
app = apphook_pool.get_apphook(request.curre... | [
"\n Actual modifier function\n :param request: request\n :param nodes: complete list of nodes\n :param namespace: Menu namespace\n :param root_id: eventual root_id\n :param post_cut: flag for modifier stage\n :param breadcrumb: flag for modifier stage\n :retur... |
Please provide a description of the function:def tagged(self, other_model=None, queryset=None):
tags = self._taglist(other_model, queryset)
return self.get_queryset().filter(tags__in=tags).distinct() | [
"\n Restituisce una queryset di elementi del model taggati,\n o con gli stessi tag di un model o un queryset\n "
] |
Please provide a description of the function:def _taglist(self, other_model=None, queryset=None):
from taggit.models import TaggedItem
filter = None
if queryset is not None:
filter = set()
for item in queryset.all():
filter.update(item.tags.all())... | [
"\n Restituisce una lista di id di tag comuni al model corrente e al model\n o queryset passati come argomento\n "
] |
Please provide a description of the function:def tag_list(self, other_model=None, queryset=None):
from taggit.models import Tag
return Tag.objects.filter(id__in=self._taglist(other_model, queryset)) | [
"\n Restituisce un queryset di tag comuni al model corrente e\n al model o queryset passati come argomento\n "
] |
Please provide a description of the function:def get_months(self, queryset=None, current_site=True):
if queryset is None:
queryset = self.get_queryset()
if current_site:
queryset = queryset.on_site()
dates_qs = queryset.values_list(queryset.start_date_field, quer... | [
"\n Get months with aggregate count (how much posts is in the month).\n Results are ordered by date.\n "
] |
Please provide a description of the function:def liveblog_connect(message, apphook, lang, post):
try:
post = Post.objects.namespace(apphook).language(lang).active_translations(slug=post).get()
except Post.DoesNotExist:
message.reply_channel.send({
'text': json.dumps({'error': 'n... | [
"\n Connect users to the group of the given post according to the given language\n\n Return with an error message if a post cannot be found\n\n :param message: channel connect message\n :param apphook: apphook config namespace\n :param lang: language\n :param post: post slug\n "
] |
Please provide a description of the function:def liveblog_disconnect(message, apphook, lang, post):
try:
post = Post.objects.namespace(apphook).language(lang).active_translations(slug=post).get()
except Post.DoesNotExist:
message.reply_channel.send({
'text': json.dumps({'error':... | [
"\n Disconnect users to the group of the given post according to the given language\n\n Return with an error message if a post cannot be found\n\n :param message: channel connect message\n :param apphook: apphook config namespace\n :param lang: language\n :param post: post slug\n "
] |
Please provide a description of the function:def record_config(self, rec_opt):
ret = self.command(
'configManager.cgi?action=setConfig&{0}'.format(rec_opt)
)
return ret.content.decode('utf-8') | [
"\n rec_opt is the Record options listed as example below:\n\n +----------------------+--------+------------------------------------+\n | ParamName | Value | Description |\n +----------------------+--------+------------------------------------+\n ... |
Please provide a description of the function:def record_mode(self, record_opt, channel=0):
ret = self.command(
'configManager.cgi?action=setConfig&RecordMode'
'[{0}].Mode={1}'.format(channel, record_opt)
)
return ret.content.decode('utf-8') | [
"\n Params:\n\n channel:\n video index, start from 0\n\n record_opt:\n +----------------------------+-----------------+-------------------+\n | ParamName | ParamValue type | Description |\n +----------------------------+-----------------+------... |
Please provide a description of the function:def video_in_option(self, param, profile='Day'):
if profile == 'Day':
field = param
else:
field = '{}Options.{}'.format(profile, param)
return utils.pretty(
[opt for opt in self.video_in_options.split()
... | [
"\n Return video input option.\n\n Params:\n param - parameter, such as 'DayNightColor'\n profile - 'Day', 'Night' or 'Normal'\n "
] |
Please provide a description of the function:def _generate_token(self):
session = self.get_session()
url = self.__base_url('magicBox.cgi?action=getMachineName')
try:
# try old basic method
auth = requests.auth.HTTPBasicAuth(self._user, self._password)
... | [
"Create authentation to use with requests."
] |
Please provide a description of the function:def _set_name(self):
try:
self._name = pretty(self.machine_name)
self._serial = self.serial_number
except AttributeError:
self._name = None
self._serial = None | [
"Set device name."
] |
Please provide a description of the function:def as_dict(self):
cdict = self.__dict__.copy()
redacted = '**********'
cdict['_token'] = redacted
cdict['_password'] = redacted
return cdict | [
"Callback for __dict__."
] |
Please provide a description of the function:def command(self, cmd, retries=None, timeout_cmd=None):
retries = retries or self._retries_default
timeout = timeout_cmd or self._timeout_default
session = self.get_session(retries)
url = self.__base_url(cmd)
for loop in rang... | [
"\n Args:\n cmd - command to execute via http\n timeout_cmd - timeout, default 3sec\n retries - maximum number of retries each connection should attempt\n "
] |
Please provide a description of the function:def event_channels_happened(self, eventcode):
ret = self.command(
'eventManager.cgi?action=getEventIndexes&code={0}'.format(
eventcode)
)
return ret.content.decode('utf-8') | [
"\n Params:\n\n VideoMotion: motion detection event\n VideoLoss: video loss detection event\n VideoBlind: video blind detection event\n AlarmLocal: alarm detection event\n StorageNotExist: storage not exist event\n StorageFailure: storage failure event\n Stora... |
Please provide a description of the function:def str2bool(value):
try:
if isinstance(value, (str, unicode)):
return bool(util.strtobool(value))
except NameError: # python 3
if isinstance(value, str):
return bool(util.strtobool(value))
return bool(value) | [
"\n Args:\n value - text to be converted to boolean\n True values: y, yes, true, t, on, 1\n False values: n, no, false, off, 0\n "
] |
Please provide a description of the function:def to_unit(value, unit='B'):
byte_array = ['B', 'KB', 'MB', 'GB', 'TB']
if not isinstance(value, (int, float)):
value = float(value)
if unit in byte_array:
result = value / 1024**byte_array.index(unit)
return round(result, PRECISIO... | [
"Convert bytes to give unit."
] |
Please provide a description of the function:def extract_audio_video_enabled(param, resp):
return 'true' in [part.split('=')[1] for part in resp.split()
if '.{}Enable='.format(param) in part] | [
"Extract if any audio/video stream enabled from response."
] |
Please provide a description of the function:def enable_audio_video_cmd(param, enable):
cmd = 'configManager.cgi?action=setConfig'
formats = [('Extra', 3), ('Main', 4)]
if param == 'Video':
formats.append(('Snap', 3))
for fmt, num in formats:
for i in range(num):
cmd += ... | [
"Return command to enable/disable all audio/video streams."
] |
Please provide a description of the function:def snapshot(self, channel=0, path_file=None, timeout=None):
ret = self.command(
"snapshot.cgi?channel={0}".format(channel),
timeout_cmd=timeout
)
if path_file:
with open(path_file, 'wb') as out_file:
... | [
"\n Args:\n\n channel:\n Values according with Amcrest API:\n 0 - regular snapshot\n 1 - motion detection snapshot\n 2 - alarm snapshot\n\n If no channel param is used, default is 0\n\n path_file:\n ... |
Please provide a description of the function:def add_user(self, username, password, group, sharable=True,
reserved=False, memo=None):
cmd = "userManager.cgi?action=addUser&user.Name={0}" \
"&user.Password={1}&user.Group={2}&user.Sharable={3}" \
"&user.Reser... | [
"\n Params:\n username - username for user\n password - password for user\n group - string the range is \"admin\" and \"user\". In different group,\n the user has different authorities.\n\n sharable - bool, true means allow multi-point login\n\n ... |
Please provide a description of the function:def modify_password(self, username, newpwd, oldpwd):
ret = self.command(
'userManager.cgi?action=modifyPassword&name={0}&pwd={1}'
'&pwdOld={2}'.format(username, newpwd, oldpwd)
)
return ret.content.decode('utf-8') | [
"\n Params:\n username - user name\n newpwd - new password\n oldpwd - old password\n "
] |
Please provide a description of the function:def modify_user(self, username, attribute, value):
cmd = "userManager.cgi?action=modifyUser&name={0}".format(
username)
if attribute.lower() == "group":
cmd += "&user.Group=%s" % value.lower()
elif attribute.lower()... | [
"\n Params:\n username - username for user\n attribute - the attribute name that will change:\n group, sharable, reserved, memo\n\n value - the new value for attribute\n "
] |
Please provide a description of the function:def zoom_in(self, action=None, channel=0):
ret = self.command(
'ptz.cgi?action={0}&channel={1}&code=ZoomTele&arg1=0'
'&arg2=0&arg3=0'.format(action, channel)
)
return ret.content.decode('utf-8') | [
"\n Params:\n action - start or stop\n channel - channel number\n\n The magic of zoom in 1x, 2x etc. is the timer between the cmd\n 'start' and cmd 'stop'. My suggestion for start/stop cmd is 0.5 sec\n "
] |
Please provide a description of the function:def go_to_preset(self, action=None, channel=0, preset_point_number=1):
ret = self.command(
'ptz.cgi?action={0}&channel={1}&code=GotoPreset&arg1=0'
'&arg2={2}&arg3=0'.format(action, channel, preset_point_number)
)
retur... | [
"\n Params:\n action - start or stop\n channel - channel number\n preset_point_number - preset point number\n "
] |
Please provide a description of the function:def tour(self, action='start', channel=0, start=True, tour_path_number=1):
ret = self.command(
'ptz.cgi?action={0}&channel={1}&code={2}Tour&arg1={3}'
'&arg2=0&arg3=0&arg4=0'.format(
action, channel, 'Start' if start el... | [
"\n Params:\n action - start or stop\n channel - channel number\n start - True (StartTour) or False (StopTour)\n tour_path_number - tour path number\n "
] |
Please provide a description of the function:def move_right_down(self, action=None, channel=0,
vertical_speed=1, horizontal_speed=1):
ret = self.command(
'ptz.cgi?action={0}&channel={1}&code=RightDown&arg1=0'
'&arg2={2}&arg3=0'.format(action, channel, ve... | [
"\n Params:\n action - start or stop\n channel - channel number\n vertical_speed - range is 1-8\n horizontal_speed - range is 1-8\n "
] |
Please provide a description of the function:def current_time(self, date):
ret = self.command(
'global.cgi?action=setCurrentTime&time={0}'.format(date)
)
if "ok" in ret.content.decode('utf-8').lower():
return True
return False | [
"\n According with API:\n The time format is \"Y-M-D H-m-S\". It is not be effected by Locales.\n TimeFormat in SetLocalesConfig\n\n Params:\n date = \"Y-M-D H-m-S\"\n Example: 2016-10-28 13:48:00\n\n Return: True\n "
] |
Please provide a description of the function:def realtime_stream(self, channel=1, typeno=0, path_file=None):
ret = self.command(
'realmonitor.cgi?action=getStream&channel={0}&subtype={1}'.format(
channel, typeno)
)
if path_file:
with open(path_fi... | [
"\n If the stream is redirect to a file, use mplayer tool to\n visualize the video record\n\n camera.realtime_stream(path_file=\"/home/user/Desktop/myvideo)\n $ mplayer /home/user/Desktop/myvideo\n "
] |
Please provide a description of the function:def rtsp_url(self, channelno=None, typeno=None):
if channelno is None:
channelno = 1
if typeno is None:
typeno = 0
cmd = 'cam/realmonitor?channel={0}&subtype={1}'.format(
channelno, typeno)
try:
... | [
"\n Return RTSP streaming url\n\n Params:\n channelno: integer, the video channel index which starts from 1,\n default 1 if not specified.\n\n typeno: the stream type, default 0 if not specified. It can be\n the following value:\n\n ... |
Please provide a description of the function:def mjpeg_url(self, channelno=None, typeno=None):
if channelno is None:
channelno = 0
if typeno is None:
typeno = 1
cmd = "mjpg/video.cgi?channel={0}&subtype={1}".format(
channelno, typeno)
return... | [
"\n Return MJPEG streaming url\n\n Params:\n channelno: integer, the video channel index which starts from 1,\n default 1 if not specified.\n\n typeno: the stream type, default 0 if not specified. It can be\n the following value:\n\n ... |
Please provide a description of the function:def mjpg_stream(self, channelno=None, typeno=None, path_file=None):
cmd = self.mjpeg_url(channelno=channelno, typeno=typeno)
ret = self.command(cmd)
if path_file:
with open(path_file, 'wb') as out_file:
shutil.cop... | [
"\n Params:\n channelno: integer, the video channel index which starts from 1,\n default 1 if not specified.\n\n typeno: the stream type, default 0 if not specified. It can be\n the following value:\n\n 0-Main Stream\n ... |
Please provide a description of the function:def scan_devices(self, subnet, timeout=None):
# Maximum range from mask
# Format is mask: max_range
max_range = {
16: 256,
24: 256,
25: 128,
27: 32,
28: 16,
29: 8,
... | [
"\n Scan cameras in a range of ips\n\n Params:\n subnet - subnet, i.e: 192.168.1.0/24\n if mask not used, assuming mask 24\n\n timeout_sec - timeout in sec\n\n Returns:\n "
] |
Please provide a description of the function:def telnet_config(self, status):
ret = self.command(
'configManager.cgi?action=setConfig&Telnet.Enable={0}'.format(
status)
)
return ret.content.decode('utf-8') | [
"\n status:\n false - Telnet is disabled\n true - Telnet is enabled\n "
] |
Please provide a description of the function:def upnp_config(self, upnp_opt):
ret = self.command(
'configManager.cgi?action=setConfig&{0}'.format(upnp_opt)
)
return ret.content.decode('utf-8') | [
"\n 01/21/2017\n\n Note 1:\n -------\n The current SDK from Amcrest is case sensitive, do not\n mix UPPERCASE options with lowercase. Otherwise it will\n ignore your call.\n\n Example:\n\n Correct:\n \"UPnP.Enable=true&UPnP.MapTable[0].Protocol=... |
Please provide a description of the function:def ntp_config(self, ntp_opt):
ret = self.command(
'configManager.cgi?action=setConfig&{0}'.format(ntp_opt)
)
return ret.content.decode('utf-8') | [
"\n ntp_opt is the NTP options listed as example below:\n\n NTP.Address=clock.isc.org\n NTP.Enable=false\n NTP.Port=38\n NTP.TimeZone=9\n NTP.UpdatePeriod=31\n\n ntp_opt format:\n <paramName>=<paramValue>[&<paramName>=<paramValue>...]\n "
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.