idx
int64
0
63k
question
stringlengths
61
4.03k
target
stringlengths
6
1.23k
9,000
def set_registers ( self , cpu_id , names , values ) : if not isinstance ( cpu_id , baseinteger ) : raise TypeError ( "cpu_id can only be an instance of type baseinteger" ) if not isinstance ( names , list ) : raise TypeError ( "names can only be an instance of type list" ) for a in names [ : 10 ] : if not isinstance (...
Sets zero or more registers atomically . This feature is not implemented in the 4 . 0 . 0 release but may show up in a dot release .
9,001
def dump_guest_stack ( self , cpu_id ) : if not isinstance ( cpu_id , baseinteger ) : raise TypeError ( "cpu_id can only be an instance of type baseinteger" ) stack = self . _call ( "dumpGuestStack" , in_p = [ cpu_id ] ) return stack
Produce a simple stack dump using the current guest state . This feature is not implemented in the 4 . 0 . 0 release but may show up in a dot release .
9,002
def reset_stats ( self , pattern ) : if not isinstance ( pattern , basestring ) : raise TypeError ( "pattern can only be an instance of type basestring" ) self . _call ( "resetStats" , in_p = [ pattern ] )
Reset VM statistics .
9,003
def dump_stats ( self , pattern ) : if not isinstance ( pattern , basestring ) : raise TypeError ( "pattern can only be an instance of type basestring" ) self . _call ( "dumpStats" , in_p = [ pattern ] )
Dumps VM statistics .
9,004
def get_stats ( self , pattern , with_descriptions ) : if not isinstance ( pattern , basestring ) : raise TypeError ( "pattern can only be an instance of type basestring" ) if not isinstance ( with_descriptions , bool ) : raise TypeError ( "with_descriptions can only be an instance of type bool" ) stats = self . _call ...
Get the VM statistics in a XMLish format .
9,005
def on_network_adapter_change ( self , network_adapter , change_adapter ) : if not isinstance ( network_adapter , INetworkAdapter ) : raise TypeError ( "network_adapter can only be an instance of type INetworkAdapter" ) if not isinstance ( change_adapter , bool ) : raise TypeError ( "change_adapter can only be an insta...
Triggered when settings of a network adapter of the associated virtual machine have changed .
9,006
def on_audio_adapter_change ( self , audio_adapter ) : if not isinstance ( audio_adapter , IAudioAdapter ) : raise TypeError ( "audio_adapter can only be an instance of type IAudioAdapter" ) self . _call ( "onAudioAdapterChange" , in_p = [ audio_adapter ] )
Triggerd when settings of the audio adapter of the associated virtual machine have changed .
9,007
def on_serial_port_change ( self , serial_port ) : if not isinstance ( serial_port , ISerialPort ) : raise TypeError ( "serial_port can only be an instance of type ISerialPort" ) self . _call ( "onSerialPortChange" , in_p = [ serial_port ] )
Triggered when settings of a serial port of the associated virtual machine have changed .
9,008
def on_parallel_port_change ( self , parallel_port ) : if not isinstance ( parallel_port , IParallelPort ) : raise TypeError ( "parallel_port can only be an instance of type IParallelPort" ) self . _call ( "onParallelPortChange" , in_p = [ parallel_port ] )
Triggered when settings of a parallel port of the associated virtual machine have changed .
9,009
def on_medium_change ( self , medium_attachment , force ) : if not isinstance ( medium_attachment , IMediumAttachment ) : raise TypeError ( "medium_attachment can only be an instance of type IMediumAttachment" ) if not isinstance ( force , bool ) : raise TypeError ( "force can only be an instance of type bool" ) self ....
Triggered when attached media of the associated virtual machine have changed .
9,010
def on_storage_device_change ( self , medium_attachment , remove , silent ) : if not isinstance ( medium_attachment , IMediumAttachment ) : raise TypeError ( "medium_attachment can only be an instance of type IMediumAttachment" ) if not isinstance ( remove , bool ) : raise TypeError ( "remove can only be an instance of...
Triggered when attached storage devices of the associated virtual machine have changed .
9,011
def on_vm_process_priority_change ( self , priority ) : if not isinstance ( priority , VMProcPriority ) : raise TypeError ( "priority can only be an instance of type VMProcPriority" ) self . _call ( "onVMProcessPriorityChange" , in_p = [ priority ] )
Triggered when process priority of the associated virtual machine have changed .
9,012
def on_clipboard_mode_change ( self , clipboard_mode ) : if not isinstance ( clipboard_mode , ClipboardMode ) : raise TypeError ( "clipboard_mode can only be an instance of type ClipboardMode" ) self . _call ( "onClipboardModeChange" , in_p = [ clipboard_mode ] )
Notification when the shared clipboard mode changes .
9,013
def on_dn_d_mode_change ( self , dnd_mode ) : if not isinstance ( dnd_mode , DnDMode ) : raise TypeError ( "dnd_mode can only be an instance of type DnDMode" ) self . _call ( "onDnDModeChange" , in_p = [ dnd_mode ] )
Notification when the drag n drop mode changes .
9,014
def on_cpu_change ( self , cpu , add ) : if not isinstance ( cpu , baseinteger ) : raise TypeError ( "cpu can only be an instance of type baseinteger" ) if not isinstance ( add , bool ) : raise TypeError ( "add can only be an instance of type bool" ) self . _call ( "onCPUChange" , in_p = [ cpu , add ] )
Notification when a CPU changes .
9,015
def on_cpu_execution_cap_change ( self , execution_cap ) : if not isinstance ( execution_cap , baseinteger ) : raise TypeError ( "execution_cap can only be an instance of type baseinteger" ) self . _call ( "onCPUExecutionCapChange" , in_p = [ execution_cap ] )
Notification when the CPU execution cap changes .
9,016
def on_vrde_server_change ( self , restart ) : if not isinstance ( restart , bool ) : raise TypeError ( "restart can only be an instance of type bool" ) self . _call ( "onVRDEServerChange" , in_p = [ restart ] )
Triggered when settings of the VRDE server object of the associated virtual machine have changed .
9,017
def on_recording_change ( self , enable ) : if not isinstance ( enable , bool ) : raise TypeError ( "enable can only be an instance of type bool" ) self . _call ( "onRecordingChange" , in_p = [ enable ] )
Triggered when recording settings have changed .
9,018
def on_bandwidth_group_change ( self , bandwidth_group ) : if not isinstance ( bandwidth_group , IBandwidthGroup ) : raise TypeError ( "bandwidth_group can only be an instance of type IBandwidthGroup" ) self . _call ( "onBandwidthGroupChange" , in_p = [ bandwidth_group ] )
Notification when one of the bandwidth groups change .
9,019
def online_merge_medium ( self , medium_attachment , source_idx , target_idx , progress ) : if not isinstance ( medium_attachment , IMediumAttachment ) : raise TypeError ( "medium_attachment can only be an instance of type IMediumAttachment" ) if not isinstance ( source_idx , baseinteger ) : raise TypeError ( "source_i...
Triggers online merging of a hard disk . Used internally when deleting a snapshot while a VM referring to the same hard disk chain is running .
9,020
def reconfigure_medium_attachments ( self , attachments ) : if not isinstance ( attachments , list ) : raise TypeError ( "attachments can only be an instance of type list" ) for a in attachments [ : 10 ] : if not isinstance ( a , IMediumAttachment ) : raise TypeError ( "array can only contain objects of type IMediumAtt...
Reconfigure all specified medium attachments in one go making sure the current state corresponds to the specified medium .
9,021
def enable_vmm_statistics ( self , enable ) : if not isinstance ( enable , bool ) : raise TypeError ( "enable can only be an instance of type bool" ) self . _call ( "enableVMMStatistics" , in_p = [ enable ] )
Enables or disables collection of VMM RAM statistics .
9,022
def set_network_settings ( self , mtu , sock_snd , sock_rcv , tcp_wnd_snd , tcp_wnd_rcv ) : if not isinstance ( mtu , baseinteger ) : raise TypeError ( "mtu can only be an instance of type baseinteger" ) if not isinstance ( sock_snd , baseinteger ) : raise TypeError ( "sock_snd can only be an instance of type baseinteg...
Sets network configuration of the NAT engine .
9,023
def add_redirect ( self , name , proto , host_ip , host_port , guest_ip , guest_port ) : if not isinstance ( name , basestring ) : raise TypeError ( "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 ...
Adds a new NAT port - forwarding rule .
9,024
def remove_redirect ( self , name ) : if not isinstance ( name , basestring ) : raise TypeError ( "name can only be an instance of type basestring" ) self . _call ( "removeRedirect" , in_p = [ name ] )
Removes a port - forwarding rule that was previously registered .
9,025
def query_license ( self , preferred_locale , preferred_language , format_p ) : if not isinstance ( preferred_locale , basestring ) : raise TypeError ( "preferred_locale can only be an instance of type basestring" ) if not isinstance ( preferred_language , basestring ) : raise TypeError ( "preferred_language can only b...
Full feature version of the license attribute .
9,026
def query_object ( self , obj_uuid ) : if not isinstance ( obj_uuid , basestring ) : raise TypeError ( "obj_uuid can only be an instance of type basestring" ) return_interface = self . _call ( "queryObject" , in_p = [ obj_uuid ] ) return_interface = Interface ( return_interface ) return return_interface
Queries the IUnknown interface to an object in the extension pack main module . This allows plug - ins and others to talk directly to an extension pack .
9,027
def install ( self , replace , display_info ) : if not isinstance ( replace , bool ) : raise TypeError ( "replace can only be an instance of type bool" ) if not isinstance ( display_info , basestring ) : raise TypeError ( "display_info can only be an instance of type basestring" ) progess = self . _call ( "install" , i...
Install the extension pack .
9,028
def find ( self , name ) : if not isinstance ( name , basestring ) : raise TypeError ( "name can only be an instance of type basestring" ) return_data = self . _call ( "find" , in_p = [ name ] ) return_data = IExtPack ( return_data ) return return_data
Returns the extension pack with the specified name if found .
9,029
def open_ext_pack_file ( self , path ) : if not isinstance ( path , basestring ) : raise TypeError ( "path can only be an instance of type basestring" ) file_p = self . _call ( "openExtPackFile" , in_p = [ path ] ) file_p = IExtPackFile ( file_p ) return file_p
Attempts to open an extension pack file in preparation for installation .
9,030
def uninstall ( self , name , forced_removal , display_info ) : if not isinstance ( name , basestring ) : raise TypeError ( "name can only be an instance of type basestring" ) if not isinstance ( forced_removal , bool ) : raise TypeError ( "forced_removal can only be an instance of type bool" ) if not isinstance ( disp...
Uninstalls an extension pack removing all related files .
9,031
def query_all_plug_ins_for_frontend ( self , frontend_name ) : if not isinstance ( frontend_name , basestring ) : raise TypeError ( "frontend_name can only be an instance of type basestring" ) plug_in_modules = self . _call ( "queryAllPlugInsForFrontend" , in_p = [ frontend_name ] ) return plug_in_modules
Gets the path to all the plug - in modules for a given frontend . This is a convenience method that is intended to simplify the plug - in loading process for a frontend .
9,032
def is_ext_pack_usable ( self , name ) : if not isinstance ( name , basestring ) : raise TypeError ( "name can only be an instance of type basestring" ) usable = self . _call ( "isExtPackUsable" , in_p = [ name ] ) return usable
Check if the given extension pack is loaded and usable .
9,033
def create_bandwidth_group ( self , name , type_p , max_bytes_per_sec ) : if not isinstance ( name , basestring ) : raise TypeError ( "name can only be an instance of type basestring" ) if not isinstance ( type_p , BandwidthGroupType ) : raise TypeError ( "type_p can only be an instance of type BandwidthGroupType" ) if...
Creates a new bandwidth group .
9,034
def delete_bandwidth_group ( self , name ) : if not isinstance ( name , basestring ) : raise TypeError ( "name can only be an instance of type basestring" ) self . _call ( "deleteBandwidthGroup" , in_p = [ name ] )
Deletes a new bandwidth group .
9,035
def get_bandwidth_group ( self , name ) : if not isinstance ( name , basestring ) : raise TypeError ( "name can only be an instance of type basestring" ) bandwidth_group = self . _call ( "getBandwidthGroup" , in_p = [ name ] ) bandwidth_group = IBandwidthGroup ( bandwidth_group ) return bandwidth_group
Get a bandwidth group by name .
9,036
def get_all_bandwidth_groups ( self ) : bandwidth_groups = self . _call ( "getAllBandwidthGroups" ) bandwidth_groups = [ IBandwidthGroup ( a ) for a in bandwidth_groups ] return bandwidth_groups
Get all managed bandwidth groups .
9,037
def unregister_listener ( self , listener ) : if not isinstance ( listener , IEventListener ) : raise TypeError ( "listener can only be an instance of type IEventListener" ) self . _call ( "unregisterListener" , in_p = [ listener ] )
Unregister an event listener . If listener is passive and some waitable events are still in queue they are marked as processed automatically .
9,038
def fire_event ( self , event , timeout ) : if not isinstance ( event , IEvent ) : raise TypeError ( "event can only be an instance of type IEvent" ) if not isinstance ( timeout , baseinteger ) : raise TypeError ( "timeout can only be an instance of type baseinteger" ) result = self . _call ( "fireEvent" , in_p = [ eve...
Fire an event for this source .
9,039
def wait_processed ( self , timeout ) : if not isinstance ( timeout , baseinteger ) : raise TypeError ( "timeout can only be an instance of type baseinteger" ) result = self . _call ( "waitProcessed" , in_p = [ timeout ] ) return result
Wait until time outs or this event is processed . Event must be waitable for this operation to have described semantics for non - waitable returns true immediately .
9,040
def add_veto ( self , reason ) : if not isinstance ( reason , basestring ) : raise TypeError ( "reason can only be an instance of type basestring" ) self . _call ( "addVeto" , in_p = [ reason ] )
Adds a veto on this event .
9,041
def add_approval ( self , reason ) : if not isinstance ( reason , basestring ) : raise TypeError ( "reason can only be an instance of type basestring" ) self . _call ( "addApproval" , in_p = [ reason ] )
Adds an approval on this event .
9,042
def export_launch_vm ( self , description , progress , virtual_box ) : if not isinstance ( description , IVirtualSystemDescription ) : raise TypeError ( "description can only be an instance of type IVirtualSystemDescription" ) if not isinstance ( progress , IProgress ) : raise TypeError ( "progress can only be an insta...
Exports and optionally launch a VM described in description parameter
9,043
def list_instances ( self , machine_state ) : if not isinstance ( machine_state , CloudMachineState ) : raise TypeError ( "machine_state can only be an instance of type CloudMachineState" ) ( return_ids , return_names ) = self . _call ( "listInstances" , in_p = [ machine_state ] ) return ( return_ids , return_names )
Returns the list of the instances in the Cloud .
9,044
def list_images ( self , image_state ) : if not isinstance ( image_state , CloudImageState ) : raise TypeError ( "image_state can only be an instance of type CloudImageState" ) ( return_ids , return_names ) = self . _call ( "listImages" , in_p = [ image_state ] ) return ( return_ids , return_names )
Returns the list of the images in the Cloud .
9,045
def get_property_description ( self , name ) : if not isinstance ( name , basestring ) : raise TypeError ( "name can only be an instance of type basestring" ) description = self . _call ( "getPropertyDescription" , in_p = [ name ] ) return description
Property name .
9,046
def create_profile ( self , profile_name , names , values ) : if not isinstance ( profile_name , basestring ) : raise TypeError ( "profile_name can only be an instance of type basestring" ) if not isinstance ( names , list ) : raise TypeError ( "names can only be an instance of type list" ) for a in names [ : 10 ] : if...
Creates a new profile .
9,047
def register_on_guest_mouse ( self , callback ) : event_type = library . VBoxEventType . on_guest_mouse return self . event_source . register_callback ( callback , event_type )
Set the callback function to consume on guest mouse events .
9,048
def put_keys ( self , press_keys = None , hold_keys = None , press_delay = 50 ) : if press_keys is None : press_keys = [ ] if hold_keys is None : hold_keys = [ ] release_codes = set ( ) put_codes = set ( ) try : for k in hold_keys : put , release = self . SCANCODES [ k ] put = set ( put ) - put_codes self . put_scancod...
Put scancodes that represent keys defined in the sequences provided .
9,049
def register_on_guest_keyboard ( self , callback ) : return self . event_source . register_callback ( callback , library . VBoxEventType . on_guest_keyboard )
Set the callback function to consume on guest keyboard events
9,050
def execute ( self , command , arguments = None , stdin = "" , environment = None , flags = None , priority = library . ProcessPriority . default , affinity = None , timeout_ms = 0 ) : if arguments is None : arguments = [ ] if environment is None : environment = [ ] if flags is None : flags = [ library . ProcessCreateF...
Execute a command in the Guest
9,051
def path_exists ( self , path , follow_symlinks = True ) : "test if path exists" return ( self . file_exists ( path , follow_symlinks ) or self . symlink_exists ( path , follow_symlinks ) or self . directory_exists ( path , follow_symlinks ) )
test if path exists
9,052
def read ( self , ova_path ) : "Read and interpret ova file into this Appliance object." p = super ( IAppliance , self ) . read ( ova_path ) p . wait_for_completion ( ) self . interpret ( ) warnings = self . get_warnings ( ) if warnings : warning = Warning ( "\n" . join ( warnings ) ) warning . warnings = warnings rais...
Read and interpret ova file into this Appliance object .
9,053
def find_description ( self , name ) : "Find a description for the given appliance name." for desc in self . virtual_system_descriptions : values = desc . get_values_by_type ( DescType . name , DescValueType . original ) if name in values : break else : raise Exception ( "Failed to find description for %s" % name ) ret...
Find a description for the given appliance name .
9,054
def get_vbox_version ( config_kmk ) : "Return the vbox config major, minor, build" with open ( config_kmk , 'rb' ) as f : config = f . read ( ) major = b"6" minor = b"0" build = b"4" return b"." . join ( [ major , minor , build ] )
Return the vbox config major minor build
9,055
def register_on_machine_state_changed ( self , callback ) : event_type = library . VBoxEventType . on_machine_state_changed return self . event_source . register_callback ( callback , event_type )
Set the callback function to consume on machine state changed events .
9,056
def register_on_machine_data_changed ( self , callback ) : event_type = library . VBoxEventType . on_machine_data_changed return self . event_source . register_callback ( callback , event_type )
Set the callback function to consume on machine data changed events .
9,057
def register_on_machine_registered ( self , callback ) : event_type = library . VBoxEventType . on_machine_registered return self . event_source . register_callback ( callback , event_type )
Set the callback function to consume on machine registered events .
9,058
def register_on_snapshot_deleted ( self , callback ) : event_type = library . VBoxEventType . on_snapshot_deleted return self . event_source . register_callback ( callback , event_type )
Set the callback function to consume on snapshot deleted events .
9,059
def register_on_snapshot_taken ( self , callback ) : event_type = library . VBoxEventType . on_snapshot_taken return self . event_source . register_callback ( callback , event_type )
Set the callback function to consume on snapshot taken events .
9,060
def register_on_snapshot_changed ( self , callback ) : event_type = library . VBoxEventType . on_snapshot_changed return self . event_source . register_callback ( callback , event_type )
Set the callback function to consume on snapshot changed events which occur when snapshot properties have been changed .
9,061
def register_on_guest_property_changed ( self , callback ) : event_type = library . VBoxEventType . on_guest_property_changed return self . event_source . register_callback ( callback , event_type )
Set the callback function to consume on guest property changed events .
9,062
def register_on_session_state_changed ( self , callback ) : event_type = library . VBoxEventType . on_session_state_changed return self . event_source . register_callback ( callback , event_type )
Set the callback function to consume on session state changed events .
9,063
def type_to_interface ( event_type ) : global _lookup if not isinstance ( event_type , library . VBoxEventType ) : raise TypeError ( "event_type was not of VBoxEventType" ) if not _lookup : for attr in dir ( library ) : event_interface = getattr ( library , attr ) if not inspect . isclass ( event_interface ) : continue...
Return the event interface object that corresponds to the event type enumeration
9,064
def register_callback ( callback , event_source , event_type ) : global _callbacks event_interface = type_to_interface ( event_type ) listener = event_source . create_listener ( ) event_source . register_listener ( listener , [ event_type ] , False ) quit = threading . Event ( ) t = threading . Thread ( target = _event...
register a callback function against an event_source for a given event_type .
9,065
def unregister_callback ( callback_id ) : global _callbacks obj = _callbacks . pop ( callback_id , None ) threads = [ ] if obj is not None : t , quit = obj quit . set ( ) threads . append ( t ) for t in threads : t . join ( )
unregister a callback registration
9,066
def remove ( self , delete = True ) : if self . state >= library . MachineState . running : session = virtualbox . Session ( ) self . lock_machine ( session , library . LockType . shared ) try : progress = session . console . power_down ( ) progress . wait_for_completion ( - 1 ) except Exception : print ( "Error poweri...
Unregister and optionally delete associated config
9,067
def clone ( self , snapshot_name_or_id = None , mode = library . CloneMode . machine_state , options = None , name = None , uuid = None , groups = None , basefolder = '' , register = True ) : if options is None : options = [ library . CloneOptions . link ] if groups is None : groups = [ ] vbox = virtualbox . VirtualBox...
Clone this Machine
9,068
def create_session ( self , lock_type = library . LockType . shared , session = None ) : if session is None : session = library . ISession ( ) error = None for _ in range ( 10 ) : try : self . lock_machine ( session , lock_type ) except Exception as exc : error = exc time . sleep ( 1 ) continue else : break else : if e...
Lock this machine
9,069
def set_final_value ( self , description_type , value ) : types , _ , _ , vbox_values , extra_config = self . get_description ( ) for offset , t in enumerate ( types ) : if t == description_type : break else : raise Exception ( "Failed to find type for %s" % description_type ) enabled = [ True ] * len ( types ) vbox_va...
Set the value for the given description type .
9,070
def chain_return_value ( future , loop , return_value ) : chained = asyncio . Future ( loop = loop ) def copy ( _future ) : if _future . exception ( ) is not None : chained . set_exception ( _future . exception ( ) ) else : chained . set_result ( return_value ) future . _future . add_done_callback ( functools . partial...
Compatible way to return a value in all Pythons .
9,071
def pymongo_class_wrapper ( f , pymongo_class ) : @ functools . wraps ( f ) @ coroutine def _wrapper ( self , * args , ** kwargs ) : result = yield f ( self , * args , ** kwargs ) if result . __class__ == pymongo_class : raise gen . Return ( self . wrap ( result ) ) else : raise gen . Return ( result ) return _wrapper
Executes the coroutine f and wraps its result in a Motor class .
9,072
def aggregate ( self , pipeline , ** kwargs ) : cursor_class = create_class_with_framework ( AgnosticLatentCommandCursor , self . _framework , self . __module__ ) return cursor_class ( self , self . _async_aggregate , pipeline , ** unwrap_kwargs_session ( kwargs ) )
Execute an aggregation pipeline on this collection .
9,073
def _get_more ( self ) : if not self . alive : raise pymongo . errors . InvalidOperation ( "Can't call get_more() on a MotorCursor that has been" " exhausted or killed." ) self . started = True return self . _refresh ( )
Initial query or getMore . Returns a Future .
9,074
def to_list ( self , length ) : if length is not None : if not isinstance ( length , int ) : raise TypeError ( 'length must be an int, not %r' % length ) elif length < 0 : raise ValueError ( 'length must be non-negative' ) if self . _query_flags ( ) & _QUERY_OPTIONS [ 'tailable_cursor' ] : raise pymongo . errors . Inva...
Get a list of documents .
9,075
def close ( self ) : if self . delegate : return self . _close ( ) future = self . _framework . get_future ( self . get_io_loop ( ) ) future . set_result ( None ) return future
Close this change stream .
9,076
def asynchronize ( framework , sync_method , doc = None , wrap_class = None , unwrap_class = None ) : @ functools . wraps ( sync_method ) def method ( self , * args , ** kwargs ) : if unwrap_class is not None : unwrapped_args = [ obj . delegate if obj . __class__ . __name__ . endswith ( ( unwrap_class , 'MotorClientSes...
Decorate sync_method so it returns a Future .
9,077
def wrap_synchro ( fn ) : @ functools . wraps ( fn ) def _wrap_synchro ( * args , ** kwargs ) : motor_obj = fn ( * args , ** kwargs ) if isinstance ( motor_obj , motor . MotorCollection ) : client = MongoClient ( delegate = motor_obj . database . client ) database = Database ( client , motor_obj . database . name ) ret...
If decorated Synchro function returns a Motor object wrap in a Synchro object .
9,078
def unwrap_synchro ( fn ) : @ functools . wraps ( fn ) def _unwrap_synchro ( * args , ** kwargs ) : def _unwrap_obj ( obj ) : if isinstance ( obj , Synchro ) : return obj . delegate else : return obj args = [ _unwrap_obj ( arg ) for arg in args ] kwargs = dict ( [ ( key , _unwrap_obj ( value ) ) for key , value in kwar...
Unwrap Synchro objects passed to a method and pass Motor objects instead .
9,079
def open ( self ) : return self . _framework . chain_return_value ( self . _ensure_file ( ) , self . get_io_loop ( ) , self )
Retrieve this file s attributes from the server .
9,080
def find ( self , * args , ** kwargs ) : cursor = self . delegate . find ( * args , ** kwargs ) grid_out_cursor = create_class_with_framework ( AgnosticGridOutCursor , self . _framework , self . __module__ ) return grid_out_cursor ( cursor , self . collection )
Find and return the files collection documents that match filter .
9,081
def get_motor_attr ( motor_class , name , * defargs ) : attr = safe_getattr ( motor_class , name ) full_name = '%s.%s.%s' % ( motor_class . __module__ , motor_class . __name__ , name ) full_name_legacy = 'motor.%s.%s.%s' % ( motor_class . __module__ , motor_class . __name__ , name ) has_coroutine_annotation = getattr (...
If any Motor attributes can t be accessed grab the equivalent PyMongo attribute . While we re at it store some info about each attribute in the global motor_info dict .
9,082
def get_attached_instruments ( self , expected : Dict [ Mount , str ] ) -> Dict [ Mount , Dict [ str , Optional [ str ] ] ] : to_return : Dict [ Mount , Dict [ str , Optional [ str ] ] ] = { } for mount in Mount : found_model = self . _smoothie_driver . read_pipette_model ( mount . name . lower ( ) ) found_id = self . ...
Find the instruments attached to our mounts .
9,083
def probe ( self , axis : str , distance : float ) -> Dict [ str , float ] : return self . _smoothie_driver . probe_axis ( axis , distance )
Run a probe and return the new position dict
9,084
async def delay ( self , duration_s : int ) : self . pause ( ) await asyncio . sleep ( duration_s ) self . resume ( )
Pause and sleep
9,085
def init_pipette ( ) : global session pipette_info = set_current_mount ( session . adapter , session ) pipette = pipette_info [ 'pipette' ] res = { } if pipette : session . current_model = pipette_info [ 'model' ] if not feature_flags . use_protocol_api_v2 ( ) : mount = pipette . mount session . current_mount = mount e...
Finds pipettes attached to the robot currently and chooses the correct one to add to the session .
9,086
def set_current_mount ( hardware , session ) : pipette = None right_channel = None left_channel = None right_pipette , left_pipette = get_pipettes ( hardware ) if right_pipette : if not feature_flags . use_protocol_api_v2 ( ) : right_channel = right_pipette . channels else : right_channel = right_pipette . get ( 'chann...
Choose the pipette in which to execute commands . If there is no pipette or it is uncommissioned the pipette is not mounted .
9,087
async def attach_tip ( data ) : global session tip_length = data . get ( 'tipLength' ) if not tip_length : message = 'Error: "tipLength" must be specified in request' status = 400 else : if not feature_flags . use_protocol_api_v2 ( ) : pipette = session . pipettes [ session . current_mount ] if pipette . tip_attached :...
Attach a tip to the current pipette
9,088
async def detach_tip ( data ) : global session if not feature_flags . use_protocol_api_v2 ( ) : pipette = session . pipettes [ session . current_mount ] if not pipette . tip_attached : log . warning ( 'detach tip called with no tip' ) pipette . _remove_tip ( session . tip_length ) else : session . adapter . remove_tip ...
Detach the tip from the current pipette
9,089
async def run_jog ( data ) : axis = data . get ( 'axis' ) direction = data . get ( 'direction' ) step = data . get ( 'step' ) if axis not in ( 'x' , 'y' , 'z' ) : message = '"axis" must be "x", "y", or "z"' status = 400 elif direction not in ( - 1 , 1 ) : message = '"direction" must be -1 or 1' status = 400 elif step i...
Allow the user to jog the selected pipette around the deck map
9,090
async def move ( data ) : global session point_name = data . get ( 'point' ) point = safe_points ( ) . get ( point_name ) if point and len ( point ) == 3 : if not feature_flags . use_protocol_api_v2 ( ) : pipette = session . pipettes [ session . current_mount ] channels = pipette . channels if not channels == 1 : x = p...
Allow the user to move the selected pipette to a specific point
9,091
async def save_xy ( data ) : global session valid_points = list ( session . points . keys ( ) ) point = data . get ( 'point' ) if point not in valid_points : message = 'point must be one of {}' . format ( valid_points ) status = 400 elif not session . current_mount : message = "Mount must be set before calibrating" sta...
Save the current XY values for the calibration data
9,092
async def save_z ( data ) : if not session . tip_length : message = "Tip length must be set before calibrating" status = 400 else : if not feature_flags . use_protocol_api_v2 ( ) : mount = 'Z' if session . current_mount == 'left' else 'A' actual_z = position ( mount , session . adapter ) [ - 1 ] length_offset = pipette...
Save the current Z height value for the calibration data
9,093
async def release ( data ) : global session if not feature_flags . use_protocol_api_v2 ( ) : session . adapter . remove_instrument ( 'left' ) session . adapter . remove_instrument ( 'right' ) else : session . adapter . cache_instruments ( ) session = None return web . json_response ( { "message" : "calibration session ...
Release a session
9,094
async def dispatch ( request ) : if session : message = '' data = await request . json ( ) try : log . info ( "Dispatching {}" . format ( data ) ) _id = data . get ( 'token' ) if not _id : message = '"token" field required for calibration requests' raise AssertionError command = data . get ( 'command' ) if not command ...
Routes commands to subhandlers based on the command field in the body .
9,095
def _serial_poller ( self ) : while True : _next = dict ( self . _poller . poll ( POLLING_FREQUENCY_MS ) ) if self . _halt_read_file . fileno ( ) in _next : log . debug ( "Poller [{}]: halt" . format ( hash ( self ) ) ) self . _halt_read_file . read ( ) break elif self . _connection . fileno ( ) in _next : log . debug ...
Priority - sorted list of checks
9,096
def disconnect ( self ) : if self . _poll_stop_event : self . _poll_stop_event . set ( ) if self . _driver : if self . status != 'idle' : self . deactivate ( ) self . _driver . disconnect ( )
Disconnect from the serial port
9,097
def temp_connect ( self , hardware : hc . API ) : old_hw = self . _hw_manager . hardware try : self . _hw_manager . set_hw ( hardware ) yield self finally : self . _hw_manager . set_hw ( old_hw )
Connect temporarily to the specified hardware controller .
9,098
def connect ( self , hardware : hc . API ) : self . _hw_manager . set_hw ( hardware ) self . _hw_manager . hardware . cache_instruments ( )
Connect to a running hardware API .
9,099
def load_labware ( self , labware_obj : Labware , location : types . DeckLocation ) -> Labware : self . _deck_layout [ location ] = labware_obj return labware_obj
Specify the presence of a piece of labware on the OT2 deck .