text_prompt
stringlengths
157
13.1k
code_prompt
stringlengths
7
19.8k
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_session(self): """Return a Session interface :rtype: library.ISession """
# The inconsistent vboxapi implementation makes this annoying... if hasattr(self.manager, 'mgr'): manager = getattr(self.manager, 'mgr') else: manager = self.manager return Session(interface=manager.getSessionObject(None))
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def cast_object(self, interface_object, interface_class): """Cast the obj to the interface class :rtype: interface_class(interface_object) """
name = interface_class.__name__ i = self.manager.queryInterface(interface_object._i, name) return interface_class(interface=i)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _lock(self, timeout_ms=-1): """Exclusive lock over root machine"""
vbox = VirtualBox() machine = vbox.find_machine(self.machine_name) wait_time = 0 while True: session = Session() try: machine.lock_machine(session, LockType.write) except Exception as exc: if timeout_ms != -1 and wait_time > timeout_ms: raise ValueError("Failed to acquire lock - %s" % exc) time.sleep(1) wait_time += 1000 else: try: yield session finally: session.unlock_machine() break
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _clones(self): """Yield all machines under this pool"""
vbox = VirtualBox() machines = [] for machine in vbox.machines: if machine.name == self.machine_name: continue if machine.name.startswith(self.machine_name): machines.append(machine) return machines
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def acquire(self, username, password, frontend='headless'): """Acquire a Machine resource."""
with self._lock() as root_session: for clone in self._clones: # Search for a free clone session = Session() try: clone.lock_machine(session, LockType.write) except Exception: continue else: try: p = session.machine.restore_snapshot() p.wait_for_completion(60 * 1000) except Exception: pass session.unlock_machine() break else: # Build a new clone machine = root_session.machine clone = machine.clone(name="%s Pool" % self.machine_name) p = clone.launch_vm_process(type_p=frontend) p.wait_for_completion(60 * 1000) session = clone.create_session() console = session.console guest = console.guest try: guest_session = guest.create_session(username, password, timeout_ms=300 * 1000) idle_count = 0 timeout = 60 while idle_count < 5 and timeout > 0: act = console.get_device_activity([DeviceType.hard_disk]) if act[0] == DeviceActivity.idle: idle_count += 1 time.sleep(0.5) timeout -= 0.5 guest_session.close() console.pause() p, id_p = console.machine.take_snapshot('initialised', 'machine pool', True) p.wait_for_completion(60 * 1000) self._power_down(session) finally: if session.state == SessionState.locked: session.unlock_machine() # Launch our clone p = clone.launch_vm_process(type_p=frontend) p.wait_for_completion(60 * 1000) session = clone.create_session() return session
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def release(self, session): """Release a machine session resource."""
if session.state != SessionState.locked: return with self._lock(): return self._power_down(session)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def add_port_forward_rule(self, is_ipv6, rule_name, proto, host_ip, host_port, guest_ip, guest_port): """Protocol handled with the rule. in is_ipv6 of type bool in rule_name of type str in proto of type :class:`NATProtocol` Protocol handled with the rule. in host_ip of type str IP of the host interface to which the rule should apply. An empty ip address is acceptable, in which case the NAT engine binds the handling socket to any interface. in host_port of type int The port number to listen on. in guest_ip of type str The IP address of the guest which the NAT engine will forward matching packets to. An empty IP address is not acceptable. in guest_port of type int The port number to forward. """
if not isinstance(is_ipv6, bool): raise TypeError("is_ipv6 can only be an instance of type bool") if not isinstance(rule_name, basestring): raise TypeError("rule_name can only be an instance of type basestring") if not isinstance(proto, NATProtocol): raise TypeError("proto can only be an instance of type NATProtocol") if not isinstance(host_ip, basestring): raise TypeError("host_ip can only be an instance of type basestring") if not isinstance(host_port, baseinteger): raise TypeError("host_port can only be an instance of type baseinteger") if not isinstance(guest_ip, basestring): raise TypeError("guest_ip can only be an instance of type basestring") if not isinstance(guest_port, baseinteger): raise TypeError("guest_port can only be an instance of type baseinteger") self._call("addPortForwardRule", in_p=[is_ipv6, rule_name, proto, host_ip, host_port, guest_ip, guest_port])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def start(self, trunk_type): """Type of internal network trunk. in trunk_type of type str Type of internal network trunk. """
if not isinstance(trunk_type, basestring): raise TypeError("trunk_type can only be an instance of type basestring") self._call("start", in_p=[trunk_type])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def remove_vm_slot_options(self, vmname, slot): """removes all option for the specified adapter in vmname of type str in slot of type int raises :class:`OleErrorInvalidarg` invalid VM or slot supplied """
if not isinstance(vmname, basestring): raise TypeError("vmname can only be an instance of type basestring") if not isinstance(slot, baseinteger): raise TypeError("slot can only be an instance of type baseinteger") self._call("removeVmSlotOptions", in_p=[vmname, slot])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_configuration(self, ip_address, network_mask, from_ip_address, to_ip_address): """configures the server in ip_address of type str server IP address in network_mask of type str server network mask in from_ip_address of type str server From IP address for address range in to_ip_address of type str server To IP address for address range raises :class:`OleErrorInvalidarg` invalid configuration supplied """
if not isinstance(ip_address, basestring): raise TypeError("ip_address can only be an instance of type basestring") if not isinstance(network_mask, basestring): raise TypeError("network_mask can only be an instance of type basestring") if not isinstance(from_ip_address, basestring): raise TypeError("from_ip_address can only be an instance of type basestring") if not isinstance(to_ip_address, basestring): raise TypeError("to_ip_address can only be an instance of type basestring") self._call("setConfiguration", in_p=[ip_address, network_mask, from_ip_address, to_ip_address])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def start(self, network_name, trunk_name, trunk_type): """Starts DHCP server process. in network_name of type str Name of internal network DHCP server should attach to. in trunk_name of type str Name of internal network trunk. in trunk_type of type str Type of internal network trunk. raises :class:`OleErrorFail` Failed to start the process. """
if not isinstance(network_name, basestring): raise TypeError("network_name can only be an instance of type basestring") if not isinstance(trunk_name, basestring): raise TypeError("trunk_name can only be an instance of type basestring") if not isinstance(trunk_type, basestring): raise TypeError("trunk_type can only be an instance of type basestring") self._call("start", in_p=[network_name, trunk_name, trunk_type])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def find_machine(self, name_or_id): """Attempts to find a virtual machine given its name or UUID. Inaccessible machines cannot be found by name, only by UUID, because their name cannot safely be determined. in name_or_id of type str What to search for. This can either be the UUID or the name of a virtual machine. return machine of type :class:`IMachine` Machine object, if found. raises :class:`VBoxErrorObjectNotFound` Could not find registered machine matching @a nameOrId. """
if not isinstance(name_or_id, basestring): raise TypeError("name_or_id can only be an instance of type basestring") machine = self._call("findMachine", in_p=[name_or_id]) machine = IMachine(machine) return machine
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_machines_by_groups(self, groups): """Gets all machine references which are in one of the specified groups. in groups of type str What groups to match. The usual group list rules apply, i.e. passing an empty list will match VMs in the toplevel group, likewise the empty string. return machines of type :class:`IMachine` All machines which matched. """
if not isinstance(groups, list): raise TypeError("groups can only be an instance of type list") for a in groups[:10]: if not isinstance(a, basestring): raise TypeError( "array can only contain objects of type basestring") machines = self._call("getMachinesByGroups", in_p=[groups]) machines = [IMachine(a) for a in machines] return machines
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_machine_states(self, machines): """Gets the state of several machines in a single operation. in machines of type :class:`IMachine` Array with the machine references. return states of type :class:`MachineState` Machine states, corresponding to the machines. """
if not isinstance(machines, list): raise TypeError("machines can only be an instance of type list") for a in machines[:10]: if not isinstance(a, IMachine): raise TypeError( "array can only contain objects of type IMachine") states = self._call("getMachineStates", in_p=[machines]) states = [MachineState(a) for a in states] return states
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_settings_secret(self, password): """Unlocks the secret data by passing the unlock password to the server. The server will cache the password for that machine. in password of type str The cipher key. raises :class:`VBoxErrorInvalidVmState` Virtual machine is not mutable. """
if not isinstance(password, basestring): raise TypeError("password can only be an instance of type basestring") self._call("setSettingsSecret", in_p=[password])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_dhcp_server(self, name): """Creates a DHCP server settings to be used for the given internal network name in name of type str server name return server of type :class:`IDHCPServer` DHCP server settings raises :class:`OleErrorInvalidarg` Host network interface @a name already exists. """
if not isinstance(name, basestring): raise TypeError("name can only be an instance of type basestring") server = self._call("createDHCPServer", in_p=[name]) server = IDHCPServer(server) return server
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def remove_dhcp_server(self, server): """Removes the DHCP server settings in server of type :class:`IDHCPServer` DHCP server settings to be removed raises :class:`OleErrorInvalidarg` Host network interface @a name already exists. """
if not isinstance(server, IDHCPServer): raise TypeError("server can only be an instance of type IDHCPServer") self._call("removeDHCPServer", in_p=[server])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def check_firmware_present(self, firmware_type, version): """Check if this VirtualBox installation has a firmware of the given type available, either system-wide or per-user. Optionally, this may return a hint where this firmware can be downloaded from. in firmware_type of type :class:`FirmwareType` Type of firmware to check. in version of type str Expected version number, usually empty string (presently ignored). out url of type str Suggested URL to download this firmware from. out file_p of type str Filename of firmware, only valid if result == TRUE. return result of type bool If firmware of this type and version is available. """
if not isinstance(firmware_type, FirmwareType): raise TypeError("firmware_type can only be an instance of type FirmwareType") if not isinstance(version, basestring): raise TypeError("version can only be an instance of type basestring") (result, url, file_p) = self._call("checkFirmwarePresent", in_p=[firmware_type, version]) return (result, url, file_p)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def cd(self, dir_p): """Change the current directory level. in dir_p of type str The name of the directory to go in. return progress of type :class:`IProgress` Progress object to track the operation completion. """
if not isinstance(dir_p, basestring): raise TypeError("dir_p can only be an instance of type basestring") progress = self._call("cd", in_p=[dir_p]) progress = IProgress(progress) return progress
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def exists(self, names): """Checks if the given file list exists in the current directory level. in names of type str The names to check. return exists of type str The names which exist. """
if not isinstance(names, list): raise TypeError("names can only be an instance of type list") for a in names[:10]: if not isinstance(a, basestring): raise TypeError( "array can only contain objects of type basestring") exists = self._call("exists", in_p=[names]) return exists
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def remove(self, names): """Deletes the given files in the current directory level. in names of type str The names to remove. return progress of type :class:`IProgress` Progress object to track the operation completion. """
if not isinstance(names, list): raise TypeError("names can only be an instance of type list") for a in names[:10]: if not isinstance(a, basestring): raise TypeError( "array can only contain objects of type basestring") progress = self._call("remove", in_p=[names]) progress = IProgress(progress) return progress
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def query_info(self, what): """Way to extend the interface. in what of type int return result of type str """
if not isinstance(what, baseinteger): raise TypeError("what can only be an instance of type baseinteger") result = self._call("queryInfo", in_p=[what]) return result
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_medium_ids_for_password_id(self, password_id): """Returns a list of medium identifiers which use the given password identifier. in password_id of type str The password identifier to get the medium identifiers for. return identifiers of type str The list of medium identifiers returned on success. """
if not isinstance(password_id, basestring): raise TypeError("password_id can only be an instance of type basestring") identifiers = self._call("getMediumIdsForPasswordId", in_p=[password_id]) return identifiers
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def add_passwords(self, identifiers, passwords): """Adds a list of passwords required to import or export encrypted virtual machines. in identifiers of type str List of identifiers. in passwords of type str List of matching passwords. """
if not isinstance(identifiers, list): raise TypeError("identifiers can only be an instance of type list") for a in identifiers[:10]: if not isinstance(a, basestring): raise TypeError( "array can only contain objects of type basestring") if not isinstance(passwords, list): raise TypeError("passwords can only be an instance of type list") for a in passwords[:10]: if not isinstance(a, basestring): raise TypeError( "array can only contain objects of type basestring") self._call("addPasswords", in_p=[identifiers, passwords])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def remove_description_by_type(self, type_p): """Delete all records which are equal to the passed type from the list in type_p of type :class:`VirtualSystemDescriptionType` """
if not isinstance(type_p, VirtualSystemDescriptionType): raise TypeError("type_p can only be an instance of type VirtualSystemDescriptionType") self._call("removeDescriptionByType", in_p=[type_p])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_state(self, state): """Updates the VM state. This operation will also update the settings file with the correct information about the saved state file and delete this file from disk when appropriate. in state of type :class:`MachineState` """
if not isinstance(state, MachineState): raise TypeError("state can only be an instance of type MachineState") self._call("updateState", in_p=[state])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def on_session_end(self, session): """Triggered by the given session object when the session is about to close normally. in session of type :class:`ISession` Session that is being closed return progress of type :class:`IProgress` Used to wait until the corresponding machine is actually dissociated from the given session on the server. Returned only when this session is a direct one. """
if not isinstance(session, ISession): raise TypeError("session can only be an instance of type ISession") progress = self._call("onSessionEnd", in_p=[session]) progress = IProgress(progress) return progress
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def pull_guest_properties(self): """Get the list of the guest properties matching a set of patterns along with their values, timestamps and flags and give responsibility for managing properties to the console. out names of type str The names of the properties returned. out values of type str The values of the properties returned. The array entries match the corresponding entries in the @a name array. out timestamps of type int The timestamps of the properties returned. The array entries match the corresponding entries in the @a name array. out flags of type str The flags of the properties returned. The array entries match the corresponding entries in the @a name array. """
(names, values, timestamps, flags) = self._call("pullGuestProperties") return (names, values, timestamps, flags)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def push_guest_property(self, name, value, timestamp, flags): """Update a single guest property in IMachine. in name of type str The name of the property to be updated. in value of type str The value of the property. in timestamp of type int The timestamp of the property. in flags of type str The flags of the property. """
if not isinstance(name, basestring): raise TypeError("name can only be an instance of type basestring") if not isinstance(value, basestring): raise TypeError("value can only be an instance of type basestring") if not isinstance(timestamp, baseinteger): raise TypeError("timestamp can only be an instance of type baseinteger") if not isinstance(flags, basestring): raise TypeError("flags can only be an instance of type basestring") self._call("pushGuestProperty", in_p=[name, value, timestamp, flags])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def eject_medium(self, attachment): """Tells VBoxSVC that the guest has ejected the medium associated with the medium attachment. in attachment of type :class:`IMediumAttachment` The medium attachment where the eject happened. return new_attachment of type :class:`IMediumAttachment` A new reference to the medium attachment, as the config change can result in the creation of a new instance. """
if not isinstance(attachment, IMediumAttachment): raise TypeError("attachment can only be an instance of type IMediumAttachment") new_attachment = self._call("ejectMedium", in_p=[attachment]) new_attachment = IMediumAttachment(new_attachment) return new_attachment
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def authenticate_external(self, auth_params): """Verify credentials using the external auth library. in auth_params of type str The auth parameters, credentials, etc. out result of type str The authentification result. """
if not isinstance(auth_params, list): raise TypeError("auth_params can only be an instance of type list") for a in auth_params[:10]: if not isinstance(a, basestring): raise TypeError( "array can only contain objects of type basestring") result = self._call("authenticateExternal", in_p=[auth_params]) return result
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def is_feature_enabled(self, feature): """Returns whether a particular recording feature is enabled for this screen or not. in feature of type :class:`RecordingFeature` Feature to check for. return enabled of type bool @c true if the feature is enabled, @c false if not. """
if not isinstance(feature, RecordingFeature): raise TypeError("feature can only be an instance of type RecordingFeature") enabled = self._call("isFeatureEnabled", in_p=[feature]) return enabled
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_screen_settings(self, screen_id): """Returns the recording settings for a particular screen. in screen_id of type int Screen ID to retrieve recording screen settings for. return record_screen_settings of type :class:`IRecordingScreenSettings` Recording screen settings for the requested screen. """
if not isinstance(screen_id, baseinteger): raise TypeError("screen_id can only be an instance of type baseinteger") record_screen_settings = self._call("getScreenSettings", in_p=[screen_id]) record_screen_settings = IRecordingScreenSettings(record_screen_settings) return record_screen_settings
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def from_long(self, number): """Make PCI address from long. in number of type int """
if not isinstance(number, baseinteger): raise TypeError("number can only be an instance of type baseinteger") self._call("fromLong", in_p=[number])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_medium_attachments_of_controller(self, name): """Returns an array of medium attachments which are attached to the the controller with the given name. in name of type str return medium_attachments of type :class:`IMediumAttachment` raises :class:`VBoxErrorObjectNotFound` A storage controller with given name doesn't exist. """
if not isinstance(name, basestring): raise TypeError("name can only be an instance of type basestring") medium_attachments = self._call("getMediumAttachmentsOfController", in_p=[name]) medium_attachments = [IMediumAttachment(a) for a in medium_attachments] return medium_attachments
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_medium_attachment(self, name, controller_port, device): """Returns a medium attachment which corresponds to the controller with the given name, on the given port and device slot. in name of type str in controller_port of type int in device of type int return attachment of type :class:`IMediumAttachment` raises :class:`VBoxErrorObjectNotFound` No attachment exists for the given controller/port/device combination. """
if not isinstance(name, basestring): raise TypeError("name can only be an instance of type basestring") if not isinstance(controller_port, baseinteger): raise TypeError("controller_port can only be an instance of type baseinteger") if not isinstance(device, baseinteger): raise TypeError("device can only be an instance of type baseinteger") attachment = self._call("getMediumAttachment", in_p=[name, controller_port, device]) attachment = IMediumAttachment(attachment) return attachment
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_storage_controller_by_name(self, name): """Returns a storage controller with the given name. in name of type str return storage_controller of type :class:`IStorageController` raises :class:`VBoxErrorObjectNotFound` A storage controller with given name doesn't exist. """
if not isinstance(name, basestring): raise TypeError("name can only be an instance of type basestring") storage_controller = self._call("getStorageControllerByName", in_p=[name]) storage_controller = IStorageController(storage_controller) return storage_controller
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_storage_controller_by_instance(self, connection_type, instance): """Returns a storage controller of a specific storage bus with the given instance number. in connection_type of type :class:`StorageBus` in instance of type int return storage_controller of type :class:`IStorageController` raises :class:`VBoxErrorObjectNotFound` A storage controller with given instance number doesn't exist. """
if not isinstance(connection_type, StorageBus): raise TypeError("connection_type can only be an instance of type StorageBus") if not isinstance(instance, baseinteger): raise TypeError("instance can only be an instance of type baseinteger") storage_controller = self._call("getStorageControllerByInstance", in_p=[connection_type, instance]) storage_controller = IStorageController(storage_controller) return storage_controller
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def remove_storage_controller(self, name): """Removes a storage controller from the machine with all devices attached to it. in name of type str raises :class:`VBoxErrorObjectNotFound` A storage controller with given name doesn't exist. raises :class:`VBoxErrorNotSupported` Medium format does not support storage deletion (only for implicitly created differencing media, should not happen). """
if not isinstance(name, basestring): raise TypeError("name can only be an instance of type basestring") self._call("removeStorageController", in_p=[name])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_storage_controller_bootable(self, name, bootable): """Sets the bootable flag of the storage controller with the given name. in name of type str in bootable of type bool raises :class:`VBoxErrorObjectNotFound` A storage controller with given name doesn't exist. raises :class:`VBoxErrorObjectInUse` Another storage controller is marked as bootable already. """
if not isinstance(name, basestring): raise TypeError("name can only be an instance of type basestring") if not isinstance(bootable, bool): raise TypeError("bootable can only be an instance of type bool") self._call("setStorageControllerBootable", in_p=[name, bootable])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def remove_usb_controller(self, name): """Removes a USB controller from the machine. in name of type str raises :class:`VBoxErrorObjectNotFound` A USB controller with given type doesn't exist. """
if not isinstance(name, basestring): raise TypeError("name can only be an instance of type basestring") self._call("removeUSBController", in_p=[name])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_usb_controller_by_name(self, name): """Returns a USB controller with the given type. in name of type str return controller of type :class:`IUSBController` raises :class:`VBoxErrorObjectNotFound` A USB controller with given name doesn't exist. """
if not isinstance(name, basestring): raise TypeError("name can only be an instance of type basestring") controller = self._call("getUSBControllerByName", in_p=[name]) controller = IUSBController(controller) return controller
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_usb_controller_count_by_type(self, type_p): """Returns the number of USB controllers of the given type attached to the VM. in type_p of type :class:`USBControllerType` return controllers of type int """
if not isinstance(type_p, USBControllerType): raise TypeError("type_p can only be an instance of type USBControllerType") controllers = self._call("getUSBControllerCountByType", in_p=[type_p]) return controllers
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_cpu_property(self, property_p): """Returns the virtual CPU boolean value of the specified property. in property_p of type :class:`CPUPropertyType` Property type to query. return value of type bool Property value. raises :class:`OleErrorInvalidarg` Invalid property. """
if not isinstance(property_p, CPUPropertyType): raise TypeError("property_p can only be an instance of type CPUPropertyType") value = self._call("getCPUProperty", in_p=[property_p]) return value
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_cpu_property(self, property_p, value): """Sets the virtual CPU boolean value of the specified property. in property_p of type :class:`CPUPropertyType` Property type to query. in value of type bool Property value. raises :class:`OleErrorInvalidarg` Invalid property. """
if not isinstance(property_p, CPUPropertyType): raise TypeError("property_p can only be an instance of type CPUPropertyType") if not isinstance(value, bool): raise TypeError("value can only be an instance of type bool") self._call("setCPUProperty", in_p=[property_p, value])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_cpuid_leaf_by_ordinal(self, ordinal): """Used to enumerate CPUID information override values. in ordinal of type int The ordinal number of the leaf to get. out idx of type int CPUID leaf index. out idx_sub of type int CPUID leaf sub-index. out val_eax of type int CPUID leaf value for register eax. out val_ebx of type int CPUID leaf value for register ebx. out val_ecx of type int CPUID leaf value for register ecx. out val_edx of type int CPUID leaf value for register edx. raises :class:`OleErrorInvalidarg` Invalid ordinal number is out of range. """
if not isinstance(ordinal, baseinteger): raise TypeError("ordinal can only be an instance of type baseinteger") (idx, idx_sub, val_eax, val_ebx, val_ecx, val_edx) = self._call("getCPUIDLeafByOrdinal", in_p=[ordinal]) return (idx, idx_sub, val_eax, val_ebx, val_ecx, val_edx)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def remove_cpuid_leaf(self, idx, idx_sub): """Removes the virtual CPU cpuid leaf for the specified index in idx of type int CPUID leaf index. in idx_sub of type int CPUID leaf sub-index (ECX). Set to 0xffffffff (or 0) if not applicable. The 0xffffffff value works like a wildcard. raises :class:`OleErrorInvalidarg` Invalid index. """
if not isinstance(idx, baseinteger): raise TypeError("idx can only be an instance of type baseinteger") if not isinstance(idx_sub, baseinteger): raise TypeError("idx_sub can only be an instance of type baseinteger") self._call("removeCPUIDLeaf", in_p=[idx, idx_sub])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_hw_virt_ex_property(self, property_p): """Returns the value of the specified hardware virtualization boolean property. in property_p of type :class:`HWVirtExPropertyType` Property type to query. return value of type bool Property value. raises :class:`OleErrorInvalidarg` Invalid property. """
if not isinstance(property_p, HWVirtExPropertyType): raise TypeError("property_p can only be an instance of type HWVirtExPropertyType") value = self._call("getHWVirtExProperty", in_p=[property_p]) return value
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_hw_virt_ex_property(self, property_p, value): """Sets a new value for the specified hardware virtualization boolean property. in property_p of type :class:`HWVirtExPropertyType` Property type to set. in value of type bool New property value. raises :class:`OleErrorInvalidarg` Invalid property. """
if not isinstance(property_p, HWVirtExPropertyType): raise TypeError("property_p can only be an instance of type HWVirtExPropertyType") if not isinstance(value, bool): raise TypeError("value can only be an instance of type bool") self._call("setHWVirtExProperty", in_p=[property_p, value])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_guest_property(self, name): """Reads an entry from the machine's guest property store. in name of type str The name of the property to read. out value of type str The value of the property. If the property does not exist then this will be empty. out timestamp of type int The time at which the property was last modified, as seen by the server process. out flags of type str Additional property parameters, passed as a comma-separated list of "name=value" type entries. raises :class:`VBoxErrorInvalidVmState` Machine session is not open. """
if not isinstance(name, basestring): raise TypeError("name can only be an instance of type basestring") (value, timestamp, flags) = self._call("getGuestProperty", in_p=[name]) return (value, timestamp, flags)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_guest_property_value(self, property_p): """Reads a value from the machine's guest property store. in property_p of type str The name of the property to read. return value of type str The value of the property. If the property does not exist then this will be empty. raises :class:`VBoxErrorInvalidVmState` Machine session is not open. """
if not isinstance(property_p, basestring): raise TypeError("property_p can only be an instance of type basestring") value = self._call("getGuestPropertyValue", in_p=[property_p]) return value
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_guest_property(self, property_p, value, flags): """Sets, changes or deletes an entry in the machine's guest property store. in property_p of type str The name of the property to set, change or delete. in value of type str The new value of the property to set, change or delete. If the property does not yet exist and value is non-empty, it will be created. If the value is @c null or empty, the property will be deleted if it exists. in flags of type str Additional property parameters, passed as a comma-separated list of "name=value" type entries. raises :class:`OleErrorAccessdenied` Property cannot be changed. raises :class:`OleErrorInvalidarg` Invalid @a flags. raises :class:`VBoxErrorInvalidVmState` Virtual machine is not mutable or session not open. raises :class:`VBoxErrorInvalidObjectState` Cannot set transient property when machine not running. """
if not isinstance(property_p, basestring): raise TypeError("property_p can only be an instance of type basestring") if not isinstance(value, basestring): raise TypeError("value can only be an instance of type basestring") if not isinstance(flags, basestring): raise TypeError("flags can only be an instance of type basestring") self._call("setGuestProperty", in_p=[property_p, value, flags])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_guest_property_value(self, property_p, value): """Sets or changes a value in the machine's guest property store. The flags field will be left unchanged or created empty for a new property. in property_p of type str The name of the property to set or change. in value of type str The new value of the property to set or change. If the property does not yet exist and value is non-empty, it will be created. raises :class:`OleErrorAccessdenied` Property cannot be changed. raises :class:`VBoxErrorInvalidVmState` Virtual machine is not mutable or session not open. raises :class:`VBoxErrorInvalidObjectState` Cannot set transient property when machine not running. """
if not isinstance(property_p, basestring): raise TypeError("property_p can only be an instance of type basestring") if not isinstance(value, basestring): raise TypeError("value can only be an instance of type basestring") self._call("setGuestPropertyValue", in_p=[property_p, value])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def delete_guest_property(self, name): """Deletes an entry from the machine's guest property store. in name of type str The name of the property to delete. raises :class:`VBoxErrorInvalidVmState` Machine session is not open. """
if not isinstance(name, basestring): raise TypeError("name can only be an instance of type basestring") self._call("deleteGuestProperty", in_p=[name])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def enumerate_guest_properties(self, patterns): """Return a list of the guest properties matching a set of patterns along with their values, timestamps and flags. in patterns of type str The patterns to match the properties against, separated by '|' characters. If this is empty or @c null, all properties will match. out names of type str The names of the properties returned. out values of type str The values of the properties returned. The array entries match the corresponding entries in the @a name array. out timestamps of type int The timestamps of the properties returned. The array entries match the corresponding entries in the @a name array. out flags of type str The flags of the properties returned. The array entries match the corresponding entries in the @a name array. """
if not isinstance(patterns, basestring): raise TypeError("patterns can only be an instance of type basestring") (names, values, timestamps, flags) = self._call("enumerateGuestProperties", in_p=[patterns]) return (names, values, timestamps, flags)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def query_saved_guest_screen_info(self, screen_id): """Returns the guest dimensions from the saved state. in screen_id of type int Saved guest screen to query info from. out origin_x of type int The X position of the guest monitor top left corner. out origin_y of type int The Y position of the guest monitor top left corner. out width of type int Guest width at the time of the saved state was taken. out height of type int Guest height at the time of the saved state was taken. out enabled of type bool Whether the monitor is enabled in the guest. """
if not isinstance(screen_id, baseinteger): raise TypeError("screen_id can only be an instance of type baseinteger") (origin_x, origin_y, width, height, enabled) = self._call("querySavedGuestScreenInfo", in_p=[screen_id]) return (origin_x, origin_y, width, height, enabled)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def query_saved_screenshot_info(self, screen_id): """Returns available formats and size of the screenshot from saved state. in screen_id of type int Saved guest screen to query info from. out width of type int Image width. out height of type int Image height. return bitmap_formats of type :class:`BitmapFormat` Formats supported by readSavedScreenshotToArray. """
if not isinstance(screen_id, baseinteger): raise TypeError("screen_id can only be an instance of type baseinteger") (bitmap_formats, width, height) = self._call("querySavedScreenshotInfo", in_p=[screen_id]) bitmap_formats = [BitmapFormat(a) for a in bitmap_formats] return (bitmap_formats, width, height)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def read_saved_screenshot_to_array(self, screen_id, bitmap_format): """Screenshot in requested format is retrieved to an array of bytes. in screen_id of type int Saved guest screen to read from. in bitmap_format of type :class:`BitmapFormat` The requested format. out width of type int Image width. out height of type int Image height. return data of type str Array with resulting image data. """
if not isinstance(screen_id, baseinteger): raise TypeError("screen_id can only be an instance of type baseinteger") if not isinstance(bitmap_format, BitmapFormat): raise TypeError("bitmap_format can only be an instance of type BitmapFormat") (data, width, height) = self._call("readSavedScreenshotToArray", in_p=[screen_id, bitmap_format]) return (data, width, height)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def hot_plug_cpu(self, cpu): """Plugs a CPU into the machine. in cpu of type int The CPU id to insert. """
if not isinstance(cpu, baseinteger): raise TypeError("cpu can only be an instance of type baseinteger") self._call("hotPlugCPU", in_p=[cpu])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def hot_unplug_cpu(self, cpu): """Removes a CPU from the machine. in cpu of type int The CPU id to remove. """
if not isinstance(cpu, baseinteger): raise TypeError("cpu can only be an instance of type baseinteger") self._call("hotUnplugCPU", in_p=[cpu])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_cpu_status(self, cpu): """Returns the current status of the given CPU. in cpu of type int The CPU id to check for. return attached of type bool Status of the CPU. """
if not isinstance(cpu, baseinteger): raise TypeError("cpu can only be an instance of type baseinteger") attached = self._call("getCPUStatus", in_p=[cpu]) return attached
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def query_log_filename(self, idx): """Queries for the VM log file name of an given index. Returns an empty string if a log file with that index doesn't exists. in idx of type int Which log file name to query. 0=current log file. return filename of type str On return the full path to the log file or an empty string on error. """
if not isinstance(idx, baseinteger): raise TypeError("idx can only be an instance of type baseinteger") filename = self._call("queryLogFilename", in_p=[idx]) return filename
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def read_log(self, idx, offset, size): """Reads the VM log file. The chunk size is limited, so even if you ask for a big piece there might be less data returned. in idx of type int Which log file to read. 0=current log file. in offset of type int Offset in the log file. in size of type int Chunk size to read in the log file. return data of type str Data read from the log file. A data size of 0 means end of file if the requested chunk size was not 0. This is the unprocessed file data, i.e. the line ending style depends on the platform of the system the server is running on. """
if not isinstance(idx, baseinteger): raise TypeError("idx can only be an instance of type baseinteger") if not isinstance(offset, baseinteger): raise TypeError("offset can only be an instance of type baseinteger") if not isinstance(size, baseinteger): raise TypeError("size can only be an instance of type baseinteger") data = self._call("readLog", in_p=[idx, offset, size]) return data
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def apply_defaults(self, flags): """Applies the defaults for the configured guest OS type. This is primarily for getting sane settings straight after creating a new VM, but it can also be applied later. This is primarily a shortcut, centralizing the tedious job of getting the recommended settings and translating them into settings updates. The settings are made at the end of the call, but not saved. in flags of type str Additional flags, to be defined later. raises :class:`OleErrorNotimpl` This method is not implemented yet. """
if not isinstance(flags, basestring): raise TypeError("flags can only be an instance of type basestring") self._call("applyDefaults", in_p=[flags])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def webcam_attach(self, path, settings): """Attaches the emulated USB webcam to the VM, which will use a host video capture device. in path of type str The host path of the capture device to use. in settings of type str Optional settings. """
if not isinstance(path, basestring): raise TypeError("path can only be an instance of type basestring") if not isinstance(settings, basestring): raise TypeError("settings can only be an instance of type basestring") self._call("webcamAttach", in_p=[path, settings])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def webcam_detach(self, path): """Detaches the emulated USB webcam from the VM in path of type str The host path of the capture device to detach. """
if not isinstance(path, basestring): raise TypeError("path can only be an instance of type basestring") self._call("webcamDetach", in_p=[path])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_device_activity(self, type_p): """Gets the current activity type of given devices or device groups. in type_p of type :class:`DeviceType` return activity of type :class:`DeviceActivity` raises :class:`OleErrorInvalidarg` Invalid device type. """
if not isinstance(type_p, list): raise TypeError("type_p can only be an instance of type list") for a in type_p[:10]: if not isinstance(a, DeviceType): raise TypeError( "array can only contain objects of type DeviceType") activity = self._call("getDeviceActivity", in_p=[type_p]) activity = [DeviceActivity(a) for a in activity] return activity
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def enable_static_ip_config(self, ip_address, network_mask): """sets and enables the static IP V4 configuration for the given interface. in ip_address of type str IP address. in network_mask of type str network mask. """
if not isinstance(ip_address, basestring): raise TypeError("ip_address can only be an instance of type basestring") if not isinstance(network_mask, basestring): raise TypeError("network_mask can only be an instance of type basestring") self._call("enableStaticIPConfig", in_p=[ip_address, network_mask])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def enable_static_ip_config_v6(self, ipv6_address, ipv6_network_mask_prefix_length): """sets and enables the static IP V6 configuration for the given interface. in ipv6_address of type str IP address. in ipv6_network_mask_prefix_length of type int network mask. """
if not isinstance(ipv6_address, basestring): raise TypeError("ipv6_address can only be an instance of type basestring") if not isinstance(ipv6_network_mask_prefix_length, baseinteger): raise TypeError("ipv6_network_mask_prefix_length can only be an instance of type baseinteger") self._call("enableStaticIPConfigV6", in_p=[ipv6_address, ipv6_network_mask_prefix_length])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_processor_feature(self, feature): """Query whether a CPU feature is supported or not. in feature of type :class:`ProcessorFeature` CPU Feature identifier. return supported of type bool Feature is supported or not. """
if not isinstance(feature, ProcessorFeature): raise TypeError("feature can only be an instance of type ProcessorFeature") supported = self._call("getProcessorFeature", in_p=[feature]) return supported
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_processor_description(self, cpu_id): """Query the model string of a specified host CPU. in cpu_id of type int Identifier of the CPU. The current implementation might not necessarily return the description for this exact CPU. return description of type str Model string. An empty string is returned if value is not known or @a cpuId is invalid. """
if not isinstance(cpu_id, baseinteger): raise TypeError("cpu_id can only be an instance of type baseinteger") description = self._call("getProcessorDescription", in_p=[cpu_id]) return description
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_processor_cpuid_leaf(self, cpu_id, leaf, sub_leaf): """Returns the CPU cpuid information for the specified leaf. in cpu_id of type int Identifier of the CPU. The CPU most be online. The current implementation might not necessarily return the description for this exact CPU. in leaf of type int CPUID leaf index (eax). in sub_leaf of type int CPUID leaf sub index (ecx). This currently only applies to cache information on Intel CPUs. Use 0 if retrieving values for :py:func:`IMachine.set_cpuid_leaf` . out val_eax of type int CPUID leaf value for register eax. out val_ebx of type int CPUID leaf value for register ebx. out val_ecx of type int CPUID leaf value for register ecx. out val_edx of type int CPUID leaf value for register edx. """
if not isinstance(cpu_id, baseinteger): raise TypeError("cpu_id can only be an instance of type baseinteger") if not isinstance(leaf, baseinteger): raise TypeError("leaf can only be an instance of type baseinteger") if not isinstance(sub_leaf, baseinteger): raise TypeError("sub_leaf can only be an instance of type baseinteger") (val_eax, val_ebx, val_ecx, val_edx) = self._call("getProcessorCPUIDLeaf", in_p=[cpu_id, leaf, sub_leaf]) return (val_eax, val_ebx, val_ecx, val_edx)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_host_only_network_interface(self): """Creates a new adapter for Host Only Networking. out host_interface of type :class:`IHostNetworkInterface` Created host interface object. return progress of type :class:`IProgress` Progress object to track the operation completion. raises :class:`OleErrorInvalidarg` Host network interface @a name already exists. """
(progress, host_interface) = self._call("createHostOnlyNetworkInterface") progress = IProgress(progress) host_interface = IHostNetworkInterface(host_interface) return (progress, host_interface)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def remove_host_only_network_interface(self, id_p): """Removes the given Host Only Networking interface. in id_p of type str Adapter GUID. return progress of type :class:`IProgress` Progress object to track the operation completion. raises :class:`VBoxErrorObjectNotFound` No host network interface matching @a id found. """
if not isinstance(id_p, basestring): raise TypeError("id_p can only be an instance of type basestring") progress = self._call("removeHostOnlyNetworkInterface", in_p=[id_p]) progress = IProgress(progress) return progress
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def find_host_network_interface_by_id(self, id_p): """Searches through all host network interfaces for an interface with the given GUID. The method returns an error if the given GUID does not correspond to any host network interface. in id_p of type str GUID of the host network interface to search for. return network_interface of type :class:`IHostNetworkInterface` Found host network interface object. """
if not isinstance(id_p, basestring): raise TypeError("id_p can only be an instance of type basestring") network_interface = self._call("findHostNetworkInterfaceById", in_p=[id_p]) network_interface = IHostNetworkInterface(network_interface) return network_interface
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def find_host_network_interfaces_of_type(self, type_p): """Searches through all host network interfaces and returns a list of interfaces of the specified type in type_p of type :class:`HostNetworkInterfaceType` type of the host network interfaces to search for. return network_interfaces of type :class:`IHostNetworkInterface` Found host network interface objects. """
if not isinstance(type_p, HostNetworkInterfaceType): raise TypeError("type_p can only be an instance of type HostNetworkInterfaceType") network_interfaces = self._call("findHostNetworkInterfacesOfType", in_p=[type_p]) network_interfaces = [IHostNetworkInterface(a) for a in network_interfaces] return network_interfaces
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def add_usb_device_source(self, backend, id_p, address, property_names, property_values): """Adds a new USB device source. in backend of type str The backend to use as the new device source. in id_p of type str Unique ID to identify the source. in address of type str Address to use, the format is dependent on the backend. For USB/IP backends for example the notation is host[:port]. in property_names of type str Array of property names for more detailed configuration. Not used at the moment. in property_values of type str Array of property values for more detailed configuration. Not used at the moment. """
if not isinstance(backend, basestring): raise TypeError("backend can only be an instance of type basestring") if not isinstance(id_p, basestring): raise TypeError("id_p can only be an instance of type basestring") if not isinstance(address, basestring): raise TypeError("address can only be an instance of type basestring") if not isinstance(property_names, list): raise TypeError("property_names can only be an instance of type list") for a in property_names[:10]: if not isinstance(a, basestring): raise TypeError( "array can only contain objects of type basestring") if not isinstance(property_values, list): raise TypeError("property_values can only be an instance of type list") for a in property_values[:10]: if not isinstance(a, basestring): raise TypeError( "array can only contain objects of type basestring") self._call("addUSBDeviceSource", in_p=[backend, id_p, address, property_names, property_values])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def remove_usb_device_source(self, id_p): """Removes a previously added USB device source. in id_p of type str The identifier used when the source was added. """
if not isinstance(id_p, basestring): raise TypeError("id_p can only be an instance of type basestring") self._call("removeUSBDeviceSource", in_p=[id_p])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_max_devices_per_port_for_storage_bus(self, bus): """Returns the maximum number of devices which can be attached to a port for the given storage bus. in bus of type :class:`StorageBus` The storage bus type to get the value for. return max_devices_per_port of type int The maximum number of devices which can be attached to the port for the given storage bus. """
if not isinstance(bus, StorageBus): raise TypeError("bus can only be an instance of type StorageBus") max_devices_per_port = self._call("getMaxDevicesPerPortForStorageBus", in_p=[bus]) return max_devices_per_port
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_min_port_count_for_storage_bus(self, bus): """Returns the minimum number of ports the given storage bus supports. in bus of type :class:`StorageBus` The storage bus type to get the value for. return min_port_count of type int The minimum number of ports for the given storage bus. """
if not isinstance(bus, StorageBus): raise TypeError("bus can only be an instance of type StorageBus") min_port_count = self._call("getMinPortCountForStorageBus", in_p=[bus]) return min_port_count
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_max_port_count_for_storage_bus(self, bus): """Returns the maximum number of ports the given storage bus supports. in bus of type :class:`StorageBus` The storage bus type to get the value for. return max_port_count of type int The maximum number of ports for the given storage bus. """
if not isinstance(bus, StorageBus): raise TypeError("bus can only be an instance of type StorageBus") max_port_count = self._call("getMaxPortCountForStorageBus", in_p=[bus]) return max_port_count
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_max_instances_of_storage_bus(self, chipset, bus): """Returns the maximum number of storage bus instances which can be configured for each VM. This corresponds to the number of storage controllers one can have. Value may depend on chipset type used. in chipset of type :class:`ChipsetType` The chipset type to get the value for. in bus of type :class:`StorageBus` The storage bus type to get the value for. return max_instances of type int The maximum number of instances for the given storage bus. """
if not isinstance(chipset, ChipsetType): raise TypeError("chipset can only be an instance of type ChipsetType") if not isinstance(bus, StorageBus): raise TypeError("bus can only be an instance of type StorageBus") max_instances = self._call("getMaxInstancesOfStorageBus", in_p=[chipset, bus]) return max_instances
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_storage_controller_hotplug_capable(self, controller_type): """Returns whether the given storage controller supports hot-plugging devices. in controller_type of type :class:`StorageControllerType` The storage controller to check the setting for. return hotplug_capable of type bool Returned flag indicating whether the controller is hotplug capable """
if not isinstance(controller_type, StorageControllerType): raise TypeError("controller_type can only be an instance of type StorageControllerType") hotplug_capable = self._call("getStorageControllerHotplugCapable", in_p=[controller_type]) return hotplug_capable
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_max_instances_of_usb_controller_type(self, chipset, type_p): """Returns the maximum number of USB controller instances which can be configured for each VM. This corresponds to the number of USB controllers one can have. Value may depend on chipset type used. in chipset of type :class:`ChipsetType` The chipset type to get the value for. in type_p of type :class:`USBControllerType` The USB controller type to get the value for. return max_instances of type int The maximum number of instances for the given USB controller type. """
if not isinstance(chipset, ChipsetType): raise TypeError("chipset can only be an instance of type ChipsetType") if not isinstance(type_p, USBControllerType): raise TypeError("type_p can only be an instance of type USBControllerType") max_instances = self._call("getMaxInstancesOfUSBControllerType", in_p=[chipset, type_p]) return max_instances
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def drag_is_pending(self, screen_id): """Ask the source if there is any drag and drop operation pending. If no drag and drop operation is pending currently, DnDAction_Ignore is returned. in screen_id of type int The screen ID where the drag and drop event occurred. out formats of type str On return the supported mime types. out allowed_actions of type :class:`DnDAction` On return the actions which are allowed. return default_action of type :class:`DnDAction` On return the default action to use. raises :class:`VBoxErrorVmError` VMM device is not available. """
if not isinstance(screen_id, baseinteger): raise TypeError("screen_id can only be an instance of type baseinteger") (default_action, formats, allowed_actions) = self._call("dragIsPending", in_p=[screen_id]) default_action = DnDAction(default_action) allowed_actions = [DnDAction(a) for a in allowed_actions] return (default_action, formats, allowed_actions)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def drop(self, format_p, action): """Informs the source that a drop event occurred for a pending drag and drop operation. in format_p of type str The mime type the data must be in. in action of type :class:`DnDAction` The action to use. return progress of type :class:`IProgress` Progress object to track the operation completion. raises :class:`VBoxErrorVmError` VMM device is not available. """
if not isinstance(format_p, basestring): raise TypeError("format_p can only be an instance of type basestring") if not isinstance(action, DnDAction): raise TypeError("action can only be an instance of type DnDAction") progress = self._call("drop", in_p=[format_p, action]) progress = IProgress(progress) return progress
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def enter(self, screen_id, y, x, default_action, allowed_actions, formats): """Informs the target about a drag and drop enter event. in screen_id of type int The screen ID where the drag and drop event occurred. in y of type int Y-position of the event. in x of type int X-position of the event. in default_action of type :class:`DnDAction` The default action to use. in allowed_actions of type :class:`DnDAction` The actions which are allowed. in formats of type str The supported MIME types. return result_action of type :class:`DnDAction` The resulting action of this event. raises :class:`VBoxErrorVmError` VMM device is not available. """
if not isinstance(screen_id, baseinteger): raise TypeError("screen_id can only be an instance of type baseinteger") if not isinstance(y, baseinteger): raise TypeError("y can only be an instance of type baseinteger") if not isinstance(x, baseinteger): raise TypeError("x can only be an instance of type baseinteger") if not isinstance(default_action, DnDAction): raise TypeError("default_action can only be an instance of type DnDAction") if not isinstance(allowed_actions, list): raise TypeError("allowed_actions can only be an instance of type list") for a in allowed_actions[:10]: if not isinstance(a, DnDAction): raise TypeError( "array can only contain objects of type DnDAction") if not isinstance(formats, list): raise TypeError("formats can only be an instance of type list") for a in formats[:10]: if not isinstance(a, basestring): raise TypeError( "array can only contain objects of type basestring") result_action = self._call("enter", in_p=[screen_id, y, x, default_action, allowed_actions, formats]) result_action = DnDAction(result_action) return result_action
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def leave(self, screen_id): """Informs the target about a drag and drop leave event. in screen_id of type int The screen ID where the drag and drop event occurred. raises :class:`VBoxErrorVmError` VMM device is not available. """
if not isinstance(screen_id, baseinteger): raise TypeError("screen_id can only be an instance of type baseinteger") self._call("leave", in_p=[screen_id])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def send_data(self, screen_id, format_p, data): """Initiates sending data to the target. in screen_id of type int The screen ID where the drag and drop event occurred. in format_p of type str The MIME type the data is in. in data of type str The actual data. return progress of type :class:`IProgress` Progress object to track the operation completion. raises :class:`VBoxErrorVmError` VMM device is not available. """
if not isinstance(screen_id, baseinteger): raise TypeError("screen_id can only be an instance of type baseinteger") if not isinstance(format_p, basestring): raise TypeError("format_p can only be an instance of type basestring") if not isinstance(data, list): raise TypeError("data can only be an instance of type list") for a in data[:10]: if not isinstance(a, basestring): raise TypeError( "array can only contain objects of type basestring") progress = self._call("sendData", in_p=[screen_id, format_p, data]) progress = IProgress(progress) return progress
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def directory_copy(self, source, destination, flags): """Recursively copies a directory from one guest location to another. in source of type str The path to the directory to copy (in the guest). Guest path style. in destination of type str The path to the target directory (in the guest). Unless the :py:attr:`DirectoryCopyFlag.copy_into_existing` flag is given, the directory shall not already exist. Guest path style. in flags of type :class:`DirectoryCopyFlag` Zero or more :py:class:`DirectoryCopyFlag` values. return progress of type :class:`IProgress` Progress object to track the operation to completion. raises :class:`OleErrorNotimpl` Not yet implemented. """
if not isinstance(source, basestring): raise TypeError("source can only be an instance of type basestring") if not isinstance(destination, basestring): raise TypeError("destination can only be an instance of type basestring") if not isinstance(flags, list): raise TypeError("flags can only be an instance of type list") for a in flags[:10]: if not isinstance(a, DirectoryCopyFlag): raise TypeError( "array can only contain objects of type DirectoryCopyFlag") progress = self._call("directoryCopy", in_p=[source, destination, flags]) progress = IProgress(progress) return progress
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def directory_create(self, path, mode, flags): """Creates a directory in the guest. in path of type str Path to the directory directory to be created. Guest path style. in mode of type int The UNIX-style access mode mask to create the directory with. Whether/how all three access groups and associated access rights are realized is guest OS dependent. The API does the best it can on each OS. in flags of type :class:`DirectoryCreateFlag` Zero or more :py:class:`DirectoryCreateFlag` flags. raises :class:`VBoxErrorIprtError` Error while creating the directory. """
if not isinstance(path, basestring): raise TypeError("path can only be an instance of type basestring") if not isinstance(mode, baseinteger): raise TypeError("mode can only be an instance of type baseinteger") if not isinstance(flags, list): raise TypeError("flags can only be an instance of type list") for a in flags[:10]: if not isinstance(a, DirectoryCreateFlag): raise TypeError( "array can only contain objects of type DirectoryCreateFlag") self._call("directoryCreate", in_p=[path, mode, flags])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def directory_create_temp(self, template_name, mode, path, secure): """Creates a temporary directory in the guest. in template_name of type str Template for the name of the directory to create. This must contain at least one 'X' character. The first group of consecutive 'X' characters in the template will be replaced by a random alphanumeric string to produce a unique name. in mode of type int The UNIX-style access mode mask to create the directory with. Whether/how all three access groups and associated access rights are realized is guest OS dependent. The API does the best it can on each OS. This parameter is ignore if the @a secure parameter is set to @c true. It is strongly recommended to use 0700. in path of type str The path to the directory in which the temporary directory should be created. Guest path style. in secure of type bool Whether to fail if the directory can not be securely created. Currently this means that another unprivileged user cannot manipulate the path specified or remove the temporary directory after it has been created. Also causes the mode specified to be ignored. May not be supported on all guest types. return directory of type str On success this will contain the full path to the created directory. Guest path style. raises :class:`VBoxErrorNotSupported` The operation is not possible as requested on this particular guest type. raises :class:`OleErrorInvalidarg` Invalid argument. This includes an incorrectly formatted template, or a non-absolute path. raises :class:`VBoxErrorIprtError` The temporary directory could not be created. Possible reasons include a non-existing path or an insecure path when the secure option was requested. """
if not isinstance(template_name, basestring): raise TypeError("template_name can only be an instance of type basestring") if not isinstance(mode, baseinteger): raise TypeError("mode can only be an instance of type baseinteger") if not isinstance(path, basestring): raise TypeError("path can only be an instance of type basestring") if not isinstance(secure, bool): raise TypeError("secure can only be an instance of type bool") directory = self._call("directoryCreateTemp", in_p=[template_name, mode, path, secure]) return directory
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def directory_remove(self, path): """Removes a guest directory if empty. Symbolic links in the final component will not be followed, instead an not-a-directory error is reported. in path of type str Path to the directory that should be removed. Guest path style. """
if not isinstance(path, basestring): raise TypeError("path can only be an instance of type basestring") self._call("directoryRemove", in_p=[path])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def file_create_temp(self, template_name, mode, path, secure): """Creates a temporary file in the guest. in template_name of type str Template for the name of the file to create. This must contain at least one 'X' character. The first group of consecutive 'X' characters in the template will be replaced by a random alphanumeric string to produce a unique name. in mode of type int The UNIX-style access mode mask to create the file with. Whether/how all three access groups and associated access rights are realized is guest OS dependent. The API does the best it can on each OS. This parameter is ignore if the @a secure parameter is set to @c true. It is strongly recommended to use 0600. in path of type str The path to the directory in which the temporary file should be created. in secure of type bool Whether to fail if the file can not be securely created. Currently this means that another unprivileged user cannot manipulate the path specified or remove the temporary file after it has been created. Also causes the mode specified to be ignored. May not be supported on all guest types. return file_p of type :class:`IGuestFile` On success this will contain an open file object for the new temporary file. raises :class:`VBoxErrorNotSupported` The operation is not possible as requested on this particular guest OS. raises :class:`OleErrorInvalidarg` Invalid argument. This includes an incorrectly formatted template, or a non-absolute path. raises :class:`VBoxErrorIprtError` The temporary file could not be created. Possible reasons include a non-existing path or an insecure path when the secure option was requested. """
if not isinstance(template_name, basestring): raise TypeError("template_name can only be an instance of type basestring") if not isinstance(mode, baseinteger): raise TypeError("mode can only be an instance of type baseinteger") if not isinstance(path, basestring): raise TypeError("path can only be an instance of type basestring") if not isinstance(secure, bool): raise TypeError("secure can only be an instance of type bool") file_p = self._call("fileCreateTemp", in_p=[template_name, mode, path, secure]) file_p = IGuestFile(file_p) return file_p
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def file_query_size(self, path, follow_symlinks): """Queries the size of a regular file in the guest. in path of type str Path to the file which size is requested. Guest path style. in follow_symlinks of type bool It @c true, symbolic links in the final path component will be followed to their target, and the size of the target is returned. If @c false, symbolic links in the final path component will make the method call fail (symblink is not a regular file). return size of type int Queried file size. raises :class:`VBoxErrorObjectNotFound` File to was not found. raises :class:`VBoxErrorIprtError` Error querying file size. """
if not isinstance(path, basestring): raise TypeError("path can only be an instance of type basestring") if not isinstance(follow_symlinks, bool): raise TypeError("follow_symlinks can only be an instance of type bool") size = self._call("fileQuerySize", in_p=[path, follow_symlinks]) return size
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def symlink_create(self, symlink, target, type_p): """Creates a symbolic link in the guest. in symlink of type str Path to the symbolic link that should be created. Guest path style. in target of type str The path to the symbolic link target. If not an absolute, this will be relative to the @a symlink location at access time. Guest path style. in type_p of type :class:`SymlinkType` The symbolic link type (mainly for Windows). See :py:class:`SymlinkType` for more information. raises :class:`OleErrorNotimpl` The method is not implemented yet. """
if not isinstance(symlink, basestring): raise TypeError("symlink can only be an instance of type basestring") if not isinstance(target, basestring): raise TypeError("target can only be an instance of type basestring") if not isinstance(type_p, SymlinkType): raise TypeError("type_p can only be an instance of type SymlinkType") self._call("symlinkCreate", in_p=[symlink, target, type_p])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def symlink_exists(self, symlink): """Checks whether a symbolic link exists in the guest. in symlink of type str Path to the alleged symbolic link. Guest path style. return exists of type bool Returns @c true if the symbolic link exists. Returns @c false if it does not exist, if the file system object identified by the path is not a symbolic link, or if the object type is inaccessible to the user, or if the @a symlink argument is empty. raises :class:`OleErrorNotimpl` The method is not implemented yet. """
if not isinstance(symlink, basestring): raise TypeError("symlink can only be an instance of type basestring") exists = self._call("symlinkExists", in_p=[symlink]) return exists
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def symlink_read(self, symlink, flags): """Reads the target value of a symbolic link in the guest. in symlink of type str Path to the symbolic link to read. in flags of type :class:`SymlinkReadFlag` Zero or more :py:class:`SymlinkReadFlag` values. return target of type str Target value of the symbolic link. Guest path style. raises :class:`OleErrorNotimpl` The method is not implemented yet. """
if not isinstance(symlink, basestring): raise TypeError("symlink can only be an instance of type basestring") if not isinstance(flags, list): raise TypeError("flags can only be an instance of type list") for a in flags[:10]: if not isinstance(a, SymlinkReadFlag): raise TypeError( "array can only contain objects of type SymlinkReadFlag") target = self._call("symlinkRead", in_p=[symlink, flags]) return target
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def wait_for(self, wait_for, timeout_ms): """Waits for one or more events to happen. in wait_for of type int Specifies what to wait for; see :py:class:`ProcessWaitForFlag` for more information. in timeout_ms of type int Timeout (in ms) to wait for the operation to complete. Pass 0 for an infinite timeout. return reason of type :class:`ProcessWaitResult` The overall wait result; see :py:class:`ProcessWaitResult` for more information. """
if not isinstance(wait_for, baseinteger): raise TypeError("wait_for can only be an instance of type baseinteger") if not isinstance(timeout_ms, baseinteger): raise TypeError("timeout_ms can only be an instance of type baseinteger") reason = self._call("waitFor", in_p=[wait_for, timeout_ms]) reason = ProcessWaitResult(reason) return reason
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def write(self, handle, flags, data, timeout_ms): """Writes data to a running process. in handle of type int Handle to write to. Usually 0 is stdin, 1 is stdout and 2 is stderr. in flags of type int A combination of :py:class:`ProcessInputFlag` flags. in data of type str Array of bytes to write. The size of the array also specifies how much to write. in timeout_ms of type int Timeout (in ms) to wait for the operation to complete. Pass 0 for an infinite timeout. return written of type int How many bytes were written. """
if not isinstance(handle, baseinteger): raise TypeError("handle can only be an instance of type baseinteger") if not isinstance(flags, baseinteger): raise TypeError("flags can only be an instance of type baseinteger") if not isinstance(data, list): raise TypeError("data can only be an instance of type list") for a in data[:10]: if not isinstance(a, basestring): raise TypeError( "array can only contain objects of type basestring") if not isinstance(timeout_ms, baseinteger): raise TypeError("timeout_ms can only be an instance of type baseinteger") written = self._call("write", in_p=[handle, flags, data, timeout_ms]) return written