id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
226,300
fhamborg/news-please
newsplease/helper_classes/savepath_parser.py
SavepathParser.append_md5_if_too_long
def append_md5_if_too_long(component, size): """ Trims the component if it is longer than size and appends the component's md5. Total must be of length size. :param str component: component to work on :param int size: component's size limit :return str: component and app...
python
def append_md5_if_too_long(component, size): """ Trims the component if it is longer than size and appends the component's md5. Total must be of length size. :param str component: component to work on :param int size: component's size limit :return str: component and app...
[ "def", "append_md5_if_too_long", "(", "component", ",", "size", ")", ":", "if", "len", "(", "component", ")", ">", "size", ":", "if", "size", ">", "32", ":", "component_size", "=", "size", "-", "32", "-", "1", "return", "\"%s_%s\"", "%", "(", "componen...
Trims the component if it is longer than size and appends the component's md5. Total must be of length size. :param str component: component to work on :param int size: component's size limit :return str: component and appended md5 trimmed to be of length size
[ "Trims", "the", "component", "if", "it", "is", "longer", "than", "size", "and", "appends", "the", "component", "s", "md5", ".", "Total", "must", "be", "of", "length", "size", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/savepath_parser.py#L90-L108
226,301
fhamborg/news-please
newsplease/helper_classes/savepath_parser.py
SavepathParser.remove_not_allowed_chars
def remove_not_allowed_chars(savepath): """ Removes invalid filepath characters from the savepath. :param str savepath: the savepath to work on :return str: the savepath without invalid filepath characters """ split_savepath = os.path.splitdrive(savepath) # https...
python
def remove_not_allowed_chars(savepath): """ Removes invalid filepath characters from the savepath. :param str savepath: the savepath to work on :return str: the savepath without invalid filepath characters """ split_savepath = os.path.splitdrive(savepath) # https...
[ "def", "remove_not_allowed_chars", "(", "savepath", ")", ":", "split_savepath", "=", "os", ".", "path", ".", "splitdrive", "(", "savepath", ")", "# https://msdn.microsoft.com/en-us/library/aa365247.aspx", "savepath_without_invalid_chars", "=", "re", ".", "sub", "(", "r'...
Removes invalid filepath characters from the savepath. :param str savepath: the savepath to work on :return str: the savepath without invalid filepath characters
[ "Removes", "invalid", "filepath", "characters", "from", "the", "savepath", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/savepath_parser.py#L219-L230
226,302
fhamborg/news-please
newsplease/helper_classes/savepath_parser.py
SavepathParser.get_abs_path_static
def get_abs_path_static(savepath, relative_to_path): """ Figures out the savepath's absolute version. :param str savepath: the savepath to return an absolute version of :param str relative_to_path: the file path this savepath should be relative to ...
python
def get_abs_path_static(savepath, relative_to_path): """ Figures out the savepath's absolute version. :param str savepath: the savepath to return an absolute version of :param str relative_to_path: the file path this savepath should be relative to ...
[ "def", "get_abs_path_static", "(", "savepath", ",", "relative_to_path", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "savepath", ")", ":", "return", "os", ".", "path", ".", "abspath", "(", "savepath", ")", "else", ":", "return", "os", ".", "pa...
Figures out the savepath's absolute version. :param str savepath: the savepath to return an absolute version of :param str relative_to_path: the file path this savepath should be relative to :return str: absolute version of savepath
[ "Figures", "out", "the", "savepath", "s", "absolute", "version", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/savepath_parser.py#L233-L247
226,303
fhamborg/news-please
newsplease/helper_classes/savepath_parser.py
SavepathParser.get_base_path
def get_base_path(path): """ Determines the longest possible beginning of a path that does not contain a %-Symbol. /this/is/a/pa%th would become /this/is/a :param str path: the path to get the base from :return: the path's base """ if "%" not in path: ...
python
def get_base_path(path): """ Determines the longest possible beginning of a path that does not contain a %-Symbol. /this/is/a/pa%th would become /this/is/a :param str path: the path to get the base from :return: the path's base """ if "%" not in path: ...
[ "def", "get_base_path", "(", "path", ")", ":", "if", "\"%\"", "not", "in", "path", ":", "return", "path", "path", "=", "os", ".", "path", ".", "split", "(", "path", ")", "[", "0", "]", "while", "\"%\"", "in", "path", ":", "path", "=", "os", ".", ...
Determines the longest possible beginning of a path that does not contain a %-Symbol. /this/is/a/pa%th would become /this/is/a :param str path: the path to get the base from :return: the path's base
[ "Determines", "the", "longest", "possible", "beginning", "of", "a", "path", "that", "does", "not", "contain", "a", "%", "-", "Symbol", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/savepath_parser.py#L260-L278
226,304
fhamborg/news-please
newsplease/helper_classes/savepath_parser.py
SavepathParser.get_max_url_file_name_length
def get_max_url_file_name_length(savepath): """ Determines the max length for any max... parts. :param str savepath: absolute savepath to work on :return: max. allowed number of chars for any of the max... parts """ number_occurrences = savepath.count('%max_url_file_name...
python
def get_max_url_file_name_length(savepath): """ Determines the max length for any max... parts. :param str savepath: absolute savepath to work on :return: max. allowed number of chars for any of the max... parts """ number_occurrences = savepath.count('%max_url_file_name...
[ "def", "get_max_url_file_name_length", "(", "savepath", ")", ":", "number_occurrences", "=", "savepath", ".", "count", "(", "'%max_url_file_name'", ")", "number_occurrences", "+=", "savepath", ".", "count", "(", "'%appendmd5_max_url_file_name'", ")", "savepath_copy", "=...
Determines the max length for any max... parts. :param str savepath: absolute savepath to work on :return: max. allowed number of chars for any of the max... parts
[ "Determines", "the", "max", "length", "for", "any", "max", "...", "parts", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/savepath_parser.py#L295-L316
226,305
fhamborg/news-please
newsplease/pipeline/extractor/extractors/readability_extractor.py
ReadabilityExtractor.extract
def extract(self, item): """Creates an readability document and returns an ArticleCandidate containing article title and text. :param item: A NewscrawlerItem to parse. :return: ArticleCandidate containing the recovered article data. """ doc = Document(deepcopy(item['spider_resp...
python
def extract(self, item): """Creates an readability document and returns an ArticleCandidate containing article title and text. :param item: A NewscrawlerItem to parse. :return: ArticleCandidate containing the recovered article data. """ doc = Document(deepcopy(item['spider_resp...
[ "def", "extract", "(", "self", ",", "item", ")", ":", "doc", "=", "Document", "(", "deepcopy", "(", "item", "[", "'spider_response'", "]", ".", "body", ")", ")", "description", "=", "doc", ".", "summary", "(", ")", "article_candidate", "=", "ArticleCandi...
Creates an readability document and returns an ArticleCandidate containing article title and text. :param item: A NewscrawlerItem to parse. :return: ArticleCandidate containing the recovered article data.
[ "Creates", "an", "readability", "document", "and", "returns", "an", "ArticleCandidate", "containing", "article", "title", "and", "text", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/pipeline/extractor/extractors/readability_extractor.py#L18-L38
226,306
fhamborg/news-please
newsplease/pipeline/extractor/article_extractor.py
Extractor.extract
def extract(self, item): """Runs the HTML-response trough a list of initialized extractors, a cleaner and compares the results. :param item: NewscrawlerItem to be processed. :return: An updated NewscrawlerItem including the results of the extraction """ article_candidates = [] ...
python
def extract(self, item): """Runs the HTML-response trough a list of initialized extractors, a cleaner and compares the results. :param item: NewscrawlerItem to be processed. :return: An updated NewscrawlerItem including the results of the extraction """ article_candidates = [] ...
[ "def", "extract", "(", "self", ",", "item", ")", ":", "article_candidates", "=", "[", "]", "for", "extractor", "in", "self", ".", "extractor_list", ":", "article_candidates", ".", "append", "(", "extractor", ".", "extract", "(", "item", ")", ")", "article_...
Runs the HTML-response trough a list of initialized extractors, a cleaner and compares the results. :param item: NewscrawlerItem to be processed. :return: An updated NewscrawlerItem including the results of the extraction
[ "Runs", "the", "HTML", "-", "response", "trough", "a", "list", "of", "initialized", "extractors", "a", "cleaner", "and", "compares", "the", "results", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/pipeline/extractor/article_extractor.py#L43-L66
226,307
fhamborg/news-please
newsplease/helper_classes/parse_crawler.py
ParseCrawler.pass_to_pipeline_if_article
def pass_to_pipeline_if_article( self, response, source_domain, original_url, rss_title=None ): """ Responsible for passing a NewscrawlerItem to the pipeline if the response contains an article. :param obj response: the scr...
python
def pass_to_pipeline_if_article( self, response, source_domain, original_url, rss_title=None ): """ Responsible for passing a NewscrawlerItem to the pipeline if the response contains an article. :param obj response: the scr...
[ "def", "pass_to_pipeline_if_article", "(", "self", ",", "response", ",", "source_domain", ",", "original_url", ",", "rss_title", "=", "None", ")", ":", "if", "self", ".", "helper", ".", "heuristics", ".", "is_article", "(", "response", ",", "original_url", ")"...
Responsible for passing a NewscrawlerItem to the pipeline if the response contains an article. :param obj response: the scrapy response to work on :param str source_domain: the response's domain as set for the crawler :param str original_url: the url set in the json file :param ...
[ "Responsible", "for", "passing", "a", "NewscrawlerItem", "to", "the", "pipeline", "if", "the", "response", "contains", "an", "article", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/parse_crawler.py#L27-L46
226,308
fhamborg/news-please
newsplease/helper_classes/parse_crawler.py
ParseCrawler.recursive_requests
def recursive_requests(response, spider, ignore_regex='', ignore_file_extensions='pdf'): """ Manages recursive requests. Determines urls to recursivly crawl if they do not match certain file extensions and do not match a certain regex set in the config file. ...
python
def recursive_requests(response, spider, ignore_regex='', ignore_file_extensions='pdf'): """ Manages recursive requests. Determines urls to recursivly crawl if they do not match certain file extensions and do not match a certain regex set in the config file. ...
[ "def", "recursive_requests", "(", "response", ",", "spider", ",", "ignore_regex", "=", "''", ",", "ignore_file_extensions", "=", "'pdf'", ")", ":", "# Recursivly crawl all URLs on the current page", "# that do not point to irrelevant file types", "# or contain any of the given ig...
Manages recursive requests. Determines urls to recursivly crawl if they do not match certain file extensions and do not match a certain regex set in the config file. :param obj response: the response to extract any urls from :param obj spider: the crawler the callback should be called o...
[ "Manages", "recursive", "requests", ".", "Determines", "urls", "to", "recursivly", "crawl", "if", "they", "do", "not", "match", "certain", "file", "extensions", "and", "do", "not", "match", "a", "certain", "regex", "set", "in", "the", "config", "file", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/parse_crawler.py#L87-L112
226,309
fhamborg/news-please
newsplease/helper_classes/parse_crawler.py
ParseCrawler.content_type
def content_type(self, response): """ Ensures the response is of type :param obj response: The scrapy response :return bool: Determines wether the response is of the correct type """ if not re_html.match(response.headers.get('Content-Type').decode('utf-8')): ...
python
def content_type(self, response): """ Ensures the response is of type :param obj response: The scrapy response :return bool: Determines wether the response is of the correct type """ if not re_html.match(response.headers.get('Content-Type').decode('utf-8')): ...
[ "def", "content_type", "(", "self", ",", "response", ")", ":", "if", "not", "re_html", ".", "match", "(", "response", ".", "headers", ".", "get", "(", "'Content-Type'", ")", ".", "decode", "(", "'utf-8'", ")", ")", ":", "self", ".", "log", ".", "warn...
Ensures the response is of type :param obj response: The scrapy response :return bool: Determines wether the response is of the correct type
[ "Ensures", "the", "response", "is", "of", "type" ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/parse_crawler.py#L114-L128
226,310
fhamborg/news-please
newsplease/pipeline/extractor/comparer/comparer_topimage.py
ComparerTopimage.extract
def extract(self, item, list_article_candidate): """Compares the extracted top images. :param item: The corresponding NewscrawlerItem :param list_article_candidate: A list, the list of ArticleCandidate-Objects which have been extracted :return: A string (url), the most likely top image ...
python
def extract(self, item, list_article_candidate): """Compares the extracted top images. :param item: The corresponding NewscrawlerItem :param list_article_candidate: A list, the list of ArticleCandidate-Objects which have been extracted :return: A string (url), the most likely top image ...
[ "def", "extract", "(", "self", ",", "item", ",", "list_article_candidate", ")", ":", "list_topimage", "=", "[", "]", "for", "article_candidate", "in", "list_article_candidate", ":", "if", "article_candidate", ".", "topimage", "is", "not", "None", ":", "# Changes...
Compares the extracted top images. :param item: The corresponding NewscrawlerItem :param list_article_candidate: A list, the list of ArticleCandidate-Objects which have been extracted :return: A string (url), the most likely top image
[ "Compares", "the", "extracted", "top", "images", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/pipeline/extractor/comparer/comparer_topimage.py#L15-L41
226,311
fhamborg/news-please
newsplease/pipeline/extractor/comparer/comparer_text.py
ComparerText.extract
def extract(self, item, article_candidate_list): """Compares the extracted texts. :param item: The corresponding NewscrawlerItem :param article_candidate_list: A list, the list of ArticleCandidate-Objects which have been extracted :return: A string, the most likely text """ ...
python
def extract(self, item, article_candidate_list): """Compares the extracted texts. :param item: The corresponding NewscrawlerItem :param article_candidate_list: A list, the list of ArticleCandidate-Objects which have been extracted :return: A string, the most likely text """ ...
[ "def", "extract", "(", "self", ",", "item", ",", "article_candidate_list", ")", ":", "list_text", "=", "[", "]", "# The minimal number of words a text needs to have", "min_number_words", "=", "15", "# The texts of the article candidates and the respective extractors are saved in ...
Compares the extracted texts. :param item: The corresponding NewscrawlerItem :param article_candidate_list: A list, the list of ArticleCandidate-Objects which have been extracted :return: A string, the most likely text
[ "Compares", "the", "extracted", "texts", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/pipeline/extractor/comparer/comparer_text.py#L7-L79
226,312
fhamborg/news-please
newsplease/helper_classes/sub_classes/heuristics_manager.py
HeuristicsManager.is_article
def is_article(self, response, url): """ Tests if the given response is an article by calling and checking the heuristics set in config.cfg and sitelist.json :param obj response: The response of the site. :param str url: The base_url (needed to get the site-specific config ...
python
def is_article(self, response, url): """ Tests if the given response is an article by calling and checking the heuristics set in config.cfg and sitelist.json :param obj response: The response of the site. :param str url: The base_url (needed to get the site-specific config ...
[ "def", "is_article", "(", "self", ",", "response", ",", "url", ")", ":", "site", "=", "self", ".", "__sites_object", "[", "url", "]", "heuristics", "=", "self", ".", "__get_enabled_heuristics", "(", "url", ")", "self", ".", "log", ".", "info", "(", "\"...
Tests if the given response is an article by calling and checking the heuristics set in config.cfg and sitelist.json :param obj response: The response of the site. :param str url: The base_url (needed to get the site-specific config from the JSON-file) :return bo...
[ "Tests", "if", "the", "given", "response", "is", "an", "article", "by", "calling", "and", "checking", "the", "heuristics", "set", "in", "config", ".", "cfg", "and", "sitelist", ".", "json" ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/sub_classes/heuristics_manager.py#L36-L67
226,313
fhamborg/news-please
newsplease/helper_classes/sub_classes/heuristics_manager.py
HeuristicsManager.__get_condition
def __get_condition(self, url): """ Gets the condition for a url and validates it. :param str url: The url to get the condition for """ if self.__heuristics_condition is not None: return self.__heuristics_condition if "pass_heuristics_condition" in self.__sit...
python
def __get_condition(self, url): """ Gets the condition for a url and validates it. :param str url: The url to get the condition for """ if self.__heuristics_condition is not None: return self.__heuristics_condition if "pass_heuristics_condition" in self.__sit...
[ "def", "__get_condition", "(", "self", ",", "url", ")", ":", "if", "self", ".", "__heuristics_condition", "is", "not", "None", ":", "return", "self", ".", "__heuristics_condition", "if", "\"pass_heuristics_condition\"", "in", "self", ".", "__sites_object", "[", ...
Gets the condition for a url and validates it. :param str url: The url to get the condition for
[ "Gets", "the", "condition", "for", "a", "url", "and", "validates", "it", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/sub_classes/heuristics_manager.py#L69-L110
226,314
fhamborg/news-please
newsplease/helper_classes/sub_classes/heuristics_manager.py
HeuristicsManager.__evaluate_result
def __evaluate_result(self, result, condition): """ Evaluates a result of a heuristic with the condition given in the config. :param mixed result: The result of the heuristic :param mixed condition: The condition string to evaluate on the result :return bool: Whether the...
python
def __evaluate_result(self, result, condition): """ Evaluates a result of a heuristic with the condition given in the config. :param mixed result: The result of the heuristic :param mixed condition: The condition string to evaluate on the result :return bool: Whether the...
[ "def", "__evaluate_result", "(", "self", ",", "result", ",", "condition", ")", ":", "# If result is bool this means, that the heuristic", "# is bool as well or has a special situation", "# (for example some condition [e.g. in config] is [not] met, thus", "# just pass it)", "if", "isin...
Evaluates a result of a heuristic with the condition given in the config. :param mixed result: The result of the heuristic :param mixed condition: The condition string to evaluate on the result :return bool: Whether the heuristic result matches the condition
[ "Evaluates", "a", "result", "of", "a", "heuristic", "with", "the", "condition", "given", "in", "the", "config", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/sub_classes/heuristics_manager.py#L112-L200
226,315
fhamborg/news-please
newsplease/helper_classes/sub_classes/heuristics_manager.py
HeuristicsManager.__evaluation_error
def __evaluation_error(self, result, condition, throw): """Helper-method for easy error-logging""" self.log.error("Result does not match condition, dropping item. " "Result %s; Condition: %s; Throw: %s", result, condition, throw) return False
python
def __evaluation_error(self, result, condition, throw): """Helper-method for easy error-logging""" self.log.error("Result does not match condition, dropping item. " "Result %s; Condition: %s; Throw: %s", result, condition, throw) return False
[ "def", "__evaluation_error", "(", "self", ",", "result", ",", "condition", ",", "throw", ")", ":", "self", ".", "log", ".", "error", "(", "\"Result does not match condition, dropping item. \"", "\"Result %s; Condition: %s; Throw: %s\"", ",", "result", ",", "condition", ...
Helper-method for easy error-logging
[ "Helper", "-", "method", "for", "easy", "error", "-", "logging" ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/sub_classes/heuristics_manager.py#L202-L207
226,316
fhamborg/news-please
newsplease/helper_classes/sub_classes/heuristics_manager.py
HeuristicsManager.__try_parse_number
def __try_parse_number(self, string): """Try to parse a string to a number, else return False.""" try: return int(string) except ValueError: try: return float(string) except ValueError: return False
python
def __try_parse_number(self, string): """Try to parse a string to a number, else return False.""" try: return int(string) except ValueError: try: return float(string) except ValueError: return False
[ "def", "__try_parse_number", "(", "self", ",", "string", ")", ":", "try", ":", "return", "int", "(", "string", ")", "except", "ValueError", ":", "try", ":", "return", "float", "(", "string", ")", "except", "ValueError", ":", "return", "False" ]
Try to parse a string to a number, else return False.
[ "Try", "to", "parse", "a", "string", "to", "a", "number", "else", "return", "False", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/sub_classes/heuristics_manager.py#L209-L217
226,317
fhamborg/news-please
newsplease/helper_classes/sub_classes/heuristics_manager.py
HeuristicsManager.__get_enabled_heuristics
def __get_enabled_heuristics(self, url): """ Get the enabled heuristics for a site, merging the default and the overwrite together. The config will only be read once and the merged site-config will be cached. :param str url: The url to get the heuristics for. """...
python
def __get_enabled_heuristics(self, url): """ Get the enabled heuristics for a site, merging the default and the overwrite together. The config will only be read once and the merged site-config will be cached. :param str url: The url to get the heuristics for. """...
[ "def", "__get_enabled_heuristics", "(", "self", ",", "url", ")", ":", "if", "url", "in", "self", ".", "__sites_heuristics", ":", "return", "self", ".", "__sites_heuristics", "[", "url", "]", "site", "=", "self", ".", "__sites_object", "[", "url", "]", "heu...
Get the enabled heuristics for a site, merging the default and the overwrite together. The config will only be read once and the merged site-config will be cached. :param str url: The url to get the heuristics for.
[ "Get", "the", "enabled", "heuristics", "for", "a", "site", "merging", "the", "default", "and", "the", "overwrite", "together", ".", "The", "config", "will", "only", "be", "read", "once", "and", "the", "merged", "site", "-", "config", "will", "be", "cached"...
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/helper_classes/sub_classes/heuristics_manager.py#L219-L245
226,318
fhamborg/news-please
newsplease/pipeline/extractor/extractors/abstract_extractor.py
AbstractExtractor.extract
def extract(self, item): """Executes all implemented functions on the given article and returns an object containing the recovered data. :param item: A NewscrawlerItem to parse. :return: ArticleCandidate containing the recovered article data. """ article_candidate = Art...
python
def extract(self, item): """Executes all implemented functions on the given article and returns an object containing the recovered data. :param item: A NewscrawlerItem to parse. :return: ArticleCandidate containing the recovered article data. """ article_candidate = Art...
[ "def", "extract", "(", "self", ",", "item", ")", ":", "article_candidate", "=", "ArticleCandidate", "(", ")", "article_candidate", ".", "extractor", "=", "self", ".", "_name", "(", ")", "article_candidate", ".", "title", "=", "self", ".", "_title", "(", "i...
Executes all implemented functions on the given article and returns an object containing the recovered data. :param item: A NewscrawlerItem to parse. :return: ArticleCandidate containing the recovered article data.
[ "Executes", "all", "implemented", "functions", "on", "the", "given", "article", "and", "returns", "an", "object", "containing", "the", "recovered", "data", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/pipeline/extractor/extractors/abstract_extractor.py#L48-L66
226,319
fhamborg/news-please
newsplease/pipeline/extractor/extractors/newspaper_extractor.py
NewspaperExtractor.extract
def extract(self, item): """Creates an instance of Article without a Download and returns an ArticleCandidate with the results of parsing the HTML-Code. :param item: A NewscrawlerItem to parse. :return: ArticleCandidate containing the recovered article data. """ article_...
python
def extract(self, item): """Creates an instance of Article without a Download and returns an ArticleCandidate with the results of parsing the HTML-Code. :param item: A NewscrawlerItem to parse. :return: ArticleCandidate containing the recovered article data. """ article_...
[ "def", "extract", "(", "self", ",", "item", ")", ":", "article_candidate", "=", "ArticleCandidate", "(", ")", "article_candidate", ".", "extractor", "=", "self", ".", "_name", "(", ")", "article", "=", "Article", "(", "''", ")", "article", ".", "set_html",...
Creates an instance of Article without a Download and returns an ArticleCandidate with the results of parsing the HTML-Code. :param item: A NewscrawlerItem to parse. :return: ArticleCandidate containing the recovered article data.
[ "Creates", "an", "instance", "of", "Article", "without", "a", "Download", "and", "returns", "an", "ArticleCandidate", "with", "the", "results", "of", "parsing", "the", "HTML", "-", "Code", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/pipeline/extractor/extractors/newspaper_extractor.py#L18-L44
226,320
fhamborg/news-please
newsplease/pipeline/extractor/comparer/comparer_author.py
ComparerAuthor.extract
def extract(self, item, list_article_candidate): """Compares the extracted authors. :param item: The corresponding NewscrawlerItem :param list_article_candidate: A list, the list of ArticleCandidate-Objects which have been extracted :return: A string, the most likely authors """...
python
def extract(self, item, list_article_candidate): """Compares the extracted authors. :param item: The corresponding NewscrawlerItem :param list_article_candidate: A list, the list of ArticleCandidate-Objects which have been extracted :return: A string, the most likely authors """...
[ "def", "extract", "(", "self", ",", "item", ",", "list_article_candidate", ")", ":", "list_author", "=", "[", "]", "# The authors of the ArticleCandidates and the respective extractors are saved in a tuple in list_author.", "for", "article_candidate", "in", "list_article_candidat...
Compares the extracted authors. :param item: The corresponding NewscrawlerItem :param list_article_candidate: A list, the list of ArticleCandidate-Objects which have been extracted :return: A string, the most likely authors
[ "Compares", "the", "extracted", "authors", "." ]
731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/pipeline/extractor/comparer/comparer_author.py#L4-L29
226,321
GNS3/gns3-server
gns3server/utils/asyncio/serial.py
_asyncio_open_serial_windows
def _asyncio_open_serial_windows(path): """ Open a windows named pipe :returns: An IO like object """ try: yield from wait_for_named_pipe_creation(path) except asyncio.TimeoutError: raise NodeError('Pipe file "{}" is missing'.format(path)) return WindowsPipe(path)
python
def _asyncio_open_serial_windows(path): """ Open a windows named pipe :returns: An IO like object """ try: yield from wait_for_named_pipe_creation(path) except asyncio.TimeoutError: raise NodeError('Pipe file "{}" is missing'.format(path)) return WindowsPipe(path)
[ "def", "_asyncio_open_serial_windows", "(", "path", ")", ":", "try", ":", "yield", "from", "wait_for_named_pipe_creation", "(", "path", ")", "except", "asyncio", ".", "TimeoutError", ":", "raise", "NodeError", "(", "'Pipe file \"{}\" is missing'", ".", "format", "("...
Open a windows named pipe :returns: An IO like object
[ "Open", "a", "windows", "named", "pipe" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/serial.py#L99-L110
226,322
GNS3/gns3-server
gns3server/utils/asyncio/serial.py
_asyncio_open_serial_unix
def _asyncio_open_serial_unix(path): """ Open a unix socket or a windows named pipe :returns: An IO like object """ try: # wait for VM to create the pipe file. yield from wait_for_file_creation(path) except asyncio.TimeoutError: raise NodeError('Pipe file "{}" is missin...
python
def _asyncio_open_serial_unix(path): """ Open a unix socket or a windows named pipe :returns: An IO like object """ try: # wait for VM to create the pipe file. yield from wait_for_file_creation(path) except asyncio.TimeoutError: raise NodeError('Pipe file "{}" is missin...
[ "def", "_asyncio_open_serial_unix", "(", "path", ")", ":", "try", ":", "# wait for VM to create the pipe file.", "yield", "from", "wait_for_file_creation", "(", "path", ")", "except", "asyncio", ".", "TimeoutError", ":", "raise", "NodeError", "(", "'Pipe file \"{}\" is ...
Open a unix socket or a windows named pipe :returns: An IO like object
[ "Open", "a", "unix", "socket", "or", "a", "windows", "named", "pipe" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/serial.py#L114-L132
226,323
GNS3/gns3-server
gns3server/controller/udp_link.py
UDPLink.create
def create(self): """ Create the link on the nodes """ node1 = self._nodes[0]["node"] adapter_number1 = self._nodes[0]["adapter_number"] port_number1 = self._nodes[0]["port_number"] node2 = self._nodes[1]["node"] adapter_number2 = self._nodes[1]["adapter_...
python
def create(self): """ Create the link on the nodes """ node1 = self._nodes[0]["node"] adapter_number1 = self._nodes[0]["adapter_number"] port_number1 = self._nodes[0]["port_number"] node2 = self._nodes[1]["node"] adapter_number2 = self._nodes[1]["adapter_...
[ "def", "create", "(", "self", ")", ":", "node1", "=", "self", ".", "_nodes", "[", "0", "]", "[", "\"node\"", "]", "adapter_number1", "=", "self", ".", "_nodes", "[", "0", "]", "[", "\"adapter_number\"", "]", "port_number1", "=", "self", ".", "_nodes", ...
Create the link on the nodes
[ "Create", "the", "link", "on", "the", "nodes" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/udp_link.py#L41-L96
226,324
GNS3/gns3-server
gns3server/controller/udp_link.py
UDPLink.delete
def delete(self): """ Delete the link and free the resources """ if not self._created: return try: node1 = self._nodes[0]["node"] adapter_number1 = self._nodes[0]["adapter_number"] port_number1 = self._nodes[0]["port_number"] ...
python
def delete(self): """ Delete the link and free the resources """ if not self._created: return try: node1 = self._nodes[0]["node"] adapter_number1 = self._nodes[0]["adapter_number"] port_number1 = self._nodes[0]["port_number"] ...
[ "def", "delete", "(", "self", ")", ":", "if", "not", "self", ".", "_created", ":", "return", "try", ":", "node1", "=", "self", ".", "_nodes", "[", "0", "]", "[", "\"node\"", "]", "adapter_number1", "=", "self", ".", "_nodes", "[", "0", "]", "[", ...
Delete the link and free the resources
[ "Delete", "the", "link", "and", "free", "the", "resources" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/udp_link.py#L118-L147
226,325
GNS3/gns3-server
gns3server/controller/udp_link.py
UDPLink.start_capture
def start_capture(self, data_link_type="DLT_EN10MB", capture_file_name=None): """ Start capture on a link """ if not capture_file_name: capture_file_name = self.default_capture_file_name() self._capture_node = self._choose_capture_side() data = { "...
python
def start_capture(self, data_link_type="DLT_EN10MB", capture_file_name=None): """ Start capture on a link """ if not capture_file_name: capture_file_name = self.default_capture_file_name() self._capture_node = self._choose_capture_side() data = { "...
[ "def", "start_capture", "(", "self", ",", "data_link_type", "=", "\"DLT_EN10MB\"", ",", "capture_file_name", "=", "None", ")", ":", "if", "not", "capture_file_name", ":", "capture_file_name", "=", "self", ".", "default_capture_file_name", "(", ")", "self", ".", ...
Start capture on a link
[ "Start", "capture", "on", "a", "link" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/udp_link.py#L150-L162
226,326
GNS3/gns3-server
gns3server/controller/udp_link.py
UDPLink.stop_capture
def stop_capture(self): """ Stop capture on a link """ if self._capture_node: yield from self._capture_node["node"].post("/adapters/{adapter_number}/ports/{port_number}/stop_capture".format(adapter_number=self._capture_node["adapter_number"], port_number=self._capture_node["p...
python
def stop_capture(self): """ Stop capture on a link """ if self._capture_node: yield from self._capture_node["node"].post("/adapters/{adapter_number}/ports/{port_number}/stop_capture".format(adapter_number=self._capture_node["adapter_number"], port_number=self._capture_node["p...
[ "def", "stop_capture", "(", "self", ")", ":", "if", "self", ".", "_capture_node", ":", "yield", "from", "self", ".", "_capture_node", "[", "\"node\"", "]", ".", "post", "(", "\"/adapters/{adapter_number}/ports/{port_number}/stop_capture\"", ".", "format", "(", "ad...
Stop capture on a link
[ "Stop", "capture", "on", "a", "link" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/udp_link.py#L165-L172
226,327
GNS3/gns3-server
gns3server/controller/udp_link.py
UDPLink._choose_capture_side
def _choose_capture_side(self): """ Run capture on the best candidate. The ideal candidate is a node who on controller server and always running (capture will not be cut off) :returns: Node where the capture should run """ ALWAYS_RUNNING_NODES_TYPE = ("cloud", ...
python
def _choose_capture_side(self): """ Run capture on the best candidate. The ideal candidate is a node who on controller server and always running (capture will not be cut off) :returns: Node where the capture should run """ ALWAYS_RUNNING_NODES_TYPE = ("cloud", ...
[ "def", "_choose_capture_side", "(", "self", ")", ":", "ALWAYS_RUNNING_NODES_TYPE", "=", "(", "\"cloud\"", ",", "\"nat\"", ",", "\"ethernet_switch\"", ",", "\"ethernet_hub\"", ")", "for", "node", "in", "self", ".", "_nodes", ":", "if", "node", "[", "\"node\"", ...
Run capture on the best candidate. The ideal candidate is a node who on controller server and always running (capture will not be cut off) :returns: Node where the capture should run
[ "Run", "capture", "on", "the", "best", "candidate", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/udp_link.py#L174-L202
226,328
GNS3/gns3-server
gns3server/controller/udp_link.py
UDPLink.read_pcap_from_source
def read_pcap_from_source(self): """ Return a FileStream of the Pcap from the compute node """ if self._capture_node: compute = self._capture_node["node"].compute return compute.stream_file(self._project, "tmp/captures/" + self._capture_file_name)
python
def read_pcap_from_source(self): """ Return a FileStream of the Pcap from the compute node """ if self._capture_node: compute = self._capture_node["node"].compute return compute.stream_file(self._project, "tmp/captures/" + self._capture_file_name)
[ "def", "read_pcap_from_source", "(", "self", ")", ":", "if", "self", ".", "_capture_node", ":", "compute", "=", "self", ".", "_capture_node", "[", "\"node\"", "]", ".", "compute", "return", "compute", ".", "stream_file", "(", "self", ".", "_project", ",", ...
Return a FileStream of the Pcap from the compute node
[ "Return", "a", "FileStream", "of", "the", "Pcap", "from", "the", "compute", "node" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/udp_link.py#L205-L211
226,329
GNS3/gns3-server
gns3server/controller/udp_link.py
UDPLink.node_updated
def node_updated(self, node): """ Called when a node member of the link is updated """ if self._capture_node and node == self._capture_node["node"] and node.status != "started": yield from self.stop_capture()
python
def node_updated(self, node): """ Called when a node member of the link is updated """ if self._capture_node and node == self._capture_node["node"] and node.status != "started": yield from self.stop_capture()
[ "def", "node_updated", "(", "self", ",", "node", ")", ":", "if", "self", ".", "_capture_node", "and", "node", "==", "self", ".", "_capture_node", "[", "\"node\"", "]", "and", "node", ".", "status", "!=", "\"started\"", ":", "yield", "from", "self", ".", ...
Called when a node member of the link is updated
[ "Called", "when", "a", "node", "member", "of", "the", "link", "is", "updated" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/udp_link.py#L214-L219
226,330
GNS3/gns3-server
gns3server/utils/vmnet.py
parse_networking_file
def parse_networking_file(): """ Parse the VMware networking file. """ pairs = dict() allocated_subnets = [] try: with open(VMWARE_NETWORKING_FILE, "r", encoding="utf-8") as f: version = f.readline() for line in f.read().splitlines(): try: ...
python
def parse_networking_file(): """ Parse the VMware networking file. """ pairs = dict() allocated_subnets = [] try: with open(VMWARE_NETWORKING_FILE, "r", encoding="utf-8") as f: version = f.readline() for line in f.read().splitlines(): try: ...
[ "def", "parse_networking_file", "(", ")", ":", "pairs", "=", "dict", "(", ")", "allocated_subnets", "=", "[", "]", "try", ":", "with", "open", "(", "VMWARE_NETWORKING_FILE", ",", "\"r\"", ",", "encoding", "=", "\"utf-8\"", ")", "as", "f", ":", "version", ...
Parse the VMware networking file.
[ "Parse", "the", "VMware", "networking", "file", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/vmnet.py#L39-L61
226,331
GNS3/gns3-server
gns3server/utils/vmnet.py
write_networking_file
def write_networking_file(version, pairs): """ Write the VMware networking file. """ vmnets = OrderedDict(sorted(pairs.items(), key=lambda t: t[0])) try: with open(VMWARE_NETWORKING_FILE, "w", encoding="utf-8") as f: f.write(version) for key, value in vmnets.items():...
python
def write_networking_file(version, pairs): """ Write the VMware networking file. """ vmnets = OrderedDict(sorted(pairs.items(), key=lambda t: t[0])) try: with open(VMWARE_NETWORKING_FILE, "w", encoding="utf-8") as f: f.write(version) for key, value in vmnets.items():...
[ "def", "write_networking_file", "(", "version", ",", "pairs", ")", ":", "vmnets", "=", "OrderedDict", "(", "sorted", "(", "pairs", ".", "items", "(", ")", ",", "key", "=", "lambda", "t", ":", "t", "[", "0", "]", ")", ")", "try", ":", "with", "open"...
Write the VMware networking file.
[ "Write", "the", "VMware", "networking", "file", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/vmnet.py#L64-L87
226,332
GNS3/gns3-server
gns3server/utils/vmnet.py
parse_vmnet_range
def parse_vmnet_range(start, end): """ Parse the vmnet range on the command line. """ class Range(argparse.Action): def __call__(self, parser, args, values, option_string=None): if len(values) != 2: raise argparse.ArgumentTypeError("vmnet range must consist of 2 num...
python
def parse_vmnet_range(start, end): """ Parse the vmnet range on the command line. """ class Range(argparse.Action): def __call__(self, parser, args, values, option_string=None): if len(values) != 2: raise argparse.ArgumentTypeError("vmnet range must consist of 2 num...
[ "def", "parse_vmnet_range", "(", "start", ",", "end", ")", ":", "class", "Range", "(", "argparse", ".", "Action", ")", ":", "def", "__call__", "(", "self", ",", "parser", ",", "args", ",", "values", ",", "option_string", "=", "None", ")", ":", "if", ...
Parse the vmnet range on the command line.
[ "Parse", "the", "vmnet", "range", "on", "the", "command", "line", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/vmnet.py#L90-L103
226,333
GNS3/gns3-server
gns3server/utils/vmnet.py
vmnet_unix
def vmnet_unix(args, vmnet_range_start, vmnet_range_end): """ Implementation on Linux and Mac OS X. """ if not os.path.exists(VMWARE_NETWORKING_FILE): raise SystemExit("VMware Player, Workstation or Fusion is not installed") if not os.access(VMWARE_NETWORKING_FILE, os.W_OK): raise S...
python
def vmnet_unix(args, vmnet_range_start, vmnet_range_end): """ Implementation on Linux and Mac OS X. """ if not os.path.exists(VMWARE_NETWORKING_FILE): raise SystemExit("VMware Player, Workstation or Fusion is not installed") if not os.access(VMWARE_NETWORKING_FILE, os.W_OK): raise S...
[ "def", "vmnet_unix", "(", "args", ",", "vmnet_range_start", ",", "vmnet_range_end", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "VMWARE_NETWORKING_FILE", ")", ":", "raise", "SystemExit", "(", "\"VMware Player, Workstation or Fusion is not installed\"...
Implementation on Linux and Mac OS X.
[ "Implementation", "on", "Linux", "and", "Mac", "OS", "X", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/vmnet.py#L183-L229
226,334
GNS3/gns3-server
gns3server/utils/vmnet.py
main
def main(): """ Entry point for the VMNET tool. """ parser = argparse.ArgumentParser(description='%(prog)s add/remove vmnet interfaces') parser.add_argument('-r', "--range", nargs='+', action=parse_vmnet_range(1, 255), type=int, help="vmnet range to add (default is {} {})".f...
python
def main(): """ Entry point for the VMNET tool. """ parser = argparse.ArgumentParser(description='%(prog)s add/remove vmnet interfaces') parser.add_argument('-r', "--range", nargs='+', action=parse_vmnet_range(1, 255), type=int, help="vmnet range to add (default is {} {})".f...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'%(prog)s add/remove vmnet interfaces'", ")", "parser", ".", "add_argument", "(", "'-r'", ",", "\"--range\"", ",", "nargs", "=", "'+'", ",", "action", "="...
Entry point for the VMNET tool.
[ "Entry", "point", "for", "the", "VMNET", "tool", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/vmnet.py#L232-L256
226,335
GNS3/gns3-server
gns3server/utils/asyncio/telnet_server.py
AsyncioTelnetServer._get_reader
def _get_reader(self, network_reader): """ Get a reader or None if another reader is already reading. """ with (yield from self._lock): if self._reader_process is None: self._reader_process = network_reader if self._reader: if self....
python
def _get_reader(self, network_reader): """ Get a reader or None if another reader is already reading. """ with (yield from self._lock): if self._reader_process is None: self._reader_process = network_reader if self._reader: if self....
[ "def", "_get_reader", "(", "self", ",", "network_reader", ")", ":", "with", "(", "yield", "from", "self", ".", "_lock", ")", ":", "if", "self", ".", "_reader_process", "is", "None", ":", "self", ".", "_reader_process", "=", "network_reader", "if", "self", ...
Get a reader or None if another reader is already reading.
[ "Get", "a", "reader", "or", "None", "if", "another", "reader", "is", "already", "reading", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/telnet_server.py#L223-L234
226,336
GNS3/gns3-server
gns3server/utils/asyncio/telnet_server.py
AsyncioTelnetServer._read
def _read(self, cmd, buffer, location, reader): """ Reads next op from the buffer or reader""" try: op = buffer[location] cmd.append(op) return op except IndexError: op = yield from reader.read(1) buffer.extend(op) cmd.appen...
python
def _read(self, cmd, buffer, location, reader): """ Reads next op from the buffer or reader""" try: op = buffer[location] cmd.append(op) return op except IndexError: op = yield from reader.read(1) buffer.extend(op) cmd.appen...
[ "def", "_read", "(", "self", ",", "cmd", ",", "buffer", ",", "location", ",", "reader", ")", ":", "try", ":", "op", "=", "buffer", "[", "location", "]", "cmd", ".", "append", "(", "op", ")", "return", "op", "except", "IndexError", ":", "op", "=", ...
Reads next op from the buffer or reader
[ "Reads", "next", "op", "from", "the", "buffer", "or", "reader" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/telnet_server.py#L295-L305
226,337
GNS3/gns3-server
gns3server/utils/asyncio/telnet_server.py
AsyncioTelnetServer._negotiate
def _negotiate(self, data, connection): """ Performs negotiation commands""" command, payload = data[0], data[1:] if command == NAWS: if len(payload) == 4: columns, rows = struct.unpack(str('!HH'), bytes(payload)) connection.window_size_changed(column...
python
def _negotiate(self, data, connection): """ Performs negotiation commands""" command, payload = data[0], data[1:] if command == NAWS: if len(payload) == 4: columns, rows = struct.unpack(str('!HH'), bytes(payload)) connection.window_size_changed(column...
[ "def", "_negotiate", "(", "self", ",", "data", ",", "connection", ")", ":", "command", ",", "payload", "=", "data", "[", "0", "]", ",", "data", "[", "1", ":", "]", "if", "command", "==", "NAWS", ":", "if", "len", "(", "payload", ")", "==", "4", ...
Performs negotiation commands
[ "Performs", "negotiation", "commands" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/telnet_server.py#L307-L318
226,338
GNS3/gns3-server
gns3server/utils/ping_stats.py
PingStats.get
def get(cls): """ Get ping statistics :returns: hash """ stats = {} cur_time = time.time() # minimum interval for getting CPU and memory statistics if cur_time < cls._last_measurement or \ cur_time > cls._last_measurement + 1.9: cls...
python
def get(cls): """ Get ping statistics :returns: hash """ stats = {} cur_time = time.time() # minimum interval for getting CPU and memory statistics if cur_time < cls._last_measurement or \ cur_time > cls._last_measurement + 1.9: cls...
[ "def", "get", "(", "cls", ")", ":", "stats", "=", "{", "}", "cur_time", "=", "time", ".", "time", "(", ")", "# minimum interval for getting CPU and memory statistics", "if", "cur_time", "<", "cls", ".", "_last_measurement", "or", "cur_time", ">", "cls", ".", ...
Get ping statistics :returns: hash
[ "Get", "ping", "statistics" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/ping_stats.py#L33-L50
226,339
GNS3/gns3-server
gns3server/ubridge/ubridge_hypervisor.py
UBridgeHypervisor.send
def send(self, command): """ Sends commands to this hypervisor. :param command: a uBridge hypervisor command :returns: results as a list """ # uBridge responses are of the form: # 1xx yyyyyy\r\n # 1xx yyyyyy\r\n # ... # 100-yyyy\...
python
def send(self, command): """ Sends commands to this hypervisor. :param command: a uBridge hypervisor command :returns: results as a list """ # uBridge responses are of the form: # 1xx yyyyyy\r\n # 1xx yyyyyy\r\n # ... # 100-yyyy\...
[ "def", "send", "(", "self", ",", "command", ")", ":", "# uBridge responses are of the form:", "# 1xx yyyyyy\\r\\n", "# 1xx yyyyyy\\r\\n", "# ...", "# 100-yyyy\\r\\n", "# or", "# 2xx-yyyy\\r\\n", "#", "# Where 1xx is a code from 100-199 for a success or 200-299 for an error"...
Sends commands to this hypervisor. :param command: a uBridge hypervisor command :returns: results as a list
[ "Sends", "commands", "to", "this", "hypervisor", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/ubridge/ubridge_hypervisor.py#L180-L277
226,340
GNS3/gns3-server
gns3server/web/route.py
parse_request
def parse_request(request, input_schema, raw): """Parse body of request and raise HTTP errors in case of problems""" request.json = {} if not raw: body = yield from request.read() if body: try: request.json = json.loads(body.decode('utf-8')) except Va...
python
def parse_request(request, input_schema, raw): """Parse body of request and raise HTTP errors in case of problems""" request.json = {} if not raw: body = yield from request.read() if body: try: request.json = json.loads(body.decode('utf-8')) except Va...
[ "def", "parse_request", "(", "request", ",", "input_schema", ",", "raw", ")", ":", "request", ".", "json", "=", "{", "}", "if", "not", "raw", ":", "body", "=", "yield", "from", "request", ".", "read", "(", ")", "if", "body", ":", "try", ":", "reque...
Parse body of request and raise HTTP errors in case of problems
[ "Parse", "body", "of", "request", "and", "raise", "HTTP", "errors", "in", "case", "of", "problems" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/web/route.py#L40-L67
226,341
GNS3/gns3-server
gns3server/web/route.py
Route.authenticate
def authenticate(cls, request, route, server_config): """ Ask user for authentication :returns: Response if you need to auth the user otherwise None """ if not server_config.getboolean("auth", False): return user = server_config.get("user", "").strip() ...
python
def authenticate(cls, request, route, server_config): """ Ask user for authentication :returns: Response if you need to auth the user otherwise None """ if not server_config.getboolean("auth", False): return user = server_config.get("user", "").strip() ...
[ "def", "authenticate", "(", "cls", ",", "request", ",", "route", ",", "server_config", ")", ":", "if", "not", "server_config", ".", "getboolean", "(", "\"auth\"", ",", "False", ")", ":", "return", "user", "=", "server_config", ".", "get", "(", "\"user\"", ...
Ask user for authentication :returns: Response if you need to auth the user otherwise None
[ "Ask", "user", "for", "authentication" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/web/route.py#L100-L127
226,342
GNS3/gns3-server
gns3server/notification_queue.py
NotificationQueue.get
def get(self, timeout): """ When timeout is expire we send a ping notification with server information """ # At first get we return a ping so the client immediately receives data if self._first: self._first = False return ("ping", PingStats.get(), {}) ...
python
def get(self, timeout): """ When timeout is expire we send a ping notification with server information """ # At first get we return a ping so the client immediately receives data if self._first: self._first = False return ("ping", PingStats.get(), {}) ...
[ "def", "get", "(", "self", ",", "timeout", ")", ":", "# At first get we return a ping so the client immediately receives data", "if", "self", ".", "_first", ":", "self", ".", "_first", "=", "False", "return", "(", "\"ping\"", ",", "PingStats", ".", "get", "(", "...
When timeout is expire we send a ping notification with server information
[ "When", "timeout", "is", "expire", "we", "send", "a", "ping", "notification", "with", "server", "information" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/notification_queue.py#L34-L48
226,343
GNS3/gns3-server
gns3server/notification_queue.py
NotificationQueue.get_json
def get_json(self, timeout): """ Get a message as a JSON """ (action, msg, kwargs) = yield from self.get(timeout) if hasattr(msg, "__json__"): msg = {"action": action, "event": msg.__json__()} else: msg = {"action": action, "event": msg} ms...
python
def get_json(self, timeout): """ Get a message as a JSON """ (action, msg, kwargs) = yield from self.get(timeout) if hasattr(msg, "__json__"): msg = {"action": action, "event": msg.__json__()} else: msg = {"action": action, "event": msg} ms...
[ "def", "get_json", "(", "self", ",", "timeout", ")", ":", "(", "action", ",", "msg", ",", "kwargs", ")", "=", "yield", "from", "self", ".", "get", "(", "timeout", ")", "if", "hasattr", "(", "msg", ",", "\"__json__\"", ")", ":", "msg", "=", "{", "...
Get a message as a JSON
[ "Get", "a", "message", "as", "a", "JSON" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/notification_queue.py#L51-L61
226,344
GNS3/gns3-server
gns3server/compute/vpcs/vpcs_vm.py
VPCSVM.close
def close(self): """ Closes this VPCS VM. """ if not (yield from super().close()): return False nio = self._ethernet_adapter.get_nio(0) if isinstance(nio, NIOUDP): self.manager.port_manager.release_udp_port(nio.lport, self._project) if s...
python
def close(self): """ Closes this VPCS VM. """ if not (yield from super().close()): return False nio = self._ethernet_adapter.get_nio(0) if isinstance(nio, NIOUDP): self.manager.port_manager.release_udp_port(nio.lport, self._project) if s...
[ "def", "close", "(", "self", ")", ":", "if", "not", "(", "yield", "from", "super", "(", ")", ".", "close", "(", ")", ")", ":", "return", "False", "nio", "=", "self", ".", "_ethernet_adapter", ".", "get_nio", "(", "0", ")", "if", "isinstance", "(", ...
Closes this VPCS VM.
[ "Closes", "this", "VPCS", "VM", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L81-L103
226,345
GNS3/gns3-server
gns3server/compute/vpcs/vpcs_vm.py
VPCSVM._check_requirements
def _check_requirements(self): """ Check if VPCS is available with the correct version. """ path = self._vpcs_path() if not path: raise VPCSError("No path to a VPCS executable has been set") # This raise an error if ubridge is not available self.ubri...
python
def _check_requirements(self): """ Check if VPCS is available with the correct version. """ path = self._vpcs_path() if not path: raise VPCSError("No path to a VPCS executable has been set") # This raise an error if ubridge is not available self.ubri...
[ "def", "_check_requirements", "(", "self", ")", ":", "path", "=", "self", ".", "_vpcs_path", "(", ")", "if", "not", "path", ":", "raise", "VPCSError", "(", "\"No path to a VPCS executable has been set\"", ")", "# This raise an error if ubridge is not available", "self",...
Check if VPCS is available with the correct version.
[ "Check", "if", "VPCS", "is", "available", "with", "the", "correct", "version", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L106-L124
226,346
GNS3/gns3-server
gns3server/compute/vpcs/vpcs_vm.py
VPCSVM._vpcs_path
def _vpcs_path(self): """ Returns the VPCS executable path. :returns: path to VPCS """ search_path = self._manager.config.get_section_config("VPCS").get("vpcs_path", "vpcs") path = shutil.which(search_path) # shutil.which return None if the path doesn't exists ...
python
def _vpcs_path(self): """ Returns the VPCS executable path. :returns: path to VPCS """ search_path = self._manager.config.get_section_config("VPCS").get("vpcs_path", "vpcs") path = shutil.which(search_path) # shutil.which return None if the path doesn't exists ...
[ "def", "_vpcs_path", "(", "self", ")", ":", "search_path", "=", "self", ".", "_manager", ".", "config", ".", "get_section_config", "(", "\"VPCS\"", ")", ".", "get", "(", "\"vpcs_path\"", ",", "\"vpcs\"", ")", "path", "=", "shutil", ".", "which", "(", "se...
Returns the VPCS executable path. :returns: path to VPCS
[ "Returns", "the", "VPCS", "executable", "path", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L137-L149
226,347
GNS3/gns3-server
gns3server/compute/vpcs/vpcs_vm.py
VPCSVM.name
def name(self, new_name): """ Sets the name of this VPCS VM. :param new_name: name """ if self.script_file: content = self.startup_script content = content.replace(self._name, new_name) escaped_name = new_name.replace('\\', '') co...
python
def name(self, new_name): """ Sets the name of this VPCS VM. :param new_name: name """ if self.script_file: content = self.startup_script content = content.replace(self._name, new_name) escaped_name = new_name.replace('\\', '') co...
[ "def", "name", "(", "self", ",", "new_name", ")", ":", "if", "self", ".", "script_file", ":", "content", "=", "self", ".", "startup_script", "content", "=", "content", ".", "replace", "(", "self", ".", "_name", ",", "new_name", ")", "escaped_name", "=", ...
Sets the name of this VPCS VM. :param new_name: name
[ "Sets", "the", "name", "of", "this", "VPCS", "VM", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L152-L166
226,348
GNS3/gns3-server
gns3server/compute/vpcs/vpcs_vm.py
VPCSVM.startup_script
def startup_script(self): """ Returns the content of the current startup script """ script_file = self.script_file if script_file is None: return None try: with open(script_file, "rb") as f: return f.read().decode("utf-8", errors=...
python
def startup_script(self): """ Returns the content of the current startup script """ script_file = self.script_file if script_file is None: return None try: with open(script_file, "rb") as f: return f.read().decode("utf-8", errors=...
[ "def", "startup_script", "(", "self", ")", ":", "script_file", "=", "self", ".", "script_file", "if", "script_file", "is", "None", ":", "return", "None", "try", ":", "with", "open", "(", "script_file", ",", "\"rb\"", ")", "as", "f", ":", "return", "f", ...
Returns the content of the current startup script
[ "Returns", "the", "content", "of", "the", "current", "startup", "script" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L169-L182
226,349
GNS3/gns3-server
gns3server/compute/vpcs/vpcs_vm.py
VPCSVM.startup_script
def startup_script(self, startup_script): """ Updates the startup script. :param startup_script: content of the startup script """ try: startup_script_path = os.path.join(self.working_dir, 'startup.vpc') with open(startup_script_path, "w+", encoding='utf...
python
def startup_script(self, startup_script): """ Updates the startup script. :param startup_script: content of the startup script """ try: startup_script_path = os.path.join(self.working_dir, 'startup.vpc') with open(startup_script_path, "w+", encoding='utf...
[ "def", "startup_script", "(", "self", ",", "startup_script", ")", ":", "try", ":", "startup_script_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "working_dir", ",", "'startup.vpc'", ")", "with", "open", "(", "startup_script_path", ",", "\"w+\...
Updates the startup script. :param startup_script: content of the startup script
[ "Updates", "the", "startup", "script", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L185-L201
226,350
GNS3/gns3-server
gns3server/compute/vpcs/vpcs_vm.py
VPCSVM._check_vpcs_version
def _check_vpcs_version(self): """ Checks if the VPCS executable version is >= 0.8b or == 0.6.1. """ try: output = yield from subprocess_check_output(self._vpcs_path(), "-v", cwd=self.working_dir) match = re.search("Welcome to Virtual PC Simulator, version ([0-9a-...
python
def _check_vpcs_version(self): """ Checks if the VPCS executable version is >= 0.8b or == 0.6.1. """ try: output = yield from subprocess_check_output(self._vpcs_path(), "-v", cwd=self.working_dir) match = re.search("Welcome to Virtual PC Simulator, version ([0-9a-...
[ "def", "_check_vpcs_version", "(", "self", ")", ":", "try", ":", "output", "=", "yield", "from", "subprocess_check_output", "(", "self", ".", "_vpcs_path", "(", ")", ",", "\"-v\"", ",", "cwd", "=", "self", ".", "working_dir", ")", "match", "=", "re", "."...
Checks if the VPCS executable version is >= 0.8b or == 0.6.1.
[ "Checks", "if", "the", "VPCS", "executable", "version", "is", ">", "=", "0", ".", "8b", "or", "==", "0", ".", "6", ".", "1", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L204-L219
226,351
GNS3/gns3-server
gns3server/compute/vpcs/vpcs_vm.py
VPCSVM.start
def start(self): """ Starts the VPCS process. """ yield from self._check_requirements() if not self.is_running(): nio = self._ethernet_adapter.get_nio(0) command = self._build_command() try: log.info("Starting VPCS: {}".format(...
python
def start(self): """ Starts the VPCS process. """ yield from self._check_requirements() if not self.is_running(): nio = self._ethernet_adapter.get_nio(0) command = self._build_command() try: log.info("Starting VPCS: {}".format(...
[ "def", "start", "(", "self", ")", ":", "yield", "from", "self", ".", "_check_requirements", "(", ")", "if", "not", "self", ".", "is_running", "(", ")", ":", "nio", "=", "self", ".", "_ethernet_adapter", ".", "get_nio", "(", "0", ")", "command", "=", ...
Starts the VPCS process.
[ "Starts", "the", "VPCS", "process", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L222-L259
226,352
GNS3/gns3-server
gns3server/compute/vpcs/vpcs_vm.py
VPCSVM.stop
def stop(self): """ Stops the VPCS process. """ yield from self._stop_ubridge() if self.is_running(): self._terminate_process() if self._process.returncode is None: try: yield from wait_for_process_termination(self._pro...
python
def stop(self): """ Stops the VPCS process. """ yield from self._stop_ubridge() if self.is_running(): self._terminate_process() if self._process.returncode is None: try: yield from wait_for_process_termination(self._pro...
[ "def", "stop", "(", "self", ")", ":", "yield", "from", "self", ".", "_stop_ubridge", "(", ")", "if", "self", ".", "is_running", "(", ")", ":", "self", ".", "_terminate_process", "(", ")", "if", "self", ".", "_process", ".", "returncode", "is", "None", ...
Stops the VPCS process.
[ "Stops", "the", "VPCS", "process", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L276-L298
226,353
GNS3/gns3-server
gns3server/compute/vpcs/vpcs_vm.py
VPCSVM._terminate_process
def _terminate_process(self): """ Terminate the process if running """ log.info("Stopping VPCS instance {} PID={}".format(self.name, self._process.pid)) if sys.platform.startswith("win32"): self._process.send_signal(signal.CTRL_BREAK_EVENT) else: ...
python
def _terminate_process(self): """ Terminate the process if running """ log.info("Stopping VPCS instance {} PID={}".format(self.name, self._process.pid)) if sys.platform.startswith("win32"): self._process.send_signal(signal.CTRL_BREAK_EVENT) else: ...
[ "def", "_terminate_process", "(", "self", ")", ":", "log", ".", "info", "(", "\"Stopping VPCS instance {} PID={}\"", ".", "format", "(", "self", ".", "name", ",", "self", ".", "_process", ".", "pid", ")", ")", "if", "sys", ".", "platform", ".", "startswith...
Terminate the process if running
[ "Terminate", "the", "process", "if", "running" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L309-L322
226,354
GNS3/gns3-server
gns3server/compute/vpcs/vpcs_vm.py
VPCSVM.read_vpcs_stdout
def read_vpcs_stdout(self): """ Reads the standard output of the VPCS process. Only use when the process has been stopped or has crashed. """ output = "" if self._vpcs_stdout_file: try: with open(self._vpcs_stdout_file, "rb") as file: ...
python
def read_vpcs_stdout(self): """ Reads the standard output of the VPCS process. Only use when the process has been stopped or has crashed. """ output = "" if self._vpcs_stdout_file: try: with open(self._vpcs_stdout_file, "rb") as file: ...
[ "def", "read_vpcs_stdout", "(", "self", ")", ":", "output", "=", "\"\"", "if", "self", ".", "_vpcs_stdout_file", ":", "try", ":", "with", "open", "(", "self", ".", "_vpcs_stdout_file", ",", "\"rb\"", ")", "as", "file", ":", "output", "=", "file", ".", ...
Reads the standard output of the VPCS process. Only use when the process has been stopped or has crashed.
[ "Reads", "the", "standard", "output", "of", "the", "VPCS", "process", ".", "Only", "use", "when", "the", "process", "has", "been", "stopped", "or", "has", "crashed", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L324-L337
226,355
GNS3/gns3-server
gns3server/compute/vpcs/vpcs_vm.py
VPCSVM.script_file
def script_file(self): """ Returns the startup script file for this VPCS VM. :returns: path to startup script file """ # use the default VPCS file if it exists path = os.path.join(self.working_dir, 'startup.vpc') if os.path.exists(path): return path ...
python
def script_file(self): """ Returns the startup script file for this VPCS VM. :returns: path to startup script file """ # use the default VPCS file if it exists path = os.path.join(self.working_dir, 'startup.vpc') if os.path.exists(path): return path ...
[ "def", "script_file", "(", "self", ")", ":", "# use the default VPCS file if it exists", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "working_dir", ",", "'startup.vpc'", ")", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":",...
Returns the startup script file for this VPCS VM. :returns: path to startup script file
[ "Returns", "the", "startup", "script", "file", "for", "this", "VPCS", "VM", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L539-L551
226,356
GNS3/gns3-server
gns3server/utils/interfaces.py
get_windows_interfaces
def get_windows_interfaces(): """ Get Windows interfaces. :returns: list of windows interfaces """ import win32com.client import pywintypes interfaces = [] try: locator = win32com.client.Dispatch("WbemScripting.SWbemLocator") service = locator.ConnectServer(".", "root\...
python
def get_windows_interfaces(): """ Get Windows interfaces. :returns: list of windows interfaces """ import win32com.client import pywintypes interfaces = [] try: locator = win32com.client.Dispatch("WbemScripting.SWbemLocator") service = locator.ConnectServer(".", "root\...
[ "def", "get_windows_interfaces", "(", ")", ":", "import", "win32com", ".", "client", "import", "pywintypes", "interfaces", "=", "[", "]", "try", ":", "locator", "=", "win32com", ".", "client", ".", "Dispatch", "(", "\"WbemScripting.SWbemLocator\"", ")", "service...
Get Windows interfaces. :returns: list of windows interfaces
[ "Get", "Windows", "interfaces", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/interfaces.py#L79-L119
226,357
GNS3/gns3-server
gns3server/utils/interfaces.py
has_netmask
def has_netmask(interface_name): """ Checks if an interface has a netmask. :param interface: interface name :returns: boolean """ for interface in interfaces(): if interface["name"] == interface_name: if interface["netmask"] and len(interface["netmask"]) > 0: ...
python
def has_netmask(interface_name): """ Checks if an interface has a netmask. :param interface: interface name :returns: boolean """ for interface in interfaces(): if interface["name"] == interface_name: if interface["netmask"] and len(interface["netmask"]) > 0: ...
[ "def", "has_netmask", "(", "interface_name", ")", ":", "for", "interface", "in", "interfaces", "(", ")", ":", "if", "interface", "[", "\"name\"", "]", "==", "interface_name", ":", "if", "interface", "[", "\"netmask\"", "]", "and", "len", "(", "interface", ...
Checks if an interface has a netmask. :param interface: interface name :returns: boolean
[ "Checks", "if", "an", "interface", "has", "a", "netmask", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/interfaces.py#L122-L135
226,358
GNS3/gns3-server
gns3server/utils/interfaces.py
is_interface_up
def is_interface_up(interface): """ Checks if an interface is up. :param interface: interface name :returns: boolean """ if sys.platform.startswith("linux"): if interface not in psutil.net_if_addrs(): return False import fcntl SIOCGIFFLAGS = 0x8913 ...
python
def is_interface_up(interface): """ Checks if an interface is up. :param interface: interface name :returns: boolean """ if sys.platform.startswith("linux"): if interface not in psutil.net_if_addrs(): return False import fcntl SIOCGIFFLAGS = 0x8913 ...
[ "def", "is_interface_up", "(", "interface", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "\"linux\"", ")", ":", "if", "interface", "not", "in", "psutil", ".", "net_if_addrs", "(", ")", ":", "return", "False", "import", "fcntl", "SIOCGIFF...
Checks if an interface is up. :param interface: interface name :returns: boolean
[ "Checks", "if", "an", "interface", "is", "up", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/interfaces.py#L138-L165
226,359
GNS3/gns3-server
gns3server/utils/interfaces.py
interfaces
def interfaces(): """ Gets the network interfaces on this server. :returns: list of network interfaces """ results = [] if not sys.platform.startswith("win"): net_if_addrs = psutil.net_if_addrs() for interface in sorted(net_if_addrs.keys()): ip_address = "" ...
python
def interfaces(): """ Gets the network interfaces on this server. :returns: list of network interfaces """ results = [] if not sys.platform.startswith("win"): net_if_addrs = psutil.net_if_addrs() for interface in sorted(net_if_addrs.keys()): ip_address = "" ...
[ "def", "interfaces", "(", ")", ":", "results", "=", "[", "]", "if", "not", "sys", ".", "platform", ".", "startswith", "(", "\"win\"", ")", ":", "net_if_addrs", "=", "psutil", ".", "net_if_addrs", "(", ")", "for", "interface", "in", "sorted", "(", "net_...
Gets the network interfaces on this server. :returns: list of network interfaces
[ "Gets", "the", "network", "interfaces", "on", "this", "server", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/interfaces.py#L192-L251
226,360
GNS3/gns3-server
gns3server/controller/gns3vm/vmware_gns3_vm.py
VMwareGNS3VM._set_vcpus_ram
def _set_vcpus_ram(self, vcpus, ram): """ Set the number of vCPU cores and amount of RAM for the GNS3 VM. :param vcpus: number of vCPU cores :param ram: amount of RAM """ # memory must be a multiple of 4 (VMware requirement) if ram % 4 != 0: raise GN...
python
def _set_vcpus_ram(self, vcpus, ram): """ Set the number of vCPU cores and amount of RAM for the GNS3 VM. :param vcpus: number of vCPU cores :param ram: amount of RAM """ # memory must be a multiple of 4 (VMware requirement) if ram % 4 != 0: raise GN...
[ "def", "_set_vcpus_ram", "(", "self", ",", "vcpus", ",", "ram", ")", ":", "# memory must be a multiple of 4 (VMware requirement)", "if", "ram", "%", "4", "!=", "0", ":", "raise", "GNS3VMError", "(", "\"Allocated memory {} for the GNS3 VM must be a multiple of 4\"", ".", ...
Set the number of vCPU cores and amount of RAM for the GNS3 VM. :param vcpus: number of vCPU cores :param ram: amount of RAM
[ "Set", "the", "number", "of", "vCPU", "cores", "and", "amount", "of", "RAM", "for", "the", "GNS3", "VM", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/gns3vm/vmware_gns3_vm.py#L63-L86
226,361
GNS3/gns3-server
gns3server/controller/gns3vm/vmware_gns3_vm.py
VMwareGNS3VM.list
def list(self): """ List all VMware VMs """ try: return (yield from self._vmware_manager.list_vms()) except VMwareError as e: raise GNS3VMError("Could not list VMware VMs: {}".format(str(e)))
python
def list(self): """ List all VMware VMs """ try: return (yield from self._vmware_manager.list_vms()) except VMwareError as e: raise GNS3VMError("Could not list VMware VMs: {}".format(str(e)))
[ "def", "list", "(", "self", ")", ":", "try", ":", "return", "(", "yield", "from", "self", ".", "_vmware_manager", ".", "list_vms", "(", ")", ")", "except", "VMwareError", "as", "e", ":", "raise", "GNS3VMError", "(", "\"Could not list VMware VMs: {}\"", ".", ...
List all VMware VMs
[ "List", "all", "VMware", "VMs" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/gns3vm/vmware_gns3_vm.py#L113-L120
226,362
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM._read_vmx_file
def _read_vmx_file(self): """ Reads from the VMware VMX file corresponding to this VM. """ try: self._vmx_pairs = self.manager.parse_vmware_file(self._vmx_path) except OSError as e: raise VMwareError('Could not read VMware VMX file "{}": {}'.format(self._...
python
def _read_vmx_file(self): """ Reads from the VMware VMX file corresponding to this VM. """ try: self._vmx_pairs = self.manager.parse_vmware_file(self._vmx_path) except OSError as e: raise VMwareError('Could not read VMware VMX file "{}": {}'.format(self._...
[ "def", "_read_vmx_file", "(", "self", ")", ":", "try", ":", "self", ".", "_vmx_pairs", "=", "self", ".", "manager", ".", "parse_vmware_file", "(", "self", ".", "_vmx_path", ")", "except", "OSError", "as", "e", ":", "raise", "VMwareError", "(", "'Could not ...
Reads from the VMware VMX file corresponding to this VM.
[ "Reads", "from", "the", "VMware", "VMX", "file", "corresponding", "to", "this", "VM", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L107-L115
226,363
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM._write_vmx_file
def _write_vmx_file(self): """ Writes pairs to the VMware VMX file corresponding to this VM. """ try: self.manager.write_vmx_file(self._vmx_path, self._vmx_pairs) except OSError as e: raise VMwareError('Could not write VMware VMX file "{}": {}'.format(sel...
python
def _write_vmx_file(self): """ Writes pairs to the VMware VMX file corresponding to this VM. """ try: self.manager.write_vmx_file(self._vmx_path, self._vmx_pairs) except OSError as e: raise VMwareError('Could not write VMware VMX file "{}": {}'.format(sel...
[ "def", "_write_vmx_file", "(", "self", ")", ":", "try", ":", "self", ".", "manager", ".", "write_vmx_file", "(", "self", ".", "_vmx_path", ",", "self", ".", "_vmx_pairs", ")", "except", "OSError", "as", "e", ":", "raise", "VMwareError", "(", "'Could not wr...
Writes pairs to the VMware VMX file corresponding to this VM.
[ "Writes", "pairs", "to", "the", "VMware", "VMX", "file", "corresponding", "to", "this", "VM", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L117-L125
226,364
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM.create
def create(self): """ Creates this VM and handle linked clones. """ if not self.linked_clone: yield from self._check_duplicate_linked_clone() yield from self.manager.check_vmrun_version() if self.linked_clone and not os.path.exists(os.path.join(self.working_d...
python
def create(self): """ Creates this VM and handle linked clones. """ if not self.linked_clone: yield from self._check_duplicate_linked_clone() yield from self.manager.check_vmrun_version() if self.linked_clone and not os.path.exists(os.path.join(self.working_d...
[ "def", "create", "(", "self", ")", ":", "if", "not", "self", ".", "linked_clone", ":", "yield", "from", "self", ".", "_check_duplicate_linked_clone", "(", ")", "yield", "from", "self", ".", "manager", ".", "check_vmrun_version", "(", ")", "if", "self", "."...
Creates this VM and handle linked clones.
[ "Creates", "this", "VM", "and", "handle", "linked", "clones", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L163-L233
226,365
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM._set_network_options
def _set_network_options(self): """ Set up VMware networking. """ # first some sanity checks for adapter_number in range(0, self._adapters): # we want the vmnet interface to be connected when starting the VM connected = "ethernet{}.startConnected".format...
python
def _set_network_options(self): """ Set up VMware networking. """ # first some sanity checks for adapter_number in range(0, self._adapters): # we want the vmnet interface to be connected when starting the VM connected = "ethernet{}.startConnected".format...
[ "def", "_set_network_options", "(", "self", ")", ":", "# first some sanity checks", "for", "adapter_number", "in", "range", "(", "0", ",", "self", ".", "_adapters", ")", ":", "# we want the vmnet interface to be connected when starting the VM", "connected", "=", "\"ethern...
Set up VMware networking.
[ "Set", "up", "VMware", "networking", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L245-L311
226,366
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM._get_vnet
def _get_vnet(self, adapter_number): """ Return the vnet will use in ubridge """ vnet = "ethernet{}.vnet".format(adapter_number) if vnet not in self._vmx_pairs: raise VMwareError("vnet {} not in VMX file".format(vnet)) return vnet
python
def _get_vnet(self, adapter_number): """ Return the vnet will use in ubridge """ vnet = "ethernet{}.vnet".format(adapter_number) if vnet not in self._vmx_pairs: raise VMwareError("vnet {} not in VMX file".format(vnet)) return vnet
[ "def", "_get_vnet", "(", "self", ",", "adapter_number", ")", ":", "vnet", "=", "\"ethernet{}.vnet\"", ".", "format", "(", "adapter_number", ")", "if", "vnet", "not", "in", "self", ".", "_vmx_pairs", ":", "raise", "VMwareError", "(", "\"vnet {} not in VMX file\""...
Return the vnet will use in ubridge
[ "Return", "the", "vnet", "will", "use", "in", "ubridge" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L313-L320
226,367
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM._update_ubridge_connection
def _update_ubridge_connection(self, adapter_number, nio): """ Update a connection in uBridge. :param nio: NIO instance :param adapter_number: adapter number """ try: bridge_name = self._get_vnet(adapter_number) except VMwareError: return ...
python
def _update_ubridge_connection(self, adapter_number, nio): """ Update a connection in uBridge. :param nio: NIO instance :param adapter_number: adapter number """ try: bridge_name = self._get_vnet(adapter_number) except VMwareError: return ...
[ "def", "_update_ubridge_connection", "(", "self", ",", "adapter_number", ",", "nio", ")", ":", "try", ":", "bridge_name", "=", "self", ".", "_get_vnet", "(", "adapter_number", ")", "except", "VMwareError", ":", "return", "# vnet not yet available", "yield", "from"...
Update a connection in uBridge. :param nio: NIO instance :param adapter_number: adapter number
[ "Update", "a", "connection", "in", "uBridge", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L355-L366
226,368
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM.start
def start(self): """ Starts this VMware VM. """ if self.status == "started": return if (yield from self.is_running()): raise VMwareError("The VM is already running in VMware") ubridge_path = self.ubridge_path if not ubridge_path or not o...
python
def start(self): """ Starts this VMware VM. """ if self.status == "started": return if (yield from self.is_running()): raise VMwareError("The VM is already running in VMware") ubridge_path = self.ubridge_path if not ubridge_path or not o...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "status", "==", "\"started\"", ":", "return", "if", "(", "yield", "from", "self", ".", "is_running", "(", ")", ")", ":", "raise", "VMwareError", "(", "\"The VM is already running in VMware\"", ")", ...
Starts this VMware VM.
[ "Starts", "this", "VMware", "VM", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L426-L472
226,369
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM.stop
def stop(self): """ Stops this VMware VM. """ self._hw_virtualization = False yield from self._stop_remote_console() yield from self._stop_ubridge() try: if (yield from self.is_running()): if self.acpi_shutdown: # ...
python
def stop(self): """ Stops this VMware VM. """ self._hw_virtualization = False yield from self._stop_remote_console() yield from self._stop_ubridge() try: if (yield from self.is_running()): if self.acpi_shutdown: # ...
[ "def", "stop", "(", "self", ")", ":", "self", ".", "_hw_virtualization", "=", "False", "yield", "from", "self", ".", "_stop_remote_console", "(", ")", "yield", "from", "self", ".", "_stop_ubridge", "(", ")", "try", ":", "if", "(", "yield", "from", "self"...
Stops this VMware VM.
[ "Stops", "this", "VMware", "VM", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L475-L517
226,370
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM.suspend
def suspend(self): """ Suspends this VMware VM. """ if self.manager.host_type != "ws": raise VMwareError("Pausing a VM is only supported by VMware Workstation") yield from self._control_vm("pause") self.status = "suspended" log.info("VMware VM '{name}...
python
def suspend(self): """ Suspends this VMware VM. """ if self.manager.host_type != "ws": raise VMwareError("Pausing a VM is only supported by VMware Workstation") yield from self._control_vm("pause") self.status = "suspended" log.info("VMware VM '{name}...
[ "def", "suspend", "(", "self", ")", ":", "if", "self", ".", "manager", ".", "host_type", "!=", "\"ws\"", ":", "raise", "VMwareError", "(", "\"Pausing a VM is only supported by VMware Workstation\"", ")", "yield", "from", "self", ".", "_control_vm", "(", "\"pause\"...
Suspends this VMware VM.
[ "Suspends", "this", "VMware", "VM", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L520-L529
226,371
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM.close
def close(self): """ Closes this VMware VM. """ if not (yield from super().close()): return False for adapter in self._ethernet_adapters.values(): if adapter is not None: for nio in adapter.ports.values(): if nio and i...
python
def close(self): """ Closes this VMware VM. """ if not (yield from super().close()): return False for adapter in self._ethernet_adapters.values(): if adapter is not None: for nio in adapter.ports.values(): if nio and i...
[ "def", "close", "(", "self", ")", ":", "if", "not", "(", "yield", "from", "super", "(", ")", ".", "close", "(", ")", ")", ":", "return", "False", "for", "adapter", "in", "self", ".", "_ethernet_adapters", ".", "values", "(", ")", ":", "if", "adapte...
Closes this VMware VM.
[ "Closes", "this", "VMware", "VM", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L553-L573
226,372
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM.headless
def headless(self, headless): """ Sets either the VM will start in headless mode :param headless: boolean """ if headless: log.info("VMware VM '{name}' [{id}] has enabled the headless mode".format(name=self.name, id=self.id)) else: log.info("VMwa...
python
def headless(self, headless): """ Sets either the VM will start in headless mode :param headless: boolean """ if headless: log.info("VMware VM '{name}' [{id}] has enabled the headless mode".format(name=self.name, id=self.id)) else: log.info("VMwa...
[ "def", "headless", "(", "self", ",", "headless", ")", ":", "if", "headless", ":", "log", ".", "info", "(", "\"VMware VM '{name}' [{id}] has enabled the headless mode\"", ".", "format", "(", "name", "=", "self", ".", "name", ",", "id", "=", "self", ".", "id",...
Sets either the VM will start in headless mode :param headless: boolean
[ "Sets", "either", "the", "VM", "will", "start", "in", "headless", "mode" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L586-L597
226,373
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM.vmx_path
def vmx_path(self, vmx_path): """ Sets the path to the vmx file. :param vmx_path: VMware vmx file """ log.info("VMware VM '{name}' [{id}] has set the vmx file path to '{vmx}'".format(name=self.name, id=self.id, vmx=vmx_path)) self._vmx_path = vmx_path
python
def vmx_path(self, vmx_path): """ Sets the path to the vmx file. :param vmx_path: VMware vmx file """ log.info("VMware VM '{name}' [{id}] has set the vmx file path to '{vmx}'".format(name=self.name, id=self.id, vmx=vmx_path)) self._vmx_path = vmx_path
[ "def", "vmx_path", "(", "self", ",", "vmx_path", ")", ":", "log", ".", "info", "(", "\"VMware VM '{name}' [{id}] has set the vmx file path to '{vmx}'\"", ".", "format", "(", "name", "=", "self", ".", "name", ",", "id", "=", "self", ".", "id", ",", "vmx", "="...
Sets the path to the vmx file. :param vmx_path: VMware vmx file
[ "Sets", "the", "path", "to", "the", "vmx", "file", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L634-L642
226,374
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM.adapters
def adapters(self, adapters): """ Sets the number of Ethernet adapters for this VMware VM instance. :param adapters: number of adapters """ # VMware VMs are limited to 10 adapters if adapters > 10: raise VMwareError("Number of adapters above the maximum supp...
python
def adapters(self, adapters): """ Sets the number of Ethernet adapters for this VMware VM instance. :param adapters: number of adapters """ # VMware VMs are limited to 10 adapters if adapters > 10: raise VMwareError("Number of adapters above the maximum supp...
[ "def", "adapters", "(", "self", ",", "adapters", ")", ":", "# VMware VMs are limited to 10 adapters", "if", "adapters", ">", "10", ":", "raise", "VMwareError", "(", "\"Number of adapters above the maximum supported of 10\"", ")", "self", ".", "_ethernet_adapters", ".", ...
Sets the number of Ethernet adapters for this VMware VM instance. :param adapters: number of adapters
[ "Sets", "the", "number", "of", "Ethernet", "adapters", "for", "this", "VMware", "VM", "instance", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L655-L673
226,375
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM.adapter_type
def adapter_type(self, adapter_type): """ Sets the adapter type for this VMware VM instance. :param adapter_type: adapter type (string) """ self._adapter_type = adapter_type log.info("VMware VM '{name}' [{id}]: adapter type changed to {adapter_type}".format(name=self.na...
python
def adapter_type(self, adapter_type): """ Sets the adapter type for this VMware VM instance. :param adapter_type: adapter type (string) """ self._adapter_type = adapter_type log.info("VMware VM '{name}' [{id}]: adapter type changed to {adapter_type}".format(name=self.na...
[ "def", "adapter_type", "(", "self", ",", "adapter_type", ")", ":", "self", ".", "_adapter_type", "=", "adapter_type", "log", ".", "info", "(", "\"VMware VM '{name}' [{id}]: adapter type changed to {adapter_type}\"", ".", "format", "(", "name", "=", "self", ".", "nam...
Sets the adapter type for this VMware VM instance. :param adapter_type: adapter type (string)
[ "Sets", "the", "adapter", "type", "for", "this", "VMware", "VM", "instance", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L686-L696
226,376
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM.use_any_adapter
def use_any_adapter(self, use_any_adapter): """ Allows GNS3 to use any VMware adapter on this instance. :param use_any_adapter: boolean """ if use_any_adapter: log.info("VMware VM '{name}' [{id}] is allowed to use any adapter".format(name=self.name, id=self.id)) ...
python
def use_any_adapter(self, use_any_adapter): """ Allows GNS3 to use any VMware adapter on this instance. :param use_any_adapter: boolean """ if use_any_adapter: log.info("VMware VM '{name}' [{id}] is allowed to use any adapter".format(name=self.name, id=self.id)) ...
[ "def", "use_any_adapter", "(", "self", ",", "use_any_adapter", ")", ":", "if", "use_any_adapter", ":", "log", ".", "info", "(", "\"VMware VM '{name}' [{id}] is allowed to use any adapter\"", ".", "format", "(", "name", "=", "self", ".", "name", ",", "id", "=", "...
Allows GNS3 to use any VMware adapter on this instance. :param use_any_adapter: boolean
[ "Allows", "GNS3", "to", "use", "any", "VMware", "adapter", "on", "this", "instance", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L709-L720
226,377
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM._get_pipe_name
def _get_pipe_name(self): """ Returns the pipe name to create a serial connection. :returns: pipe path (string) """ if sys.platform.startswith("win"): pipe_name = r"\\.\pipe\gns3_vmware\{}".format(self.id) else: pipe_name = os.path.join(tempfile....
python
def _get_pipe_name(self): """ Returns the pipe name to create a serial connection. :returns: pipe path (string) """ if sys.platform.startswith("win"): pipe_name = r"\\.\pipe\gns3_vmware\{}".format(self.id) else: pipe_name = os.path.join(tempfile....
[ "def", "_get_pipe_name", "(", "self", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "\"win\"", ")", ":", "pipe_name", "=", "r\"\\\\.\\pipe\\gns3_vmware\\{}\"", ".", "format", "(", "self", ".", "id", ")", "else", ":", "pipe_name", "=", "os...
Returns the pipe name to create a serial connection. :returns: pipe path (string)
[ "Returns", "the", "pipe", "name", "to", "create", "a", "serial", "connection", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L811-L826
226,378
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM._start_console
def _start_console(self): """ Starts remote console support for this VM. """ self._remote_pipe = yield from asyncio_open_serial(self._get_pipe_name()) server = AsyncioTelnetServer(reader=self._remote_pipe, writer=self._remote_pipe, ...
python
def _start_console(self): """ Starts remote console support for this VM. """ self._remote_pipe = yield from asyncio_open_serial(self._get_pipe_name()) server = AsyncioTelnetServer(reader=self._remote_pipe, writer=self._remote_pipe, ...
[ "def", "_start_console", "(", "self", ")", ":", "self", ".", "_remote_pipe", "=", "yield", "from", "asyncio_open_serial", "(", "self", ".", "_get_pipe_name", "(", ")", ")", "server", "=", "AsyncioTelnetServer", "(", "reader", "=", "self", ".", "_remote_pipe", ...
Starts remote console support for this VM.
[ "Starts", "remote", "console", "support", "for", "this", "VM", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L842-L851
226,379
GNS3/gns3-server
gns3server/compute/vmware/vmware_vm.py
VMwareVM._stop_remote_console
def _stop_remote_console(self): """ Stops remote console support for this VM. """ if self._telnet_server: self._telnet_server.close() yield from self._telnet_server.wait_closed() self._remote_pipe.close() self._telnet_server = None
python
def _stop_remote_console(self): """ Stops remote console support for this VM. """ if self._telnet_server: self._telnet_server.close() yield from self._telnet_server.wait_closed() self._remote_pipe.close() self._telnet_server = None
[ "def", "_stop_remote_console", "(", "self", ")", ":", "if", "self", ".", "_telnet_server", ":", "self", ".", "_telnet_server", ".", "close", "(", ")", "yield", "from", "self", ".", "_telnet_server", ".", "wait_closed", "(", ")", "self", ".", "_remote_pipe", ...
Stops remote console support for this VM.
[ "Stops", "remote", "console", "support", "for", "this", "VM", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L854-L862
226,380
GNS3/gns3-server
gns3server/utils/path.py
get_default_project_directory
def get_default_project_directory(): """ Return the default location for the project directory depending of the operating system """ server_config = Config.instance().get_section_config("Server") path = os.path.expanduser(server_config.get("projects_path", "~/GNS3/projects")) path = os.path...
python
def get_default_project_directory(): """ Return the default location for the project directory depending of the operating system """ server_config = Config.instance().get_section_config("Server") path = os.path.expanduser(server_config.get("projects_path", "~/GNS3/projects")) path = os.path...
[ "def", "get_default_project_directory", "(", ")", ":", "server_config", "=", "Config", ".", "instance", "(", ")", ".", "get_section_config", "(", "\"Server\"", ")", "path", "=", "os", ".", "path", ".", "expanduser", "(", "server_config", ".", "get", "(", "\"...
Return the default location for the project directory depending of the operating system
[ "Return", "the", "default", "location", "for", "the", "project", "directory", "depending", "of", "the", "operating", "system" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/path.py#L24-L37
226,381
GNS3/gns3-server
gns3server/utils/path.py
check_path_allowed
def check_path_allowed(path): """ If the server is non local raise an error if the path is outside project directories Raise a 403 in case of error """ config = Config.instance().get_section_config("Server") project_directory = get_default_project_directory() if len(os.path.commonpref...
python
def check_path_allowed(path): """ If the server is non local raise an error if the path is outside project directories Raise a 403 in case of error """ config = Config.instance().get_section_config("Server") project_directory = get_default_project_directory() if len(os.path.commonpref...
[ "def", "check_path_allowed", "(", "path", ")", ":", "config", "=", "Config", ".", "instance", "(", ")", ".", "get_section_config", "(", "\"Server\"", ")", "project_directory", "=", "get_default_project_directory", "(", ")", "if", "len", "(", "os", ".", "path",...
If the server is non local raise an error if the path is outside project directories Raise a 403 in case of error
[ "If", "the", "server", "is", "non", "local", "raise", "an", "error", "if", "the", "path", "is", "outside", "project", "directories" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/path.py#L40-L55
226,382
GNS3/gns3-server
gns3server/compute/dynamips/nodes/ethernet_hub.py
EthernetHub.ports_mapping
def ports_mapping(self, ports): """ Set the ports on this hub :param ports: ports info """ if ports != self._ports: if len(self._mappings) > 0: raise NodeError("Can't modify a hub already connected.") port_number = 0 for port ...
python
def ports_mapping(self, ports): """ Set the ports on this hub :param ports: ports info """ if ports != self._ports: if len(self._mappings) > 0: raise NodeError("Can't modify a hub already connected.") port_number = 0 for port ...
[ "def", "ports_mapping", "(", "self", ",", "ports", ")", ":", "if", "ports", "!=", "self", ".", "_ports", ":", "if", "len", "(", "self", ".", "_mappings", ")", ">", "0", ":", "raise", "NodeError", "(", "\"Can't modify a hub already connected.\"", ")", "port...
Set the ports on this hub :param ports: ports info
[ "Set", "the", "ports", "on", "this", "hub" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_hub.py#L78-L94
226,383
GNS3/gns3-server
gns3server/compute/dynamips/nodes/ethernet_hub.py
EthernetHub.close
def close(self): """ Deletes this hub. """ for nio in self._nios: if nio: yield from nio.close() try: yield from Bridge.delete(self) log.info('Ethernet hub "{name}" [{id}] has been deleted'.format(name=self._name, id=self._id)...
python
def close(self): """ Deletes this hub. """ for nio in self._nios: if nio: yield from nio.close() try: yield from Bridge.delete(self) log.info('Ethernet hub "{name}" [{id}] has been deleted'.format(name=self._name, id=self._id)...
[ "def", "close", "(", "self", ")", ":", "for", "nio", "in", "self", ".", "_nios", ":", "if", "nio", ":", "yield", "from", "nio", ".", "close", "(", ")", "try", ":", "yield", "from", "Bridge", ".", "delete", "(", "self", ")", "log", ".", "info", ...
Deletes this hub.
[ "Deletes", "this", "hub", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_hub.py#L117-L134
226,384
GNS3/gns3-server
gns3server/compute/dynamips/nodes/ethernet_hub.py
EthernetHub.add_nio
def add_nio(self, nio, port_number): """ Adds a NIO as new port on this hub. :param nio: NIO instance to add :param port_number: port to allocate for the NIO """ if port_number not in [port["port_number"] for port in self._ports]: raise DynamipsError("Port {...
python
def add_nio(self, nio, port_number): """ Adds a NIO as new port on this hub. :param nio: NIO instance to add :param port_number: port to allocate for the NIO """ if port_number not in [port["port_number"] for port in self._ports]: raise DynamipsError("Port {...
[ "def", "add_nio", "(", "self", ",", "nio", ",", "port_number", ")", ":", "if", "port_number", "not", "in", "[", "port", "[", "\"port_number\"", "]", "for", "port", "in", "self", ".", "_ports", "]", ":", "raise", "DynamipsError", "(", "\"Port {} doesn't exi...
Adds a NIO as new port on this hub. :param nio: NIO instance to add :param port_number: port to allocate for the NIO
[ "Adds", "a", "NIO", "as", "new", "port", "on", "this", "hub", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_hub.py#L137-L157
226,385
GNS3/gns3-server
gns3server/compute/dynamips/nodes/ethernet_hub.py
EthernetHub.remove_nio
def remove_nio(self, port_number): """ Removes the specified NIO as member of this hub. :param port_number: allocated port number :returns: the NIO that was bound to the allocated port """ if port_number not in self._mappings: raise DynamipsError("Port {} i...
python
def remove_nio(self, port_number): """ Removes the specified NIO as member of this hub. :param port_number: allocated port number :returns: the NIO that was bound to the allocated port """ if port_number not in self._mappings: raise DynamipsError("Port {} i...
[ "def", "remove_nio", "(", "self", ",", "port_number", ")", ":", "if", "port_number", "not", "in", "self", ".", "_mappings", ":", "raise", "DynamipsError", "(", "\"Port {} is not allocated\"", ".", "format", "(", "port_number", ")", ")", "nio", "=", "self", "...
Removes the specified NIO as member of this hub. :param port_number: allocated port number :returns: the NIO that was bound to the allocated port
[ "Removes", "the", "specified", "NIO", "as", "member", "of", "this", "hub", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_hub.py#L160-L183
226,386
GNS3/gns3-server
gns3server/compute/base_manager.py
BaseManager.instance
def instance(cls): """ Singleton to return only one instance of BaseManager. :returns: instance of BaseManager """ if not hasattr(cls, "_instance") or cls._instance is None: cls._instance = cls() return cls._instance
python
def instance(cls): """ Singleton to return only one instance of BaseManager. :returns: instance of BaseManager """ if not hasattr(cls, "_instance") or cls._instance is None: cls._instance = cls() return cls._instance
[ "def", "instance", "(", "cls", ")", ":", "if", "not", "hasattr", "(", "cls", ",", "\"_instance\"", ")", "or", "cls", ".", "_instance", "is", "None", ":", "cls", ".", "_instance", "=", "cls", "(", ")", "return", "cls", ".", "_instance" ]
Singleton to return only one instance of BaseManager. :returns: instance of BaseManager
[ "Singleton", "to", "return", "only", "one", "instance", "of", "BaseManager", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L78-L87
226,387
GNS3/gns3-server
gns3server/compute/base_manager.py
BaseManager.port_manager
def port_manager(self): """ Returns the port manager. :returns: Port manager """ if self._port_manager is None: self._port_manager = PortManager.instance() return self._port_manager
python
def port_manager(self): """ Returns the port manager. :returns: Port manager """ if self._port_manager is None: self._port_manager = PortManager.instance() return self._port_manager
[ "def", "port_manager", "(", "self", ")", ":", "if", "self", ".", "_port_manager", "is", "None", ":", "self", ".", "_port_manager", "=", "PortManager", ".", "instance", "(", ")", "return", "self", ".", "_port_manager" ]
Returns the port manager. :returns: Port manager
[ "Returns", "the", "port", "manager", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L100-L108
226,388
GNS3/gns3-server
gns3server/compute/base_manager.py
BaseManager.convert_old_project
def convert_old_project(self, project, legacy_id, name): """ Convert projects made before version 1.3 :param project: Project instance :param legacy_id: old identifier :param name: node name :returns: new identifier """ new_id = str(uuid4()) leg...
python
def convert_old_project(self, project, legacy_id, name): """ Convert projects made before version 1.3 :param project: Project instance :param legacy_id: old identifier :param name: node name :returns: new identifier """ new_id = str(uuid4()) leg...
[ "def", "convert_old_project", "(", "self", ",", "project", ",", "legacy_id", ",", "name", ")", ":", "new_id", "=", "str", "(", "uuid4", "(", ")", ")", "legacy_project_files_path", "=", "os", ".", "path", ".", "join", "(", "project", ".", "path", ",", "...
Convert projects made before version 1.3 :param project: Project instance :param legacy_id: old identifier :param name: node name :returns: new identifier
[ "Convert", "projects", "made", "before", "version", "1", ".", "3" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L175-L226
226,389
GNS3/gns3-server
gns3server/compute/base_manager.py
BaseManager.close_node
def close_node(self, node_id): """ Close a node :param node_id: Node identifier :returns: Node instance """ node = self.get_node(node_id) if asyncio.iscoroutinefunction(node.close): yield from node.close() else: node.close() ...
python
def close_node(self, node_id): """ Close a node :param node_id: Node identifier :returns: Node instance """ node = self.get_node(node_id) if asyncio.iscoroutinefunction(node.close): yield from node.close() else: node.close() ...
[ "def", "close_node", "(", "self", ",", "node_id", ")", ":", "node", "=", "self", ".", "get_node", "(", "node_id", ")", "if", "asyncio", ".", "iscoroutinefunction", "(", "node", ".", "close", ")", ":", "yield", "from", "node", ".", "close", "(", ")", ...
Close a node :param node_id: Node identifier :returns: Node instance
[ "Close", "a", "node" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L291-L305
226,390
GNS3/gns3-server
gns3server/compute/base_manager.py
BaseManager.delete_node
def delete_node(self, node_id): """ Delete a node. The node working directory will be destroyed when a commit is received. :param node_id: Node identifier :returns: Node instance """ node = None try: node = self.get_node(node_id) yield fr...
python
def delete_node(self, node_id): """ Delete a node. The node working directory will be destroyed when a commit is received. :param node_id: Node identifier :returns: Node instance """ node = None try: node = self.get_node(node_id) yield fr...
[ "def", "delete_node", "(", "self", ",", "node_id", ")", ":", "node", "=", "None", "try", ":", "node", "=", "self", ".", "get_node", "(", "node_id", ")", "yield", "from", "self", ".", "close_node", "(", "node_id", ")", "finally", ":", "if", "node", ":...
Delete a node. The node working directory will be destroyed when a commit is received. :param node_id: Node identifier :returns: Node instance
[ "Delete", "a", "node", ".", "The", "node", "working", "directory", "will", "be", "destroyed", "when", "a", "commit", "is", "received", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L330-L348
226,391
GNS3/gns3-server
gns3server/compute/base_manager.py
BaseManager.has_privileged_access
def has_privileged_access(executable): """ Check if an executable have the right to attach to Ethernet and TAP adapters. :param executable: executable path :returns: True or False """ if sys.platform.startswith("win"): # do not check anything on Windows ...
python
def has_privileged_access(executable): """ Check if an executable have the right to attach to Ethernet and TAP adapters. :param executable: executable path :returns: True or False """ if sys.platform.startswith("win"): # do not check anything on Windows ...
[ "def", "has_privileged_access", "(", "executable", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "\"win\"", ")", ":", "# do not check anything on Windows", "return", "True", "if", "sys", ".", "platform", ".", "startswith", "(", "\"darwin\"", ")...
Check if an executable have the right to attach to Ethernet and TAP adapters. :param executable: executable path :returns: True or False
[ "Check", "if", "an", "executable", "have", "the", "right", "to", "attach", "to", "Ethernet", "and", "TAP", "adapters", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L351-L386
226,392
GNS3/gns3-server
gns3server/compute/base_manager.py
BaseManager.get_abs_image_path
def get_abs_image_path(self, path): """ Get the absolute path of an image :param path: file path :return: file path """ if not path: return "" orig_path = path server_config = self.config.get_section_config("Server") img_directory = ...
python
def get_abs_image_path(self, path): """ Get the absolute path of an image :param path: file path :return: file path """ if not path: return "" orig_path = path server_config = self.config.get_section_config("Server") img_directory = ...
[ "def", "get_abs_image_path", "(", "self", ",", "path", ")", ":", "if", "not", "path", ":", "return", "\"\"", "orig_path", "=", "path", "server_config", "=", "self", ".", "config", ".", "get_section_config", "(", "\"Server\"", ")", "img_directory", "=", "self...
Get the absolute path of an image :param path: file path :return: file path
[ "Get", "the", "absolute", "path", "of", "an", "image" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L430-L476
226,393
GNS3/gns3-server
gns3server/compute/base_manager.py
BaseManager._recursive_search_file_in_directory
def _recursive_search_file_in_directory(self, directory, searched_file): """ Search for a file in directory and is subdirectories :returns: Path or None if not found """ s = os.path.split(searched_file) for root, dirs, files in os.walk(directory): for file i...
python
def _recursive_search_file_in_directory(self, directory, searched_file): """ Search for a file in directory and is subdirectories :returns: Path or None if not found """ s = os.path.split(searched_file) for root, dirs, files in os.walk(directory): for file i...
[ "def", "_recursive_search_file_in_directory", "(", "self", ",", "directory", ",", "searched_file", ")", ":", "s", "=", "os", ".", "path", ".", "split", "(", "searched_file", ")", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "di...
Search for a file in directory and is subdirectories :returns: Path or None if not found
[ "Search", "for", "a", "file", "in", "directory", "and", "is", "subdirectories" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L478-L493
226,394
GNS3/gns3-server
gns3server/compute/base_manager.py
BaseManager.get_relative_image_path
def get_relative_image_path(self, path): """ Get a path relative to images directory path or an abspath if the path is not located inside image directory :param path: file path :return: file path """ if not path: return "" path = forc...
python
def get_relative_image_path(self, path): """ Get a path relative to images directory path or an abspath if the path is not located inside image directory :param path: file path :return: file path """ if not path: return "" path = forc...
[ "def", "get_relative_image_path", "(", "self", ",", "path", ")", ":", "if", "not", "path", ":", "return", "\"\"", "path", "=", "force_unix_path", "(", "self", ".", "get_abs_image_path", "(", "path", ")", ")", "img_directory", "=", "self", ".", "get_images_di...
Get a path relative to images directory path or an abspath if the path is not located inside image directory :param path: file path :return: file path
[ "Get", "a", "path", "relative", "to", "images", "directory", "path", "or", "an", "abspath", "if", "the", "path", "is", "not", "located", "inside", "image", "directory" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L495-L517
226,395
GNS3/gns3-server
gns3server/compute/base_manager.py
BaseManager.list_images
def list_images(self): """ Return the list of available images for this node type :returns: Array of hash """ try: return list_images(self._NODE_TYPE) except OSError as e: raise aiohttp.web.HTTPConflict(text="Can not list images {}".format(e))
python
def list_images(self): """ Return the list of available images for this node type :returns: Array of hash """ try: return list_images(self._NODE_TYPE) except OSError as e: raise aiohttp.web.HTTPConflict(text="Can not list images {}".format(e))
[ "def", "list_images", "(", "self", ")", ":", "try", ":", "return", "list_images", "(", "self", ".", "_NODE_TYPE", ")", "except", "OSError", "as", "e", ":", "raise", "aiohttp", ".", "web", ".", "HTTPConflict", "(", "text", "=", "\"Can not list images {}\"", ...
Return the list of available images for this node type :returns: Array of hash
[ "Return", "the", "list", "of", "available", "images", "for", "this", "node", "type" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L520-L530
226,396
GNS3/gns3-server
gns3server/compute/dynamips/hypervisor.py
Hypervisor.start
def start(self): """ Starts the Dynamips hypervisor process. """ self._command = self._build_command() env = os.environ.copy() if sys.platform.startswith("win"): # add the Npcap directory to $PATH to force Dynamips to use npcap DLL instead of Winpcap (if inst...
python
def start(self): """ Starts the Dynamips hypervisor process. """ self._command = self._build_command() env = os.environ.copy() if sys.platform.startswith("win"): # add the Npcap directory to $PATH to force Dynamips to use npcap DLL instead of Winpcap (if inst...
[ "def", "start", "(", "self", ")", ":", "self", ".", "_command", "=", "self", ".", "_build_command", "(", ")", "env", "=", "os", ".", "environ", ".", "copy", "(", ")", "if", "sys", ".", "platform", ".", "startswith", "(", "\"win\"", ")", ":", "# add...
Starts the Dynamips hypervisor process.
[ "Starts", "the", "Dynamips", "hypervisor", "process", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/hypervisor.py#L115-L141
226,397
GNS3/gns3-server
gns3server/compute/dynamips/hypervisor.py
Hypervisor.stop
def stop(self): """ Stops the Dynamips hypervisor process. """ if self.is_running(): log.info("Stopping Dynamips process PID={}".format(self._process.pid)) yield from DynamipsHypervisor.stop(self) # give some time for the hypervisor to properly stop. ...
python
def stop(self): """ Stops the Dynamips hypervisor process. """ if self.is_running(): log.info("Stopping Dynamips process PID={}".format(self._process.pid)) yield from DynamipsHypervisor.stop(self) # give some time for the hypervisor to properly stop. ...
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "is_running", "(", ")", ":", "log", ".", "info", "(", "\"Stopping Dynamips process PID={}\"", ".", "format", "(", "self", ".", "_process", ".", "pid", ")", ")", "yield", "from", "DynamipsHypervisor",...
Stops the Dynamips hypervisor process.
[ "Stops", "the", "Dynamips", "hypervisor", "process", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/hypervisor.py#L144-L172
226,398
GNS3/gns3-server
gns3server/compute/dynamips/hypervisor.py
Hypervisor.read_stdout
def read_stdout(self): """ Reads the standard output of the Dynamips process. Only use when the process has been stopped or has crashed. """ output = "" if self._stdout_file and os.access(self._stdout_file, os.R_OK): try: with open(self._stdou...
python
def read_stdout(self): """ Reads the standard output of the Dynamips process. Only use when the process has been stopped or has crashed. """ output = "" if self._stdout_file and os.access(self._stdout_file, os.R_OK): try: with open(self._stdou...
[ "def", "read_stdout", "(", "self", ")", ":", "output", "=", "\"\"", "if", "self", ".", "_stdout_file", "and", "os", ".", "access", "(", "self", ".", "_stdout_file", ",", "os", ".", "R_OK", ")", ":", "try", ":", "with", "open", "(", "self", ".", "_s...
Reads the standard output of the Dynamips process. Only use when the process has been stopped or has crashed.
[ "Reads", "the", "standard", "output", "of", "the", "Dynamips", "process", ".", "Only", "use", "when", "the", "process", "has", "been", "stopped", "or", "has", "crashed", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/hypervisor.py#L174-L187
226,399
GNS3/gns3-server
gns3server/compute/dynamips/adapters/adapter.py
Adapter.install_wic
def install_wic(self, wic_slot_id, wic): """ Installs a WIC on this adapter. :param wic_slot_id: WIC slot ID (integer) :param wic: WIC instance """ self._wics[wic_slot_id] = wic # Dynamips WICs ports start on a multiple of 16 + port number # WIC1 port 1...
python
def install_wic(self, wic_slot_id, wic): """ Installs a WIC on this adapter. :param wic_slot_id: WIC slot ID (integer) :param wic: WIC instance """ self._wics[wic_slot_id] = wic # Dynamips WICs ports start on a multiple of 16 + port number # WIC1 port 1...
[ "def", "install_wic", "(", "self", ",", "wic_slot_id", ",", "wic", ")", ":", "self", ".", "_wics", "[", "wic_slot_id", "]", "=", "wic", "# Dynamips WICs ports start on a multiple of 16 + port number", "# WIC1 port 1 = 16, WIC1 port 2 = 17", "# WIC2 port 1 = 32, WIC2 port 2 = ...
Installs a WIC on this adapter. :param wic_slot_id: WIC slot ID (integer) :param wic: WIC instance
[ "Installs", "a", "WIC", "on", "this", "adapter", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/adapters/adapter.py#L70-L87