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,700 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.start | def start(self):
"""
Starts the IOU process.
"""
self._check_requirements()
if not self.is_running():
yield from self._library_check()
try:
self._rename_nvram_file()
except OSError as e:
raise IOUError("Could ... | python | def start(self):
"""
Starts the IOU process.
"""
self._check_requirements()
if not self.is_running():
yield from self._library_check()
try:
self._rename_nvram_file()
except OSError as e:
raise IOUError("Could ... | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"_check_requirements",
"(",
")",
"if",
"not",
"self",
".",
"is_running",
"(",
")",
":",
"yield",
"from",
"self",
".",
"_library_check",
"(",
")",
"try",
":",
"self",
".",
"_rename_nvram_file",
"(",
")... | Starts the IOU process. | [
"Starts",
"the",
"IOU",
"process",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L480-L547 |
226,701 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM._networking | def _networking(self):
"""
Configures the IOL bridge in uBridge.
"""
bridge_name = "IOL-BRIDGE-{}".format(self.application_id + 512)
try:
# delete any previous bridge if it exists
yield from self._ubridge_send("iol_bridge delete {name}".format(name=bridge... | python | def _networking(self):
"""
Configures the IOL bridge in uBridge.
"""
bridge_name = "IOL-BRIDGE-{}".format(self.application_id + 512)
try:
# delete any previous bridge if it exists
yield from self._ubridge_send("iol_bridge delete {name}".format(name=bridge... | [
"def",
"_networking",
"(",
"self",
")",
":",
"bridge_name",
"=",
"\"IOL-BRIDGE-{}\"",
".",
"format",
"(",
"self",
".",
"application_id",
"+",
"512",
")",
"try",
":",
"# delete any previous bridge if it exists",
"yield",
"from",
"self",
".",
"_ubridge_send",
"(",
... | Configures the IOL bridge in uBridge. | [
"Configures",
"the",
"IOL",
"bridge",
"in",
"uBridge",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L550-L585 |
226,702 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM._rename_nvram_file | def _rename_nvram_file(self):
"""
Before starting the VM, rename the nvram and vlan.dat files with the correct IOU application identifier.
"""
destination = self._nvram_file()
for file_path in glob.glob(os.path.join(glob.escape(self.working_dir), "nvram_*")):
shutil.... | python | def _rename_nvram_file(self):
"""
Before starting the VM, rename the nvram and vlan.dat files with the correct IOU application identifier.
"""
destination = self._nvram_file()
for file_path in glob.glob(os.path.join(glob.escape(self.working_dir), "nvram_*")):
shutil.... | [
"def",
"_rename_nvram_file",
"(",
"self",
")",
":",
"destination",
"=",
"self",
".",
"_nvram_file",
"(",
")",
"for",
"file_path",
"in",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"glob",
".",
"escape",
"(",
"self",
".",
"working_dir... | Before starting the VM, rename the nvram and vlan.dat files with the correct IOU application identifier. | [
"Before",
"starting",
"the",
"VM",
"rename",
"the",
"nvram",
"and",
"vlan",
".",
"dat",
"files",
"with",
"the",
"correct",
"IOU",
"application",
"identifier",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L608-L618 |
226,703 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.stop | def stop(self):
"""
Stops the IOU process.
"""
yield from self._stop_ubridge()
if self._nvram_watcher:
self._nvram_watcher.close()
self._nvram_watcher = None
if self._telnet_server:
self._telnet_server.close()
self._telnet... | python | def stop(self):
"""
Stops the IOU process.
"""
yield from self._stop_ubridge()
if self._nvram_watcher:
self._nvram_watcher.close()
self._nvram_watcher = None
if self._telnet_server:
self._telnet_server.close()
self._telnet... | [
"def",
"stop",
"(",
"self",
")",
":",
"yield",
"from",
"self",
".",
"_stop_ubridge",
"(",
")",
"if",
"self",
".",
"_nvram_watcher",
":",
"self",
".",
"_nvram_watcher",
".",
"close",
"(",
")",
"self",
".",
"_nvram_watcher",
"=",
"None",
"if",
"self",
".... | Stops the IOU process. | [
"Stops",
"the",
"IOU",
"process",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L621-L650 |
226,704 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM._terminate_process_iou | def _terminate_process_iou(self):
"""
Terminate the IOU process if running
"""
if self._iou_process:
log.info('Stopping IOU process for IOU VM "{}" PID={}'.format(self.name, self._iou_process.pid))
try:
self._iou_process.terminate()
# ... | python | def _terminate_process_iou(self):
"""
Terminate the IOU process if running
"""
if self._iou_process:
log.info('Stopping IOU process for IOU VM "{}" PID={}'.format(self.name, self._iou_process.pid))
try:
self._iou_process.terminate()
# ... | [
"def",
"_terminate_process_iou",
"(",
"self",
")",
":",
"if",
"self",
".",
"_iou_process",
":",
"log",
".",
"info",
"(",
"'Stopping IOU process for IOU VM \"{}\" PID={}'",
".",
"format",
"(",
"self",
".",
"name",
",",
"self",
".",
"_iou_process",
".",
"pid",
"... | Terminate the IOU process if running | [
"Terminate",
"the",
"IOU",
"process",
"if",
"running"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L652-L665 |
226,705 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM._create_netmap_config | def _create_netmap_config(self):
"""
Creates the NETMAP file.
"""
netmap_path = os.path.join(self.working_dir, "NETMAP")
try:
with open(netmap_path, "w", encoding="utf-8") as f:
for bay in range(0, 16):
for unit in range(0, 4):
... | python | def _create_netmap_config(self):
"""
Creates the NETMAP file.
"""
netmap_path = os.path.join(self.working_dir, "NETMAP")
try:
with open(netmap_path, "w", encoding="utf-8") as f:
for bay in range(0, 16):
for unit in range(0, 4):
... | [
"def",
"_create_netmap_config",
"(",
"self",
")",
":",
"netmap_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"working_dir",
",",
"\"NETMAP\"",
")",
"try",
":",
"with",
"open",
"(",
"netmap_path",
",",
"\"w\"",
",",
"encoding",
"=",
"\"utf... | Creates the NETMAP file. | [
"Creates",
"the",
"NETMAP",
"file",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L687-L704 |
226,706 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.read_iou_stdout | def read_iou_stdout(self):
"""
Reads the standard output of the IOU process.
Only use when the process has been stopped or has crashed.
"""
output = ""
if self._iou_stdout_file:
try:
with open(self._iou_stdout_file, "rb") as file:
... | python | def read_iou_stdout(self):
"""
Reads the standard output of the IOU process.
Only use when the process has been stopped or has crashed.
"""
output = ""
if self._iou_stdout_file:
try:
with open(self._iou_stdout_file, "rb") as file:
... | [
"def",
"read_iou_stdout",
"(",
"self",
")",
":",
"output",
"=",
"\"\"",
"if",
"self",
".",
"_iou_stdout_file",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"_iou_stdout_file",
",",
"\"rb\"",
")",
"as",
"file",
":",
"output",
"=",
"file",
".",
"re... | Reads the standard output of the IOU process.
Only use when the process has been stopped or has crashed. | [
"Reads",
"the",
"standard",
"output",
"of",
"the",
"IOU",
"process",
".",
"Only",
"use",
"when",
"the",
"process",
"has",
"been",
"stopped",
"or",
"has",
"crashed",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L756-L769 |
226,707 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.ethernet_adapters | def ethernet_adapters(self, ethernet_adapters):
"""
Sets the number of Ethernet adapters for this IOU VM.
:param ethernet_adapters: number of adapters
"""
self._ethernet_adapters.clear()
for _ in range(0, ethernet_adapters):
self._ethernet_adapters.append(Et... | python | def ethernet_adapters(self, ethernet_adapters):
"""
Sets the number of Ethernet adapters for this IOU VM.
:param ethernet_adapters: number of adapters
"""
self._ethernet_adapters.clear()
for _ in range(0, ethernet_adapters):
self._ethernet_adapters.append(Et... | [
"def",
"ethernet_adapters",
"(",
"self",
",",
"ethernet_adapters",
")",
":",
"self",
".",
"_ethernet_adapters",
".",
"clear",
"(",
")",
"for",
"_",
"in",
"range",
"(",
"0",
",",
"ethernet_adapters",
")",
":",
"self",
".",
"_ethernet_adapters",
".",
"append",... | Sets the number of Ethernet adapters for this IOU VM.
:param ethernet_adapters: number of adapters | [
"Sets",
"the",
"number",
"of",
"Ethernet",
"adapters",
"for",
"this",
"IOU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L786-L801 |
226,708 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.serial_adapters | def serial_adapters(self, serial_adapters):
"""
Sets the number of Serial adapters for this IOU VM.
:param serial_adapters: number of adapters
"""
self._serial_adapters.clear()
for _ in range(0, serial_adapters):
self._serial_adapters.append(SerialAdapter(in... | python | def serial_adapters(self, serial_adapters):
"""
Sets the number of Serial adapters for this IOU VM.
:param serial_adapters: number of adapters
"""
self._serial_adapters.clear()
for _ in range(0, serial_adapters):
self._serial_adapters.append(SerialAdapter(in... | [
"def",
"serial_adapters",
"(",
"self",
",",
"serial_adapters",
")",
":",
"self",
".",
"_serial_adapters",
".",
"clear",
"(",
")",
"for",
"_",
"in",
"range",
"(",
"0",
",",
"serial_adapters",
")",
":",
"self",
".",
"_serial_adapters",
".",
"append",
"(",
... | Sets the number of Serial adapters for this IOU VM.
:param serial_adapters: number of adapters | [
"Sets",
"the",
"number",
"of",
"Serial",
"adapters",
"for",
"this",
"IOU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L814-L829 |
226,709 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.adapter_add_nio_binding | def adapter_add_nio_binding(self, adapter_number, port_number, nio):
"""
Adds a adapter NIO binding.
:param adapter_number: adapter number
:param port_number: port number
:param nio: NIO instance to add to the adapter/port
"""
try:
adapter = self._ad... | python | def adapter_add_nio_binding(self, adapter_number, port_number, nio):
"""
Adds a adapter NIO binding.
:param adapter_number: adapter number
:param port_number: port number
:param nio: NIO instance to add to the adapter/port
"""
try:
adapter = self._ad... | [
"def",
"adapter_add_nio_binding",
"(",
"self",
",",
"adapter_number",
",",
"port_number",
",",
"nio",
")",
":",
"try",
":",
"adapter",
"=",
"self",
".",
"_adapters",
"[",
"adapter_number",
"]",
"except",
"IndexError",
":",
"raise",
"IOUError",
"(",
"'Adapter {... | Adds a adapter NIO binding.
:param adapter_number: adapter number
:param port_number: port number
:param nio: NIO instance to add to the adapter/port | [
"Adds",
"a",
"adapter",
"NIO",
"binding",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L832-L867 |
226,710 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM._ubridge_apply_filters | def _ubridge_apply_filters(self, adapter_number, port_number, filters):
"""
Apply filter like rate limiting
:param adapter_number: adapter number
:param port_number: port number
:param filters: Array of filter dictionnary
"""
bridge_name = "IOL-BRIDGE-{}".format(... | python | def _ubridge_apply_filters(self, adapter_number, port_number, filters):
"""
Apply filter like rate limiting
:param adapter_number: adapter number
:param port_number: port number
:param filters: Array of filter dictionnary
"""
bridge_name = "IOL-BRIDGE-{}".format(... | [
"def",
"_ubridge_apply_filters",
"(",
"self",
",",
"adapter_number",
",",
"port_number",
",",
"filters",
")",
":",
"bridge_name",
"=",
"\"IOL-BRIDGE-{}\"",
".",
"format",
"(",
"self",
".",
"application_id",
"+",
"512",
")",
"location",
"=",
"'{bridge_name} {bay} {... | Apply filter like rate limiting
:param adapter_number: adapter number
:param port_number: port number
:param filters: Array of filter dictionnary | [
"Apply",
"filter",
"like",
"rate",
"limiting"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L883-L901 |
226,711 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.l1_keepalives | def l1_keepalives(self, state):
"""
Enables or disables layer 1 keepalive messages.
:param state: boolean
"""
self._l1_keepalives = state
if state:
log.info('IOU "{name}" [{id}]: has activated layer 1 keepalive messages'.format(name=self._name, id=self._id))... | python | def l1_keepalives(self, state):
"""
Enables or disables layer 1 keepalive messages.
:param state: boolean
"""
self._l1_keepalives = state
if state:
log.info('IOU "{name}" [{id}]: has activated layer 1 keepalive messages'.format(name=self._name, id=self._id))... | [
"def",
"l1_keepalives",
"(",
"self",
",",
"state",
")",
":",
"self",
".",
"_l1_keepalives",
"=",
"state",
"if",
"state",
":",
"log",
".",
"info",
"(",
"'IOU \"{name}\" [{id}]: has activated layer 1 keepalive messages'",
".",
"format",
"(",
"name",
"=",
"self",
"... | Enables or disables layer 1 keepalive messages.
:param state: boolean | [
"Enables",
"or",
"disables",
"layer",
"1",
"keepalive",
"messages",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L952-L963 |
226,712 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM._enable_l1_keepalives | def _enable_l1_keepalives(self, command):
"""
Enables L1 keepalive messages if supported.
:param command: command line
"""
env = os.environ.copy()
if "IOURC" not in os.environ:
env["IOURC"] = self.iourc_path
try:
output = yield from gns3s... | python | def _enable_l1_keepalives(self, command):
"""
Enables L1 keepalive messages if supported.
:param command: command line
"""
env = os.environ.copy()
if "IOURC" not in os.environ:
env["IOURC"] = self.iourc_path
try:
output = yield from gns3s... | [
"def",
"_enable_l1_keepalives",
"(",
"self",
",",
"command",
")",
":",
"env",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"if",
"\"IOURC\"",
"not",
"in",
"os",
".",
"environ",
":",
"env",
"[",
"\"IOURC\"",
"]",
"=",
"self",
".",
"iourc_path",
"... | Enables L1 keepalive messages if supported.
:param command: command line | [
"Enables",
"L1",
"keepalive",
"messages",
"if",
"supported",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L966-L983 |
226,713 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.startup_config_content | def startup_config_content(self):
"""
Returns the content of the current startup-config file.
"""
config_file = self.startup_config_file
if config_file is None:
return None
try:
with open(config_file, "rb") as f:
return f.read().d... | python | def startup_config_content(self):
"""
Returns the content of the current startup-config file.
"""
config_file = self.startup_config_file
if config_file is None:
return None
try:
with open(config_file, "rb") as f:
return f.read().d... | [
"def",
"startup_config_content",
"(",
"self",
")",
":",
"config_file",
"=",
"self",
".",
"startup_config_file",
"if",
"config_file",
"is",
"None",
":",
"return",
"None",
"try",
":",
"with",
"open",
"(",
"config_file",
",",
"\"rb\"",
")",
"as",
"f",
":",
"r... | Returns the content of the current startup-config file. | [
"Returns",
"the",
"content",
"of",
"the",
"current",
"startup",
"-",
"config",
"file",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L986-L999 |
226,714 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.startup_config_content | def startup_config_content(self, startup_config):
"""
Update the startup config
:param startup_config: content of the startup configuration file
"""
try:
startup_config_path = os.path.join(self.working_dir, "startup-config.cfg")
if startup_config is Non... | python | def startup_config_content(self, startup_config):
"""
Update the startup config
:param startup_config: content of the startup configuration file
"""
try:
startup_config_path = os.path.join(self.working_dir, "startup-config.cfg")
if startup_config is Non... | [
"def",
"startup_config_content",
"(",
"self",
",",
"startup_config",
")",
":",
"try",
":",
"startup_config_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"working_dir",
",",
"\"startup-config.cfg\"",
")",
"if",
"startup_config",
"is",
"None",
":... | Update the startup config
:param startup_config: content of the startup configuration file | [
"Update",
"the",
"startup",
"config"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L1002-L1034 |
226,715 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.private_config_content | def private_config_content(self):
"""
Returns the content of the current private-config file.
"""
config_file = self.private_config_file
if config_file is None:
return None
try:
with open(config_file, "rb") as f:
return f.read().d... | python | def private_config_content(self):
"""
Returns the content of the current private-config file.
"""
config_file = self.private_config_file
if config_file is None:
return None
try:
with open(config_file, "rb") as f:
return f.read().d... | [
"def",
"private_config_content",
"(",
"self",
")",
":",
"config_file",
"=",
"self",
".",
"private_config_file",
"if",
"config_file",
"is",
"None",
":",
"return",
"None",
"try",
":",
"with",
"open",
"(",
"config_file",
",",
"\"rb\"",
")",
"as",
"f",
":",
"r... | Returns the content of the current private-config file. | [
"Returns",
"the",
"content",
"of",
"the",
"current",
"private",
"-",
"config",
"file",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L1037-L1050 |
226,716 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.private_config_content | def private_config_content(self, private_config):
"""
Update the private config
:param private_config: content of the private configuration file
"""
try:
private_config_path = os.path.join(self.working_dir, "private-config.cfg")
if private_config is Non... | python | def private_config_content(self, private_config):
"""
Update the private config
:param private_config: content of the private configuration file
"""
try:
private_config_path = os.path.join(self.working_dir, "private-config.cfg")
if private_config is Non... | [
"def",
"private_config_content",
"(",
"self",
",",
"private_config",
")",
":",
"try",
":",
"private_config_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"working_dir",
",",
"\"private-config.cfg\"",
")",
"if",
"private_config",
"is",
"None",
":... | Update the private config
:param private_config: content of the private configuration file | [
"Update",
"the",
"private",
"config"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L1053-L1077 |
226,717 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.startup_config_file | def startup_config_file(self):
"""
Returns the startup-config file for this IOU VM.
:returns: path to config file. None if the file doesn't exist
"""
path = os.path.join(self.working_dir, 'startup-config.cfg')
if os.path.exists(path):
return path
els... | python | def startup_config_file(self):
"""
Returns the startup-config file for this IOU VM.
:returns: path to config file. None if the file doesn't exist
"""
path = os.path.join(self.working_dir, 'startup-config.cfg')
if os.path.exists(path):
return path
els... | [
"def",
"startup_config_file",
"(",
"self",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"working_dir",
",",
"'startup-config.cfg'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"return",
"path",
"else"... | Returns the startup-config file for this IOU VM.
:returns: path to config file. None if the file doesn't exist | [
"Returns",
"the",
"startup",
"-",
"config",
"file",
"for",
"this",
"IOU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L1080-L1091 |
226,718 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.private_config_file | def private_config_file(self):
"""
Returns the private-config file for this IOU VM.
:returns: path to config file. None if the file doesn't exist
"""
path = os.path.join(self.working_dir, 'private-config.cfg')
if os.path.exists(path):
return path
els... | python | def private_config_file(self):
"""
Returns the private-config file for this IOU VM.
:returns: path to config file. None if the file doesn't exist
"""
path = os.path.join(self.working_dir, 'private-config.cfg')
if os.path.exists(path):
return path
els... | [
"def",
"private_config_file",
"(",
"self",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"working_dir",
",",
"'private-config.cfg'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"return",
"path",
"else"... | Returns the private-config file for this IOU VM.
:returns: path to config file. None if the file doesn't exist | [
"Returns",
"the",
"private",
"-",
"config",
"file",
"for",
"this",
"IOU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L1094-L1105 |
226,719 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.relative_startup_config_file | def relative_startup_config_file(self):
"""
Returns the startup-config file relative to the project directory.
It's compatible with pre 1.3 projects.
:returns: path to startup-config file. None if the file doesn't exist
"""
path = os.path.join(self.working_dir, 'startup... | python | def relative_startup_config_file(self):
"""
Returns the startup-config file relative to the project directory.
It's compatible with pre 1.3 projects.
:returns: path to startup-config file. None if the file doesn't exist
"""
path = os.path.join(self.working_dir, 'startup... | [
"def",
"relative_startup_config_file",
"(",
"self",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"working_dir",
",",
"'startup-config.cfg'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"return",
"'start... | Returns the startup-config file relative to the project directory.
It's compatible with pre 1.3 projects.
:returns: path to startup-config file. None if the file doesn't exist | [
"Returns",
"the",
"startup",
"-",
"config",
"file",
"relative",
"to",
"the",
"project",
"directory",
".",
"It",
"s",
"compatible",
"with",
"pre",
"1",
".",
"3",
"projects",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L1108-L1120 |
226,720 | GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | IOUVM.relative_private_config_file | def relative_private_config_file(self):
"""
Returns the private-config file relative to the project directory.
:returns: path to private-config file. None if the file doesn't exist
"""
path = os.path.join(self.working_dir, 'private-config.cfg')
if os.path.exists(path):
... | python | def relative_private_config_file(self):
"""
Returns the private-config file relative to the project directory.
:returns: path to private-config file. None if the file doesn't exist
"""
path = os.path.join(self.working_dir, 'private-config.cfg')
if os.path.exists(path):
... | [
"def",
"relative_private_config_file",
"(",
"self",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"working_dir",
",",
"'private-config.cfg'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"return",
"'priva... | Returns the private-config file relative to the project directory.
:returns: path to private-config file. None if the file doesn't exist | [
"Returns",
"the",
"private",
"-",
"config",
"file",
"relative",
"to",
"the",
"project",
"directory",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L1123-L1134 |
226,721 | GNS3/gns3-server | gns3server/controller/drawing.py | Drawing.svg | def svg(self, value):
"""
Set SVG field value.
If the svg has embed base64 element we will extract them
to disk in order to avoid duplication of content
"""
if len(value) < 500:
self._svg = value
return
try:
root = ET.fromstr... | python | def svg(self, value):
"""
Set SVG field value.
If the svg has embed base64 element we will extract them
to disk in order to avoid duplication of content
"""
if len(value) < 500:
self._svg = value
return
try:
root = ET.fromstr... | [
"def",
"svg",
"(",
"self",
",",
"value",
")",
":",
"if",
"len",
"(",
"value",
")",
"<",
"500",
":",
"self",
".",
"_svg",
"=",
"value",
"return",
"try",
":",
"root",
"=",
"ET",
".",
"fromstring",
"(",
"value",
")",
"except",
"ET",
".",
"ParseError... | Set SVG field value.
If the svg has embed base64 element we will extract them
to disk in order to avoid duplication of content | [
"Set",
"SVG",
"field",
"value",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/drawing.py#L84-L134 |
226,722 | GNS3/gns3-server | gns3server/controller/drawing.py | Drawing.update | def update(self, **kwargs):
"""
Update the drawing
:param kwargs: Drawing properties
"""
# Update node properties with additional elements
svg_changed = False
for prop in kwargs:
if prop == "drawing_id":
pass # No good reason to chan... | python | def update(self, **kwargs):
"""
Update the drawing
:param kwargs: Drawing properties
"""
# Update node properties with additional elements
svg_changed = False
for prop in kwargs:
if prop == "drawing_id":
pass # No good reason to chan... | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Update node properties with additional elements",
"svg_changed",
"=",
"False",
"for",
"prop",
"in",
"kwargs",
":",
"if",
"prop",
"==",
"\"drawing_id\"",
":",
"pass",
"# No good reason to change a dr... | Update the drawing
:param kwargs: Drawing properties | [
"Update",
"the",
"drawing"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/drawing.py#L169-L190 |
226,723 | GNS3/gns3-server | gns3server/compute/vpcs/__init__.py | VPCS.create_node | def create_node(self, *args, **kwargs):
"""
Creates a new VPCS VM.
:returns: VPCSVM instance
"""
node = yield from super().create_node(*args, **kwargs)
self._free_mac_ids.setdefault(node.project.id, list(range(0, 255)))
try:
self._used_mac_ids[node.i... | python | def create_node(self, *args, **kwargs):
"""
Creates a new VPCS VM.
:returns: VPCSVM instance
"""
node = yield from super().create_node(*args, **kwargs)
self._free_mac_ids.setdefault(node.project.id, list(range(0, 255)))
try:
self._used_mac_ids[node.i... | [
"def",
"create_node",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"node",
"=",
"yield",
"from",
"super",
"(",
")",
".",
"create_node",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"_free_mac_ids",
".",
"setdefa... | Creates a new VPCS VM.
:returns: VPCSVM instance | [
"Creates",
"a",
"new",
"VPCS",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/__init__.py#L41-L54 |
226,724 | GNS3/gns3-server | gns3server/compute/vpcs/__init__.py | VPCS.close_node | def close_node(self, node_id, *args, **kwargs):
"""
Closes a VPCS VM.
:returns: VPCSVM instance
"""
node = self.get_node(node_id)
if node_id in self._used_mac_ids:
i = self._used_mac_ids[node_id]
self._free_mac_ids[node.project.id].insert(0, i)
... | python | def close_node(self, node_id, *args, **kwargs):
"""
Closes a VPCS VM.
:returns: VPCSVM instance
"""
node = self.get_node(node_id)
if node_id in self._used_mac_ids:
i = self._used_mac_ids[node_id]
self._free_mac_ids[node.project.id].insert(0, i)
... | [
"def",
"close_node",
"(",
"self",
",",
"node_id",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"node",
"=",
"self",
".",
"get_node",
"(",
"node_id",
")",
"if",
"node_id",
"in",
"self",
".",
"_used_mac_ids",
":",
"i",
"=",
"self",
".",
"_use... | Closes a VPCS VM.
:returns: VPCSVM instance | [
"Closes",
"a",
"VPCS",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/__init__.py#L57-L70 |
226,725 | GNS3/gns3-server | gns3server/compute/dynamips/nios/nio.py | NIO.delete | def delete(self):
"""
Deletes this NIO.
"""
if self._input_filter or self._output_filter:
yield from self.unbind_filter("both")
yield from self._hypervisor.send("nio delete {}".format(self._name))
log.info("NIO {name} has been deleted".format(name=self._name)... | python | def delete(self):
"""
Deletes this NIO.
"""
if self._input_filter or self._output_filter:
yield from self.unbind_filter("both")
yield from self._hypervisor.send("nio delete {}".format(self._name))
log.info("NIO {name} has been deleted".format(name=self._name)... | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"_input_filter",
"or",
"self",
".",
"_output_filter",
":",
"yield",
"from",
"self",
".",
"unbind_filter",
"(",
"\"both\"",
")",
"yield",
"from",
"self",
".",
"_hypervisor",
".",
"send",
"(",
"\"n... | Deletes this NIO. | [
"Deletes",
"this",
"NIO",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nios/nio.py#L61-L69 |
226,726 | GNS3/gns3-server | gns3server/compute/dynamips/nios/nio.py | NIO.rename | def rename(self, new_name):
"""
Renames this NIO
:param new_name: new NIO name
"""
yield from self._hypervisor.send("nio rename {name} {new_name}".format(name=self._name, new_name=new_name))
log.info("NIO {name} renamed to {new_name}".format(name=self._name, new_name=n... | python | def rename(self, new_name):
"""
Renames this NIO
:param new_name: new NIO name
"""
yield from self._hypervisor.send("nio rename {name} {new_name}".format(name=self._name, new_name=new_name))
log.info("NIO {name} renamed to {new_name}".format(name=self._name, new_name=n... | [
"def",
"rename",
"(",
"self",
",",
"new_name",
")",
":",
"yield",
"from",
"self",
".",
"_hypervisor",
".",
"send",
"(",
"\"nio rename {name} {new_name}\"",
".",
"format",
"(",
"name",
"=",
"self",
".",
"_name",
",",
"new_name",
"=",
"new_name",
")",
")",
... | Renames this NIO
:param new_name: new NIO name | [
"Renames",
"this",
"NIO"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nios/nio.py#L72-L82 |
226,727 | GNS3/gns3-server | gns3server/compute/dynamips/nios/nio.py | NIO.bind_filter | def bind_filter(self, direction, filter_name):
"""
Adds a packet filter to this NIO.
Filter "freq_drop" drops packets.
Filter "capture" captures packets.
:param direction: "in", "out" or "both"
:param filter_name: name of the filter to apply
"""
if direc... | python | def bind_filter(self, direction, filter_name):
"""
Adds a packet filter to this NIO.
Filter "freq_drop" drops packets.
Filter "capture" captures packets.
:param direction: "in", "out" or "both"
:param filter_name: name of the filter to apply
"""
if direc... | [
"def",
"bind_filter",
"(",
"self",
",",
"direction",
",",
"filter_name",
")",
":",
"if",
"direction",
"not",
"in",
"self",
".",
"_dynamips_direction",
":",
"raise",
"DynamipsError",
"(",
"\"Unknown direction {} to bind filter {}:\"",
".",
"format",
"(",
"direction",... | Adds a packet filter to this NIO.
Filter "freq_drop" drops packets.
Filter "capture" captures packets.
:param direction: "in", "out" or "both"
:param filter_name: name of the filter to apply | [
"Adds",
"a",
"packet",
"filter",
"to",
"this",
"NIO",
".",
"Filter",
"freq_drop",
"drops",
"packets",
".",
"Filter",
"capture",
"captures",
"packets",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nios/nio.py#L95-L119 |
226,728 | GNS3/gns3-server | gns3server/compute/dynamips/nios/nio.py | NIO.unbind_filter | def unbind_filter(self, direction):
"""
Removes packet filter for this NIO.
:param direction: "in", "out" or "both"
"""
if direction not in self._dynamips_direction:
raise DynamipsError("Unknown direction {} to unbind filter:".format(direction))
dynamips_dir... | python | def unbind_filter(self, direction):
"""
Removes packet filter for this NIO.
:param direction: "in", "out" or "both"
"""
if direction not in self._dynamips_direction:
raise DynamipsError("Unknown direction {} to unbind filter:".format(direction))
dynamips_dir... | [
"def",
"unbind_filter",
"(",
"self",
",",
"direction",
")",
":",
"if",
"direction",
"not",
"in",
"self",
".",
"_dynamips_direction",
":",
"raise",
"DynamipsError",
"(",
"\"Unknown direction {} to unbind filter:\"",
".",
"format",
"(",
"direction",
")",
")",
"dynam... | Removes packet filter for this NIO.
:param direction: "in", "out" or "both" | [
"Removes",
"packet",
"filter",
"for",
"this",
"NIO",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nios/nio.py#L122-L142 |
226,729 | GNS3/gns3-server | gns3server/compute/dynamips/nios/nio.py | NIO.setup_filter | def setup_filter(self, direction, options):
"""
Setups a packet filter bound with this NIO.
Filter "freq_drop" has 1 argument "<frequency>". It will drop
everything with a -1 frequency, drop every Nth packet with a
positive frequency, or drop nothing.
Filter "capture" h... | python | def setup_filter(self, direction, options):
"""
Setups a packet filter bound with this NIO.
Filter "freq_drop" has 1 argument "<frequency>". It will drop
everything with a -1 frequency, drop every Nth packet with a
positive frequency, or drop nothing.
Filter "capture" h... | [
"def",
"setup_filter",
"(",
"self",
",",
"direction",
",",
"options",
")",
":",
"if",
"direction",
"not",
"in",
"self",
".",
"_dynamips_direction",
":",
"raise",
"DynamipsError",
"(",
"\"Unknown direction {} to setup filter:\"",
".",
"format",
"(",
"direction",
")... | Setups a packet filter bound with this NIO.
Filter "freq_drop" has 1 argument "<frequency>". It will drop
everything with a -1 frequency, drop every Nth packet with a
positive frequency, or drop nothing.
Filter "capture" has 2 arguments "<link_type_name> <output_file>".
It will... | [
"Setups",
"a",
"packet",
"filter",
"bound",
"with",
"this",
"NIO",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nios/nio.py#L145-L177 |
226,730 | GNS3/gns3-server | gns3server/compute/dynamips/nios/nio.py | NIO.get_stats | def get_stats(self):
"""
Gets statistics for this NIO.
:returns: NIO statistics (string with packets in, packets out, bytes in, bytes out)
"""
stats = yield from self._hypervisor.send("nio get_stats {}".format(self._name))
return stats[0] | python | def get_stats(self):
"""
Gets statistics for this NIO.
:returns: NIO statistics (string with packets in, packets out, bytes in, bytes out)
"""
stats = yield from self._hypervisor.send("nio get_stats {}".format(self._name))
return stats[0] | [
"def",
"get_stats",
"(",
"self",
")",
":",
"stats",
"=",
"yield",
"from",
"self",
".",
"_hypervisor",
".",
"send",
"(",
"\"nio get_stats {}\"",
".",
"format",
"(",
"self",
".",
"_name",
")",
")",
"return",
"stats",
"[",
"0",
"]"
] | Gets statistics for this NIO.
:returns: NIO statistics (string with packets in, packets out, bytes in, bytes out) | [
"Gets",
"statistics",
"for",
"this",
"NIO",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nios/nio.py#L200-L208 |
226,731 | GNS3/gns3-server | gns3server/compute/dynamips/nios/nio.py | NIO.set_bandwidth | def set_bandwidth(self, bandwidth):
"""
Sets bandwidth constraint.
:param bandwidth: bandwidth integer value (in Kb/s)
"""
yield from self._hypervisor.send("nio set_bandwidth {name} {bandwidth}".format(name=self._name, bandwidth=bandwidth))
self._bandwidth = bandwidth | python | def set_bandwidth(self, bandwidth):
"""
Sets bandwidth constraint.
:param bandwidth: bandwidth integer value (in Kb/s)
"""
yield from self._hypervisor.send("nio set_bandwidth {name} {bandwidth}".format(name=self._name, bandwidth=bandwidth))
self._bandwidth = bandwidth | [
"def",
"set_bandwidth",
"(",
"self",
",",
"bandwidth",
")",
":",
"yield",
"from",
"self",
".",
"_hypervisor",
".",
"send",
"(",
"\"nio set_bandwidth {name} {bandwidth}\"",
".",
"format",
"(",
"name",
"=",
"self",
".",
"_name",
",",
"bandwidth",
"=",
"bandwidth... | Sets bandwidth constraint.
:param bandwidth: bandwidth integer value (in Kb/s) | [
"Sets",
"bandwidth",
"constraint",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nios/nio.py#L229-L237 |
226,732 | GNS3/gns3-server | gns3server/controller/node.py | Node.create | def create(self):
"""
Create the node on the compute server
"""
data = self._node_data()
data["node_id"] = self._id
if self._node_type == "docker":
timeout = None
else:
timeout = 1200
trial = 0
while trial != 6:
... | python | def create(self):
"""
Create the node on the compute server
"""
data = self._node_data()
data["node_id"] = self._id
if self._node_type == "docker":
timeout = None
else:
timeout = 1200
trial = 0
while trial != 6:
... | [
"def",
"create",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"_node_data",
"(",
")",
"data",
"[",
"\"node_id\"",
"]",
"=",
"self",
".",
"_id",
"if",
"self",
".",
"_node_type",
"==",
"\"docker\"",
":",
"timeout",
"=",
"None",
"else",
":",
"timeou... | Create the node on the compute server | [
"Create",
"the",
"node",
"on",
"the",
"compute",
"server"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/node.py#L326-L350 |
226,733 | GNS3/gns3-server | gns3server/controller/node.py | Node.update | def update(self, **kwargs):
"""
Update the node on the compute server
:param kwargs: Node properties
"""
# When updating properties used only on controller we don't need to call the compute
update_compute = False
old_json = self.__json__()
compute_prop... | python | def update(self, **kwargs):
"""
Update the node on the compute server
:param kwargs: Node properties
"""
# When updating properties used only on controller we don't need to call the compute
update_compute = False
old_json = self.__json__()
compute_prop... | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# When updating properties used only on controller we don't need to call the compute",
"update_compute",
"=",
"False",
"old_json",
"=",
"self",
".",
"__json__",
"(",
")",
"compute_properties",
"=",
"None"... | Update the node on the compute server
:param kwargs: Node properties | [
"Update",
"the",
"node",
"on",
"the",
"compute",
"server"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/node.py#L353-L386 |
226,734 | GNS3/gns3-server | gns3server/controller/node.py | Node.parse_node_response | def parse_node_response(self, response):
"""
Update the object with the remote node object
"""
for key, value in response.items():
if key == "console":
self._console = value
elif key == "node_directory":
self._node_directory = value... | python | def parse_node_response(self, response):
"""
Update the object with the remote node object
"""
for key, value in response.items():
if key == "console":
self._console = value
elif key == "node_directory":
self._node_directory = value... | [
"def",
"parse_node_response",
"(",
"self",
",",
"response",
")",
":",
"for",
"key",
",",
"value",
"in",
"response",
".",
"items",
"(",
")",
":",
"if",
"key",
"==",
"\"console\"",
":",
"self",
".",
"_console",
"=",
"value",
"elif",
"key",
"==",
"\"node_... | Update the object with the remote node object | [
"Update",
"the",
"object",
"with",
"the",
"remote",
"node",
"object"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/node.py#L389-L416 |
226,735 | GNS3/gns3-server | gns3server/controller/node.py | Node._node_data | def _node_data(self, properties=None):
"""
Prepare node data to send to the remote controller
:param properties: If properties is None use actual property otherwise use the parameter
"""
if properties:
data = copy.copy(properties)
else:
data = cop... | python | def _node_data(self, properties=None):
"""
Prepare node data to send to the remote controller
:param properties: If properties is None use actual property otherwise use the parameter
"""
if properties:
data = copy.copy(properties)
else:
data = cop... | [
"def",
"_node_data",
"(",
"self",
",",
"properties",
"=",
"None",
")",
":",
"if",
"properties",
":",
"data",
"=",
"copy",
".",
"copy",
"(",
"properties",
")",
"else",
":",
"data",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"_properties",
")",
"# We ... | Prepare node data to send to the remote controller
:param properties: If properties is None use actual property otherwise use the parameter | [
"Prepare",
"node",
"data",
"to",
"send",
"to",
"the",
"remote",
"controller"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/node.py#L418-L450 |
226,736 | GNS3/gns3-server | gns3server/controller/node.py | Node.reload | def reload(self):
"""
Suspend a node
"""
try:
yield from self.post("/reload", timeout=240)
except asyncio.TimeoutError:
raise aiohttp.web.HTTPRequestTimeout(text="Timeout when reloading {}".format(self._name)) | python | def reload(self):
"""
Suspend a node
"""
try:
yield from self.post("/reload", timeout=240)
except asyncio.TimeoutError:
raise aiohttp.web.HTTPRequestTimeout(text="Timeout when reloading {}".format(self._name)) | [
"def",
"reload",
"(",
"self",
")",
":",
"try",
":",
"yield",
"from",
"self",
".",
"post",
"(",
"\"/reload\"",
",",
"timeout",
"=",
"240",
")",
"except",
"asyncio",
".",
"TimeoutError",
":",
"raise",
"aiohttp",
".",
"web",
".",
"HTTPRequestTimeout",
"(",
... | Suspend a node | [
"Suspend",
"a",
"node"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/node.py#L498-L505 |
226,737 | GNS3/gns3-server | gns3server/controller/node.py | Node._upload_missing_image | def _upload_missing_image(self, type, img):
"""
Search an image on local computer and upload it to remote compute
if the image exists
"""
for directory in images_directories(type):
image = os.path.join(directory, img)
if os.path.exists(image):
... | python | def _upload_missing_image(self, type, img):
"""
Search an image on local computer and upload it to remote compute
if the image exists
"""
for directory in images_directories(type):
image = os.path.join(directory, img)
if os.path.exists(image):
... | [
"def",
"_upload_missing_image",
"(",
"self",
",",
"type",
",",
"img",
")",
":",
"for",
"directory",
"in",
"images_directories",
"(",
"type",
")",
":",
"image",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"img",
")",
"if",
"os",
".",
"... | Search an image on local computer and upload it to remote compute
if the image exists | [
"Search",
"an",
"image",
"on",
"local",
"computer",
"and",
"upload",
"it",
"to",
"remote",
"compute",
"if",
"the",
"image",
"exists"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/node.py#L542-L558 |
226,738 | GNS3/gns3-server | gns3server/controller/node.py | Node.dynamips_auto_idlepc | def dynamips_auto_idlepc(self):
"""
Compute the idle PC for a dynamips node
"""
return (yield from self._compute.get("/projects/{}/{}/nodes/{}/auto_idlepc".format(self._project.id, self._node_type, self._id), timeout=240)).json | python | def dynamips_auto_idlepc(self):
"""
Compute the idle PC for a dynamips node
"""
return (yield from self._compute.get("/projects/{}/{}/nodes/{}/auto_idlepc".format(self._project.id, self._node_type, self._id), timeout=240)).json | [
"def",
"dynamips_auto_idlepc",
"(",
"self",
")",
":",
"return",
"(",
"yield",
"from",
"self",
".",
"_compute",
".",
"get",
"(",
"\"/projects/{}/{}/nodes/{}/auto_idlepc\"",
".",
"format",
"(",
"self",
".",
"_project",
".",
"id",
",",
"self",
".",
"_node_type",
... | Compute the idle PC for a dynamips node | [
"Compute",
"the",
"idle",
"PC",
"for",
"a",
"dynamips",
"node"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/node.py#L561-L565 |
226,739 | GNS3/gns3-server | gns3server/controller/node.py | Node.get_port | def get_port(self, adapter_number, port_number):
"""
Return the port for this adapter_number and port_number
or returns None if the port is not found
"""
for port in self.ports:
if port.adapter_number == adapter_number and port.port_number == port_number:
... | python | def get_port(self, adapter_number, port_number):
"""
Return the port for this adapter_number and port_number
or returns None if the port is not found
"""
for port in self.ports:
if port.adapter_number == adapter_number and port.port_number == port_number:
... | [
"def",
"get_port",
"(",
"self",
",",
"adapter_number",
",",
"port_number",
")",
":",
"for",
"port",
"in",
"self",
".",
"ports",
":",
"if",
"port",
".",
"adapter_number",
"==",
"adapter_number",
"and",
"port",
".",
"port_number",
"==",
"port_number",
":",
"... | Return the port for this adapter_number and port_number
or returns None if the port is not found | [
"Return",
"the",
"port",
"for",
"this",
"adapter_number",
"and",
"port_number",
"or",
"returns",
"None",
"if",
"the",
"port",
"is",
"not",
"found"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/node.py#L574-L582 |
226,740 | GNS3/gns3-server | gns3server/compute/dynamips/nodes/c1700.py | C1700.set_chassis | def set_chassis(self, chassis):
"""
Sets the chassis.
:param: chassis string:
1720, 1721, 1750, 1751 or 1760
"""
yield from self._hypervisor.send('c1700 set_chassis "{name}" {chassis}'.format(name=self._name, chassis=chassis))
log.info('Router "{name}" [{id}]: ... | python | def set_chassis(self, chassis):
"""
Sets the chassis.
:param: chassis string:
1720, 1721, 1750, 1751 or 1760
"""
yield from self._hypervisor.send('c1700 set_chassis "{name}" {chassis}'.format(name=self._name, chassis=chassis))
log.info('Router "{name}" [{id}]: ... | [
"def",
"set_chassis",
"(",
"self",
",",
"chassis",
")",
":",
"yield",
"from",
"self",
".",
"_hypervisor",
".",
"send",
"(",
"'c1700 set_chassis \"{name}\" {chassis}'",
".",
"format",
"(",
"name",
"=",
"self",
".",
"_name",
",",
"chassis",
"=",
"chassis",
")"... | Sets the chassis.
:param: chassis string:
1720, 1721, 1750, 1751 or 1760 | [
"Sets",
"the",
"chassis",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/c1700.py#L107-L122 |
226,741 | GNS3/gns3-server | gns3server/controller/topology.py | load_topology | def load_topology(path):
"""
Open a topology file, patch it for last GNS3 release and return it
"""
log.debug("Read topology %s", path)
try:
with open(path, encoding="utf-8") as f:
topo = json.load(f)
except (OSError, UnicodeDecodeError, ValueError) as e:
raise aiohtt... | python | def load_topology(path):
"""
Open a topology file, patch it for last GNS3 release and return it
"""
log.debug("Read topology %s", path)
try:
with open(path, encoding="utf-8") as f:
topo = json.load(f)
except (OSError, UnicodeDecodeError, ValueError) as e:
raise aiohtt... | [
"def",
"load_topology",
"(",
"path",
")",
":",
"log",
".",
"debug",
"(",
"\"Read topology %s\"",
",",
"path",
")",
"try",
":",
"with",
"open",
"(",
"path",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"as",
"f",
":",
"topo",
"=",
"json",
".",
"load",
"(",... | Open a topology file, patch it for last GNS3 release and return it | [
"Open",
"a",
"topology",
"file",
"patch",
"it",
"for",
"last",
"GNS3",
"release",
"and",
"return",
"it"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/topology.py#L115-L166 |
226,742 | GNS3/gns3-server | gns3server/controller/topology.py | _convert_2_0_0 | def _convert_2_0_0(topo, topo_path):
"""
Convert topologies from GNS3 2.0.0 to 2.1
Changes:
* Remove startup_script_path from VPCS and base config file for IOU and Dynamips
"""
topo["revision"] = 8
for node in topo.get("topology", {}).get("nodes", []):
if "properties" in node:
... | python | def _convert_2_0_0(topo, topo_path):
"""
Convert topologies from GNS3 2.0.0 to 2.1
Changes:
* Remove startup_script_path from VPCS and base config file for IOU and Dynamips
"""
topo["revision"] = 8
for node in topo.get("topology", {}).get("nodes", []):
if "properties" in node:
... | [
"def",
"_convert_2_0_0",
"(",
"topo",
",",
"topo_path",
")",
":",
"topo",
"[",
"\"revision\"",
"]",
"=",
"8",
"for",
"node",
"in",
"topo",
".",
"get",
"(",
"\"topology\"",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"nodes\"",
",",
"[",
"]",
")",
":",
... | Convert topologies from GNS3 2.0.0 to 2.1
Changes:
* Remove startup_script_path from VPCS and base config file for IOU and Dynamips | [
"Convert",
"topologies",
"from",
"GNS3",
"2",
".",
"0",
".",
"0",
"to",
"2",
".",
"1"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/topology.py#L169-L194 |
226,743 | GNS3/gns3-server | gns3server/controller/topology.py | _convert_2_0_0_beta_2 | def _convert_2_0_0_beta_2(topo, topo_path):
"""
Convert topologies from GNS3 2.0.0 beta 2 to beta 3.
Changes:
* Node id folders for dynamips
"""
topo_dir = os.path.dirname(topo_path)
topo["revision"] = 7
for node in topo.get("topology", {}).get("nodes", []):
if node["node_type... | python | def _convert_2_0_0_beta_2(topo, topo_path):
"""
Convert topologies from GNS3 2.0.0 beta 2 to beta 3.
Changes:
* Node id folders for dynamips
"""
topo_dir = os.path.dirname(topo_path)
topo["revision"] = 7
for node in topo.get("topology", {}).get("nodes", []):
if node["node_type... | [
"def",
"_convert_2_0_0_beta_2",
"(",
"topo",
",",
"topo_path",
")",
":",
"topo_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"topo_path",
")",
"topo",
"[",
"\"revision\"",
"]",
"=",
"7",
"for",
"node",
"in",
"topo",
".",
"get",
"(",
"\"topology\"",
... | Convert topologies from GNS3 2.0.0 beta 2 to beta 3.
Changes:
* Node id folders for dynamips | [
"Convert",
"topologies",
"from",
"GNS3",
"2",
".",
"0",
".",
"0",
"beta",
"2",
"to",
"beta",
"3",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/topology.py#L197-L222 |
226,744 | GNS3/gns3-server | gns3server/controller/topology.py | _convert_2_0_0_alpha | def _convert_2_0_0_alpha(topo, topo_path):
"""
Convert topologies from GNS3 2.0.0 alpha to 2.0.0 final.
Changes:
* No more serial console
* No more option for VMware / VirtualBox remote console (always use telnet)
"""
topo["revision"] = 6
for node in topo.get("topology", {}).get("node... | python | def _convert_2_0_0_alpha(topo, topo_path):
"""
Convert topologies from GNS3 2.0.0 alpha to 2.0.0 final.
Changes:
* No more serial console
* No more option for VMware / VirtualBox remote console (always use telnet)
"""
topo["revision"] = 6
for node in topo.get("topology", {}).get("node... | [
"def",
"_convert_2_0_0_alpha",
"(",
"topo",
",",
"topo_path",
")",
":",
"topo",
"[",
"\"revision\"",
"]",
"=",
"6",
"for",
"node",
"in",
"topo",
".",
"get",
"(",
"\"topology\"",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"nodes\"",
",",
"[",
"]",
")",
... | Convert topologies from GNS3 2.0.0 alpha to 2.0.0 final.
Changes:
* No more serial console
* No more option for VMware / VirtualBox remote console (always use telnet) | [
"Convert",
"topologies",
"from",
"GNS3",
"2",
".",
"0",
".",
"0",
"alpha",
"to",
"2",
".",
"0",
".",
"0",
"final",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/topology.py#L225-L241 |
226,745 | GNS3/gns3-server | gns3server/controller/topology.py | _convert_label | def _convert_label(label):
"""
Convert a label from 1.X to the new format
"""
style = qt_font_to_style(label.get("font"), label.get("color"))
return {
"text": html.escape(label["text"]),
"rotation": 0,
"style": style,
"x": int(label["x"]),
"y": int(label["y"])... | python | def _convert_label(label):
"""
Convert a label from 1.X to the new format
"""
style = qt_font_to_style(label.get("font"), label.get("color"))
return {
"text": html.escape(label["text"]),
"rotation": 0,
"style": style,
"x": int(label["x"]),
"y": int(label["y"])... | [
"def",
"_convert_label",
"(",
"label",
")",
":",
"style",
"=",
"qt_font_to_style",
"(",
"label",
".",
"get",
"(",
"\"font\"",
")",
",",
"label",
".",
"get",
"(",
"\"color\"",
")",
")",
"return",
"{",
"\"text\"",
":",
"html",
".",
"escape",
"(",
"label"... | Convert a label from 1.X to the new format | [
"Convert",
"a",
"label",
"from",
"1",
".",
"X",
"to",
"the",
"new",
"format"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/topology.py#L573-L584 |
226,746 | GNS3/gns3-server | gns3server/controller/topology.py | _convert_snapshots | def _convert_snapshots(topo_dir):
"""
Convert 1.x snapshot to the new format
"""
old_snapshots_dir = os.path.join(topo_dir, "project-files", "snapshots")
if os.path.exists(old_snapshots_dir):
new_snapshots_dir = os.path.join(topo_dir, "snapshots")
os.makedirs(new_snapshots_dir)
... | python | def _convert_snapshots(topo_dir):
"""
Convert 1.x snapshot to the new format
"""
old_snapshots_dir = os.path.join(topo_dir, "project-files", "snapshots")
if os.path.exists(old_snapshots_dir):
new_snapshots_dir = os.path.join(topo_dir, "snapshots")
os.makedirs(new_snapshots_dir)
... | [
"def",
"_convert_snapshots",
"(",
"topo_dir",
")",
":",
"old_snapshots_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"topo_dir",
",",
"\"project-files\"",
",",
"\"snapshots\"",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"old_snapshots_dir",
")",
":"... | Convert 1.x snapshot to the new format | [
"Convert",
"1",
".",
"x",
"snapshot",
"to",
"the",
"new",
"format"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/topology.py#L638-L665 |
226,747 | GNS3/gns3-server | gns3server/controller/topology.py | _convert_qemu_node | def _convert_qemu_node(node, old_node):
"""
Convert qemu node from 1.X to 2.0
"""
# In 2.0 the internet VM is replaced by the NAT node
if old_node.get("properties", {}).get("hda_disk_image_md5sum") == "8ebc5a6ec53a1c05b7aa101b5ceefe31":
node["console"] = None
node["console_type"] = ... | python | def _convert_qemu_node(node, old_node):
"""
Convert qemu node from 1.X to 2.0
"""
# In 2.0 the internet VM is replaced by the NAT node
if old_node.get("properties", {}).get("hda_disk_image_md5sum") == "8ebc5a6ec53a1c05b7aa101b5ceefe31":
node["console"] = None
node["console_type"] = ... | [
"def",
"_convert_qemu_node",
"(",
"node",
",",
"old_node",
")",
":",
"# In 2.0 the internet VM is replaced by the NAT node",
"if",
"old_node",
".",
"get",
"(",
"\"properties\"",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"hda_disk_image_md5sum\"",
")",
"==",
"\"8ebc5a6e... | Convert qemu node from 1.X to 2.0 | [
"Convert",
"qemu",
"node",
"from",
"1",
".",
"X",
"to",
"2",
".",
"0"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/topology.py#L668-L696 |
226,748 | GNS3/gns3-server | gns3server/controller/project.py | open_required | def open_required(func):
"""
Use this decorator to raise an error if the project is not opened
"""
def wrapper(self, *args, **kwargs):
if self._status == "closed":
raise aiohttp.web.HTTPForbidden(text="The project is not opened")
return func(self, *args, **kwargs)
return... | python | def open_required(func):
"""
Use this decorator to raise an error if the project is not opened
"""
def wrapper(self, *args, **kwargs):
if self._status == "closed":
raise aiohttp.web.HTTPForbidden(text="The project is not opened")
return func(self, *args, **kwargs)
return... | [
"def",
"open_required",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_status",
"==",
"\"closed\"",
":",
"raise",
"aiohttp",
".",
"web",
".",
"HTTPForbidden",
"(",
"text... | Use this decorator to raise an error if the project is not opened | [
"Use",
"this",
"decorator",
"to",
"raise",
"an",
"error",
"if",
"the",
"project",
"is",
"not",
"opened"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L47-L56 |
226,749 | GNS3/gns3-server | gns3server/controller/project.py | Project.captures_directory | def captures_directory(self):
"""
Location of the captures files
"""
path = os.path.join(self._path, "project-files", "captures")
os.makedirs(path, exist_ok=True)
return path | python | def captures_directory(self):
"""
Location of the captures files
"""
path = os.path.join(self._path, "project-files", "captures")
os.makedirs(path, exist_ok=True)
return path | [
"def",
"captures_directory",
"(",
"self",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_path",
",",
"\"project-files\"",
",",
"\"captures\"",
")",
"os",
".",
"makedirs",
"(",
"path",
",",
"exist_ok",
"=",
"True",
")",
"retu... | Location of the captures files | [
"Location",
"of",
"the",
"captures",
"files"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L325-L331 |
226,750 | GNS3/gns3-server | gns3server/controller/project.py | Project.remove_allocated_node_name | def remove_allocated_node_name(self, name):
"""
Removes an allocated node name
:param name: allocated node name
"""
if name in self._allocated_node_names:
self._allocated_node_names.remove(name) | python | def remove_allocated_node_name(self, name):
"""
Removes an allocated node name
:param name: allocated node name
"""
if name in self._allocated_node_names:
self._allocated_node_names.remove(name) | [
"def",
"remove_allocated_node_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_allocated_node_names",
":",
"self",
".",
"_allocated_node_names",
".",
"remove",
"(",
"name",
")"
] | Removes an allocated node name
:param name: allocated node name | [
"Removes",
"an",
"allocated",
"node",
"name"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L349-L357 |
226,751 | GNS3/gns3-server | gns3server/controller/project.py | Project.update_allocated_node_name | def update_allocated_node_name(self, base_name):
"""
Updates a node name or generate a new if no node
name is available.
:param base_name: new node base name
"""
if base_name is None:
return None
base_name = re.sub(r"[ ]", "", base_name)
if b... | python | def update_allocated_node_name(self, base_name):
"""
Updates a node name or generate a new if no node
name is available.
:param base_name: new node base name
"""
if base_name is None:
return None
base_name = re.sub(r"[ ]", "", base_name)
if b... | [
"def",
"update_allocated_node_name",
"(",
"self",
",",
"base_name",
")",
":",
"if",
"base_name",
"is",
"None",
":",
"return",
"None",
"base_name",
"=",
"re",
".",
"sub",
"(",
"r\"[ ]\"",
",",
"\"\"",
",",
"base_name",
")",
"if",
"base_name",
"in",
"self",
... | Updates a node name or generate a new if no node
name is available.
:param base_name: new node base name | [
"Updates",
"a",
"node",
"name",
"or",
"generate",
"a",
"new",
"if",
"no",
"node",
"name",
"is",
"available",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L359-L395 |
226,752 | GNS3/gns3-server | gns3server/controller/project.py | Project.add_node_from_appliance | def add_node_from_appliance(self, appliance_id, x=0, y=0, compute_id=None):
"""
Create a node from an appliance
"""
try:
template = self.controller.appliances[appliance_id].data
except KeyError:
msg = "Appliance {} doesn't exist".format(appliance_id)
... | python | def add_node_from_appliance(self, appliance_id, x=0, y=0, compute_id=None):
"""
Create a node from an appliance
"""
try:
template = self.controller.appliances[appliance_id].data
except KeyError:
msg = "Appliance {} doesn't exist".format(appliance_id)
... | [
"def",
"add_node_from_appliance",
"(",
"self",
",",
"appliance_id",
",",
"x",
"=",
"0",
",",
"y",
"=",
"0",
",",
"compute_id",
"=",
"None",
")",
":",
"try",
":",
"template",
"=",
"self",
".",
"controller",
".",
"appliances",
"[",
"appliance_id",
"]",
"... | Create a node from an appliance | [
"Create",
"a",
"node",
"from",
"an",
"appliance"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L406-L425 |
226,753 | GNS3/gns3-server | gns3server/controller/project.py | Project.add_node | def add_node(self, compute, name, node_id, dump=True, node_type=None, **kwargs):
"""
Create a node or return an existing node
:param dump: Dump topology to disk
:param kwargs: See the documentation of node
"""
if node_id in self._nodes:
return self._nodes[no... | python | def add_node(self, compute, name, node_id, dump=True, node_type=None, **kwargs):
"""
Create a node or return an existing node
:param dump: Dump topology to disk
:param kwargs: See the documentation of node
"""
if node_id in self._nodes:
return self._nodes[no... | [
"def",
"add_node",
"(",
"self",
",",
"compute",
",",
"name",
",",
"node_id",
",",
"dump",
"=",
"True",
",",
"node_type",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"node_id",
"in",
"self",
".",
"_nodes",
":",
"return",
"self",
".",
"_nod... | Create a node or return an existing node
:param dump: Dump topology to disk
:param kwargs: See the documentation of node | [
"Create",
"a",
"node",
"or",
"return",
"an",
"existing",
"node"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L429-L461 |
226,754 | GNS3/gns3-server | gns3server/controller/project.py | Project.__delete_node_links | def __delete_node_links(self, node):
"""
Delete all link connected to this node.
The operation use a lock to avoid cleaning links from
multiple nodes at the same time.
"""
for link in list(self._links.values()):
if node in link.nodes:
yield fr... | python | def __delete_node_links(self, node):
"""
Delete all link connected to this node.
The operation use a lock to avoid cleaning links from
multiple nodes at the same time.
"""
for link in list(self._links.values()):
if node in link.nodes:
yield fr... | [
"def",
"__delete_node_links",
"(",
"self",
",",
"node",
")",
":",
"for",
"link",
"in",
"list",
"(",
"self",
".",
"_links",
".",
"values",
"(",
")",
")",
":",
"if",
"node",
"in",
"link",
".",
"nodes",
":",
"yield",
"from",
"self",
".",
"delete_link",
... | Delete all link connected to this node.
The operation use a lock to avoid cleaning links from
multiple nodes at the same time. | [
"Delete",
"all",
"link",
"connected",
"to",
"this",
"node",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L464-L473 |
226,755 | GNS3/gns3-server | gns3server/controller/project.py | Project.get_node | def get_node(self, node_id):
"""
Return the node or raise a 404 if the node is unknown
"""
try:
return self._nodes[node_id]
except KeyError:
raise aiohttp.web.HTTPNotFound(text="Node ID {} doesn't exist".format(node_id)) | python | def get_node(self, node_id):
"""
Return the node or raise a 404 if the node is unknown
"""
try:
return self._nodes[node_id]
except KeyError:
raise aiohttp.web.HTTPNotFound(text="Node ID {} doesn't exist".format(node_id)) | [
"def",
"get_node",
"(",
"self",
",",
"node_id",
")",
":",
"try",
":",
"return",
"self",
".",
"_nodes",
"[",
"node_id",
"]",
"except",
"KeyError",
":",
"raise",
"aiohttp",
".",
"web",
".",
"HTTPNotFound",
"(",
"text",
"=",
"\"Node ID {} doesn't exist\"",
".... | Return the node or raise a 404 if the node is unknown | [
"Return",
"the",
"node",
"or",
"raise",
"a",
"404",
"if",
"the",
"node",
"is",
"unknown"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L487-L494 |
226,756 | GNS3/gns3-server | gns3server/controller/project.py | Project.add_drawing | def add_drawing(self, drawing_id=None, dump=True, **kwargs):
"""
Create an drawing or return an existing drawing
:param dump: Dump the topology to disk
:param kwargs: See the documentation of drawing
"""
if drawing_id not in self._drawings:
drawing = Drawing(... | python | def add_drawing(self, drawing_id=None, dump=True, **kwargs):
"""
Create an drawing or return an existing drawing
:param dump: Dump the topology to disk
:param kwargs: See the documentation of drawing
"""
if drawing_id not in self._drawings:
drawing = Drawing(... | [
"def",
"add_drawing",
"(",
"self",
",",
"drawing_id",
"=",
"None",
",",
"dump",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"drawing_id",
"not",
"in",
"self",
".",
"_drawings",
":",
"drawing",
"=",
"Drawing",
"(",
"self",
",",
"drawing_id",
... | Create an drawing or return an existing drawing
:param dump: Dump the topology to disk
:param kwargs: See the documentation of drawing | [
"Create",
"an",
"drawing",
"or",
"return",
"an",
"existing",
"drawing"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L512-L526 |
226,757 | GNS3/gns3-server | gns3server/controller/project.py | Project.get_drawing | def get_drawing(self, drawing_id):
"""
Return the Drawing or raise a 404 if the drawing is unknown
"""
try:
return self._drawings[drawing_id]
except KeyError:
raise aiohttp.web.HTTPNotFound(text="Drawing ID {} doesn't exist".format(drawing_id)) | python | def get_drawing(self, drawing_id):
"""
Return the Drawing or raise a 404 if the drawing is unknown
"""
try:
return self._drawings[drawing_id]
except KeyError:
raise aiohttp.web.HTTPNotFound(text="Drawing ID {} doesn't exist".format(drawing_id)) | [
"def",
"get_drawing",
"(",
"self",
",",
"drawing_id",
")",
":",
"try",
":",
"return",
"self",
".",
"_drawings",
"[",
"drawing_id",
"]",
"except",
"KeyError",
":",
"raise",
"aiohttp",
".",
"web",
".",
"HTTPNotFound",
"(",
"text",
"=",
"\"Drawing ID {} doesn't... | Return the Drawing or raise a 404 if the drawing is unknown | [
"Return",
"the",
"Drawing",
"or",
"raise",
"a",
"404",
"if",
"the",
"drawing",
"is",
"unknown"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L529-L536 |
226,758 | GNS3/gns3-server | gns3server/controller/project.py | Project.add_link | def add_link(self, link_id=None, dump=True):
"""
Create a link. By default the link is empty
:param dump: Dump topology to disk
"""
if link_id and link_id in self._links:
return self._links[link_id]
link = UDPLink(self, link_id=link_id)
self._links[li... | python | def add_link(self, link_id=None, dump=True):
"""
Create a link. By default the link is empty
:param dump: Dump topology to disk
"""
if link_id and link_id in self._links:
return self._links[link_id]
link = UDPLink(self, link_id=link_id)
self._links[li... | [
"def",
"add_link",
"(",
"self",
",",
"link_id",
"=",
"None",
",",
"dump",
"=",
"True",
")",
":",
"if",
"link_id",
"and",
"link_id",
"in",
"self",
".",
"_links",
":",
"return",
"self",
".",
"_links",
"[",
"link_id",
"]",
"link",
"=",
"UDPLink",
"(",
... | Create a link. By default the link is empty
:param dump: Dump topology to disk | [
"Create",
"a",
"link",
".",
"By",
"default",
"the",
"link",
"is",
"empty"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L548-L560 |
226,759 | GNS3/gns3-server | gns3server/controller/project.py | Project.get_link | def get_link(self, link_id):
"""
Return the Link or raise a 404 if the link is unknown
"""
try:
return self._links[link_id]
except KeyError:
raise aiohttp.web.HTTPNotFound(text="Link ID {} doesn't exist".format(link_id)) | python | def get_link(self, link_id):
"""
Return the Link or raise a 404 if the link is unknown
"""
try:
return self._links[link_id]
except KeyError:
raise aiohttp.web.HTTPNotFound(text="Link ID {} doesn't exist".format(link_id)) | [
"def",
"get_link",
"(",
"self",
",",
"link_id",
")",
":",
"try",
":",
"return",
"self",
".",
"_links",
"[",
"link_id",
"]",
"except",
"KeyError",
":",
"raise",
"aiohttp",
".",
"web",
".",
"HTTPNotFound",
"(",
"text",
"=",
"\"Link ID {} doesn't exist\"",
".... | Return the Link or raise a 404 if the link is unknown | [
"Return",
"the",
"Link",
"or",
"raise",
"a",
"404",
"if",
"the",
"link",
"is",
"unknown"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L576-L583 |
226,760 | GNS3/gns3-server | gns3server/controller/project.py | Project.get_snapshot | def get_snapshot(self, snapshot_id):
"""
Return the snapshot or raise a 404 if the snapshot is unknown
"""
try:
return self._snapshots[snapshot_id]
except KeyError:
raise aiohttp.web.HTTPNotFound(text="Snapshot ID {} doesn't exist".format(snapshot_id)) | python | def get_snapshot(self, snapshot_id):
"""
Return the snapshot or raise a 404 if the snapshot is unknown
"""
try:
return self._snapshots[snapshot_id]
except KeyError:
raise aiohttp.web.HTTPNotFound(text="Snapshot ID {} doesn't exist".format(snapshot_id)) | [
"def",
"get_snapshot",
"(",
"self",
",",
"snapshot_id",
")",
":",
"try",
":",
"return",
"self",
".",
"_snapshots",
"[",
"snapshot_id",
"]",
"except",
"KeyError",
":",
"raise",
"aiohttp",
".",
"web",
".",
"HTTPNotFound",
"(",
"text",
"=",
"\"Snapshot ID {} do... | Return the snapshot or raise a 404 if the snapshot is unknown | [
"Return",
"the",
"snapshot",
"or",
"raise",
"a",
"404",
"if",
"the",
"snapshot",
"is",
"unknown"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L600-L607 |
226,761 | GNS3/gns3-server | gns3server/controller/project.py | Project.snapshot | def snapshot(self, name):
"""
Snapshot the project
:param name: Name of the snapshot
"""
if name in [snap.name for snap in self.snapshots.values()]:
raise aiohttp.web_exceptions.HTTPConflict(text="The snapshot {} already exist".format(name))
snapshot = Snap... | python | def snapshot(self, name):
"""
Snapshot the project
:param name: Name of the snapshot
"""
if name in [snap.name for snap in self.snapshots.values()]:
raise aiohttp.web_exceptions.HTTPConflict(text="The snapshot {} already exist".format(name))
snapshot = Snap... | [
"def",
"snapshot",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"[",
"snap",
".",
"name",
"for",
"snap",
"in",
"self",
".",
"snapshots",
".",
"values",
"(",
")",
"]",
":",
"raise",
"aiohttp",
".",
"web_exceptions",
".",
"HTTPConflict",
"("... | Snapshot the project
:param name: Name of the snapshot | [
"Snapshot",
"the",
"project"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L611-L640 |
226,762 | GNS3/gns3-server | gns3server/controller/project.py | Project._cleanPictures | def _cleanPictures(self):
"""
Delete unused images
"""
# Project have been deleted
if not os.path.exists(self.path):
return
try:
pictures = set(os.listdir(self.pictures_directory))
for drawing in self._drawings.values():
... | python | def _cleanPictures(self):
"""
Delete unused images
"""
# Project have been deleted
if not os.path.exists(self.path):
return
try:
pictures = set(os.listdir(self.pictures_directory))
for drawing in self._drawings.values():
... | [
"def",
"_cleanPictures",
"(",
"self",
")",
":",
"# Project have been deleted",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"return",
"try",
":",
"pictures",
"=",
"set",
"(",
"os",
".",
"listdir",
"(",
"self",
".",... | Delete unused images | [
"Delete",
"unused",
"images"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L663-L682 |
226,763 | GNS3/gns3-server | gns3server/controller/project.py | Project.delete_on_computes | def delete_on_computes(self):
"""
Delete the project on computes but not on controller
"""
for compute in list(self._project_created_on_compute):
if compute.id != "local":
yield from compute.delete("/projects/{}".format(self._id))
self._project... | python | def delete_on_computes(self):
"""
Delete the project on computes but not on controller
"""
for compute in list(self._project_created_on_compute):
if compute.id != "local":
yield from compute.delete("/projects/{}".format(self._id))
self._project... | [
"def",
"delete_on_computes",
"(",
"self",
")",
":",
"for",
"compute",
"in",
"list",
"(",
"self",
".",
"_project_created_on_compute",
")",
":",
"if",
"compute",
".",
"id",
"!=",
"\"local\"",
":",
"yield",
"from",
"compute",
".",
"delete",
"(",
"\"/projects/{}... | Delete the project on computes but not on controller | [
"Delete",
"the",
"project",
"on",
"computes",
"but",
"not",
"on",
"controller"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L701-L708 |
226,764 | GNS3/gns3-server | gns3server/controller/project.py | Project.duplicate | def duplicate(self, name=None, location=None):
"""
Duplicate a project
It's the save as feature of the 1.X. It's implemented on top of the
export / import features. It will generate a gns3p and reimport it.
It's a little slower but we have only one implementation to maintain.
... | python | def duplicate(self, name=None, location=None):
"""
Duplicate a project
It's the save as feature of the 1.X. It's implemented on top of the
export / import features. It will generate a gns3p and reimport it.
It's a little slower but we have only one implementation to maintain.
... | [
"def",
"duplicate",
"(",
"self",
",",
"name",
"=",
"None",
",",
"location",
"=",
"None",
")",
":",
"# If the project was not open we open it temporary",
"previous_status",
"=",
"self",
".",
"_status",
"if",
"self",
".",
"_status",
"==",
"\"closed\"",
":",
"yield... | Duplicate a project
It's the save as feature of the 1.X. It's implemented on top of the
export / import features. It will generate a gns3p and reimport it.
It's a little slower but we have only one implementation to maintain.
:param name: Name of the new project. A new one will be gene... | [
"Duplicate",
"a",
"project"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L844-L875 |
226,765 | GNS3/gns3-server | gns3server/controller/project.py | Project.is_running | def is_running(self):
"""
If a node is started or paused return True
"""
for node in self._nodes.values():
# Some node type are always running we ignore them
if node.status != "stopped" and not node.is_always_running():
return True
return F... | python | def is_running(self):
"""
If a node is started or paused return True
"""
for node in self._nodes.values():
# Some node type are always running we ignore them
if node.status != "stopped" and not node.is_always_running():
return True
return F... | [
"def",
"is_running",
"(",
"self",
")",
":",
"for",
"node",
"in",
"self",
".",
"_nodes",
".",
"values",
"(",
")",
":",
"# Some node type are always running we ignore them",
"if",
"node",
".",
"status",
"!=",
"\"stopped\"",
"and",
"not",
"node",
".",
"is_always_... | If a node is started or paused return True | [
"If",
"a",
"node",
"is",
"started",
"or",
"paused",
"return",
"True"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L877-L885 |
226,766 | GNS3/gns3-server | gns3server/controller/project.py | Project.dump | def dump(self):
"""
Dump topology to disk
"""
try:
topo = project_to_topology(self)
path = self._topology_file()
log.debug("Write %s", path)
with open(path + ".tmp", "w+", encoding="utf-8") as f:
json.dump(topo, f, indent=4,... | python | def dump(self):
"""
Dump topology to disk
"""
try:
topo = project_to_topology(self)
path = self._topology_file()
log.debug("Write %s", path)
with open(path + ".tmp", "w+", encoding="utf-8") as f:
json.dump(topo, f, indent=4,... | [
"def",
"dump",
"(",
"self",
")",
":",
"try",
":",
"topo",
"=",
"project_to_topology",
"(",
"self",
")",
"path",
"=",
"self",
".",
"_topology_file",
"(",
")",
"log",
".",
"debug",
"(",
"\"Write %s\"",
",",
"path",
")",
"with",
"open",
"(",
"path",
"+"... | Dump topology to disk | [
"Dump",
"topology",
"to",
"disk"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L887-L899 |
226,767 | GNS3/gns3-server | gns3server/controller/project.py | Project.start_all | def start_all(self):
"""
Start all nodes
"""
pool = Pool(concurrency=3)
for node in self.nodes.values():
pool.append(node.start)
yield from pool.join() | python | def start_all(self):
"""
Start all nodes
"""
pool = Pool(concurrency=3)
for node in self.nodes.values():
pool.append(node.start)
yield from pool.join() | [
"def",
"start_all",
"(",
"self",
")",
":",
"pool",
"=",
"Pool",
"(",
"concurrency",
"=",
"3",
")",
"for",
"node",
"in",
"self",
".",
"nodes",
".",
"values",
"(",
")",
":",
"pool",
".",
"append",
"(",
"node",
".",
"start",
")",
"yield",
"from",
"p... | Start all nodes | [
"Start",
"all",
"nodes"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L902-L909 |
226,768 | GNS3/gns3-server | gns3server/controller/project.py | Project.stop_all | def stop_all(self):
"""
Stop all nodes
"""
pool = Pool(concurrency=3)
for node in self.nodes.values():
pool.append(node.stop)
yield from pool.join() | python | def stop_all(self):
"""
Stop all nodes
"""
pool = Pool(concurrency=3)
for node in self.nodes.values():
pool.append(node.stop)
yield from pool.join() | [
"def",
"stop_all",
"(",
"self",
")",
":",
"pool",
"=",
"Pool",
"(",
"concurrency",
"=",
"3",
")",
"for",
"node",
"in",
"self",
".",
"nodes",
".",
"values",
"(",
")",
":",
"pool",
".",
"append",
"(",
"node",
".",
"stop",
")",
"yield",
"from",
"poo... | Stop all nodes | [
"Stop",
"all",
"nodes"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L912-L919 |
226,769 | GNS3/gns3-server | gns3server/controller/project.py | Project.suspend_all | def suspend_all(self):
"""
Suspend all nodes
"""
pool = Pool(concurrency=3)
for node in self.nodes.values():
pool.append(node.suspend)
yield from pool.join() | python | def suspend_all(self):
"""
Suspend all nodes
"""
pool = Pool(concurrency=3)
for node in self.nodes.values():
pool.append(node.suspend)
yield from pool.join() | [
"def",
"suspend_all",
"(",
"self",
")",
":",
"pool",
"=",
"Pool",
"(",
"concurrency",
"=",
"3",
")",
"for",
"node",
"in",
"self",
".",
"nodes",
".",
"values",
"(",
")",
":",
"pool",
".",
"append",
"(",
"node",
".",
"suspend",
")",
"yield",
"from",
... | Suspend all nodes | [
"Suspend",
"all",
"nodes"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L922-L929 |
226,770 | GNS3/gns3-server | gns3server/utils/asyncio/input_stream.py | InputStream._get_match | def _get_match(self, prefix):
"""
Return the key that maps to this prefix.
"""
# (hard coded) If we match a CPR response, return Keys.CPRResponse.
# (This one doesn't fit in the ANSI_SEQUENCES, because it contains
# integer variables.)
if _cpr_response_re.match(pr... | python | def _get_match(self, prefix):
"""
Return the key that maps to this prefix.
"""
# (hard coded) If we match a CPR response, return Keys.CPRResponse.
# (This one doesn't fit in the ANSI_SEQUENCES, because it contains
# integer variables.)
if _cpr_response_re.match(pr... | [
"def",
"_get_match",
"(",
"self",
",",
"prefix",
")",
":",
"# (hard coded) If we match a CPR response, return Keys.CPRResponse.",
"# (This one doesn't fit in the ANSI_SEQUENCES, because it contains",
"# integer variables.)",
"if",
"_cpr_response_re",
".",
"match",
"(",
"prefix",
")... | Return the key that maps to this prefix. | [
"Return",
"the",
"key",
"that",
"maps",
"to",
"this",
"prefix",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/input_stream.py#L259-L276 |
226,771 | GNS3/gns3-server | gns3server/utils/asyncio/input_stream.py | InputStream._call_handler | def _call_handler(self, key, insert_text):
"""
Callback to handler.
"""
if isinstance(key, tuple):
for k in key:
self._call_handler(k, insert_text)
else:
if key == Keys.BracketedPaste:
self._in_bracketed_paste = True
... | python | def _call_handler(self, key, insert_text):
"""
Callback to handler.
"""
if isinstance(key, tuple):
for k in key:
self._call_handler(k, insert_text)
else:
if key == Keys.BracketedPaste:
self._in_bracketed_paste = True
... | [
"def",
"_call_handler",
"(",
"self",
",",
"key",
",",
"insert_text",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"tuple",
")",
":",
"for",
"k",
"in",
"key",
":",
"self",
".",
"_call_handler",
"(",
"k",
",",
"insert_text",
")",
"else",
":",
"if",
... | Callback to handler. | [
"Callback",
"to",
"handler",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/input_stream.py#L328-L340 |
226,772 | GNS3/gns3-server | gns3server/utils/asyncio/input_stream.py | InputStream.feed | def feed(self, data):
"""
Feed the input stream.
:param data: Input string (unicode).
"""
assert isinstance(data, six.text_type)
if _DEBUG_RENDERER_INPUT:
self.LOG.write(repr(data).encode('utf-8') + b'\n')
self.LOG.flush()
# Handle brack... | python | def feed(self, data):
"""
Feed the input stream.
:param data: Input string (unicode).
"""
assert isinstance(data, six.text_type)
if _DEBUG_RENDERER_INPUT:
self.LOG.write(repr(data).encode('utf-8') + b'\n')
self.LOG.flush()
# Handle brack... | [
"def",
"feed",
"(",
"self",
",",
"data",
")",
":",
"assert",
"isinstance",
"(",
"data",
",",
"six",
".",
"text_type",
")",
"if",
"_DEBUG_RENDERER_INPUT",
":",
"self",
".",
"LOG",
".",
"write",
"(",
"repr",
"(",
"data",
")",
".",
"encode",
"(",
"'utf-... | Feed the input stream.
:param data: Input string (unicode). | [
"Feed",
"the",
"input",
"stream",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/input_stream.py#L342-L398 |
226,773 | GNS3/gns3-server | gns3server/compute/docker/__init__.py | Docker.query | def query(self, method, path, data={}, params={}):
"""
Make a query to the docker daemon and decode the request
:param method: HTTP method
:param path: Endpoint in API
:param data: Dictionary with the body. Will be transformed to a JSON
:param params: Parameters added as... | python | def query(self, method, path, data={}, params={}):
"""
Make a query to the docker daemon and decode the request
:param method: HTTP method
:param path: Endpoint in API
:param data: Dictionary with the body. Will be transformed to a JSON
:param params: Parameters added as... | [
"def",
"query",
"(",
"self",
",",
"method",
",",
"path",
",",
"data",
"=",
"{",
"}",
",",
"params",
"=",
"{",
"}",
")",
":",
"response",
"=",
"yield",
"from",
"self",
".",
"http_query",
"(",
"method",
",",
"path",
",",
"data",
"=",
"data",
",",
... | Make a query to the docker daemon and decode the request
:param method: HTTP method
:param path: Endpoint in API
:param data: Dictionary with the body. Will be transformed to a JSON
:param params: Parameters added as a query arg | [
"Make",
"a",
"query",
"to",
"the",
"docker",
"daemon",
"and",
"decode",
"the",
"request"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/__init__.py#L96-L114 |
226,774 | GNS3/gns3-server | gns3server/compute/docker/__init__.py | Docker.http_query | def http_query(self, method, path, data={}, params={}, timeout=300):
"""
Make a query to the docker daemon
:param method: HTTP method
:param path: Endpoint in API
:param data: Dictionnary with the body. Will be transformed to a JSON
:param params: Parameters added as a q... | python | def http_query(self, method, path, data={}, params={}, timeout=300):
"""
Make a query to the docker daemon
:param method: HTTP method
:param path: Endpoint in API
:param data: Dictionnary with the body. Will be transformed to a JSON
:param params: Parameters added as a q... | [
"def",
"http_query",
"(",
"self",
",",
"method",
",",
"path",
",",
"data",
"=",
"{",
"}",
",",
"params",
"=",
"{",
"}",
",",
"timeout",
"=",
"300",
")",
":",
"data",
"=",
"json",
".",
"dumps",
"(",
"data",
")",
"if",
"timeout",
"is",
"None",
":... | Make a query to the docker daemon
:param method: HTTP method
:param path: Endpoint in API
:param data: Dictionnary with the body. Will be transformed to a JSON
:param params: Parameters added as a query arg
:param timeout: Timeout
:returns: HTTP response | [
"Make",
"a",
"query",
"to",
"the",
"docker",
"daemon"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/__init__.py#L117-L167 |
226,775 | GNS3/gns3-server | gns3server/compute/docker/__init__.py | Docker.websocket_query | def websocket_query(self, path, params={}):
"""
Open a websocket connection
:param path: Endpoint in API
:param params: Parameters added as a query arg
:returns: Websocket
"""
url = "http://docker/v" + self._api_version + "/" + path
connection = yield fr... | python | def websocket_query(self, path, params={}):
"""
Open a websocket connection
:param path: Endpoint in API
:param params: Parameters added as a query arg
:returns: Websocket
"""
url = "http://docker/v" + self._api_version + "/" + path
connection = yield fr... | [
"def",
"websocket_query",
"(",
"self",
",",
"path",
",",
"params",
"=",
"{",
"}",
")",
":",
"url",
"=",
"\"http://docker/v\"",
"+",
"self",
".",
"_api_version",
"+",
"\"/\"",
"+",
"path",
"connection",
"=",
"yield",
"from",
"self",
".",
"_session",
".",
... | Open a websocket connection
:param path: Endpoint in API
:param params: Parameters added as a query arg
:returns: Websocket | [
"Open",
"a",
"websocket",
"connection"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/__init__.py#L170-L183 |
226,776 | GNS3/gns3-server | gns3server/compute/docker/__init__.py | Docker.list_images | def list_images(self):
"""Gets Docker image list.
:returns: list of dicts
:rtype: list
"""
images = []
for image in (yield from self.query("GET", "images/json", params={"all": 0})):
if image['RepoTags']:
for tag in image['RepoTags']:
... | python | def list_images(self):
"""Gets Docker image list.
:returns: list of dicts
:rtype: list
"""
images = []
for image in (yield from self.query("GET", "images/json", params={"all": 0})):
if image['RepoTags']:
for tag in image['RepoTags']:
... | [
"def",
"list_images",
"(",
"self",
")",
":",
"images",
"=",
"[",
"]",
"for",
"image",
"in",
"(",
"yield",
"from",
"self",
".",
"query",
"(",
"\"GET\"",
",",
"\"images/json\"",
",",
"params",
"=",
"{",
"\"all\"",
":",
"0",
"}",
")",
")",
":",
"if",
... | Gets Docker image list.
:returns: list of dicts
:rtype: list | [
"Gets",
"Docker",
"image",
"list",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/__init__.py#L228-L240 |
226,777 | GNS3/gns3-server | gns3server/compute/qemu/__init__.py | Qemu.get_kvm_archs | def get_kvm_archs():
"""
Gets a list of architectures for which KVM is available on this server.
:returns: List of architectures for which KVM is available on this server.
"""
kvm = []
if not os.path.exists("/dev/kvm"):
return kvm
arch = platform.ma... | python | def get_kvm_archs():
"""
Gets a list of architectures for which KVM is available on this server.
:returns: List of architectures for which KVM is available on this server.
"""
kvm = []
if not os.path.exists("/dev/kvm"):
return kvm
arch = platform.ma... | [
"def",
"get_kvm_archs",
"(",
")",
":",
"kvm",
"=",
"[",
"]",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"\"/dev/kvm\"",
")",
":",
"return",
"kvm",
"arch",
"=",
"platform",
".",
"machine",
"(",
")",
"if",
"arch",
"==",
"\"x86_64\"",
":",
"k... | Gets a list of architectures for which KVM is available on this server.
:returns: List of architectures for which KVM is available on this server. | [
"Gets",
"a",
"list",
"of",
"architectures",
"for",
"which",
"KVM",
"is",
"available",
"on",
"this",
"server",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L45-L64 |
226,778 | GNS3/gns3-server | gns3server/compute/qemu/__init__.py | Qemu.paths_list | def paths_list():
"""
Gets a folder list of possibly available QEMU binaries on the host.
:returns: List of folders where Qemu binaries MAY reside.
"""
paths = set()
try:
paths.add(os.getcwd())
except FileNotFoundError:
log.warning("The c... | python | def paths_list():
"""
Gets a folder list of possibly available QEMU binaries on the host.
:returns: List of folders where Qemu binaries MAY reside.
"""
paths = set()
try:
paths.add(os.getcwd())
except FileNotFoundError:
log.warning("The c... | [
"def",
"paths_list",
"(",
")",
":",
"paths",
"=",
"set",
"(",
")",
"try",
":",
"paths",
".",
"add",
"(",
"os",
".",
"getcwd",
"(",
")",
")",
"except",
"FileNotFoundError",
":",
"log",
".",
"warning",
"(",
"\"The current working directory doesn't exist\"",
... | Gets a folder list of possibly available QEMU binaries on the host.
:returns: List of folders where Qemu binaries MAY reside. | [
"Gets",
"a",
"folder",
"list",
"of",
"possibly",
"available",
"QEMU",
"binaries",
"on",
"the",
"host",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L67-L107 |
226,779 | GNS3/gns3-server | gns3server/compute/qemu/__init__.py | Qemu.binary_list | def binary_list(archs=None):
"""
Gets QEMU binaries list available on the host.
:returns: Array of dictionary {"path": Qemu binary path, "version": version of Qemu}
"""
qemus = []
for path in Qemu.paths_list():
try:
for f in os.listdir(path):... | python | def binary_list(archs=None):
"""
Gets QEMU binaries list available on the host.
:returns: Array of dictionary {"path": Qemu binary path, "version": version of Qemu}
"""
qemus = []
for path in Qemu.paths_list():
try:
for f in os.listdir(path):... | [
"def",
"binary_list",
"(",
"archs",
"=",
"None",
")",
":",
"qemus",
"=",
"[",
"]",
"for",
"path",
"in",
"Qemu",
".",
"paths_list",
"(",
")",
":",
"try",
":",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
":",
"if",
"f",
".",
"endswi... | Gets QEMU binaries list available on the host.
:returns: Array of dictionary {"path": Qemu binary path, "version": version of Qemu} | [
"Gets",
"QEMU",
"binaries",
"list",
"available",
"on",
"the",
"host",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L110-L140 |
226,780 | GNS3/gns3-server | gns3server/compute/qemu/__init__.py | Qemu.img_binary_list | def img_binary_list():
"""
Gets QEMU-img binaries list available on the host.
:returns: Array of dictionary {"path": Qemu-img binary path, "version": version of Qemu-img}
"""
qemu_imgs = []
for path in Qemu.paths_list():
try:
for f in os.listd... | python | def img_binary_list():
"""
Gets QEMU-img binaries list available on the host.
:returns: Array of dictionary {"path": Qemu-img binary path, "version": version of Qemu-img}
"""
qemu_imgs = []
for path in Qemu.paths_list():
try:
for f in os.listd... | [
"def",
"img_binary_list",
"(",
")",
":",
"qemu_imgs",
"=",
"[",
"]",
"for",
"path",
"in",
"Qemu",
".",
"paths_list",
"(",
")",
":",
"try",
":",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
":",
"if",
"(",
"f",
"==",
"\"qemu-img\"",
"... | Gets QEMU-img binaries list available on the host.
:returns: Array of dictionary {"path": Qemu-img binary path, "version": version of Qemu-img} | [
"Gets",
"QEMU",
"-",
"img",
"binaries",
"list",
"available",
"on",
"the",
"host",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L143-L162 |
226,781 | GNS3/gns3-server | gns3server/compute/qemu/__init__.py | Qemu.get_qemu_version | def get_qemu_version(qemu_path):
"""
Gets the Qemu version.
:param qemu_path: path to Qemu executable.
"""
if sys.platform.startswith("win"):
# Qemu on Windows doesn't return anything with parameter -version
# look for a version number in version.txt fil... | python | def get_qemu_version(qemu_path):
"""
Gets the Qemu version.
:param qemu_path: path to Qemu executable.
"""
if sys.platform.startswith("win"):
# Qemu on Windows doesn't return anything with parameter -version
# look for a version number in version.txt fil... | [
"def",
"get_qemu_version",
"(",
"qemu_path",
")",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"win\"",
")",
":",
"# Qemu on Windows doesn't return anything with parameter -version",
"# look for a version number in version.txt file in the same directory instead",
... | Gets the Qemu version.
:param qemu_path: path to Qemu executable. | [
"Gets",
"the",
"Qemu",
"version",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L166-L197 |
226,782 | GNS3/gns3-server | gns3server/compute/qemu/__init__.py | Qemu._get_qemu_img_version | def _get_qemu_img_version(qemu_img_path):
"""
Gets the Qemu-img version.
:param qemu_img_path: path to Qemu-img executable.
"""
try:
output = yield from subprocess_check_output(qemu_img_path, "--version")
match = re.search("version\s+([0-9a-z\-\.]+)", ou... | python | def _get_qemu_img_version(qemu_img_path):
"""
Gets the Qemu-img version.
:param qemu_img_path: path to Qemu-img executable.
"""
try:
output = yield from subprocess_check_output(qemu_img_path, "--version")
match = re.search("version\s+([0-9a-z\-\.]+)", ou... | [
"def",
"_get_qemu_img_version",
"(",
"qemu_img_path",
")",
":",
"try",
":",
"output",
"=",
"yield",
"from",
"subprocess_check_output",
"(",
"qemu_img_path",
",",
"\"--version\"",
")",
"match",
"=",
"re",
".",
"search",
"(",
"\"version\\s+([0-9a-z\\-\\.]+)\"",
",",
... | Gets the Qemu-img version.
:param qemu_img_path: path to Qemu-img executable. | [
"Gets",
"the",
"Qemu",
"-",
"img",
"version",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L201-L217 |
226,783 | GNS3/gns3-server | gns3server/compute/qemu/__init__.py | Qemu.create_disk | def create_disk(self, qemu_img, path, options):
"""
Create a qemu disk with qemu-img
:param qemu_img: qemu-img binary path
:param path: Image path
:param options: Disk image creation options
"""
try:
img_format = options.pop("format")
img... | python | def create_disk(self, qemu_img, path, options):
"""
Create a qemu disk with qemu-img
:param qemu_img: qemu-img binary path
:param path: Image path
:param options: Disk image creation options
"""
try:
img_format = options.pop("format")
img... | [
"def",
"create_disk",
"(",
"self",
",",
"qemu_img",
",",
"path",
",",
"options",
")",
":",
"try",
":",
"img_format",
"=",
"options",
".",
"pop",
"(",
"\"format\"",
")",
"img_size",
"=",
"options",
".",
"pop",
"(",
"\"size\"",
")",
"if",
"not",
"os",
... | Create a qemu disk with qemu-img
:param qemu_img: qemu-img binary path
:param path: Image path
:param options: Disk image creation options | [
"Create",
"a",
"qemu",
"disk",
"with",
"qemu",
"-",
"img"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L233-L267 |
226,784 | jmcarpenter2/swifter | swifter/swifter.py | _SwifterObject.set_npartitions | def set_npartitions(self, npartitions=None):
"""
Set the number of partitions to use for dask
"""
if npartitions is None:
self._npartitions = cpu_count() * 2
else:
self._npartitions = npartitions
return self | python | def set_npartitions(self, npartitions=None):
"""
Set the number of partitions to use for dask
"""
if npartitions is None:
self._npartitions = cpu_count() * 2
else:
self._npartitions = npartitions
return self | [
"def",
"set_npartitions",
"(",
"self",
",",
"npartitions",
"=",
"None",
")",
":",
"if",
"npartitions",
"is",
"None",
":",
"self",
".",
"_npartitions",
"=",
"cpu_count",
"(",
")",
"*",
"2",
"else",
":",
"self",
".",
"_npartitions",
"=",
"npartitions",
"re... | Set the number of partitions to use for dask | [
"Set",
"the",
"number",
"of",
"partitions",
"to",
"use",
"for",
"dask"
] | ed5fc3235b43f981fa58ac9bc982c8209d4e3df3 | https://github.com/jmcarpenter2/swifter/blob/ed5fc3235b43f981fa58ac9bc982c8209d4e3df3/swifter/swifter.py#L39-L47 |
226,785 | jmcarpenter2/swifter | swifter/swifter.py | _SwifterObject.rolling | def rolling(self, window, min_periods=None, center=False, win_type=None, on=None, axis=0, closed=None):
"""
Create a swifter rolling object
"""
kwds = {
"window": window,
"min_periods": min_periods,
"center": center,
"win_type": win_type,
... | python | def rolling(self, window, min_periods=None, center=False, win_type=None, on=None, axis=0, closed=None):
"""
Create a swifter rolling object
"""
kwds = {
"window": window,
"min_periods": min_periods,
"center": center,
"win_type": win_type,
... | [
"def",
"rolling",
"(",
"self",
",",
"window",
",",
"min_periods",
"=",
"None",
",",
"center",
"=",
"False",
",",
"win_type",
"=",
"None",
",",
"on",
"=",
"None",
",",
"axis",
"=",
"0",
",",
"closed",
"=",
"None",
")",
":",
"kwds",
"=",
"{",
"\"wi... | Create a swifter rolling object | [
"Create",
"a",
"swifter",
"rolling",
"object"
] | ed5fc3235b43f981fa58ac9bc982c8209d4e3df3 | https://github.com/jmcarpenter2/swifter/blob/ed5fc3235b43f981fa58ac9bc982c8209d4e3df3/swifter/swifter.py#L78-L91 |
226,786 | jmcarpenter2/swifter | swifter/swifter.py | Transformation.apply | def apply(self, func, *args, **kwds):
"""
Apply the function to the transformed swifter object
"""
# estimate time to pandas apply
wrapped = self._wrapped_apply(func, *args, **kwds)
n_repeats = 3
timed = timeit.timeit(wrapped, number=n_repeats)
samp_proc_e... | python | def apply(self, func, *args, **kwds):
"""
Apply the function to the transformed swifter object
"""
# estimate time to pandas apply
wrapped = self._wrapped_apply(func, *args, **kwds)
n_repeats = 3
timed = timeit.timeit(wrapped, number=n_repeats)
samp_proc_e... | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"# estimate time to pandas apply",
"wrapped",
"=",
"self",
".",
"_wrapped_apply",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
"n_repeats",
"=",
... | Apply the function to the transformed swifter object | [
"Apply",
"the",
"function",
"to",
"the",
"transformed",
"swifter",
"object"
] | ed5fc3235b43f981fa58ac9bc982c8209d4e3df3 | https://github.com/jmcarpenter2/swifter/blob/ed5fc3235b43f981fa58ac9bc982c8209d4e3df3/swifter/swifter.py#L338-L357 |
226,787 | summernote/django-summernote | django_summernote/utils.py | using_config | def using_config(_func=None):
"""
This allows a function to use Summernote configuration
as a global variable, temporarily.
"""
def decorator(func):
@wraps(func)
def inner_dec(*args, **kwargs):
g = func.__globals__
var_name = 'config'
sentinel = ob... | python | def using_config(_func=None):
"""
This allows a function to use Summernote configuration
as a global variable, temporarily.
"""
def decorator(func):
@wraps(func)
def inner_dec(*args, **kwargs):
g = func.__globals__
var_name = 'config'
sentinel = ob... | [
"def",
"using_config",
"(",
"_func",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"inner_dec",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"g",
"=",
"func",
".",
"__globals__",
... | This allows a function to use Summernote configuration
as a global variable, temporarily. | [
"This",
"allows",
"a",
"function",
"to",
"use",
"Summernote",
"configuration",
"as",
"a",
"global",
"variable",
"temporarily",
"."
] | bc7fbbf065d88a909fe3e1533c84110e0dd132bc | https://github.com/summernote/django-summernote/blob/bc7fbbf065d88a909fe3e1533c84110e0dd132bc/django_summernote/utils.py#L117-L146 |
226,788 | summernote/django-summernote | django_summernote/utils.py | uploaded_filepath | def uploaded_filepath(instance, filename):
"""
Returns default filepath for uploaded files.
"""
ext = filename.split('.')[-1]
filename = "%s.%s" % (uuid.uuid4(), ext)
today = datetime.now().strftime('%Y-%m-%d')
return os.path.join('django-summernote', today, filename) | python | def uploaded_filepath(instance, filename):
"""
Returns default filepath for uploaded files.
"""
ext = filename.split('.')[-1]
filename = "%s.%s" % (uuid.uuid4(), ext)
today = datetime.now().strftime('%Y-%m-%d')
return os.path.join('django-summernote', today, filename) | [
"def",
"uploaded_filepath",
"(",
"instance",
",",
"filename",
")",
":",
"ext",
"=",
"filename",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
"filename",
"=",
"\"%s.%s\"",
"%",
"(",
"uuid",
".",
"uuid4",
"(",
")",
",",
"ext",
")",
"today",
"="... | Returns default filepath for uploaded files. | [
"Returns",
"default",
"filepath",
"for",
"uploaded",
"files",
"."
] | bc7fbbf065d88a909fe3e1533c84110e0dd132bc | https://github.com/summernote/django-summernote/blob/bc7fbbf065d88a909fe3e1533c84110e0dd132bc/django_summernote/utils.py#L149-L156 |
226,789 | summernote/django-summernote | django_summernote/utils.py | get_attachment_model | def get_attachment_model():
"""
Returns the Attachment model that is active in this project.
"""
try:
from .models import AbstractAttachment
klass = apps.get_model(config["attachment_model"])
if not issubclass(klass, AbstractAttachment):
raise ImproperlyConfigured(
... | python | def get_attachment_model():
"""
Returns the Attachment model that is active in this project.
"""
try:
from .models import AbstractAttachment
klass = apps.get_model(config["attachment_model"])
if not issubclass(klass, AbstractAttachment):
raise ImproperlyConfigured(
... | [
"def",
"get_attachment_model",
"(",
")",
":",
"try",
":",
"from",
".",
"models",
"import",
"AbstractAttachment",
"klass",
"=",
"apps",
".",
"get_model",
"(",
"config",
"[",
"\"attachment_model\"",
"]",
")",
"if",
"not",
"issubclass",
"(",
"klass",
",",
"Abst... | Returns the Attachment model that is active in this project. | [
"Returns",
"the",
"Attachment",
"model",
"that",
"is",
"active",
"in",
"this",
"project",
"."
] | bc7fbbf065d88a909fe3e1533c84110e0dd132bc | https://github.com/summernote/django-summernote/blob/bc7fbbf065d88a909fe3e1533c84110e0dd132bc/django_summernote/utils.py#L180-L199 |
226,790 | PyMySQL/mysqlclient-python | MySQLdb/connections.py | numeric_part | def numeric_part(s):
"""Returns the leading numeric part of a string.
>>> numeric_part("20-alpha")
20
>>> numeric_part("foo")
>>> numeric_part("16b")
16
"""
m = re_numeric_part.match(s)
if m:
return int(m.group(1))
return None | python | def numeric_part(s):
"""Returns the leading numeric part of a string.
>>> numeric_part("20-alpha")
20
>>> numeric_part("foo")
>>> numeric_part("16b")
16
"""
m = re_numeric_part.match(s)
if m:
return int(m.group(1))
return None | [
"def",
"numeric_part",
"(",
"s",
")",
":",
"m",
"=",
"re_numeric_part",
".",
"match",
"(",
"s",
")",
"if",
"m",
":",
"return",
"int",
"(",
"m",
".",
"group",
"(",
"1",
")",
")",
"return",
"None"
] | Returns the leading numeric part of a string.
>>> numeric_part("20-alpha")
20
>>> numeric_part("foo")
>>> numeric_part("16b")
16 | [
"Returns",
"the",
"leading",
"numeric",
"part",
"of",
"a",
"string",
"."
] | b66971ee36be96b772ae7fdec79ccc1611376f3c | https://github.com/PyMySQL/mysqlclient-python/blob/b66971ee36be96b772ae7fdec79ccc1611376f3c/MySQLdb/connections.py#L21-L34 |
226,791 | PyMySQL/mysqlclient-python | MySQLdb/connections.py | Connection.literal | def literal(self, o):
"""If o is a single object, returns an SQL literal as a string.
If o is a non-string sequence, the items of the sequence are
converted and returned as a sequence.
Non-standard. For internal use; do not use this in your
applications.
"""
if i... | python | def literal(self, o):
"""If o is a single object, returns an SQL literal as a string.
If o is a non-string sequence, the items of the sequence are
converted and returned as a sequence.
Non-standard. For internal use; do not use this in your
applications.
"""
if i... | [
"def",
"literal",
"(",
"self",
",",
"o",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
"unicode",
")",
":",
"s",
"=",
"self",
".",
"string_literal",
"(",
"o",
".",
"encode",
"(",
"self",
".",
"encoding",
")",
")",
"elif",
"isinstance",
"(",
"o",
"... | If o is a single object, returns an SQL literal as a string.
If o is a non-string sequence, the items of the sequence are
converted and returned as a sequence.
Non-standard. For internal use; do not use this in your
applications. | [
"If",
"o",
"is",
"a",
"single",
"object",
"returns",
"an",
"SQL",
"literal",
"as",
"a",
"string",
".",
"If",
"o",
"is",
"a",
"non",
"-",
"string",
"sequence",
"the",
"items",
"of",
"the",
"sequence",
"are",
"converted",
"and",
"returned",
"as",
"a",
... | b66971ee36be96b772ae7fdec79ccc1611376f3c | https://github.com/PyMySQL/mysqlclient-python/blob/b66971ee36be96b772ae7fdec79ccc1611376f3c/MySQLdb/connections.py#L238-L262 |
226,792 | PyMySQL/mysqlclient-python | MySQLdb/connections.py | Connection.set_character_set | def set_character_set(self, charset):
"""Set the connection character set to charset. The character
set can only be changed in MySQL-4.1 and newer. If you try
to change the character set from the current value in an
older version, NotSupportedError will be raised."""
if charset i... | python | def set_character_set(self, charset):
"""Set the connection character set to charset. The character
set can only be changed in MySQL-4.1 and newer. If you try
to change the character set from the current value in an
older version, NotSupportedError will be raised."""
if charset i... | [
"def",
"set_character_set",
"(",
"self",
",",
"charset",
")",
":",
"if",
"charset",
"in",
"(",
"\"utf8mb4\"",
",",
"\"utf8mb3\"",
")",
":",
"py_charset",
"=",
"\"utf8\"",
"else",
":",
"py_charset",
"=",
"charset",
"if",
"self",
".",
"character_set_name",
"("... | Set the connection character set to charset. The character
set can only be changed in MySQL-4.1 and newer. If you try
to change the character set from the current value in an
older version, NotSupportedError will be raised. | [
"Set",
"the",
"connection",
"character",
"set",
"to",
"charset",
".",
"The",
"character",
"set",
"can",
"only",
"be",
"changed",
"in",
"MySQL",
"-",
"4",
".",
"1",
"and",
"newer",
".",
"If",
"you",
"try",
"to",
"change",
"the",
"character",
"set",
"fro... | b66971ee36be96b772ae7fdec79ccc1611376f3c | https://github.com/PyMySQL/mysqlclient-python/blob/b66971ee36be96b772ae7fdec79ccc1611376f3c/MySQLdb/connections.py#L282-L299 |
226,793 | PyMySQL/mysqlclient-python | MySQLdb/connections.py | Connection.set_sql_mode | def set_sql_mode(self, sql_mode):
"""Set the connection sql_mode. See MySQL documentation for
legal values."""
if self._server_version < (4, 1):
raise NotSupportedError("server is too old to set sql_mode")
self.query("SET SESSION sql_mode='%s'" % sql_mode)
self.store_... | python | def set_sql_mode(self, sql_mode):
"""Set the connection sql_mode. See MySQL documentation for
legal values."""
if self._server_version < (4, 1):
raise NotSupportedError("server is too old to set sql_mode")
self.query("SET SESSION sql_mode='%s'" % sql_mode)
self.store_... | [
"def",
"set_sql_mode",
"(",
"self",
",",
"sql_mode",
")",
":",
"if",
"self",
".",
"_server_version",
"<",
"(",
"4",
",",
"1",
")",
":",
"raise",
"NotSupportedError",
"(",
"\"server is too old to set sql_mode\"",
")",
"self",
".",
"query",
"(",
"\"SET SESSION s... | Set the connection sql_mode. See MySQL documentation for
legal values. | [
"Set",
"the",
"connection",
"sql_mode",
".",
"See",
"MySQL",
"documentation",
"for",
"legal",
"values",
"."
] | b66971ee36be96b772ae7fdec79ccc1611376f3c | https://github.com/PyMySQL/mysqlclient-python/blob/b66971ee36be96b772ae7fdec79ccc1611376f3c/MySQLdb/connections.py#L301-L307 |
226,794 | PyMySQL/mysqlclient-python | MySQLdb/cursors.py | BaseCursor.close | def close(self):
"""Close the cursor. No further queries will be possible."""
try:
if self.connection is None:
return
while self.nextset():
pass
finally:
self.connection = None
self._result = None | python | def close(self):
"""Close the cursor. No further queries will be possible."""
try:
if self.connection is None:
return
while self.nextset():
pass
finally:
self.connection = None
self._result = None | [
"def",
"close",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"connection",
"is",
"None",
":",
"return",
"while",
"self",
".",
"nextset",
"(",
")",
":",
"pass",
"finally",
":",
"self",
".",
"connection",
"=",
"None",
"self",
".",
"_result",
... | Close the cursor. No further queries will be possible. | [
"Close",
"the",
"cursor",
".",
"No",
"further",
"queries",
"will",
"be",
"possible",
"."
] | b66971ee36be96b772ae7fdec79ccc1611376f3c | https://github.com/PyMySQL/mysqlclient-python/blob/b66971ee36be96b772ae7fdec79ccc1611376f3c/MySQLdb/cursors.py#L81-L90 |
226,795 | MagicStack/asyncpg | asyncpg/cursor.py | Cursor.fetchrow | async def fetchrow(self, *, timeout=None):
r"""Return the next row.
:param float timeout: Optional timeout value in seconds.
:return: A :class:`Record` instance.
"""
self._check_ready()
if self._exhausted:
return None
recs = await self._exec(1, timeo... | python | async def fetchrow(self, *, timeout=None):
r"""Return the next row.
:param float timeout: Optional timeout value in seconds.
:return: A :class:`Record` instance.
"""
self._check_ready()
if self._exhausted:
return None
recs = await self._exec(1, timeo... | [
"async",
"def",
"fetchrow",
"(",
"self",
",",
"*",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_check_ready",
"(",
")",
"if",
"self",
".",
"_exhausted",
":",
"return",
"None",
"recs",
"=",
"await",
"self",
".",
"_exec",
"(",
"1",
",",
"tim... | r"""Return the next row.
:param float timeout: Optional timeout value in seconds.
:return: A :class:`Record` instance. | [
"r",
"Return",
"the",
"next",
"row",
"."
] | 92c2d81256a1efd8cab12c0118d74ccd1c18131b | https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/cursor.py#L224-L238 |
226,796 | MagicStack/asyncpg | asyncpg/connresource.py | guarded | def guarded(meth):
"""A decorator to add a sanity check to ConnectionResource methods."""
@functools.wraps(meth)
def _check(self, *args, **kwargs):
self._check_conn_validity(meth.__name__)
return meth(self, *args, **kwargs)
return _check | python | def guarded(meth):
"""A decorator to add a sanity check to ConnectionResource methods."""
@functools.wraps(meth)
def _check(self, *args, **kwargs):
self._check_conn_validity(meth.__name__)
return meth(self, *args, **kwargs)
return _check | [
"def",
"guarded",
"(",
"meth",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"meth",
")",
"def",
"_check",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_check_conn_validity",
"(",
"meth",
".",
"__name__",
")",
"r... | A decorator to add a sanity check to ConnectionResource methods. | [
"A",
"decorator",
"to",
"add",
"a",
"sanity",
"check",
"to",
"ConnectionResource",
"methods",
"."
] | 92c2d81256a1efd8cab12c0118d74ccd1c18131b | https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connresource.py#L14-L22 |
226,797 | MagicStack/asyncpg | asyncpg/cluster.py | Cluster.start | def start(self, wait=60, *, server_settings={}, **opts):
"""Start the cluster."""
status = self.get_status()
if status == 'running':
return
elif status == 'not-initialized':
raise ClusterError(
'cluster in {!r} has not been initialized'.format(
... | python | def start(self, wait=60, *, server_settings={}, **opts):
"""Start the cluster."""
status = self.get_status()
if status == 'running':
return
elif status == 'not-initialized':
raise ClusterError(
'cluster in {!r} has not been initialized'.format(
... | [
"def",
"start",
"(",
"self",
",",
"wait",
"=",
"60",
",",
"*",
",",
"server_settings",
"=",
"{",
"}",
",",
"*",
"*",
"opts",
")",
":",
"status",
"=",
"self",
".",
"get_status",
"(",
")",
"if",
"status",
"==",
"'running'",
":",
"return",
"elif",
"... | Start the cluster. | [
"Start",
"the",
"cluster",
"."
] | 92c2d81256a1efd8cab12c0118d74ccd1c18131b | https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/cluster.py#L144-L222 |
226,798 | MagicStack/asyncpg | asyncpg/cluster.py | Cluster.reload | def reload(self):
"""Reload server configuration."""
status = self.get_status()
if status != 'running':
raise ClusterError('cannot reload: cluster is not running')
process = subprocess.run(
[self._pg_ctl, 'reload', '-D', self._data_dir],
stdout=subpro... | python | def reload(self):
"""Reload server configuration."""
status = self.get_status()
if status != 'running':
raise ClusterError('cannot reload: cluster is not running')
process = subprocess.run(
[self._pg_ctl, 'reload', '-D', self._data_dir],
stdout=subpro... | [
"def",
"reload",
"(",
"self",
")",
":",
"status",
"=",
"self",
".",
"get_status",
"(",
")",
"if",
"status",
"!=",
"'running'",
":",
"raise",
"ClusterError",
"(",
"'cannot reload: cluster is not running'",
")",
"process",
"=",
"subprocess",
".",
"run",
"(",
"... | Reload server configuration. | [
"Reload",
"server",
"configuration",
"."
] | 92c2d81256a1efd8cab12c0118d74ccd1c18131b | https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/cluster.py#L224-L239 |
226,799 | MagicStack/asyncpg | asyncpg/cluster.py | Cluster.reset_hba | def reset_hba(self):
"""Remove all records from pg_hba.conf."""
status = self.get_status()
if status == 'not-initialized':
raise ClusterError(
'cannot modify HBA records: cluster is not initialized')
pg_hba = os.path.join(self._data_dir, 'pg_hba.conf')
... | python | def reset_hba(self):
"""Remove all records from pg_hba.conf."""
status = self.get_status()
if status == 'not-initialized':
raise ClusterError(
'cannot modify HBA records: cluster is not initialized')
pg_hba = os.path.join(self._data_dir, 'pg_hba.conf')
... | [
"def",
"reset_hba",
"(",
"self",
")",
":",
"status",
"=",
"self",
".",
"get_status",
"(",
")",
"if",
"status",
"==",
"'not-initialized'",
":",
"raise",
"ClusterError",
"(",
"'cannot modify HBA records: cluster is not initialized'",
")",
"pg_hba",
"=",
"os",
".",
... | Remove all records from pg_hba.conf. | [
"Remove",
"all",
"records",
"from",
"pg_hba",
".",
"conf",
"."
] | 92c2d81256a1efd8cab12c0118d74ccd1c18131b | https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/cluster.py#L323-L337 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.