text
stringlengths
81
112k
Run **POST** against */api/alerts/* to create or update alert. If alert with posted scope and alert_type already exists - it will be updated. Only users with staff privileges can create alerts. Request example: .. code-block:: javascript POST /api/alerts/ Accept: appli...
To close alert - run **POST** against */api/alerts/<alert_uuid>/close/*. No data is required. Only users with staff privileges can close alerts. def close(self, request, *args, **kwargs): """ To close alert - run **POST** against */api/alerts/<alert_uuid>/close/*. No data is required. O...
To acknowledge alert - run **POST** against */api/alerts/<alert_uuid>/acknowledge/*. No payload is required. All users that can see alerts can also acknowledge it. If alert is already acknowledged endpoint will return error with code 409(conflict). def acknowledge(self, request, *args, **kwargs): ...
To get count of alerts per severities - run **GET** request against */api/alerts/stats/*. This endpoint supports all filters that are available for alerts list (*/api/alerts/*). Response example: .. code-block:: javascript { "debug": 2, "error": 1, ...
To create new web hook issue **POST** against */api/hooks-web/* as an authenticated user. You should specify list of event_types or event_groups. Example of a request: .. code-block:: http POST /api/hooks-web/ HTTP/1.1 Content-Type: application/json Accept:...
To create new email hook issue **POST** against */api/hooks-email/* as an authenticated user. You should specify list of event_types or event_groups. Example of a request: .. code-block:: http POST /api/hooks-email/ HTTP/1.1 Content-Type: application/json A...
To create new push hook issue **POST** against */api/hooks-push/* as an authenticated user. You should specify list of event_types or event_groups. Example of a request: .. code-block:: http POST /api/hooks-push/ HTTP/1.1 Content-Type: application/json Acce...
Import this instrument's settings from the given file. Will automatically add the instrument's synth and table to the song's synths and tables if needed. Note that this may invalidate existing instrument accessor objects. :param index: the index into which to import :param fil...
Load a Project from a ``.lsdsng`` file. :param filename: the name of the file from which to load :rtype: :py:class:`pylsdj.Project` def load_lsdsng(filename): """Load a Project from a ``.lsdsng`` file. :param filename: the name of the file from which to load :rtype: :py:class:`pylsdj.Project` ...
Load a Project from an ``.srm`` file. :param filename: the name of the file from which to load :rtype: :py:class:`pylsdj.Project` def load_srm(filename): """Load a Project from an ``.srm`` file. :param filename: the name of the file from which to load :rtype: :py:class:`pylsdj.Project` """ ...
the song associated with the project def song(self): """the song associated with the project""" if self._song is None: self._song = Song(self._song_data) return self._song
Save a project in .lsdsng format to the target file. :param filename: the name of the file to which to save :deprecated: use ``save_lsdsng(filename)`` instead def save(self, filename): """Save a project in .lsdsng format to the target file. :param filename: the name of the file to wh...
Save a project in .srm format to the target file. :param filename: the name of the file to which to save def save_srm(self, filename): """Save a project in .srm format to the target file. :param filename: the name of the file to which to save """ with open(filename, 'wb') as f...
compresses the waveform horizontally; one of ``"normal"``, ``"resync"``, ``"resync2"`` def phase_type(self, value): '''compresses the waveform horizontally; one of ``"normal"``, ``"resync"``, ``"resync2"``''' self._params.phase_type = value self._overwrite_lock.disable()
The list of :py:class:`pylsdj.Project` s that the .sav file contains def project_list(self): """The list of :py:class:`pylsdj.Project` s that the .sav file contains""" return [(i, self.projects[i]) for i in sorted(self.projects.keys())]
Save this file. :param filename: the file to which to save the .sav file :type filename: str :param callback: a progress callback function :type callback: function def save(self, filename, callback=_noop_callback): """Save this file. :param filename: the file to which ...
Splits compressed data into blocks. :param compressed_data: the compressed data to split :param segment_size: the size of a block in bytes :param block_factory: a BlockFactory used to construct the blocks :rtype: a list of block IDs of blocks that the block factory created while splitting def spl...
Renumber a block map's indices so that tehy match the blocks' block switch statements. :param blocks a block map to renumber :rtype: a renumbered copy of the block map def renumber_block_keys(blocks): """Renumber a block map's indices so that tehy match the blocks' block switch statements. :p...
Merge the given blocks into a contiguous block of compressed data. :param blocks: the list of blocks :rtype: a list of compressed bytes def merge(blocks): """Merge the given blocks into a contiguous block of compressed data. :param blocks: the list of blocks :rtype: a list of compressed bytes ...
Add zeroes to a segment until it reaches a certain size. :param segment: the segment to pad :param size: the size to which to pad the segment def pad(segment, size): """Add zeroes to a segment until it reaches a certain size. :param segment: the segment to pad :param size: the size to which to pa...
Decompress data that has been compressed by the filepack algorithm. :param compressed_data: an array of compressed data bytes to decompress :rtype: an array of decompressed bytes def decompress(compressed_data): """Decompress data that has been compressed by the filepack algorithm. :param compressed...
Compress raw bytes with the filepack algorithm. :param raw_data: an array of raw data bytes to compress :rtype: a list of compressed bytes def compress(raw_data): """Compress raw bytes with the filepack algorithm. :param raw_data: an array of raw data bytes to compress :rtype: a list of compres...
Return a human-readable name without LSDJ's trailing zeroes. :param name: the name from which to strip zeroes :rtype: the name, without trailing zeroes def name_without_zeroes(name): """ Return a human-readable name without LSDJ's trailing zeroes. :param name: the name from which to strip zeroes ...
the instrument's name (5 characters, zero-padded) def name(self): """the instrument's name (5 characters, zero-padded)""" instr_name = self.song.song_data.instrument_names[self.index] if type(instr_name) == bytes: instr_name = instr_name.decode('utf-8') return instr_name
a ```pylsdj.Table``` referencing the instrument's table, or None if the instrument doesn't have a table def table(self): """a ```pylsdj.Table``` referencing the instrument's table, or None if the instrument doesn't have a table""" if hasattr(self.data, 'table_on') and self.data.table_on...
import from an lsdinst struct def import_lsdinst(self, struct_data): """import from an lsdinst struct""" self.name = struct_data['name'] self.automate = struct_data['data']['automate'] self.pan = struct_data['data']['pan'] if self.table is not None: self.table.impor...
Export this instrument's settings to a file. :param filename: the name of the file def export_to_file(self, filename): """Export this instrument's settings to a file. :param filename: the name of the file """ instr_json = self.export_struct() with open(filename, 'w') ...
Write this sample to a WAV file. :param filename: the file to which to write def write_wav(self, filename): """Write this sample to a WAV file. :param filename: the file to which to write """ wave_output = None try: wave_output = wave.open(filename, 'w') ...
Read sample data for this sample from a WAV file. :param filename: the file from which to read def read_wav(self, filename): """Read sample data for this sample from a WAV file. :param filename: the file from which to read """ wave_input = None try: wave_i...
find the local ip address on the given device def get_device_address(device): """ find the local ip address on the given device """ if device is None: return None command = ['ip', 'route', 'list', 'dev', device] ip_routes = subprocess.check_output(command).strip() for line in ip_routes.spli...
Find the device where the default route is. def get_default_net_device(): """ Find the device where the default route is. """ with open('/proc/net/route') as fh: for line in fh: iface, dest, _ = line.split(None, 2) if dest == '00000000': return iface return N...
Adds key-value pairs to the passed dictionary, so that afterwards, the dictionary can be used without needing to check for KeyErrors. If the keys passed as a second argument are not present, they are added with None as a value. :args: The dictionary to be completed. :optional_args:...
Checks whether all mandatory arguments are passed. This function aims at methods with many arguments which are passed as kwargs so that the order in which the are passed does not matter. :args: The dictionary passed as args. :mandatory_args: A list of keys that have to be present i...
Retrieves the size in bytes of this ZIP content. :return: Size of the zip content in bytes def size(self, store_hashes=True): """ Retrieves the size in bytes of this ZIP content. :return: Size of the zip content in bytes """ if self.modified: self.__cache_con...
Monkey patch the django.db.migrations.writer.MIGRATION_TEMPLATE Monkey patching django.db.migrations.writer.MIGRATION_TEMPLATE means that we don't have to do any complex regex or reflection. It's hacky... but works atm. def monkey_patch_migration_template(self, app, fixture_path): ""...
Return true if it looks like a migration already exists. def migration_exists(self, app, fixture_path): """ Return true if it looks like a migration already exists. """ base_name = os.path.basename(fixture_path) # Loop through all migrations for migration_path in glob.gl...
Create a data migration for app that uses fixture_path. def create_migration(self, app, fixture_path): """ Create a data migration for app that uses fixture_path. """ self.monkey_patch_migration_template(app, fixture_path) out = StringIO() management.call_command('makem...
Initialize client with read access and with search function. :param handle_server_url: The URL of the Handle Server. May be None (then, the default 'https://hdl.handle.net' is used). :param reverselookup_username: The username to authenticate at the reverse lookup servlet. ...
Initialize client against an HSv8 instance with full read/write access. The method will throw an exception upon bad syntax or non-existing Handle. The existence or validity of the password in the handle is not checked at this moment. :param handle_server_url: The URL of the Handle Syst...
Initialize the client against an HSv8 instance with full read/write access. :param credentials: A credentials object, see separate class PIDClientCredentials. :param \**config: More key-value pairs may be passed that will be passed on to the constructor as config. Config...
Retrieve a handle record from the Handle server as a complete nested dict (including index, ttl, timestamp, ...) for later use. Note: For retrieving a simple dict with only the keys and values, please use :meth:`~b2handle.handleclient.EUDATHandleClient.retrieve_handle_record`. :param h...
Retrieve a handle record from the Handle server as a dict. If there is several entries of the same type, only the first one is returned. Values of complex types (such as HS_ADMIN) are transformed to strings. :param handle: The handle whose record to retrieve. :param handlerecord...
Retrieve a single value from a single Handle. If several entries with this key exist, the methods returns the first one. If the handle does not exist, the method will raise a HandleNotFoundException. :param handle: The handle to take the value from. :param key: The key. :return:...
Checks if there is a 10320/LOC entry in the handle record. *Note:* In the unlikely case that there is a 10320/LOC entry, but it does not contain any locations, it is treated as if there was none. :param handle: The handle. :param handlerecord_json: Optional. The content of the response ...
Register a new Handle with a unique random name (random UUID). :param prefix: The prefix of the handle to be registered. The method will generate a suffix. :param location: The URL of the data entity to be referenced. :param checksum: Optional. The checksum string. :param ex...
Modify entries (key-value-pairs) in a handle record. If the key does not exist yet, it is created. *Note:* We assume that a key exists only once. In case a key exists several time, an exception will be raised. *Note:* To modify 10320/LOC, please use :meth:`~b2handle.handleclient.EUDATH...
Delete a key-value pair from a handle record. If the key exists more than once, all key-value pairs with this key are deleted. :param handle: Handle from whose record the entry should be deleted. :param key: Key to be deleted. Also accepts a list of keys. :raises: :exc:`~b2handle.handle...
Delete the handle and its handle record. If the Handle is not found, an Exception is raised. :param handle: Handle to be deleted. :param other: Deprecated. This only exists to catch wrong method usage by users who are used to delete handle VALUES with the method. :raises: :exc:`~b2h...
Exchange an URL in the 10320/LOC entry against another, keeping the same id and other attributes. :param handle: The handle to modify. :param old: The URL to replace. :param new: The URL to set as new URL. def exchange_additional_URL(self, handle, old, new): ''' Exchang...
Add a URL entry to the handle record's 10320/LOC entry. If 10320/LOC does not exist yet, it is created. If the 10320/LOC entry already contains the URL, it is not added a second time. :param handle: The handle to add the URL to. :param urls: The URL(s) to be added. Several URLs may be s...
Remove a URL from the handle record's 10320/LOC entry. :param handle: The handle to modify. :param urls: The URL(s) to be removed. Several URLs may be specified. :raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException` :raises: :exc:`~b2handle.handleexceptions.HandleSyntaxErro...
Registers a new Handle with given name. If the handle already exists and overwrite is not set to True, the method will throw an exception. :param handle: The full name of the handle to be registered (prefix and suffix) :param location: The URL of the data entity to be refere...
Search for handles containing the specified key with the specified value. The search terms are passed on to the reverse lookup servlet as-is. The servlet is supposed to be case-insensitive, but if it isn't, the wrong case will cause a :exc:`~b2handle.handleexceptions.ReverseLookupException`. ...
Generate a unique random Handle name (random UUID). The Handle is not registered. If a prefix is specified, the PID name has the syntax <prefix>/<generatedname>, otherwise it just returns the generated random name (suffix for the Handle). :param prefix: Optional. The prefix to be used f...
Finds the Handle entry indices of all entries that have a specific type. *Important:* It finds the Handle System indices! These are not the python indices of the list, so they can not be used for iteration. :param key: The key (Handle Record type) :param list_of_entries...
Send a HTTP DELETE request to the handle server to delete either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Optional. A list of indices to delete. Defaults to None (i.e. the...
Send a HTTP PUT request to the handle server to write either an entire handle or to some specified values to an handle record, using the requests module. :param handle: The handle. :param list_of_entries: A list of handle record entries to be written, in the format [{"i...
Send a HTTP GET request to the handle server to read either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Optional. A list of indices to delete. Defaults to None (i.e. the enti...
Returns the handle record if it is None or if its handle is not the same as the specified handle. def __get_handle_record_if_necessary(self, handle, handlerecord_json): ''' Returns the handle record if it is None or if its handle is not the same as the specified handle. ...
Find an index not yet used in the handle record and not reserved for any (other) special type. :param: list_of_entries: List of all entries to find which indices are used already. :param url: If True, an index for an URL entry is returned (1, unless it is already in ...
Create an entry of any type except HS_ADMIN. :param entrytype: THe type of entry to create, e.g. 'URL' or 'checksum' or ... Note: For entries of type 'HS_ADMIN', please use __create_admin_entry(). For type '10320/LOC', please use 'add_additional_URL()' :param data: T...
Create an entry of type "HS_ADMIN". :param username: The username, i.e. a handle with an index (index:prefix/suffix). The value referenced by the index contains authentcation information, e.g. a hidden entry containing a key. :param permissions: The permissions as a string of ze...
Finds the indices of all entries that have a specific type. Important: This method finds the python indices of the list of entries! These are not the Handle System index values! :param key: The key (Handle Record type) :param list_of_entries: A list of the existing entries in wh...
Exchange every occurrence of oldurl against newurl in a 10320/LOC entry. This does not change the ids or other xml attributes of the <location> element. :param oldurl: The URL that will be overwritten. :param newurl: The URL to write into the entry. :param list_of_entrie...
Remove an URL from the handle record's "10320/LOC" entry. If it exists several times in the entry, all occurences are removed. If the URL is not present, nothing happens. If after removing, there is no more URLs in the entry, the entry is removed. :param url: The URL to be r...
Add a url to the handle record's "10320/LOC" entry. If no 10320/LOC entry exists, a new one is created (using the default "chooseby" attribute, if configured). If the URL is already present, it is not added again, but the attributes (e.g. weight) are updated/added. ...
Adds or updates attributes of a <location> element. Existing attributes are not removed! :param locelement: A location element as xml snippet (xml.etree.ElementTree.Element). :param weight: Optional. The weight to be set (integer between 0 and 1). If None, no weight ...
authorization url request weibo authorization url :return: code string 用于第二步调用oauth2/access_token接口,获取授权后的access token。 state string 如果传递参数,会回传该参数 def authorize_url(self): """ authorization url request weibo authorization url :return: ...
:param method: str, http method ["GET","POST","PUT"] :param suffix: the url suffix :param data: :return: def request(self, method, suffix, data): """ :param method: str, http method ["GET","POST","PUT"] :param suffix: the url suffix :param data: :return: ...
verify the fist authorization response url code response data 返回值字段 字段类型 字段说明 access_token string 用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据, 第三方应用应该用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态,不能使用本返回值里的UID 字段来做登录识别。 ...
授权回收接口,帮助开发者主动取消用户的授权。 应用下线时,清空所有用户的授权 应用新上线了功能,需要取得用户scope权限,可以回收后重新引导用户授权 开发者调试应用,需要反复调试授权功能 应用内实现类似登出微博帐号的功能 并传递给你以下参数,source:应用appkey,uid :取消授权的用户,auth_end :取消授权的时间 :param access_token: :return: bool def revoke_auth_access(self, access_token): """ ...
Creates and sets the authentication string for (write-)accessing the Handle Server. No return, the string is set as an attribute to the client instance. :param username: Username handle with index: index:prefix/suffix. :param password: The password contained in the index of the ...
Send a HTTP GET request to the handle server to read either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Optional. A list of indices to delete. Defaults to None (i.e. the enti...
Send a HTTP PUT request to the handle server to write either an entire handle or to some specified values to an handle record, using the requests module. :param handle: The handle. :param list_of_entries: A list of handle record entries to be written, in the format [{"i...
Send a HTTP DELETE request to the handle server to delete either an entire handle or to some specified values from a handle record, using the requests module. :param handle: The handle. :param indices: Optional. A list of indices to delete. Defaults to None (i.e. the...
Check if the username handles exists. :param username: The username, in the form index:prefix/suffix :raises: :exc:`~b2handle.handleexceptions.HandleNotFoundException` :raises: :exc:`~b2handle.handleexceptions.GenericHandleError` :return: True. If it does not exist, an exception is rais...
Create HTTP headers for different HTTP requests. Content-type and Accept are 'application/json', as the library is interacting with a REST API. :param action: Action for which to create the header ('GET', 'PUT', 'DELETE', 'SEARCH'). :return: dict containing key-value...
Create the URL for a HTTP request (URL + query string) to request a specific handle from the Handle Server. :param handle: The handle to access. :param indices: Optional. A list of integers or strings. Indices of the handle record entries to read or write. Defaults to None. ...
Record a single hit on a given metric. Args: metric_name: The name of the metric to record with Carbon. metric_value: The value to record with Carbon. epoch_seconds: Optionally specify the time for the metric hit. Returns: None def publish_metric(self, ...
Record hits to a metric at a specified interval. Args: metric_name: The name of the metric to record with Carbon. frequency: The frequency with which to poll the getter and record the value with Carbon. getter: A function which takes no arguments and returns the value to rec...
Setup integration Registers Pyblish for Maya plug-ins and appends an item to the File-menu Arguments: console (bool): Display console with GUI port (int, optional): Port from which to start looking for an available port to connect with Pyblish QML, default provided by P...
Try showing the most desirable GUI This function cycles through the currently registered graphical user interfaces, if any, and presents it to the user. def show(): """Try showing the most desirable GUI This function cycles through the currently registered graphical user interfaces, if any, a...
Remove Nuke margins when docked UI .. _More info: https://gist.github.com/maty974/4739917 def _nuke_set_zero_margins(widget_object): """Remove Nuke margins when docked UI .. _More info: https://gist.github.com/maty974/4739917 """ parentApp = QtWidgets.QApplication.allWidgets() p...
Expecting a window to parent into a Nuke panel, that is dockable. def dock(window): """ Expecting a window to parent into a Nuke panel, that is dockable. """ # Deleting existing dock # There is a bug where existing docks are kept in-memory when closed via UI if self._dock: print("Deleting exis...
Returns index and handle separately, in a tuple. :handle_with_index: The handle string with an index (e.g. 500:prefix/suffix) :return: index and handle as a tuple. def remove_index_from_handle(handle_with_index): ''' Returns index and handle separately, in a tuple. :handle_with_index: The...
Checks the syntax of a handle without an index (are prefix and suffix there, are there too many slashes?). :string: The handle without index, as string prefix/suffix. :raise: :exc:`~b2handle.handleexceptions.handleexceptions.HandleSyntaxError` :return: True. If it's not ok, exceptions are raised. def ...
Creates an authentication string from the username and password. :username: Username. :password: Password. :return: The encoded string. def create_authentication_string(username, password): ''' Creates an authentication string from the username and password. :username: Username. :password...
Creates a string containing all relevant information about a request made to the Handle System, for logging purposes. :handle: The handle that the request is about. :url: The url the request is sent to. :headers: The headers sent along with the request. :verify: Boolean parameter passed to the ...
Returns an etree.XMLRoot object loaded from the url :param str url: URL for the resource to load as an XML def request_xml(url, auth=None): ''' Returns an etree.XMLRoot object loaded from the url :param str url: URL for the resource to load as an XML ''' try: r = requests.get(url, auth=...
Returns the appropriate catalog URL by replacing html with xml in some cases :param str url: URL to the catalog def _get_catalog_url(self, url): ''' Returns the appropriate catalog URL by replacing html with xml in some cases :param str url: URL to the catalog ''...
Yields a URL corresponding to a leaf dataset for each dataset described by the catalog :param str url: URL for the current catalog :param lxml.etree.Eleemnt tree: Current XML Tree def _yield_leaves(self, url, tree): ''' Yields a URL corresponding to a leaf dataset for each dataset descr...
Returns a list of catalog reference URLs for the current catalog :param str url: URL for the current catalog :param lxml.etree.Eleemnt tree: Current XML Tree def _compile_references(self, url, tree): ''' Returns a list of catalog reference URLs for the current catalog :param str...
Performs a multiprocess depth-first-search of the catalog references and yields a URL for each leaf dataset found :param str url: URL for the current catalog :param requests.auth.AuthBase auth: requets auth object to use def _run(self, url, auth): ''' Performs a multiprocess dep...
Recursive function to perform the DFS and yield the leaf datasets :param str url: URL for the current catalog :param str xml_content: XML Body returned from HTTP Request def _build_catalog(self, url, xml_content): ''' Recursive function to perform the DFS and yield the leaf datasets ...
Find a loader for module or package `fqname`. This method will be called with the fully qualified name of the module. If the finder is installed on `sys.meta_path`, it will receive a second argument, which is `None` for a top-level module, or `package.__path__` for submodules or sub...
Load `fqname` from under `ldr.fspath`. The `fqname` argument is the fully qualified module name, eg. "spam.eggs.ham". As explained above, when :: finder.find_module("spam.eggs.ham") is called, "spam.eggs" has already been imported and added to `sys.modules`. However, the `find_...
Create an attached thread. An attached thread gets a ctx and a PAIR pipe back to its parent. It must monitor its pipe, and exit if the pipe becomes unreadable. Returns pipe, or NULL if there was an error. def zthread_fork(ctx, func, *args, **kwargs): """ Create an attached thread. An attached thread ge...
Prevent accidental assignment of existing members Arguments: object (object): Parent of new attribute name (str): Name of new attribute value (object): Value of new attribute safe (bool): Whether or not to guarantee that the new attribute was not overwritten. ...
Try loading each binding in turn Please note: the entire Qt module is replaced with this code: sys.modules["Qt"] = binding() This means no functions or variables can be called after this has executed. For debugging and testing, this module may be accessed through `Qt.__shim__`. def init(...
Log the instantiation of an object to the given logger. :LOGGER: A logger to log to. Please see module "logging". :classname: The name of the class that is being instantiated. :args: A dictionary of arguments passed to the instantiation, which will be logged on debug level. :forbidden: ...