INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Not working. Am not able ot figure out how to upload. IT return status 200OK with this code but do not store the files.
In tomcat.log (IM) there?s a complaint about character encoding whn uploading file. Not sure how to rectiy it in requests post call though | def uploadPackages(self, directory):
"""
Not working. Am not able ot figure out how to upload. IT return status 200OK with this code but do not store the files.
In tomcat.log (IM) there?s a complaint about character encoding whn uploading file. Not sure how to rectiy it in requests post ... |
Parameters as they look in the form for uploading packages to IM | def uploadFileToIM (self, directory, filename, title):
"""
Parameters as they look in the form for uploading packages to IM
"""
self.logger.debug("uploadFileToIM(" + "{},{},{})".format(directory, filename, title))
parameters = {'data-filename-placement':'inside',
... |
NOT NEEDED. JSON can be POSTed to IM instead of sending a CSV that is locally parsed and converted to JSON.
Remote Address:192.168.100.51:443
Request URL:https://192.168.100.51/types/Configuration/instances/actions/parseFromCSV
Request Method:POST
Status Code:200 OK
Requ... | def uploadCsvConfiguration(self, conf_filename):
"""
NOT NEEDED. JSON can be POSTed to IM instead of sending a CSV that is locally parsed and converted to JSON.
Remote Address:192.168.100.51:443
Request URL:https://192.168.100.51/types/Configuration/instances/actions/parseFromCS... |
Binary dump of the integer of given type
:param writer:
:param type_or:
:param pv:
:return: | async def dump_varint_t(writer, type_or, pv):
"""
Binary dump of the integer of given type
:param writer:
:param type_or:
:param pv:
:return:
"""
width = int_mark_to_size(type_or)
n = (pv << 2) | type_or
buffer = _UINT_BUFFER
for _ in range(width):
buffer[0] = n & 0... |
Binary dump of the variable size integer
:param writer:
:param val:
:return: | async def dump_varint(writer, val):
"""
Binary dump of the variable size integer
:param writer:
:param val:
:return:
"""
if val <= 63:
return await dump_varint_t(writer, PortableRawSizeMark.BYTE, val)
elif val <= 16383:
return await dump_varint_t(writer, PortableRawSizeM... |
Binary load of variable size integer serialized by dump_varint
:param reader:
:return: | async def load_varint(reader):
"""
Binary load of variable size integer serialized by dump_varint
:param reader:
:return:
"""
buffer = _UINT_BUFFER
await reader.areadinto(buffer)
width = int_mark_to_size(buffer[0] & PortableRawSizeMark.MASK)
result = buffer[0]
shift = 8
fo... |
Binary string dump
:param writer:
:param val:
:return: | async def dump_string(writer, val):
"""
Binary string dump
:param writer:
:param val:
:return:
"""
await dump_varint(writer, len(val))
await writer.awrite(val) |
Loads string from binary stream
:param reader:
:return: | async def load_string(reader):
"""
Loads string from binary stream
:param reader:
:return:
"""
ivalue = await load_varint(reader)
fvalue = bytearray(ivalue)
await reader.areadinto(fvalue)
return bytes(fvalue) |
Dumps blob to a binary stream
:param writer:
:param elem:
:param elem_type:
:param params:
:return: | async def dump_blob(writer, elem, elem_type, params=None):
"""
Dumps blob to a binary stream
:param writer:
:param elem:
:param elem_type:
:param params:
:return:
"""
elem_is_blob = isinstance(elem, x.BlobType)
data = bytes(getattr(elem, x.BlobType.DATA_ATTR) if elem_is_blob els... |
Loads blob from reader to the element. Returns the loaded blob.
:param reader:
:param elem_type:
:param params:
:param elem:
:return: | async def load_blob(reader, elem_type, params=None, elem=None):
"""
Loads blob from reader to the element. Returns the loaded blob.
:param reader:
:param elem_type:
:param params:
:param elem:
:return:
"""
ivalue = await load_varint(reader)
fvalue = bytearray(ivalue)
await r... |
Root level init
:return: | async def root(self):
"""
Root level init
:return:
"""
if self.writing:
await x.dump_uint(self.iobj, PortableStorageConsts.SIGNATUREA, 4)
await x.dump_uint(self.iobj, PortableStorageConsts.SIGNATUREB, 4)
await x.dump_uint(self.iobj, PortableSto... |
Section / dict serialization
:return: | async def section(self, sec=None):
"""
Section / dict serialization
:return:
"""
if self.writing:
await dump_varint(self.iobj, len(sec))
for key in sec:
await self.section_name(key)
await self.storage_entry(sec[key])
... |
Section name
:param sec_name:
:return: | async def section_name(self, sec_name=None):
"""
Section name
:param sec_name:
:return:
"""
if self.writing:
fvalue = sec_name.encode('ascii')
await x.dump_uint(self.iobj, len(fvalue), 1)
await self.iobj.awrite(bytearray(fvalue))
... |
Uvarint untouched
:param elem:
:return: | async def uvarint(self, elem):
"""
Uvarint untouched
:param elem:
:return:
"""
if self.writing:
return await dump_varint(self.iobj, elem)
else:
return await load_varint(self.iobj) |
Integer types
:param elem:
:param elem_type:
:param params:
:return: | async def uint(self, elem, elem_type, params=None):
"""
Integer types
:param elem:
:param elem_type:
:param params:
:return:
"""
if self.writing:
return await x.dump_uint(self.iobj, elem, elem_type.WIDTH)
else:
return await ... |
Unicode type
:param elem:
:return: | async def unicode_type(self, elem):
"""
Unicode type
:param elem:
:return:
"""
if self.writing:
return await x.dump_unicode(self.iobj, elem)
else:
return await x.load_unicode(self.iobj) |
Loads/dumps blob
:return: | async def blob(self, elem=None, elem_type=None, params=None):
"""
Loads/dumps blob
:return:
"""
elem_type = elem_type if elem_type else elem.__class__
if hasattr(elem_type, 'blob_serialize'):
elem = elem_type() if elem is None else elem
return awai... |
Loads/dumps container
:return: | async def container(self, container=None, container_type=None, params=None):
"""
Loads/dumps container
:return:
"""
if hasattr(container_type, 'blob_serialize'):
container = container_type() if container is None else container
return await container.blob_s... |
Determines element size after blob serialization.
Can be quite tricky for complicated structures - another object required to implement sizeof()
:param elem_type:
:param elem:
:param params:
:return: | async def get_element_size(self, elem_type, elem=None, params=None):
"""
Determines element size after blob serialization.
Can be quite tricky for complicated structures - another object required to implement sizeof()
:param elem_type:
:param elem:
:param params:
... |
Loads container of elements from the reader. Supports the container ref.
Returns loaded container.
Blob array writer as in XMRRPC is serialized without size serialization.
:param container_type:
:param params:
:param container:
:param obj:
:return: | async def container_load(self, container_type, params=None, container=None, obj=None):
"""
Loads container of elements from the reader. Supports the container ref.
Returns loaded container.
Blob array writer as in XMRRPC is serialized without size serialization.
:param container... |
Loads/dumps tuple
:return: | async def tuple(self, elem=None, elem_type=None, params=None):
"""
Loads/dumps tuple
:return:
"""
if hasattr(elem_type, 'blob_serialize'):
container = elem_type() if elem is None else elem
return await container.blob_serialize(self, elem=elem, elem_type=el... |
Loads/dumps variant type
:param elem:
:param elem_type:
:param params:
:param obj:
:return: | async def variant(self, elem=None, elem_type=None, params=None):
"""
Loads/dumps variant type
:param elem:
:param elem_type:
:param params:
:param obj:
:return:
"""
elem_type = elem_type if elem_type else elem.__class__
if hasattr(elem_typ... |
Loads/dumps message
:param msg:
:param msg_type:
:param obj:
:return: | async def message(self, msg, msg_type=None):
"""
Loads/dumps message
:param msg:
:param msg_type:
:param obj:
:return:
"""
elem_type = msg_type if msg_type is not None else msg.__class__
if hasattr(elem_type, 'blob_serialize'):
msg = e... |
Dumps/Loads message field
:param msg:
:param field:
:param fvalue: explicit value for dump
:param obj:
:return: | async def message_field(self, msg, field, fvalue=None, obj=None):
"""
Dumps/Loads message field
:param msg:
:param field:
:param fvalue: explicit value for dump
:param obj:
:return:
"""
fname, ftype, params = field[0], field[1], field[2:]
t... |
Load/dump individual message fields
:param msg:
:param fields:
:param obj:
:return: | async def message_fields(self, msg, fields, obj=None):
"""
Load/dump individual message fields
:param msg:
:param fields:
:param obj:
:return:
"""
for field in fields:
await self.message_field(msg, field, obj)
return msg |
Archive field
:param elem:
:param elem_type:
:param params:
:return: | async def field(self, elem=None, elem_type=None, params=None):
"""
Archive field
:param elem:
:param elem_type:
:param params:
:return:
"""
elem_type = elem_type if elem_type else elem.__class__
fvalue = None
src = elem
if issubcla... |
Main blobbing
:param elem:
:param elem_type:
:param params:
:return: | async def blobize(self, elem=None, elem_type=None, params=None):
"""
Main blobbing
:param elem:
:param elem_type:
:param params:
:return:
"""
if self.writing:
await self.field(elem=elem, elem_type=elem_type, params=params)
return by... |
Integer types
:param elem:
:param elem_type:
:param params:
:return: | async def uint(self, elem, elem_type, params=None):
"""
Integer types
:param elem:
:param elem_type:
:param params:
:return:
"""
if self.writing:
return IntegerModel(elem, elem_type.WIDTH) if self.modelize else elem
else:
re... |
Loads/dumps blob
:return: | async def blob(self, elem=None, elem_type=None, params=None):
"""
Loads/dumps blob
:return:
"""
elem_type = elem_type if elem_type else elem.__class__
if hasattr(elem_type, 'kv_serialize'):
elem = elem_type() if elem is None else elem
return await ... |
Loads/dumps container
:return: | async def container(self, container=None, container_type=None, params=None, obj=None):
"""
Loads/dumps container
:return:
"""
if hasattr(container_type, 'kv_serialize'):
container = container_type() if container is None else container
return await containe... |
Dumps container of elements to the writer.
:param container:
:param container_type:
:param params:
:param obj:
:return: | async def container_dump(self, container, container_type, params=None, obj=None):
"""
Dumps container of elements to the writer.
:param container:
:param container_type:
:param params:
:param obj:
:return:
"""
elem_type = x.container_elem_type(con... |
Loads/dumps tuple
:return: | async def tuple(self, elem=None, elem_type=None, params=None, obj=None):
"""
Loads/dumps tuple
:return:
"""
if hasattr(elem_type, 'kv_serialize'):
container = elem_type() if elem is None else elem
return await container.kv_serialize(self, elem=elem, elem_t... |
Loads container of elements from the reader. Supports the container ref.
Returns loaded container.
:param container_type:
:param params:
:param container:
:param obj:
:return: | async def container_load(self, container_type, params=None, container=None, obj=None):
"""
Loads container of elements from the reader. Supports the container ref.
Returns loaded container.
:param container_type:
:param params:
:param container:
:param obj:
... |
Dumps tuple of elements to the writer.
:param elem:
:param elem_type:
:param params:
:param obj:
:return: | async def dump_tuple(self, elem, elem_type, params=None, obj=None):
"""
Dumps tuple of elements to the writer.
:param elem:
:param elem_type:
:param params:
:param obj:
:return:
"""
if len(elem) != len(elem_type.f_specs()):
raise Value... |
Loads tuple of elements from the reader. Supports the tuple ref.
Returns loaded tuple.
:param elem_type:
:param params:
:param elem:
:param obj:
:return: | async def load_tuple(self, elem_type, params=None, elem=None, obj=None):
"""
Loads tuple of elements from the reader. Supports the tuple ref.
Returns loaded tuple.
:param elem_type:
:param params:
:param elem:
:param obj:
:return:
"""
if o... |
Loads/dumps variant type
:param elem:
:param elem_type:
:param params:
:param obj:
:return: | async def variant(self, elem=None, elem_type=None, params=None, obj=None):
"""
Loads/dumps variant type
:param elem:
:param elem_type:
:param params:
:param obj:
:return:
"""
elem_type = elem_type if elem_type else elem.__class__
if hasatt... |
Loads variant type from the reader.
Supports both wrapped and raw variant.
:param elem_type:
:param params:
:param elem:
:param wrapped:
:param obj:
:return: | async def load_variant(self, elem_type, params=None, elem=None, wrapped=None, obj=None):
"""
Loads variant type from the reader.
Supports both wrapped and raw variant.
:param elem_type:
:param params:
:param elem:
:param wrapped:
:param obj:
:retu... |
Dumps variant type to the writer.
Supports both wrapped and raw variant.
:param elem:
:param elem_type:
:param params:
:param obj:
:return: | async def dump_variant(self, elem, elem_type=None, params=None, obj=None):
"""
Dumps variant type to the writer.
Supports both wrapped and raw variant.
:param elem:
:param elem_type:
:param params:
:param obj:
:return:
"""
fvalue = None
... |
Loads/dumps message
:param msg:
:param msg_type:
:param obj:
:return: | async def message(self, msg, msg_type=None, obj=None):
"""
Loads/dumps message
:param msg:
:param msg_type:
:param obj:
:return:
"""
elem_type = msg_type if msg_type is not None else msg.__class__
obj = collections.OrderedDict() if not x.has_elem(o... |
Archive field
:param elem:
:param elem_type:
:param params:
:param obj:
:return: | async def field(self, elem=None, elem_type=None, params=None, obj=None):
"""
Archive field
:param elem:
:param elem_type:
:param params:
:param obj:
:return:
"""
elem_type = elem_type if elem_type else elem.__class__
fvalue = None
... |
Convenience method that round input to valid ScaleIO Volume size (8GB increments)
:param volsize: Size in MB
:rtype int: Valid ScaleIO Volume size rounded to nearest 8GB increment above or equal to volsize | def is_valid_volsize(self,volsize):
"""
Convenience method that round input to valid ScaleIO Volume size (8GB increments)
:param volsize: Size in MB
:rtype int: Valid ScaleIO Volume size rounded to nearest 8GB increment above or equal to volsize
"""
if type(volsi... |
removeMode = 'ONLY_ME' | 'INCLUDING_DESCENDANTS' | 'DESCENDANTS_ONLY' | 'WHOLE_VTREE'
Using kwargs it will be possible to tell delete_volume() to unmap all SDCs before delting. Not working yet | def delete_volume(self, volObj, removeMode='ONLY_ME', **kwargs):
"""
removeMode = 'ONLY_ME' | 'INCLUDING_DESCENDANTS' | 'DESCENDANTS_ONLY' | 'WHOLE_VTREE'
Using kwargs it will be possible to tell delete_volume() to unmap all SDCs before delting. Not working yet
"""
if kwargs:
... |
Map a Volume to SDC
:param volumeObj: ScaleIO Volume object
:param sdcObj: ScaleIO SDC object
:param allowMultipleMappings: True to allow more than one SDC to be mapped to volume
:return: POST request response
:rtype: Requests POST response object | def map_volume_to_sdc(self, volumeObj, sdcObj=None, allowMultipleMappings=False, **kwargs):
"""
Map a Volume to SDC
:param volumeObj: ScaleIO Volume object
:param sdcObj: ScaleIO SDC object
:param allowMultipleMappings: True to allow more than one SDC to be mapped to volume
... |
Unmap a Volume from SDC or all SDCs
:param volObj: ScaleIO Volume object
:param sdcObj: ScaleIO SDC object
:param \**kwargs:
:Keyword Arguments:
*disableMapAllSdcs* (``bool``) -- True to disable all SDCs mapping
:return: POST request response
:rtype: Requests POST... | def unmap_volume_from_sdc(self, volObj, sdcObj=None, **kwargs):
"""
Unmap a Volume from SDC or all SDCs
:param volObj: ScaleIO Volume object
:param sdcObj: ScaleIO SDC object
:param \**kwargs:
:Keyword Arguments:
*disableMapAllSdcs* (``bool``) -- True to disable a... |
:param sdcObj: SDC object
:return: list of Volumes attached to SDC
:rtyoe: ScaleIO Volume object | def get_volumes_for_sdc(self, sdcObj):
"""
:param sdcObj: SDC object
:return: list of Volumes attached to SDC
:rtyoe: ScaleIO Volume object
"""
self.conn.connection._check_login()
all_volumes = []
response = self.conn.connection._do_get("{}/{}{}/{}".format... |
Get ScaleIO Volume object by its ID
:param name: ID of volume
:return: ScaleIO Volume object
:raise KeyError: No Volume with specified ID found
:rtype: ScaleIO Volume object | def get_volume_by_id(self, id):
"""
Get ScaleIO Volume object by its ID
:param name: ID of volume
:return: ScaleIO Volume object
:raise KeyError: No Volume with specified ID found
:rtype: ScaleIO Volume object
"""
for vol in self.conn.volumes:
... |
:param vtreeObj: VTree object
Protection Domain Object
:return: list of Volumes attached to VTree
:rtype: ScaleIO Volume object | def get_volumes_for_vtree(self, vtreeObj):
"""
:param vtreeObj: VTree object
Protection Domain Object
:return: list of Volumes attached to VTree
:rtype: ScaleIO Volume object
"""
self.conn.connection._check_login()
all_volumes = []
response = s... |
Get ScaleIO Volume object by its Name
:param name: Name of volume
:return: ScaleIO Volume object
:raise KeyError: No Volume with specified name found
:rtype: ScaleIO Volume object | def get_volume_by_name(self, name):
"""
Get ScaleIO Volume object by its Name
:param name: Name of volume
:return: ScaleIO Volume object
:raise KeyError: No Volume with specified name found
:rtype: ScaleIO Volume object
"""
for vol in self.conn.volumes:
... |
Resize a volume to new GB size, must be larger than original.
:param volumeObj: ScaleIO Volume Object
:param sizeInGb: New size in GB (have to be larger than original)
:param bsize: 1000
:return: POST request response
:rtype: Requests POST response object | def resize_volume(self, volumeObj, sizeInGb, bsize=1000):
"""
Resize a volume to new GB size, must be larger than original.
:param volumeObj: ScaleIO Volume Object
:param sizeInGb: New size in GB (have to be larger than original)
:param bsize: 1000
:return: POST request r... |
Create snapshot for list of volumes
:param systemID: Cluster ID
:param snapshotSpecificationObject: Of class SnapshotSpecification
:rtype: SnapshotGroupId | def create_snapshot(self, systemId, snapshotSpecificationObject):
"""
Create snapshot for list of volumes
:param systemID: Cluster ID
:param snapshotSpecificationObject: Of class SnapshotSpecification
:rtype: SnapshotGroupId
"""
self.conn.connection._check_login(... |
:param systemId: ID of Cluster
:param snapshotGroupId: ID of snapshot group ID to be removed
/api/instances/System::{id}/action/removeConsistencyGroupSnapshots
type: POST
Required:
snapGroupId
Return:
numberOfVolumes - number of volumes t... | def delete_snapshot(self, systemId, snapshotGroupId):
"""
:param systemId: ID of Cluster
:param snapshotGroupId: ID of snapshot group ID to be removed
/api/instances/System::{id}/action/removeConsistencyGroupSnapshots
type: POST
Required:
sna... |
Get list of SDC mapped to a specific volume
:param volObj: ScaleIO volume object
:return: List of ScaleIO SDC objects (empty list if no mapping exist)
:rtype: SDC object | def get_sdc_for_volume(self, volObj):
"""
Get list of SDC mapped to a specific volume
:param volObj: ScaleIO volume object
:return: List of ScaleIO SDC objects (empty list if no mapping exist)
:rtype: SDC object
"""
sdcList = []
if volObj.mapped_sdcs is no... |
Create a pypi server like file structure below download directory.
:param download_dir: Download directory with packages.
EXAMPLE BEFORE:
+-- downloads/
+-- alice-1.0.zip
+-- alice-1.0.tar.gz
+-- bob-1.3.0.tar.gz
+-- bob-1.4.2.tar.gz
+-- charly-1... | def make_package_index(download_dir):
"""
Create a pypi server like file structure below download directory.
:param download_dir: Download directory with packages.
EXAMPLE BEFORE:
+-- downloads/
+-- alice-1.0.zip
+-- alice-1.0.tar.gz
+-- bob-1.3.0.tar.gz
... |
Create an 'index.html' for one package.
:param package: Package object to use.
:param index_dir: Where 'index.html' should be created. | def make_index_for(package, index_dir, verbose=True):
"""
Create an 'index.html' for one package.
:param package: Package object to use.
:param index_dir: Where 'index.html' should be created.
"""
index_template = """\
<html>
<head><title>{title}</title></head>
<body>
<h1>{title}</h1>
<ul>
{p... |
Return a list value translating from other types if necessary.
:param str value: The value to convert. | def _convert_to_list(self, value, delimiters):
"""
Return a list value translating from other types if necessary.
:param str value: The value to convert.
"""
if not value:
return []
if delimiters:
return [l.strip() for l in value.split(delimiters... |
A convenience method which coerces the option in the specified section to a list of strings. | def getlist(self, section, option, raw=False, vars=None, fallback=[], delimiters=','):
"""
A convenience method which coerces the option in the specified section to a list of strings.
"""
v = self.get(section, option, raw=raw, vars=vars, fallback=fallback)
return self._convert_to... |
A convenience method which coerces the option in the specified section to a file. | def getfile(self, section, option, raw=False, vars=None, fallback="", validate=False):
"""
A convenience method which coerces the option in the specified section to a file.
"""
v = self.get(section, option, raw=raw, vars=vars, fallback=fallback)
v = self._convert_to_path(v)
... |
A convenience method which coerces the option in the specified section to a directory. | def getdir(self, section, option, raw=False, vars=None, fallback="", validate=False):
"""
A convenience method which coerces the option in the specified section to a directory.
"""
v = self.get(section, option, raw=raw, vars=vars, fallback=fallback)
v = self._convert_to_path(v)
... |
A convenience method which coerces the option in the specified section to a list of directories. | def getdirs(self, section, option, raw=False, vars=None, fallback=[]):
"""
A convenience method which coerces the option in the specified section to a list of directories.
"""
globs = self.getlist(section, option, fallback=[])
return [f for g in globs for f in glob.glob(g) if os.... |
Extends :meth:`~configparser.ConfigParser.set` by auto formatting byte strings into unicode strings. | def set(self, section, option, value=None):
"""
Extends :meth:`~configparser.ConfigParser.set` by auto formatting byte strings into unicode strings.
"""
if isinstance(section, bytes):
section = section.decode('utf8')
if isinstance(option, bytes):
option =... |
Extends :meth:`~configparser.ConfigParser.set` by auto formatting byte strings into unicode strings. | def update(self, **kwargs):
"""
Extends :meth:`~configparser.ConfigParser.set` by auto formatting byte strings into unicode strings.
"""
# Override the template values with the override values.
for s in config.sections():
for o in config.options(s):
ov... |
Register a new document.
:param content: Content of this document. Jinja and rst are supported.
:type content: str
:param name: Unique name of the document for documentation purposes.
:param description: Short description of this document | def register(self, name, content, description=None):
"""
Register a new document.
:param content: Content of this document. Jinja and rst are supported.
:type content: str
:param name: Unique name of the document for documentation purposes.
:param description: Short desc... |
Registers a new document.
.. warning: You can not use any relative links inside a given document.
For instance, sphinx's toctree, image, figure or include statements do not work.
:param content: Content of the document
:type content: str
:param name: Unique name of ... | def register(self, name, content, plugin, description=None):
"""
Registers a new document.
.. warning: You can not use any relative links inside a given document.
For instance, sphinx's toctree, image, figure or include statements do not work.
:param content: Conten... |
Unregisters an existing document, so that this document is no longer available.
This function is mainly used during plugin deactivation.
:param document: Name of the document | def unregister(self, document):
"""
Unregisters an existing document, so that this document is no longer available.
This function is mainly used during plugin deactivation.
:param document: Name of the document
"""
if document not in self.documents.keys():
s... |
Get one or more documents.
:param document: Name of the document
:type document: str
:param plugin: Plugin object, under which the document was registered
:type plugin: GwBasePattern | def get(self, document=None, plugin=None):
"""
Get one or more documents.
:param document: Name of the document
:type document: str
:param plugin: Plugin object, under which the document was registered
:type plugin: GwBasePattern
"""
if plugin is not None... |
Initialises given plugins, but does not activate them.
This is needed to import and configure libraries, which are imported by used patterns, like GwFlask.
After this action, all needed python modules are imported and configured.
Also the groundwork application object is ready and contains fun... | def initialise_by_names(self, plugins=None):
"""
Initialises given plugins, but does not activate them.
This is needed to import and configure libraries, which are imported by used patterns, like GwFlask.
After this action, all needed python modules are imported and configured.
... |
Activates given plugins.
This calls mainly plugin.activate() and plugins register needed resources like commands, signals or
documents.
If given plugins have not been initialised, this is also done via :func:`_load`.
:param plugins: List of plugin names
:type plugins: list of ... | def activate(self, plugins=[]):
"""
Activates given plugins.
This calls mainly plugin.activate() and plugins register needed resources like commands, signals or
documents.
If given plugins have not been initialised, this is also done via :func:`_load`.
:param plugins: ... |
Deactivates given plugins.
A given plugin must be activated, otherwise it is ignored and no action takes place (no signals are fired,
no deactivate functions are called.)
A deactivated plugin is still loaded and initialised and can be reactivated by calling :func:`activate` again.
It i... | def deactivate(self, plugins=[]):
"""
Deactivates given plugins.
A given plugin must be activated, otherwise it is ignored and no action takes place (no signals are fired,
no deactivate functions are called.)
A deactivated plugin is still loaded and initialised and can be react... |
Returns the plugin object with the given name.
Or if a name is not given, the complete plugin dictionary is returned.
:param name: Name of a plugin
:return: None, single plugin or dictionary of plugins | def get(self, name=None):
"""
Returns the plugin object with the given name.
Or if a name is not given, the complete plugin dictionary is returned.
:param name: Name of a plugin
:return: None, single plugin or dictionary of plugins
"""
if name is None:
... |
Returns True if plugin exists and is active.
If plugin does not exist, it returns None
:param name: plugin name
:return: boolean or None | def is_active(self, name):
"""
Returns True if plugin exists and is active.
If plugin does not exist, it returns None
:param name: plugin name
:return: boolean or None
"""
if name in self._plugins.keys():
return self._plugins["name"].active
re... |
Registers plugin classes, which are in sys.path and have an entry_point called 'groundwork.plugin'.
:return: dict of plugin classes | def _get_plugins_by_entry_points(self):
"""
Registers plugin classes, which are in sys.path and have an entry_point called 'groundwork.plugin'.
:return: dict of plugin classes
"""
# Let's find and register every plugin, which is in sys.path and has defined a entry_point 'groundwo... |
Registers new plugins.
The registration only creates a new entry for a plugin inside the _classes dictionary.
It does not activate or even initialise the plugin.
A plugin must be a class, which inherits directly or indirectly from GwBasePattern.
:param classes: List of plugin classes
... | def register(self, classes=[]):
"""
Registers new plugins.
The registration only creates a new entry for a plugin inside the _classes dictionary.
It does not activate or even initialise the plugin.
A plugin must be a class, which inherits directly or indirectly from GwBasePatte... |
Returns the plugin class object with the given name.
Or if a name is not given, the complete plugin dictionary is returned.
:param name: Name of a plugin
:return: None, single plugin or dictionary of plugins | def get(self, name=None):
"""
Returns the plugin class object with the given name.
Or if a name is not given, the complete plugin dictionary is returned.
:param name: Name of a plugin
:return: None, single plugin or dictionary of plugins
"""
if name is None:
... |
Normalize path to unicode
:param path: path
:return: normalize path
>>> _(None)
u''
>>> _(u("test1"))
u'test1'
>>> _("test2")
u'test2' | def _(path):
"""
Normalize path to unicode
:param path: path
:return: normalize path
>>> _(None)
u''
>>> _(u("test1"))
u'test1'
>>> _("test2")
u'test2'
"""
if path is None:
return u("")
if not PY3:
if type(path) == unicode:
return path
... |
Normalize remote href
:param href: remote path
:return: normalize href
>>> remote("/test/hello.txt")
u'/test/hello.txt'
>>> remote("test/hello.txt")
u'/test/hello.txt'
>>> remote("test\hello.txt")
u'/test/hello.txt'
>>> remote(None)
u'/' | def remote(href):
"""
Normalize remote href
:param href: remote path
:return: normalize href
>>> remote("/test/hello.txt")
u'/test/hello.txt'
>>> remote("test/hello.txt")
u'/test/hello.txt'
>>> remote("test\hello.txt")
u'/test/hello.txt'
>>> remote(None)
u'/'
"""
... |
Get common headers
:return: | def getHeaders(self):
"""
Get common headers
:return:
"""
basicauth = base64.encodestring(b(self.user + ':' + self.password)).strip()
return {
"Depth": "1",
"Authorization": 'Basic ' + _decode_utf8(basicauth),
"Accept": "*/*"
} |
list of files and directories at remote server
:param href: remote folder
:return: list(folders, files) and list(None,None) if folder doesn't exist | def list(self, href):
"""
list of files and directories at remote server
:param href: remote folder
:return: list(folders, files) and list(None,None) if folder doesn't exist
"""
for iTry in range(TRYINGS):
logger.info(u("list(%s): %s") % (iTry, href))
... |
Sync local and remote folders
:param localpath: local folder
:param href: remote folder
:param exclude: filter folder which need to exlude
:return: respose | def sync(self, localpath, href, exclude=None, block=True):
"""
Sync local and remote folders
:param localpath: local folder
:param href: remote folder
:param exclude: filter folder which need to exlude
:return: respose
"""
logger.info(u("sync: %s %s") % (l... |
create remote folder
:param href: remote path
:return: response | def mkdir(self, href):
"""
create remote folder
:param href: remote path
:return: response
"""
for iTry in range(TRYINGS):
logger.info(u("mkdir(%s): %s") % (iTry, href))
try:
href = remote(href)
con = self.getConnect... |
Download file to localstorage
:param href: remote path
:param localpath: local path
:return: response | def downloadTo(self, href, localpath):
"""
Download file to localstorage
:param href: remote path
:param localpath: local path
:return: response
"""
for iTry in range(TRYINGS):
logger.info(u("downloadTo(%s): %s %s") % (iTry, href, localpath))
... |
Upload file from localpath to remote server
:param localpath: local path
:param href: remote path
:return: response | def upload(self, localpath, href):
"""
Upload file from localpath to remote server
:param localpath: local path
:param href: remote path
:return: response
"""
localpath = _(localpath)
href = remote(href)
if not os.path.exists(localpath):
... |
Internal method to import instance variables data from a dictionary
:param dict datadict: The dictionary containing variables values. | def _import(self, datadict):
"""
Internal method to import instance variables data from a dictionary
:param dict datadict: The dictionary containing variables values.
"""
self.GUID = datadict.get("GUID", uuid.uuid1())
self.FileName = datadict.get("FileName", "")
... |
Writes the ``.sln`` file to disk. | def write(self):
"""
Writes the ``.sln`` file to disk.
"""
filters = {
'MSGUID': lambda x: ('{%s}' % x).upper(),
'relslnfile': lambda x: os.path.relpath(x, os.path.dirname(self.FileName))
}
context = {
'sln': self
}
retu... |
Log-normalizes and filters the expression data.
Parameters
----------
div : float, optional, default 1
The factor by which the gene expression will be divided prior to
log normalization.
downsample : float, optional, default 0
The factor by which to... | def preprocess_data(self, div=1, downsample=0, sum_norm=None,
include_genes=None, exclude_genes=None,
include_cells=None, exclude_cells=None,
norm='log', min_expression=1, thresh=0.01,
filter_genes=True):
"""Log-norm... |
Loads the specified data file. The file can be a table of
read counts (i.e. '.csv' or '.txt'), with genes as rows and cells
as columns by default. The file can also be a pickle file (output from
'save_sparse_data') or an h5ad file (output from 'save_anndata').
This function that loads t... | def load_data(self, filename, transpose=True,
save_sparse_file='h5ad', sep=',', **kwargs):
"""Loads the specified data file. The file can be a table of
read counts (i.e. '.csv' or '.txt'), with genes as rows and cells
as columns by default. The file can also be a pickle file (o... |
Saves the tuple (raw_data,all_cell_names,all_gene_names) in a
Pickle file.
Parameters
----------
fname - string
The filename of the output file. | def save_sparse_data(self, fname):
"""Saves the tuple (raw_data,all_cell_names,all_gene_names) in a
Pickle file.
Parameters
----------
fname - string
The filename of the output file.
"""
data = self.adata_raw.X.T
if data.getformat()=='csr':
... |
Loads cell annotations.
Loads the cell annoations specified by the 'aname' path.
Parameters
----------
aname - string
The path to the annotations file. First column should be cell IDs
and second column should be the desired annotations. | def load_annotations(self, aname, sep=','):
"""Loads cell annotations.
Loads the cell annoations specified by the 'aname' path.
Parameters
----------
aname - string
The path to the annotations file. First column should be cell IDs
and second column shoul... |
Saves `adata_raw` to a .h5ad file (AnnData's native file format).
Parameters
----------
fname - string
The filename of the output file. | def save_anndata(self, fname, data = 'adata_raw', **kwargs):
"""Saves `adata_raw` to a .h5ad file (AnnData's native file format).
Parameters
----------
fname - string
The filename of the output file.
"""
x = self.__dict__[data]
x.write_h5ad(fname, **... |
Computes the spatial dispersion factors for each gene.
Parameters
----------
nnm - scipy.sparse, float
Square cell-to-cell nearest-neighbor matrix.
num_norm_avg - int, optional, default 50
The top 'num_norm_avg' dispersions are averaged to determine the
... | def dispersion_ranking_NN(self, nnm, num_norm_avg=50):
"""Computes the spatial dispersion factors for each gene.
Parameters
----------
nnm - scipy.sparse, float
Square cell-to-cell nearest-neighbor matrix.
num_norm_avg - int, optional, default 50
The top... |
Computes the contribution of the gene IDs in 'genes' to each
principal component (PC) of the filtered expression data as the mean of
the absolute value of the corresponding gene loadings. High values
correspond to PCs that are highly correlated with the features in
'genes'. These PCs can... | def calculate_regression_PCs(self, genes=None, npcs=None, plot=False):
"""Computes the contribution of the gene IDs in 'genes' to each
principal component (PC) of the filtered expression data as the mean of
the absolute value of the corresponding gene loadings. High values
correspond to ... |
Regress out the principal components in 'PCs' from the filtered
expression data ('SAM.D'). Assumes 'calculate_regression_PCs' has
been previously called.
Parameters
----------
PCs - int, numpy.array, list
The principal components to regress out of the expression data... | def regress_genes(self, PCs):
"""Regress out the principal components in 'PCs' from the filtered
expression data ('SAM.D'). Assumes 'calculate_regression_PCs' has
been previously called.
Parameters
----------
PCs - int, numpy.array, list
The principal compone... |
Runs the Self-Assembling Manifold algorithm.
Parameters
----------
k - int, optional, default 20
The number of nearest neighbors to identify for each cell.
distance : string, optional, default 'correlation'
The distance metric to use when constructing cell dista... | def run(self,
max_iter=10,
verbose=True,
projection='umap',
stopping_condition=5e-3,
num_norm_avg=50,
k=20,
distance='correlation',
preprocessing='Normalizer',
proj_kwargs={}):
"""Runs the Self-Assembling... |
Plots orthogonal expression patterns.
In the default mode, plots orthogonal gene expression patterns. A
specific correlated group of genes can be specified to plot gene
expression patterns within that group.
Parameters
----------
group - int, optional, default None
... | def plot_correlated_groups(self, group=None, n_genes=5, **kwargs):
"""Plots orthogonal expression patterns.
In the default mode, plots orthogonal gene expression patterns. A
specific correlated group of genes can be specified to plot gene
expression patterns within that group.
... |
Plots gene expression patterns correlated with the input gene.
Parameters
----------
name - string
The name of the gene with respect to which correlated gene
expression patterns will be displayed.
n_genes - int, optional, default 5
The number of top ... | def plot_correlated_genes(
self,
name,
n_genes=5,
number_of_features=1000,
**kwargs):
"""Plots gene expression patterns correlated with the input gene.
Parameters
----------
name - string
The name of the gene with r... |
A (hacky) method for binning groups of genes correlated along the
SAM manifold.
Parameters
----------
number_of_features - int, optional, default None
The number of genes to bin. Capped at 5000 due to memory
considerations.
input_gene - str, optional, de... | def corr_bin_genes(self, number_of_features=None, input_gene=None):
"""A (hacky) method for binning groups of genes correlated along the
SAM manifold.
Parameters
----------
number_of_features - int, optional, default None
The number of genes to bin. Capped at 5000 du... |
Wrapper for sklearn's t-SNE implementation.
See sklearn for the t-SNE documentation. All arguments are the same
with the exception that 'metric' is set to 'precomputed' by default,
implying that this function expects a distance matrix by default. | def run_tsne(self, X=None, metric='correlation', **kwargs):
"""Wrapper for sklearn's t-SNE implementation.
See sklearn for the t-SNE documentation. All arguments are the same
with the exception that 'metric' is set to 'precomputed' by default,
implying that this function expects a dista... |
Wrapper for umap-learn.
See https://github.com/lmcinnes/umap sklearn for the documentation
and source code. | def run_umap(self, X=None, metric=None, **kwargs):
"""Wrapper for umap-learn.
See https://github.com/lmcinnes/umap sklearn for the documentation
and source code.
"""
import umap as umap
if metric is None:
metric = self.distance
if(X is not None):
... |
Experimental -- running UMAP on the diffusion components | def run_diff_umap(self,use_rep='X_pca', metric='euclidean', n_comps=15,
method='gauss', **kwargs):
"""
Experimental -- running UMAP on the diffusion components
"""
import scanpy.api as sc
sc.pp.neighbors(self.adata,use_rep=use_rep,n_neig... |
Display a scatter plot.
Displays a scatter plot using the SAM projection or another input
projection with or without annotations.
Parameters
----------
projection - ndarray of floats, optional, default None
An N x 2 matrix, where N is the number of data points. If ... | def scatter(self, projection=None, c=None, cmap='rainbow', linewidth=0.0,
edgecolor='k', axes=None, colorbar=True, s=10, **kwargs):
"""Display a scatter plot.
Displays a scatter plot using the SAM projection or another input
projection with or without annotations.
Param... |
Display a gene's expressions.
Displays a scatter plot using the SAM projection or another input
projection with a particular gene's expressions overlaid.
Parameters
----------
gene - string
a case-sensitive string indicating the gene expression pattern
t... | def show_gene_expression(self, gene, avg=True, axes=None, **kwargs):
"""Display a gene's expressions.
Displays a scatter plot using the SAM projection or another input
projection with a particular gene's expressions overlaid.
Parameters
----------
gene - string
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.