text
stringlengths
81
112k
Create a new automation object. Arguments: object_type -- Type of object to create. under -- Handle of the parent of the new object. attributes -- Dictionary of attributes (name-value pairs). kwattrs -- Optional keyword attributes (name=value pairs). Return: ...
Delete the specified object. Arguments: handle -- Handle of object to delete. def delete(self, handle): """Delete the specified object. Arguments: handle -- Handle of object to delete. """ self._check_session() self._rest.delete_request('objects', str(...
Execute a command. Arguments can be supplied either as a dictionary or as keyword arguments. Examples: stc.perform('LoadFromXml', {'filename':'config.xml'}) stc.perform('LoadFromXml', filename='config.xml') Arguments: command -- Command to execute. para...
Sets or modifies one or more object attributes or relations. Arguments can be supplied either as a dictionary or as keyword arguments. Examples: stc.config('port1', location='//10.1.2.3/1/1') stc.config('port2', {'location': '//10.1.2.3/1/2'}) Arguments: handle...
Get list of chassis known to test session. def chassis(self): """Get list of chassis known to test session.""" self._check_session() status, data = self._rest.get_request('chassis') return data
Get information about the specified chassis. def chassis_info(self, chassis): """Get information about the specified chassis.""" if not chassis or not isinstance(chassis, str): raise RuntimeError('missing chassis address') self._check_session() status, data = self._rest.get_...
Get list of connections. def connections(self): """Get list of connections.""" self._check_session() status, data = self._rest.get_request('connections') return data
Get Boolean connected status of the specified chassis. def is_connected(self, chassis): """Get Boolean connected status of the specified chassis.""" self._check_session() try: status, data = self._rest.get_request('connections', chassis) except resthttp.RestHttpError as e: ...
Establish connection to one or more chassis. Arguments: chassis_list -- List of chassis (IP addresses or DNS names) Return: List of chassis addresses. def connect(self, chassis_list): """Establish connection to one or more chassis. Arguments: chassis_list -- L...
Remove connection with one or more chassis. Arguments: chassis_list -- List of chassis (IP addresses or DNS names) def disconnect(self, chassis_list): """Remove connection with one or more chassis. Arguments: chassis_list -- List of chassis (IP addresses or DNS names) ...
Get help information about Automation API. The following values can be specified for the subject: None -- gets an overview of help. 'commands' -- gets a list of API functions command name -- get info about the specified command. object type -- get info about the...
Write a diagnostic message to a log file or to standard output. Arguments: level -- Severity level of entry. One of: INFO, WARN, ERROR, FATAL. msg -- Message to write to log. def log(self, level, msg): """Write a diagnostic message to a log file or to standard output. Argum...
Download the specified file from the server. Arguments: file_name -- Name of file resource to save. save_as -- Optional path name to write file to. If not specified, then file named by the last part of the resource path is downloaded to current direc...
Download all available files. Arguments: dst_dir -- Optional destination directory to write files to. If not specified, then files are downloaded current directory. Return: Dictionary of {file_name: file_size, ..} def download_all(self, dst_dir=None): "...
Upload the specified file to the server. def upload(self, src_file_path, dst_file_name=None): """Upload the specified file to the server.""" self._check_session() status, data = self._rest.upload_file( 'files', src_file_path, dst_file_name) return data
Wait until sequencer is finished. This method blocks your application until the sequencer has completed its operation. It returns once the sequencer has finished. Arguments: timeout -- Optional. Seconds to wait for sequencer to finish. If this time is exceeded, th...
Set the results to two items: >>> objects = ManagerMock(Post.objects, 'queryset', 'result') >>> assert objects.filter() == objects.all() Force an exception: >>> objects = ManagerMock(Post.objects, Exception()) See QuerySetMock for more about how this works. def ManagerMock(manager, *return_valu...
Asserts that a chained method was called (parents in the chain do not matter, nor are they tracked). Use with `mock.call`. >>> obj.filter(foo='bar').select_related('baz') >>> obj.assert_chain_calls(mock.call.filter(foo='bar')) >>> obj.assert_chain_calls(mock.call.select_related('baz'))...
Temporarily attaches a receiver to the provided ``signal`` within the scope of the context manager. The mocked receiver is returned as the ``as`` target of the ``with`` statement. To have the mocked receiver wrap a callable, pass the callable as the ``wraps`` keyword argument. All other keyword ar...
Get a SharedMock that returns self for most attributes and a new copy of itself for any method that ordinarily generates QuerySets. Set the results to two items: >>> class Post(object): pass >>> objects = QuerySetMock(Post, 'return', 'values') >>> assert list(objects.filter()) == list(objects.all(...
Overridden read() method to call parse_flask_section() at the end def read(self, *args, **kwargs): '''Overridden read() method to call parse_flask_section() at the end''' ret = configparser.SafeConfigParser.read(self, *args, **kwargs) self.parse_flask_section() return ret
Overridden readfp() method to call parse_flask_section() at the end def readfp(self, *args, **kwargs): '''Overridden readfp() method to call parse_flask_section() at the end''' ret = configparser.SafeConfigParser.readfp(self, *args, **kwargs) self.parse_flask_section() r...
Parse the [flask] section of your config and hand off the config to the app in context. Config vars should have the same name as their flask equivalent except in all lower-case. def parse_flask_section(self): '''Parse the [flask] section of your config and hand off the config t...
Load the specified item from the [flask] section. Type is determined by the type of the equivalent value in app.default_config or string if unknown. def _load_item(self, key): '''Load the specified item from the [flask] section. Type is determined by the type of the equivalent value in ...
passed a version: this version don't exists in the database and is younger than the last version -> do migrations up until this version this version don't exists in the database and is older than the last version -> do nothing, is a unpredictable behavior this version exists in the d...
Generate a token string from bytes arrays. The token in the session is user specific. def csrf_token(): """ Generate a token string from bytes arrays. The token in the session is user specific. """ if "_csrf_token" not in session: session["_csrf_token"] = os.urandom(128) return hmac...
Checks that token is correct, aborting if not def check_csrf_token(): """Checks that token is correct, aborting if not""" if request.method in ("GET",): # not exhaustive list return token = request.form.get("csrf_token") if token is None: app.logger.warning("Expected CSRF Token: not pre...
Get the HTTPRequest object from thread storage or from a callee by searching each frame in the call stack. def get_request(cls): """ Get the HTTPRequest object from thread storage or from a callee by searching each frame in the call stack. """ request = cls.get_global('r...
An alternative to :meth:`flask.Flask.route` or :meth:`flask.Blueprint.route` that always adds the ``POST`` method to the allowed endpoint request methods. You should use this for all your view functions that would need to use Sijax. We're doing this because Sijax uses ``POST`` for data passing, which ...
Takes a Sijax response object and returns a valid Flask response object. def _make_response(sijax_response): """Takes a Sijax response object and returns a valid Flask response object.""" from types import GeneratorType if isinstance(sijax_response, GeneratorType): # Streaming response usi...
Registers a single Comet callback function (see :ref:`comet-plugin`). Refer to :func:`sijax.plugin.comet.register_comet_callback` for more details - its signature differs slightly. This method's signature is the same, except that the first argument that :func:`sijax.plugin.come...
Registers all functions from the object as Comet functions (see :ref:`comet-plugin`). This makes mass registration of functions a lot easier. Refer to :func:`sijax.plugin.comet.register_comet_object` for more details -ts signature differs slightly. This method's signature is t...
Registers an Upload function (see :ref:`upload-plugin`) to handle a certain form. Refer to :func:`sijax.plugin.upload.register_upload_callback` for more details. This method passes some additional arguments to your handler functions - the ``flask.request.files`` object. ...
Executes a callback and returns the proper response. Refer to :meth:`sijax.Sijax.execute_callback` for more details. def execute_callback(self, *args, **kwargs): """Executes a callback and returns the proper response. Refer to :meth:`sijax.Sijax.execute_callback` for more details. """...
Returns True if the given HttpRequest has permission to view *at least one* page in the admin site. def has_permission(self, request, extra_permission=None): """ Returns True if the given HttpRequest has permission to view *at least one* page in the admin site. """ permi...
Wraps a view in authentication/caching logic extra_permission can be used to require an extra permission for this view, such as a module permission def as_view(self, view, cacheable=False, extra_permission=None): """ Wraps a view in authentication/caching logic extra_permission can be...
Serve static files below a given point in the directory structure. def media(self, request, module, path): """ Serve static files below a given point in the directory structure. """ if module == 'nexus': document_root = os.path.join(NEXUS_ROOT, 'media') else: ...
Login form def login(self, request, form_class=None): "Login form" from django.contrib.auth import login as login_ from django.contrib.auth.forms import AuthenticationForm if form_class is None: form_class = AuthenticationForm if request.POST: form = fo...
Logs out user and redirects them to Nexus home def logout(self, request): "Logs out user and redirects them to Nexus home" from django.contrib.auth import logout logout(request) return HttpResponseRedirect(reverse('nexus:index', current_app=self.name))
Basic dashboard panel def dashboard(self, request): "Basic dashboard panel" # TODO: these should be ajax module_set = [] for namespace, module in self.get_modules(): home_url = module.get_home_url(request) if hasattr(module, 'render_on_dashboard'): ...
Displays the row of buttons for delete and save. def submit_row(context): """ Displays the row of buttons for delete and save. """ opts = context['opts'] change = context['change'] is_popup = context['is_popup'] save_as = context['save_as'] return { 'onclick_attrib': (opts.get_...
Auto-discover INSTALLED_APPS nexus.py modules and fail silently when not present. This forces an import on them to register any api bits they may want. Specifying ``site`` will register all auto discovered modules with the new site. def autodiscover(site=None): """ Auto-discover INSTALLED_APPS nex...
Internal for parsing def handle_starttag(self, tagName, attributeList, isSelfClosing=False): ''' Internal for parsing ''' tagName = tagName.lower() inTag = self._inTag if isSelfClosing is False and tagName in IMPLICIT_SELF_CLOSING_TAGS: isSelfClosing = T...
Internal for parsing def handle_endtag(self, tagName): ''' Internal for parsing ''' try: foundIt = False inTag = self._inTag for i in range(len(inTag)): if inTag[i].tagName == tagName: foundIt = True ...
Internal for parsing def handle_data(self, data): ''' Internal for parsing ''' if data: inTag = self._inTag if len(inTag) > 0: inTag[-1].appendText(data) elif data.strip(): #and not self.getRoot(): # Must be text pr...
Internal for parsing def handle_entityref(self, entity): ''' Internal for parsing ''' inTag = self._inTag if len(inTag) > 0: inTag[-1].appendText('&%s;' %(entity,)) else: raise MultipleRootNodeException()
Internal for parsing def handle_charref(self, charRef): ''' Internal for parsing ''' inTag = self._inTag if len(inTag) > 0: inTag[-1].appendText('&#%s;' %(charRef,)) else: raise MultipleRootNodeException()
Internal for parsing def handle_comment(self, comment): ''' Internal for parsing ''' inTag = self._inTag if len(inTag) > 0: inTag[-1].appendText('<!-- %s -->' %(comment,)) else: raise MultipleRootNodeException()
getRootNodes - Gets all objects at the "root" (first level; no parent). Use this if you may have multiple roots (not children of <html>) Use this method to get objects, for example, in an AJAX request where <html> may not be your root. Note: If there are multiple root nodes (i.e. no <ht...
getAllNodes - Get every element @return TagCollection<AdvancedTag> def getAllNodes(self): ''' getAllNodes - Get every element @return TagCollection<AdvancedTag> ''' ret = TagCollection() for rootNode in self.getRootNodes(): ret.append(...
getElementsByTagName - Searches and returns all elements with a specific tag name. @param tagName <lowercase str> - A lowercase string of the tag name. @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the p...
getElementsByName - Searches and returns all elements with a specific name. @param name <str> - A string of the name attribute @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root' [default], the root of the parsed tree will ...
getElementById - Searches and returns the first (should only be one) element with the given ID. @param id <str> - A string of the id attribute. @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root' [default], the root of the ...
getElementsByClassName - Searches and returns all elements containing a given class name. @param className <str> - A one-word class name @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root' [default], the root of the parsed ...
getElementsByAttr - Searches the full tree for elements with a given attribute name and value combination. This is always a full scan. @param attrName <lowercase str> - A lowercase attribute name @param attrValue <str> - Expected value of attribute @param ...
getElementsWithAttrValues - Returns elements with an attribute, named by #attrName contains one of the values in the list, #values @param attrName <lowercase str> - A lowercase attribute name @param attrValues set<str> - A set of all valid values. @return - TagCollection of all m...
getElementsCustomFilter - Scan elements using a provided function @param filterFunc <function>(node) - A function that takes an AdvancedTag as an argument, and returns True if some arbitrary criteria is met @return - TagCollection of all matching elements def getElementsCustomFilter(self, fil...
getFirstElementCustomFilter - Scan elements using a provided function, stop and return the first match. @see getElementsCustomFilter to match multiple elements @param filterFunc <function>(node) - A function that takes an AdvancedTag as an argument, and returns True if some arbitrary crite...
Checks if #em is found anywhere within this element tree @param em <AdvancedTag> - Tag of interest @return <bool> - If element #em is within this tree def contains(self, em): ''' Checks if #em is found anywhere within this element tree @param em <AdvancedTag> ...
Check if #uid is found anywhere within this element tree @param uid <uuid.UUID> - Uid @return <bool> - If #uid is found within this tree def containsUid(self, uid): ''' Check if #uid is found anywhere within this element tree @param uid <uuid.UUID> - Uid ...
find - Perform a search of elements using attributes as keys and potential values as values (i.e. parser.find(name='blah', tagname='span') will return all elements in this document with the name "blah" of the tag type "span" ) Arguments are key = value, or key...
getHTML - Get the full HTML as contained within this tree. If parsed from a document, this will contain the original whitespacing. @returns - <str> of html @see getFormattedHTML @see getMiniHTML def getHTML(self): ''' getHT...
getFormattedHTML - Get formatted and xhtml of this document, replacing the original whitespace with a pretty-printed version @param indent - space/tab/newline of each level of indent, or integer for how many spaces per level @return - <str> Formatted html @...
getMiniHTML - Gets the HTML representation of this document without any pretty formatting and disregarding original whitespace beyond the functional. @return <str> - HTML with only functional whitespace present def getMiniHTML(self): ''' getMiniHTML - Gets the HTML ...
_reset - reset this object. Assigned to .reset after __init__ call. def _reset(self): ''' _reset - reset this object. Assigned to .reset after __init__ call. ''' HTMLParser.reset(self) self.root = None self.doctype = None self._inTag = []
feed - Feed contents. Use parseStr or parseFile instead. @param contents - Contents def feed(self, contents): ''' feed - Feed contents. Use parseStr or parseFile instead. @param contents - Contents ''' contents = stripIEConditionals(contents) try:...
parseFile - Parses a file and creates the DOM tree and indexes @param filename <str/file> - A string to a filename or a file object. If file object, it will not be closed, you must close. def parseFile(self, filename): ''' parseFile - Parses a file and creates the DOM tree and ...
parseStr - Parses a string and creates the DOM tree and indexes. @param html <str> - valid HTML def parseStr(self, html): ''' parseStr - Parses a string and creates the DOM tree and indexes. @param html <str> - valid HTML ''' self.reset() i...
createElementFromHTML - Creates an element from a string of HTML. If this could create multiple root-level elements (children are okay), you must use #createElementsFromHTML which returns a list of elements created. @param html <str> - Some html data @param e...
createElementsFromHTML - Creates elements from provided html, and returns a list of the root-level elements children of these root-level nodes are accessable via the usual means. @param html <str> - Some html data @param encoding <str> - Encoding to use for document ...
createBlocksFromHTML - Returns the root level node (unless multiple nodes), and a list of "blocks" added (text and nodes). @return list< str/AdvancedTag > - List of blocks created. May be strings (text nodes) or AdvancedTag (tags) NOTE: Results may be checked b...
internal for parsing def handle_starttag(self, tagName, attributeList, isSelfClosing=False): ''' internal for parsing ''' newTag = AdvancedHTMLParser.handle_starttag(self, tagName, attributeList, isSelfClosing) self._indexTag(newTag) return newTag
reindex - reindex the tree. Optionally, change what fields are indexed. @param newIndexIDs <bool/None> - None to leave same, otherwise new value to index IDs @parma newIndexNames <bool/None> - None to leave same, otherwise new value to index names @param newI...
disableIndexing - Disables indexing. Consider using plain AdvancedHTMLParser class. Maybe useful in some scenarios where you want to parse, add a ton of elements, then index and do a bunch of searching. def disableIndexing(self): ''' disableIndexing - Disables indexing. ...
addIndexOnAttribute - Add an index for an arbitrary attribute. This will be used by the getElementsByAttr function. You should do this prior to parsing, or call reindex. Otherwise it will be blank. "name" and "id" will have no effect. @param attributeName <lowercase str> - An attrib...
removeIndexOnAttribute - Remove an attribute from indexing (for getElementsByAttr function) and remove indexed data. @param attributeName <lowercase str> - An attribute name. Will be lowercased. "name" and "id" will have no effect. def removeIndexOnAttribute(self, attributeName): ''' remov...
getElementsByTagName - Searches and returns all elements with a specific tag name. @param tagName <lowercase str> - A lowercase string of the tag name. @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the p...
getElementsByName - Searches and returns all elements with a specific name. @param name <str> - A string of the name attribute @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the parsed tree will be used. ...
getElementById - Searches and returns the first (should only be one) element with the given ID. @param id <str> - A string of the id attribute. @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the parsed tre...
getElementsByClassName - Searches and returns all elements containing a given class name. @param className <str> - A one-word class name @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the parsed tree will ...
getElementsByAttr - Searches the full tree for elements with a given attribute name and value combination. If you want multiple potential values, see getElementsWithAttrValues If you want an index on a random attribute, use the addIndexOnAttribute function. @param attrName...
getElementsWithAttrValues - Returns elements with an attribute matching one of several values. For a single name/value combination, see getElementsByAttr @param attrName <lowercase str> - A lowercase attribute name @param attrValues set<str> - List of expected values of attribute ...
uniqueTags - Returns the unique tags in tagList. @param tagList list<AdvancedTag> : A list of tag objects. def uniqueTags(tagList): ''' uniqueTags - Returns the unique tags in tagList. @param tagList list<AdvancedTag> : A list of tag objects. ''' ret = [] ...
toggleAttributesDOM - Toggle if the old DOM tag.attributes NamedNodeMap model should be used for the .attributes method, versus a more sane direct dict implementation. The DOM version is always accessable as AdvancedTag.attributesDOM The dict version is always accessable as Advanced...
cloneNode - Clone this node (tag name and attributes). Does not clone children. Tags will be equal according to isTagEqual method, but will contain a different internal unique id such tag origTag != origTag.cloneNode() , as is the case in JS DOM. def cloneNode(self): ''' cl...
appendText - append some inner text def appendText(self, text): ''' appendText - append some inner text ''' # self.text is just raw string of the text self.text += text self.isSelfClosing = False # inner text means it can't self close anymo # self.blocks is e...
removeText - Removes the first occurace of given text in a text node (i.e. not part of a tag) @param text <str> - text to remove @return text <str/None> - The text in that block (text node) after remove, or None if not found NOTE: To remove a node, @see removeChild NOT...
removeTextAll - Removes ALL occuraces of given text in a text node (i.e. not part of a tag) @param text <str> - text to remove @return list <str> - All text node containing #text BEFORE the text was removed. Empty list if no text removed NOTE: To remove a node, @se...
remove - Will remove this node from its parent, if it has a parent (thus taking it out of the HTML tree) NOTE: If you are using an IndexedAdvancedHTMLParser, calling this will NOT update the index. You MUST call reindex method manually. @return <bool> - While JS DOM defin...
removeBlock - Removes a list of blocks (the first occurance of each) from the direct children of this node. @param blocks list<str/AdvancedTag> - List of AdvancedTags for tag nodes, else strings for text nodes @return The removed blocks in each slot, or None if None removed. @see...
appendChild - Append a child to this element. @param child <AdvancedTag> - Append a child element to this element def appendChild(self, child): ''' appendChild - Append a child to this element. @param child <AdvancedTag> - Append a child element to this element '''...
append / appendBlock - Append a block to this element. A block can be a string (text node), or an AdvancedTag (tag node) @param <str/AdvancedTag> - block to add @return - #block NOTE: To add multiple blocks, @see appendBlocks If you know the type, use either @see...
appendBlocks - Append blocks to this element. A block can be a string (text node), or an AdvancedTag (tag node) @param blocks list<str/AdvancedTag> - A list, in order to append, of blocks to add. @return - #blocks NOTE: To add a single block, @see appendBlock If ...
appendInnerHTML - Appends nodes from arbitrary HTML as if doing element.innerHTML += 'someHTML' in javascript. @param html <str> - Some HTML NOTE: If associated with a document ( AdvancedHTMLParser ), the html will use the encoding associated with that document. ...
removeChild - Remove a child tag, if present. @param child <AdvancedTag> - The child to remove @return - The child [with parentNode cleared] if removed, otherwise None. NOTE: This removes a tag. If removing a text block, use #removeText function. If y...
removeChildren - Remove multiple child AdvancedTags. @see removeChild @return list<AdvancedTag/None> - A list of all tags removed in same order as passed. Item is "None" if it was not attached to this node, and thus was not removed. def removeChildren(self, children): ...
removeBlock - Removes a single block (text node or AdvancedTag) which is a child of this object. @param block <str/AdvancedTag> - The block (text node or AdvancedTag) to remove. @return Returns the removed block if one was removed, or None if requested block is not a child of this ...
insertBefore - Inserts a child before #beforeChild @param child <AdvancedTag/str> - Child block to insert @param beforeChild <AdvancedTag/str> - Child block to insert before. if None, will be appended @return - The added child. Note, if it is a text block (str), the retu...
insertAfter - Inserts a child after #afterChild @param child <AdvancedTag/str> - Child block to insert @param afterChild <AdvancedTag/str> - Child block to insert after. if None, will be appended @return - The added child. Note, if it is a text block (str), the return is...
firstChild - property, Get the first child block, text or tag. @return <str/AdvancedTag/None> - The first child block, or None if no child blocks def firstChild(self): ''' firstChild - property, Get the first child block, text or tag. @return <str/AdvancedTag/None>...