_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q236400
Servicegroup.get_services_by_explosion
train
def get_services_by_explosion(self, servicegroups): # pylint: disable=access-member-before-definition """ Get all services of this servicegroup and add it in members container :param servicegroups: servicegroups object :type servicegroups: alignak.objects.servicegroup.Servicegro...
python
{ "resource": "" }
q236401
Servicegroups.explode
train
def explode(self): """ Get services and put them in members container :return: None """ # We do not want a same service group to be exploded again and again # so we tag it for tmp_sg in list(self.items.values()): tmp_sg.already_exploded = False ...
python
{ "resource": "" }
q236402
setup_logger
train
def setup_logger(logger_configuration_file, log_dir=None, process_name='', log_file=''): # pylint: disable=too-many-branches """ Configure the provided logger - get and update the content of the Json configuration file - configure the logger with this file If a log_dir and process_name are prov...
python
{ "resource": "" }
q236403
set_log_console
train
def set_log_console(log_level=logging.INFO): """Set the Alignak daemons logger have a console log handler. This is only used for the arbiter verify mode to add a console log handler. :param log_level: log level :return: n/a """ # Change the logger and all its handlers log level logger_ = l...
python
{ "resource": "" }
q236404
set_log_level
train
def set_log_level(log_level=logging.INFO, handlers=None): """Set the Alignak logger log level. This is mainly used for the arbiter verify code to set the log level at INFO level whatever the configured log level is set. This is also used when changing the daemon log level thanks to the WS interface If...
python
{ "resource": "" }
q236405
make_monitoring_log
train
def make_monitoring_log(level, message, timestamp=None, to_logger=False): """ Function used to build the monitoring log. Emit a log message with the provided level to the monitoring log logger. Build a Brok typed as monitoring_log with the provided message When to_logger is True, the information i...
python
{ "resource": "" }
q236406
Contact.want_service_notification
train
def want_service_notification(self, notifways, timeperiods, timestamp, state, n_type, business_impact, cmd=None): """Check if notification options match the state of the service :param timestamp: time we want to notify the contact (usually now) :type timestamp:...
python
{ "resource": "" }
q236407
Contact.want_host_notification
train
def want_host_notification(self, notifways, timeperiods, timestamp, state, n_type, business_impact, cmd=None): """Check if notification options match the state of the host :param timestamp: time we want to notify the contact (usually now) :type timestamp: int ...
python
{ "resource": "" }
q236408
Contacts.explode
train
def explode(self, contactgroups, notificationways): """Explode all contact for each contactsgroup :param contactgroups: contactgroups to explode :type contactgroups: alignak.objects.contactgroup.Contactgroups :param notificationways: notificationways to explode :type notificatio...
python
{ "resource": "" }
q236409
InnerRetention.hook_save_retention
train
def hook_save_retention(self, scheduler): """Save retention data to a Json formated file :param scheduler: scheduler instance of alignak :type scheduler: object :return: None """ if not self.enabled: logger.warning("Alignak retention module is not enabled." ...
python
{ "resource": "" }
q236410
CheckModulation.get_check_command
train
def get_check_command(self, timeperiods, t_to_go): """Get the check_command if we are in the check period modulation :param t_to_go: time to check if we are in the timeperiod :type t_to_go: :return: A check command if we are in the check period, None otherwise :rtype: alignak.ob...
python
{ "resource": "" }
q236411
CheckModulations.linkify
train
def linkify(self, timeperiods, commands): """Replace check_period by real Timeperiod object into each CheckModulation Replace check_command by real Command object into each CheckModulation :param timeperiods: timeperiods to link to :type timeperiods: alignak.objects.timeperiod.Timeperio...
python
{ "resource": "" }
q236412
CheckModulations.new_inner_member
train
def new_inner_member(self, name=None, params=None): """Create a CheckModulation object and add it to items :param name: CheckModulation name :type name: str :param params: parameters to init CheckModulation :type params: dict :return: None TODO: Remove this defau...
python
{ "resource": "" }
q236413
ArduinoBoard.open
train
def open(self): """ Open the serial connection. """ if not self._is_connected: print("Connecting to arduino on {}... ".format(self.device),end="") self.comm = serial.Serial() self.comm.port = self.device self.comm.baudrate = ...
python
{ "resource": "" }
q236414
ArduinoBoard.close
train
def close(self): """ Close serial connection. """ if self._is_connected: self.comm.close() self._is_connected = False
python
{ "resource": "" }
q236415
CmdMessenger.receive
train
def receive(self,arg_formats=None): """ Recieve commands coming off the serial port. arg_formats is an optimal keyword that specifies the formats to use to parse incoming arguments. If specified here, arg_formats supercedes the formats specified on initialization. ""...
python
{ "resource": "" }
q236416
CmdMessenger._send_char
train
def _send_char(self,value): """ Convert a single char to a bytes object. """ if type(value) != str and type(value) != bytes: err = "char requires a string or bytes array of length 1" raise ValueError(err) if len(value) != 1: err = "char must ...
python
{ "resource": "" }
q236417
CmdMessenger._send_byte
train
def _send_byte(self,value): """ Convert a numerical value into an integer, then to a byte object. Check bounds for byte. """ # Coerce to int. This will throw a ValueError if the value can't # actually be converted. if type(value) != int: new_value = i...
python
{ "resource": "" }
q236418
CmdMessenger._send_int
train
def _send_int(self,value): """ Convert a numerical value into an integer, then to a bytes object Check bounds for signed int. """ # Coerce to int. This will throw a ValueError if the value can't # actually be converted. if type(value) != int: new_val...
python
{ "resource": "" }
q236419
CmdMessenger._send_unsigned_int
train
def _send_unsigned_int(self,value): """ Convert a numerical value into an integer, then to a bytes object. Check bounds for unsigned int. """ # Coerce to int. This will throw a ValueError if the value can't # actually be converted. if type(value) != int: ...
python
{ "resource": "" }
q236420
CmdMessenger._send_long
train
def _send_long(self,value): """ Convert a numerical value into an integer, then to a bytes object. Check bounds for signed long. """ # Coerce to int. This will throw a ValueError if the value can't # actually be converted. if type(value) != int: new_...
python
{ "resource": "" }
q236421
CmdMessenger._send_unsigned_long
train
def _send_unsigned_long(self,value): """ Convert a numerical value into an integer, then to a bytes object. Check bounds for unsigned long. """ # Coerce to int. This will throw a ValueError if the value can't # actually be converted. if type(value) != int: ...
python
{ "resource": "" }
q236422
CmdMessenger._send_string
train
def _send_string(self,value): """ Convert a string to a bytes object. If value is not a string, it is be converted to one with a standard string.format call. """ if type(value) != bytes: value = "{}".format(value).encode("ascii") return value
python
{ "resource": "" }
q236423
CmdMessenger._send_bool
train
def _send_bool(self,value): """ Convert a boolean value into a bytes object. Uses 0 and 1 as output. """ # Sanity check. if type(value) != bool and value not in [0,1]: err = "{} is not boolean.".format(value) raise ValueError(err) return struct....
python
{ "resource": "" }
q236424
CmdMessenger._recv_guess
train
def _recv_guess(self,value): """ Take the binary spew and try to make it into a float or integer. If that can't be done, return a string. Note: this is generally a bad idea, as values can be seriously mangled by going from float -> string -> float. You'll generally be bette...
python
{ "resource": "" }
q236425
BaseGELFHandler._add_full_message
train
def _add_full_message(gelf_dict, record): """Add the ``full_message`` field to the ``gelf_dict`` if any traceback information exists within the logging record :param gelf_dict: dictionary representation of a GELF log. :type gelf_dict: dict :param record: :class:`logging.LogReco...
python
{ "resource": "" }
q236426
BaseGELFHandler._resolve_host
train
def _resolve_host(fqdn, localname): """Resolve the ``host`` GELF field :param fqdn: Boolean indicating whether to use :meth:`socket.getfqdn` to obtain the ``host`` GELF field. :type fqdn: bool :param localname: Use specified hostname as the ``host`` GELF field. :typ...
python
{ "resource": "" }
q236427
BaseGELFHandler._add_debugging_fields
train
def _add_debugging_fields(gelf_dict, record): """Add debugging fields to the given ``gelf_dict`` :param gelf_dict: dictionary representation of a GELF log. :type gelf_dict: dict :param record: :class:`logging.LogRecord` to extract debugging fields from to insert into the gi...
python
{ "resource": "" }
q236428
BaseGELFHandler._add_extra_fields
train
def _add_extra_fields(gelf_dict, record): """Add extra fields to the given ``gelf_dict`` However, this does not add additional fields in to ``message_dict`` that are either duplicated from standard :class:`logging.LogRecord` attributes, duplicated from the python logging module source ...
python
{ "resource": "" }
q236429
BaseGELFHandler._pack_gelf_dict
train
def _pack_gelf_dict(gelf_dict): """Convert a given ``gelf_dict`` to a JSON-encoded string, thus, creating an uncompressed GELF log ready for consumption by Graylog. Since we cannot be 100% sure of what is contained in the ``gelf_dict`` we have to do some sanitation. :param gelf...
python
{ "resource": "" }
q236430
BaseGELFHandler._sanitize_to_unicode
train
def _sanitize_to_unicode(obj): """Convert all strings records of the object to unicode :param obj: object to sanitize to unicode. :type obj: object :return: Unicode string representation of the given object. :rtype: str """ if isinstance(obj, dict): ...
python
{ "resource": "" }
q236431
BaseGELFHandler._object_to_json
train
def _object_to_json(obj): """Convert objects that cannot be natively serialized into JSON into their string representation For datetime based objects convert them into their ISO formatted string as specified by :meth:`datetime.datetime.isoformat`. :param obj: object to convert ...
python
{ "resource": "" }
q236432
GELFTLSHandler.makeSocket
train
def makeSocket(self, timeout=1): """Override SocketHandler.makeSocket, to allow creating wrapped TLS sockets""" plain_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if hasattr(plain_socket, 'settimeout'): plain_socket.settimeout(timeout) wrapped_socket =...
python
{ "resource": "" }
q236433
to_unicode
train
def to_unicode(string): """ Ensure a passed string is unicode """ if isinstance(string, six.binary_type): return string.decode('utf8') if isinstance(string, six.text_type): return string if six.PY2: return unicode(string) return str(string)
python
{ "resource": "" }
q236434
to_utf8
train
def to_utf8(string): """ Encode a string as a UTF8 bytestring. This function could be passed a bytestring or unicode string so must distinguish between the two. """ if isinstance(string, six.text_type): return string.encode('utf8') if isinstance(string, six.binary_type): return ...
python
{ "resource": "" }
q236435
dict_to_unicode
train
def dict_to_unicode(raw_dict): """ Ensure all keys and values in a dict are unicode. The passed dict is assumed to have lists for all values. """ decoded = {} for key, value in raw_dict.items(): decoded[to_unicode(key)] = map( to_unicode, value) return decoded
python
{ "resource": "" }
q236436
unicode_urlencode
train
def unicode_urlencode(query, doseq=True): """ Custom wrapper around urlencode to support unicode Python urlencode doesn't handle unicode well so we need to convert to bytestrings before using it: http://stackoverflow.com/questions/6480723/urllib-urlencode-doesnt-like-unicode-values-how-about-this-w...
python
{ "resource": "" }
q236437
parse
train
def parse(url_str): """ Extract all parts from a URL string and return them as a dictionary """ url_str = to_unicode(url_str) result = urlparse(url_str) netloc_parts = result.netloc.rsplit('@', 1) if len(netloc_parts) == 1: username = password = None host = netloc_parts[0] ...
python
{ "resource": "" }
q236438
URL.netloc
train
def netloc(self): """ Return the netloc """ url = self._tuple if url.username and url.password: netloc = '%s:%s@%s' % (url.username, url.password, url.host) elif url.username and not url.password: netloc = '%s@%s' % (url.username, url.host) ...
python
{ "resource": "" }
q236439
URL.host
train
def host(self, value=None): """ Return the host :param string value: new host string """ if value is not None: return URL._mutate(self, host=value) return self._tuple.host
python
{ "resource": "" }
q236440
URL.username
train
def username(self, value=None): """ Return or set the username :param string value: the new username to use :returns: string or new :class:`URL` instance """ if value is not None: return URL._mutate(self, username=value) return unicode_unquote(self._t...
python
{ "resource": "" }
q236441
URL.password
train
def password(self, value=None): """ Return or set the password :param string value: the new password to use :returns: string or new :class:`URL` instance """ if value is not None: return URL._mutate(self, password=value) return unicode_unquote(self._t...
python
{ "resource": "" }
q236442
URL.scheme
train
def scheme(self, value=None): """ Return or set the scheme. :param string value: the new scheme to use :returns: string or new :class:`URL` instance """ if value is not None: return URL._mutate(self, scheme=value) return self._tuple.scheme
python
{ "resource": "" }
q236443
URL.path
train
def path(self, value=None): """ Return or set the path :param string value: the new path to use :returns: string or new :class:`URL` instance """ if value is not None: if not value.startswith('/'): value = '/' + value encoded_value...
python
{ "resource": "" }
q236444
URL.query
train
def query(self, value=None): """ Return or set the query string :param string value: the new query string to use :returns: string or new :class:`URL` instance """ if value is not None: return URL._mutate(self, query=value) return self._tuple.query
python
{ "resource": "" }
q236445
URL.port
train
def port(self, value=None): """ Return or set the port :param string value: the new port to use :returns: string or new :class:`URL` instance """ if value is not None: return URL._mutate(self, port=value) return self._tuple.port
python
{ "resource": "" }
q236446
URL.path_segment
train
def path_segment(self, index, value=None, default=None): """ Return the path segment at the given index :param integer index: :param string value: the new segment value :param string default: the default value to return if no path segment exists with the given index """ ...
python
{ "resource": "" }
q236447
URL.path_segments
train
def path_segments(self, value=None): """ Return the path segments :param list value: the new path segments to use """ if value is not None: encoded_values = map(unicode_quote_path_segment, value) new_path = '/' + '/'.join(encoded_values) retur...
python
{ "resource": "" }
q236448
URL.add_path_segment
train
def add_path_segment(self, value): """ Add a new path segment to the end of the current string :param string value: the new path segment to use Example:: >>> u = URL('http://example.com/foo/') >>> u.add_path_segment('bar').as_string() 'http://exampl...
python
{ "resource": "" }
q236449
URL.query_param
train
def query_param(self, key, value=None, default=None, as_list=False): """ Return or set a query parameter for the given key The value can be a list. :param string key: key to look for :param string default: value to return if ``key`` isn't found :param boolean as_list: w...
python
{ "resource": "" }
q236450
URL.append_query_param
train
def append_query_param(self, key, value): """ Append a query parameter :param string key: The query param key :param string value: The new value """ values = self.query_param(key, as_list=True, default=[]) values.append(value) return self.query_param(key,...
python
{ "resource": "" }
q236451
URL.query_params
train
def query_params(self, value=None): """ Return or set a dictionary of query params :param dict value: new dictionary of values """ if value is not None: return URL._mutate(self, query=unicode_urlencode(value, doseq=True)) query = '' if self._tuple.query is No...
python
{ "resource": "" }
q236452
URL.remove_query_param
train
def remove_query_param(self, key, value=None): """ Remove a query param from a URL Set the value parameter if removing from a list. :param string key: The key to delete :param string value: The value of the param to delete (of more than one) """ parse_result = s...
python
{ "resource": "" }
q236453
expand
train
def expand(template, variables=None): """ Expand a URL template string using the passed variables """ if variables is None: variables = {} return patterns.sub(functools.partial(_replace, variables), template)
python
{ "resource": "" }
q236454
_format_pair_no_equals
train
def _format_pair_no_equals(explode, separator, escape, key, value): """ Format a key, value pair but don't include the equals sign when there is no value """ if not value: return key return _format_pair(explode, separator, escape, key, value)
python
{ "resource": "" }
q236455
_format_pair_with_equals
train
def _format_pair_with_equals(explode, separator, escape, key, value): """ Format a key, value pair including the equals sign when there is no value """ if not value: return key + '=' return _format_pair(explode, separator, escape, key, value)
python
{ "resource": "" }
q236456
_replace
train
def _replace(variables, match): """ Return the appropriate replacement for `match` using the passed variables """ expression = match.group(1) # Look-up chars and functions for the specified operator (prefix_char, separator_char, split_fn, escape_fn, format_fn) = operator_map.get(expression...
python
{ "resource": "" }
q236457
ApiClient.predict
train
def predict(self, document_path: str, model_name: str, consent_id: str = None) -> Prediction: """Run inference and create prediction on document. This method takes care of creating and uploading a document specified by document_path. as well as running inference using model specified by model_na...
python
{ "resource": "" }
q236458
ApiClient.send_feedback
train
def send_feedback(self, document_id: str, feedback: List[Field]) -> dict: """Send feedback to the model. This method takes care of sending feedback related to document specified by document_id. Feedback consists of ground truth values for the document specified as a list of Field instances. ...
python
{ "resource": "" }
q236459
extra_what
train
def extra_what(file, h=None): """Code mostly copied from imghdr.what""" tests = [] def test_pdf(h, f): if b'PDF' in h[0:10]: return 'pdf' tests.append(test_pdf) f = None try: if h is None: if isinstance(file, (str, PathLike)): f = open(f...
python
{ "resource": "" }
q236460
Client.put_document
train
def put_document(document_path: str, content_type: str, presigned_url: str) -> str: """Convenience method for putting a document to presigned url. >>> from las import Client >>> client = Client(endpoint='<api endpoint>') >>> client.put_document(document_path='document.jpeg', content_typ...
python
{ "resource": "" }
q236461
ShareInfo.get_expiration
train
def get_expiration(self): """Returns the expiration date. :returns: expiration date :rtype: datetime object """ exp = self._get_int('expiration') if exp is not None: return datetime.datetime.fromtimestamp( exp ) return None
python
{ "resource": "" }
q236462
Client.login
train
def login(self, user_id, password): """Authenticate to ownCloud. This will create a session on the server. :param user_id: user id :param password: password :raises: HTTPResponseError in case an HTTP error status was returned """ self._session = requests.session...
python
{ "resource": "" }
q236463
Client.file_info
train
def file_info(self, path): """Returns the file info for the given remote file :param path: path to the remote file :returns: file info :rtype: :class:`FileInfo` object or `None` if file was not found :raises: HTTPResponseError in case an HTTP error status was returne...
python
{ "resource": "" }
q236464
Client.get_file_contents
train
def get_file_contents(self, path): """Returns the contents of a remote file :param path: path to the remote file :returns: file contents :rtype: binary data :raises: HTTPResponseError in case an HTTP error status was returned """ path = self._normalize_path(path)...
python
{ "resource": "" }
q236465
Client.get_directory_as_zip
train
def get_directory_as_zip(self, remote_path, local_file): """Downloads a remote directory as zip :param remote_path: path to the remote directory to download :param local_file: path and name of the target local file :returns: True if the operation succeeded, False otherwise :rais...
python
{ "resource": "" }
q236466
Client.put_directory
train
def put_directory(self, target_path, local_directory, **kwargs): """Upload a directory with all its contents :param target_path: path of the directory to upload into :param local_directory: path to the local directory to upload :param \*\*kwargs: optional arguments that ``put_file`` acc...
python
{ "resource": "" }
q236467
Client._put_file_chunked
train
def _put_file_chunked(self, remote_path, local_source_file, **kwargs): """Uploads a file using chunks. If the file is smaller than ``chunk_size`` it will be uploaded directly. :param remote_path: path to the target file. A target directory can also be specified instead by appending a "/...
python
{ "resource": "" }
q236468
Client.list_open_remote_share
train
def list_open_remote_share(self): """List all pending remote shares :returns: array of pending remote shares :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_request( 'GET', self.OCS_SERVICE_SHARE, ...
python
{ "resource": "" }
q236469
Client.accept_remote_share
train
def accept_remote_share(self, share_id): """Accepts a remote share :param share_id: Share ID (int) :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP error status was returned """ if not isinstance(share_id, int): ...
python
{ "resource": "" }
q236470
Client.update_share
train
def update_share(self, share_id, **kwargs): """Updates a given share :param share_id: (int) Share ID :param perms: (int) update permissions (see share_file_with_user() below) :param password: (string) updated password for public link Share :param public_upload: (boolean) enable/...
python
{ "resource": "" }
q236471
Client.share_file_with_link
train
def share_file_with_link(self, path, **kwargs): """Shares a remote file with link :param path: path to the remote file to share :param perms (optional): permission of the shared object defaults to read only (1) :param public_upload (optional): allows users to upload files or fol...
python
{ "resource": "" }
q236472
Client.is_shared
train
def is_shared(self, path): """Checks whether a path is already shared :param path: path to the share to be checked :returns: True if the path is already shared, else False :raises: HTTPResponseError in case an HTTP error status was returned """ # make sure that the path ...
python
{ "resource": "" }
q236473
Client.get_share
train
def get_share(self, share_id): """Returns share information about known share :param share_id: id of the share to be checked :returns: instance of ShareInfo class :raises: ResponseError in case an HTTP error status was returned """ if (share_id is None) or not (isinstanc...
python
{ "resource": "" }
q236474
Client.get_shares
train
def get_shares(self, path='', **kwargs): """Returns array of shares :param path: path to the share to be checked :param reshares: (optional, boolean) returns not only the shares from the current user but all shares from the given file (default: False) :param subfiles: (optio...
python
{ "resource": "" }
q236475
Client.create_user
train
def create_user(self, user_name, initial_password): """Create a new user with an initial password via provisioning API. It is not an error, if the user already existed before. If you get back an error 999, then the provisioning API is not enabled. :param user_name: name of user to be c...
python
{ "resource": "" }
q236476
Client.delete_user
train
def delete_user(self, user_name): """Deletes a user via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param user_name: name of user to be deleted :returns: True on success :raises: HTTPResponseError in case an HTTP error status was r...
python
{ "resource": "" }
q236477
Client.search_users
train
def search_users(self, user_name): """Searches for users via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param user_name: name of user to be searched for :returns: list of usernames that contain user_name as substring :raises: HTTP...
python
{ "resource": "" }
q236478
Client.set_user_attribute
train
def set_user_attribute(self, user_name, key, value): """Sets a user attribute :param user_name: name of user to modify :param key: key of the attribute to set :param value: value to set :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError...
python
{ "resource": "" }
q236479
Client.add_user_to_group
train
def add_user_to_group(self, user_name, group_name): """Adds a user to a group. :param user_name: name of user to be added :param group_name: name of group user is to be added to :returns: True if user added :raises: HTTPResponseError in case an HTTP error status was returned ...
python
{ "resource": "" }
q236480
Client.get_user_groups
train
def get_user_groups(self, user_name): """Get a list of groups associated to a user. :param user_name: name of user to list groups :returns: list of groups :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_request( ...
python
{ "resource": "" }
q236481
Client.get_user
train
def get_user(self, user_name): """Retrieves information about a user :param user_name: name of user to query :returns: Dictionary of information about user :raises: ResponseError in case an HTTP error status was returned """ res = self._make_ocs_request( 'G...
python
{ "resource": "" }
q236482
Client.get_user_subadmin_groups
train
def get_user_subadmin_groups(self, user_name): """Get a list of subadmin groups associated to a user. :param user_name: name of user :returns: list of subadmin groups :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_request...
python
{ "resource": "" }
q236483
Client.share_file_with_user
train
def share_file_with_user(self, path, user, **kwargs): """Shares a remote file with specified user :param path: path to the remote file to share :param user: name of the user whom we want to share a file/folder :param perms (optional): permissions of the shared object default...
python
{ "resource": "" }
q236484
Client.delete_group
train
def delete_group(self, group_name): """Delete a group via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param group_name: name of group to be deleted :returns: True if group deleted :raises: HTTPResponseError in case an HTTP error st...
python
{ "resource": "" }
q236485
Client.get_groups
train
def get_groups(self): """Get groups via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :returns: list of groups :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_request( ...
python
{ "resource": "" }
q236486
Client.get_group_members
train
def get_group_members(self, group_name): """Get group members via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param group_name: name of group to list members :returns: list of group members :raises: HTTPResponseError in case an HTT...
python
{ "resource": "" }
q236487
Client.group_exists
train
def group_exists(self, group_name): """Checks a group via provisioning API. If you get back an error 999, then the provisioning API is not enabled. :param group_name: name of group to be checked :returns: True if group exists :raises: HTTPResponseError in case an HTTP error sta...
python
{ "resource": "" }
q236488
Client.share_file_with_group
train
def share_file_with_group(self, path, group, **kwargs): """Shares a remote file with specified group :param path: path to the remote file to share :param group: name of the group with which we want to share a file/folder :param perms (optional): permissions of the shared object ...
python
{ "resource": "" }
q236489
Client.get_attribute
train
def get_attribute(self, app=None, key=None): """Returns an application attribute :param app: application id :param key: attribute key or None to retrieve all values for the given application :returns: attribute value if key was specified, or an array of tuples (k...
python
{ "resource": "" }
q236490
Client.set_attribute
train
def set_attribute(self, app, key, value): """Sets an application attribute :param app: application id :param key: key of the attribute to set :param value: value to set :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP ...
python
{ "resource": "" }
q236491
Client.get_apps
train
def get_apps(self): """ List all enabled apps through the provisioning api. :returns: a dict of apps, with values True/False, representing the enabled state. :raises: HTTPResponseError in case an HTTP error status was returned """ ena_apps = {} res = self._make_ocs_requ...
python
{ "resource": "" }
q236492
Client.enable_app
train
def enable_app(self, appname): """Enable an app through provisioning_api :param appname: Name of app to be enabled :returns: True if the operation succeeded, False otherwise :raises: HTTPResponseError in case an HTTP error status was returned """ res = self._make_ocs_r...
python
{ "resource": "" }
q236493
Client._encode_string
train
def _encode_string(s): """Encodes a unicode instance to utf-8. If a str is passed it will simply be returned :param s: str or unicode to encode :returns: encoded output as str """ if six.PY2 and isinstance(s, unicode): return s.encode('utf-8') return ...
python
{ "resource": "" }
q236494
Client._check_ocs_status
train
def _check_ocs_status(tree, accepted_codes=[100]): """Checks the status code of an OCS request :param tree: response parsed with elementtree :param accepted_codes: list of statuscodes we consider good. E.g. [100,102] can be used to accept a POST returning an 'already exists' cond...
python
{ "resource": "" }
q236495
Client.make_ocs_request
train
def make_ocs_request(self, method, service, action, **kwargs): """Makes a OCS API request and analyses the response :param method: HTTP method :param service: service name :param action: action path :param \*\*kwargs: optional arguments that ``requests.Request.request`` accepts ...
python
{ "resource": "" }
q236496
Client._make_ocs_request
train
def _make_ocs_request(self, method, service, action, **kwargs): """Makes a OCS API request :param method: HTTP method :param service: service name :param action: action path :param \*\*kwargs: optional arguments that ``requests.Request.request`` accepts :returns :class:`...
python
{ "resource": "" }
q236497
Client._make_dav_request
train
def _make_dav_request(self, method, path, **kwargs): """Makes a WebDAV request :param method: HTTP method :param path: remote path of the targetted file :param \*\*kwargs: optional arguments that ``requests.Request.request`` accepts :returns array of :class:`FileInfo` if the res...
python
{ "resource": "" }
q236498
Client._parse_dav_response
train
def _parse_dav_response(self, res): """Parses the DAV responses from a multi-status response :param res: DAV response :returns array of :class:`FileInfo` or False if the operation did not succeed """ if res.status_code == 207: tree = ET.fromstring(res.content...
python
{ "resource": "" }
q236499
Client._parse_dav_element
train
def _parse_dav_element(self, dav_response): """Parses a single DAV element :param dav_response: DAV response :returns :class:`FileInfo` """ href = parse.unquote( self._strip_dav_path(dav_response.find('{DAV:}href').text) ) if six.PY2: hre...
python
{ "resource": "" }