idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
32,000 | def _start_remaining_containers ( self , containers_remaining , tool_d ) : s_containers = [ ] f_containers = [ ] for container in containers_remaining : s_containers , f_containers = self . _start_container ( container , tool_d , s_containers , f_containers ) return ( s_containers , f_containers ) | Select remaining containers that didn t have priorities to start |
32,001 | def _start_container ( self , container , tool_d , s_containers , f_containers ) : section = tool_d [ container ] [ 'section' ] del tool_d [ container ] [ 'section' ] manifest = Template ( self . manifest ) try : c = self . d_client . containers . get ( container ) c . start ( ) s_containers . append ( container ) mani... | Start container that was passed in and return status |
32,002 | def repo_commits ( self , repo ) : commits = [ ] try : status = self . path_dirs . apply_path ( repo ) if status [ 0 ] : cwd = status [ 1 ] else : self . logger . error ( 'apply_path failed. Exiting repo_commits with' ' status: ' + str ( status ) ) return status status = self . repo_branches ( repo ) if status [ 0 ] : ... | Get the commit IDs for all of the branches of a repository |
32,003 | def repo_branches ( self , repo ) : branches = [ ] try : status = self . path_dirs . apply_path ( repo ) if status [ 0 ] : cwd = status [ 1 ] else : self . logger . error ( 'apply_path failed. Exiting repo_branches' ' with status ' + str ( status ) ) return status branch_output = check_output ( shlex . split ( 'git bra... | Get the branches of a repository |
32,004 | def repo_tools ( self , repo , branch , version ) : try : tools = [ ] status = self . path_dirs . apply_path ( repo ) if status [ 0 ] : cwd = status [ 1 ] else : self . logger . error ( 'apply_path failed. Exiting repo_tools with' ' status: ' + str ( status ) ) return status status = ( True , None ) if status [ 0 ] : p... | Get available tools for a repository branch at a version |
32,005 | def change_forms ( self , * args , ** keywords ) : try : self . parentApp . switchFormPrevious ( ) except Exception as e : self . parentApp . switchForm ( 'MAIN' ) | Checks which form is currently displayed and toggles to the other one |
32,006 | def capture_logger ( name ) : import logging logger = logging . getLogger ( name ) try : import StringIO stream = StringIO . StringIO ( ) except ImportError : from io import StringIO stream = StringIO ( ) handler = logging . StreamHandler ( stream ) logger . addHandler ( handler ) try : yield stream finally : logger . ... | Context manager to capture a logger output with a StringIO stream . |
32,007 | def setNeutral ( self , aMathObject , deltaName = "origin" ) : self . _neutral = aMathObject self . addDelta ( Location ( ) , aMathObject - aMathObject , deltaName , punch = False , axisOnly = True ) | Set the neutral object . |
32,008 | def getAxisNames ( self ) : s = { } for l , x in self . items ( ) : s . update ( dict . fromkeys ( [ k for k , v in l ] , None ) ) return set ( s . keys ( ) ) | Collect a set of axis names from all deltas . |
32,009 | def _collectAxisPoints ( self ) : for l , ( value , deltaName ) in self . items ( ) : location = Location ( l ) name = location . isOnAxis ( ) if name is not None and name is not False : if name not in self . _axes : self . _axes [ name ] = [ ] if l not in self . _axes [ name ] : self . _axes [ name ] . append ( l ) re... | Return a dictionary with all on - axis locations . |
32,010 | def _collectOffAxisPoints ( self ) : offAxis = { } for l , ( value , deltaName ) in self . items ( ) : location = Location ( l ) name = location . isOnAxis ( ) if name is None or name is False : offAxis [ l ] = 1 return list ( offAxis . keys ( ) ) | Return a dictionary with all off - axis locations . |
32,011 | def collectLocations ( self ) : pts = [ ] for l , ( value , deltaName ) in self . items ( ) : pts . append ( Location ( l ) ) return pts | Return a dictionary with all objects . |
32,012 | def _allLocations ( self ) : l = [ ] for locationTuple in self . keys ( ) : l . append ( Location ( locationTuple ) ) return l | Return a list of all locations of all objects . |
32,013 | def _accumulateFactors ( self , aLocation , deltaLocation , limits , axisOnly ) : relative = [ ] deltaAxis = deltaLocation . isOnAxis ( ) if deltaAxis is None : relative . append ( 1 ) elif deltaAxis : deltasOnSameAxis = self . _axes . get ( deltaAxis , [ ] ) d = ( ( deltaAxis , 0 ) , ) if d not in deltasOnSameAxis : d... | Calculate the factors of deltaLocation towards aLocation |
32,014 | def _calcOnAxisFactor ( self , aLocation , deltaAxis , deltasOnSameAxis , deltaLocation ) : if deltaAxis == "origin" : f = 0 v = 0 else : f = aLocation [ deltaAxis ] v = deltaLocation [ deltaAxis ] i = [ ] iv = { } for value in deltasOnSameAxis : iv [ Location ( value ) [ deltaAxis ] ] = 1 i = sorted ( iv . keys ( ) ) ... | Calculate the on - axis factors . |
32,015 | def _calcOffAxisFactor ( self , aLocation , deltaLocation , limits ) : relative = [ ] for dim in limits . keys ( ) : f = aLocation [ dim ] v = deltaLocation [ dim ] mB , M , mA = limits [ dim ] r = 0 if mA is not None and v > mA : relative . append ( 0 ) continue elif mB is not None and v < mB : relative . append ( 0 )... | Calculate the off - axis factors . |
32,016 | def biasFromLocations ( locs , preferOrigin = True ) : dims = { } locs . sort ( ) for l in locs : for d in l . keys ( ) : if not d in dims : dims [ d ] = [ ] v = l [ d ] if type ( v ) == tuple : dims [ d ] . append ( v [ 0 ] ) dims [ d ] . append ( v [ 1 ] ) else : dims [ d ] . append ( v ) candidate = Location ( ) for... | Find the vector that translates the whole system to the origin . |
32,017 | def getType ( self , short = False ) : if self . isOrigin ( ) : return "origin" t = [ ] onAxis = self . isOnAxis ( ) if onAxis is False : if short : t . append ( "off-axis" ) else : t . append ( "off-axis, " + " " . join ( self . getActiveAxes ( ) ) ) else : if short : t . append ( "on-axis" ) else : t . append ( "on-a... | Return a string describing the type of the location i . e . origin on axis off axis etc . |
32,018 | def distance ( self , other = None ) : t = 0 if other is None : other = self . __class__ ( ) for axisName in set ( self . keys ( ) ) | set ( other . keys ( ) ) : t += ( other . get ( axisName , 0 ) - self . get ( axisName , 0 ) ) ** 2 return math . sqrt ( t ) | Return the geometric distance to the other location . If no object is provided this will calculate the distance to the origin . |
32,019 | def connections ( self , wait ) : while wait : try : params = pika . ConnectionParameters ( host = self . rmq_host , port = self . rmq_port ) connection = pika . BlockingConnection ( params ) self . channel = connection . channel ( ) self . channel . exchange_declare ( exchange = 'topic_recs' , exchange_type = 'topic' ... | wait for connections to both rabbitmq and elasticsearch to be made before binding a routing key to a channel and sending messages to elasticsearch |
32,020 | def callback ( self , ch , method , properties , body ) : index = method . routing_key . split ( '.' ) [ 1 ] index = index . replace ( '/' , '-' ) failed = False body = str ( body ) try : doc = json . loads ( body ) except Exception as e : try : body = body . strip ( ) . replace ( '"' , '\"' ) body = '{"log":"' + body ... | callback triggered on rabiitmq message received and sends it to an elasticsearch index |
32,021 | def start ( self ) : self . connections ( True ) binding_keys = sys . argv [ 1 : ] if not binding_keys : print ( sys . stderr , 'Usage: {0!s} [binding_key]...' . format ( sys . argv [ 0 ] ) ) sys . exit ( 0 ) for binding_key in binding_keys : self . channel . queue_bind ( exchange = 'topic_recs' , queue = self . queue_... | start the channel listener and start consuming messages |
32,022 | def consume ( self ) : print ( ' [*] Waiting for logs. To exit press CTRL+C' ) self . channel . basic_consume ( self . queue_name , self . callback ) self . channel . start_consuming ( ) | start consuming rabbitmq messages |
32,023 | def backup ( self ) : status = ( True , None ) backup_name = ( '.vent-backup-' + '-' . join ( Timestamp ( ) . split ( ' ' ) ) ) backup_dir = join ( expanduser ( '~' ) , backup_name ) backup_manifest = join ( backup_dir , 'backup_manifest.cfg' ) backup_vcfg = join ( backup_dir , 'backup_vcfg.cfg' ) manifest = self . man... | Saves the configuration information of the current running vent instance to be used for restoring at a later time |
32,024 | def reset ( self ) : status = ( True , None ) error_message = '' try : c_list = set ( self . d_client . containers . list ( filters = { 'label' : 'vent' } , all = True ) ) for c in c_list : c . remove ( force = True ) except Exception as e : error_message += 'Error removing Vent containers: ' + str ( e ) + '\n' try : i... | Factory reset all of Vent s user data containers and images |
32,025 | def get_configure ( self , repo = None , name = None , groups = None , main_cfg = False ) : constraints = locals ( ) del constraints [ 'main_cfg' ] status = ( True , None ) template_dict = { } return_str = '' if main_cfg : vent_cfg = Template ( self . vent_config ) for section in vent_cfg . sections ( ) [ 1 ] : templat... | Get the vent . template settings for a given tool by looking at the plugin_manifest |
32,026 | def repo_values ( self ) : branches = [ ] commits = { } m_helper = Tools ( ) status = m_helper . repo_branches ( self . parentApp . repo_value [ 'repo' ] ) if status [ 0 ] : branches = status [ 1 ] status = m_helper . repo_commits ( self . parentApp . repo_value [ 'repo' ] ) if status [ 0 ] : r_commits = status [ 1 ] f... | Set the appropriate repo dir and get the branches and commits of it |
32,027 | def on_ok ( self ) : self . parentApp . repo_value [ 'versions' ] = { } self . parentApp . repo_value [ 'build' ] = { } for branch in self . branch_cb : if self . branch_cb [ branch ] . value : self . parentApp . repo_value [ 'versions' ] [ branch ] = self . commit_tc [ branch ] . values [ self . commit_tc [ branch ] .... | Take the branch commit and build selection and add them as plugins |
32,028 | def create ( self ) : self . add_handlers ( { '^T' : self . quit , '^Q' : self . quit } ) self . add ( npyscreen . Textfield , value = 'Add a plugin from a Git repository or an image from a ' 'Docker registry.' , editable = False , color = 'STANDOUT' ) self . add ( npyscreen . Textfield , value = 'For Git repositories,... | Create widgets for AddForm |
32,029 | def on_ok ( self ) : def popup ( thr , add_type , title ) : thr . start ( ) tool_str = 'Cloning repository...' if add_type == 'image' : tool_str = 'Pulling image...' npyscreen . notify_wait ( tool_str , title = title ) while thr . is_alive ( ) : time . sleep ( 1 ) return if self . image . value and self . link_name . v... | Add the repository |
32,030 | def toggle_view ( self , * args , ** kwargs ) : group_to_display = self . views . popleft ( ) self . cur_view . value = group_to_display for repo in self . tools_tc : for tool in self . tools_tc [ repo ] : t_groups = self . manifest . option ( tool , 'groups' ) [ 1 ] if group_to_display not in t_groups and group_to_dis... | Toggles the view between different groups |
32,031 | def options ( self , section ) : if self . config . has_section ( section ) : return ( True , self . config . options ( section ) ) return ( False , 'Section: ' + section + ' does not exist' ) | Returns a list of options for a section |
32,032 | def option ( self , section , option ) : if self . config . has_section ( section ) : if self . config . has_option ( section , option ) : return ( True , self . config . get ( section , option ) ) return ( False , 'Option: ' + option + ' does not exist' ) return ( False , 'Section: ' + section + ' does not exist' ) | Returns the value of the option |
32,033 | def add_section ( self , section ) : if not self . config . has_section ( section ) : self . config . add_section ( section ) return ( True , self . config . sections ( ) ) return ( False , 'Section: ' + section + ' already exists' ) | If section exists returns log otherwise adds section and returns list of sections . |
32,034 | def add_option ( self , section , option , value = None ) : if not self . config . has_section ( section ) : message = self . add_section ( section ) if not message [ 0 ] : return message if not self . config . has_option ( section , option ) : if value : self . config . set ( section , option , value ) else : self . c... | Creates an option for a section . If the section does not exist it will create the section . |
32,035 | def del_section ( self , section ) : if self . config . has_section ( section ) : self . config . remove_section ( section ) return ( True , self . config . sections ( ) ) return ( False , 'Section: ' + section + ' does not exist' ) | Deletes a section if it exists |
32,036 | def del_option ( self , section , option ) : if self . config . has_section ( section ) : if self . config . has_option ( section , option ) : self . config . remove_option ( section , option ) return ( True , self . config . options ( section ) ) return ( False , 'Option: ' + option + ' does not exist' ) return ( Fals... | Deletes an option if the section and option exist |
32,037 | def set_option ( self , section , option , value ) : if self . config . has_section ( section ) : self . config . set ( section , option , value ) return ( True , self . config . options ( section ) ) return ( False , 'Section: ' + section + ' does not exist' ) | Sets an option to a value in the given section . Option is created if it does not already exist |
32,038 | def constrain_opts ( self , constraint_dict , options ) : constraints = { } for constraint in constraint_dict : if constraint != 'self' : if ( constraint_dict [ constraint ] or constraint_dict [ constraint ] == '' ) : constraints [ constraint ] = constraint_dict [ constraint ] results = self . constrained_sections ( co... | Return result of constraints and options against a template |
32,039 | def list_tools ( self ) : tools = [ ] exists , sections = self . sections ( ) if exists : for section in sections : options = { 'section' : section , 'built' : None , 'version' : None , 'repo' : None , 'branch' : None , 'name' : None , 'groups' : None , 'image_name' : None } for option in list ( options . keys ( ) ) : ... | Return list of tuples of all tools |
32,040 | def when_value_edited ( self , * args , ** kargs ) : if len ( self . value ) > self . instance_num : self . value . pop ( - 2 ) self . display ( ) | Overrided to prevent user from selecting too many instances |
32,041 | def safe_to_exit ( self , * args , ** kargs ) : if len ( self . value ) == self . instance_num : return True return False | Overrided to prevent user from exiting selection until they have selected the right amount of instances |
32,042 | def create ( self ) : self . add_handlers ( { '^E' : self . quit , '^Q' : self . quit } ) to_delete = self . old_instances - self . new_instances self . add ( npyscreen . Textfield , value = 'Select which instances to delete' ' (you must select ' + str ( to_delete ) + ' instance(s) to delete):' , editable = False , col... | Creates the necessary display for this form |
32,043 | def on_ok ( self ) : npyscreen . notify_wait ( 'Deleting instances given...' , title = 'In progress' ) shift_num = 1 to_update = [ ] for i , val in enumerate ( self . del_instances . values ) : t = val . split ( ':' ) section = self . display_to_section [ val ] prev_running = self . manifest . option ( section , 'runni... | Delete the instances that the user chose to delete |
32,044 | def on_post ( self , req , resp ) : resp . content_type = falcon . MEDIA_TEXT resp . status = falcon . HTTP_200 payload = { } if req . content_length : try : payload = json . load ( req . stream ) except Exception as e : resp . body = "(False, 'malformed payload')" return else : resp . body = "(False, 'malformed payloa... | Send a POST request with a docker container ID and it will be deleted . |
32,045 | def on_get ( self , req , resp ) : resp . content_type = falcon . MEDIA_TEXT resp . status = falcon . HTTP_200 try : containers = docker . from_env ( ) except Exception as e : resp . body = "(False, 'unable to connect to docker because: " + str ( e ) + "')" return container_list = [ ] try : for c in containers . contai... | Send a GET request to get the list of all of the filter containers |
32,046 | def on_get ( self , req , resp ) : resp . content_type = falcon . MEDIA_TEXT resp . status = falcon . HTTP_200 try : d_client = docker . from_env ( ) except Exception as e : resp . body = "(False, 'unable to connect to docker because: " + str ( e ) + "')" return nics = '' try : nics = d_client . containers . run ( 'cyb... | Send a GET request to get the list of all available network interfaces |
32,047 | def create ( self ) : self . add_handlers ( { '^Q' : self . quit } ) self . add ( npyscreen . TitleText , name = self . title , editable = False ) self . add ( npyscreen . MultiLineEdit , editable = False , value = self . text , max_width = 75 , slow_scroll = True ) self . m2 = self . add_menu ( name = 'About Vent' , s... | Overridden to add handlers and content |
32,048 | def create ( self ) : self . add_handlers ( { '^T' : self . quit } ) self . add ( npyscreen . Textfield , value = 'Pick a version to restore from: ' , editable = False , color = 'STANDOUT' ) self . dir_select = self . add ( npyscreen . SelectOne , values = self . display_vals , scroll_exit = True , rely = 4 ) | Add backup files to select from |
32,049 | def on_ok ( self ) : if self . dir_select . value : npyscreen . notify_wait ( 'In the process of restoring' , title = 'Restoring...' ) status = self . restore ( self . dirs [ self . dir_select . value [ 0 ] ] ) if status [ 0 ] : npyscreen . notify_confirm ( 'Status of restore:\n' + status [ 1 ] ) else : npyscreen . not... | Perform restoration on the backup file selected |
32,050 | def ensure_dir ( path ) : try : makedirs ( path ) except OSError as e : if e . errno == errno . EEXIST and isdir ( path ) : return ( True , 'exists' ) else : return ( False , e ) return ( True , path ) | Tries to create directory if fails checks if path already exists |
32,051 | def ensure_file ( path ) : try : exists = isfile ( path ) if not exists : with open ( path , 'w+' ) as fname : fname . write ( 'initialized' ) return ( True , path ) return ( True , 'exists' ) except OSError as e : return ( False , e ) | Checks if file exists if fails tries to create file |
32,052 | def host_config ( self ) : if platform . system ( ) == 'Darwin' : default_file_dir = join ( expanduser ( '~' ) , 'vent_files' ) else : default_file_dir = '/opt/vent_files' status = self . ensure_dir ( default_file_dir ) if not isfile ( self . cfg_file ) : config = Template ( template = self . cfg_file ) sections = { 'm... | Ensure the host configuration file exists |
32,053 | def apply_path ( self , repo ) : try : if repo . endswith ( '.git' ) : repo = repo . split ( '.git' ) [ 0 ] org , name = repo . split ( '/' ) [ - 2 : ] path = join ( self . plugins_dir , org , name ) cwd = getcwd ( ) self . ensure_dir ( path ) chdir ( path ) status = ( True , cwd , path ) except Exception as e : status... | Set path to where the repo is and return original path |
32,054 | def get_path ( self , repo ) : if repo . endswith ( '.git' ) : repo = repo . split ( '.git' ) [ 0 ] org , name = repo . split ( '/' ) [ - 2 : ] path = self . plugins_dir path = join ( path , org , name ) return path , org , name | Return the path for the repo |
32,055 | def override_config ( self , path ) : status = ( True , None ) config_override = False try : c_dict = { } if exists ( self . plugin_config_file ) : with open ( self . plugin_config_file , 'r' ) as config_file : c_dict = yaml . safe_load ( config_file . read ( ) ) check_c_dict = c_dict . copy ( ) for tool in check_c_dic... | Will take a yml located in home directory titled . plugin_config . yml . It ll then override using the yml the plugin s config file |
32,056 | def Logs ( c_type = None , grep_list = None ) : def get_logs ( logs , log_entries ) : try : for log in logs : if str ( container . name ) in log_entries : log_entries [ str ( container . name ) ] . append ( log ) else : log_entries [ str ( container . name ) ] = [ log ] except Exception as e : logger . error ( 'Unable ... | Generically filter logs stored in log containers |
32,057 | def Version ( ) : version = '' try : version = pkg_resources . require ( 'vent' ) [ 0 ] . version if not version . startswith ( 'v' ) : version = 'v' + version except Exception as e : version = 'Error: ' + str ( e ) return version | Get Vent version |
32,058 | def Docker ( ) : docker_info = { 'server' : { } , 'env' : '' , 'type' : '' , 'os' : '' } try : d_client = docker . from_env ( ) docker_info [ 'server' ] = d_client . version ( ) except Exception as e : logger . error ( "Can't get docker info " + str ( e ) ) system = System ( ) docker_info [ 'os' ] = system if 'DOCKER_M... | Get Docker setup information |
32,059 | def Containers ( vent = True , running = True , exclude_labels = None ) : containers = [ ] try : d_client = docker . from_env ( ) if vent : c = d_client . containers . list ( all = not running , filters = { 'label' : 'vent' } ) else : c = d_client . containers . list ( all = not running ) for container in c : include =... | Get containers that are created by default limit to vent containers that are running |
32,060 | def Cpu ( ) : cpu = 'Unknown' try : cpu = str ( multiprocessing . cpu_count ( ) ) except Exception as e : logger . error ( "Can't access CPU count' " + str ( e ) ) return cpu | Get number of available CPUs |
32,061 | def Gpu ( pull = False ) : gpu = ( False , '' ) try : image = 'nvidia/cuda:8.0-runtime' image_name , tag = image . split ( ':' ) d_client = docker . from_env ( ) nvidia_image = d_client . images . list ( name = image ) if pull and len ( nvidia_image ) == 0 : try : d_client . images . pull ( image_name , tag = tag ) nvi... | Check for support of GPUs and return what s available |
32,062 | def Images ( vent = True ) : images = [ ] try : d_client = docker . from_env ( ) if vent : i = d_client . images . list ( filters = { 'label' : 'vent' } ) else : i = d_client . images . list ( ) for image in i : images . append ( ( image . tags [ 0 ] , image . short_id ) ) except Exception as e : logger . error ( 'Some... | Get images that are build by default limit to vent images |
32,063 | def ManifestTools ( ** kargs ) : path_dirs = PathDirs ( ** kargs ) manifest = join ( path_dirs . meta_dir , 'plugin_manifest.cfg' ) template = Template ( template = manifest ) tools = template . sections ( ) return tools [ 1 ] | Get tools that exist in the manifest |
32,064 | def ToolMatches ( tools = None , version = 'HEAD' ) : matches = [ ] if tools : for tool in tools : match_version = version if tool [ 1 ] != '' : match_version = tool [ 1 ] match = '' if tool [ 0 ] . endswith ( '/' ) : match = tool [ 0 ] [ : - 1 ] elif tool [ 0 ] != '.' : match = tool [ 0 ] if not match . startswith ( '... | Get the tools paths and versions that were specified |
32,065 | def Timestamp ( ) : timestamp = '' try : timestamp = str ( datetime . datetime . now ( ) ) + ' UTC' except Exception as e : logger . error ( 'Could not get current time ' + str ( e ) ) return timestamp | Get the current datetime in UTC |
32,066 | def Uptime ( ) : uptime = '' try : uptime = check_output ( [ 'uptime' ] , close_fds = True ) . decode ( 'utf-8' ) [ 1 : ] except Exception as e : logger . error ( 'Could not get current uptime ' + str ( e ) ) return uptime | Get the current uptime information |
32,067 | def DropLocation ( ) : template = Template ( template = PathDirs ( ) . cfg_file ) drop_loc = template . option ( 'main' , 'files' ) [ 1 ] drop_loc = expanduser ( drop_loc ) drop_loc = abspath ( drop_loc ) return ( True , drop_loc ) | Get the directory that file drop is watching |
32,068 | def ParsedSections ( file_val ) : try : template_dict = { } cur_section = '' for val in file_val . split ( '\n' ) : val = val . strip ( ) if val != '' : section_match = re . match ( r'\[.+\]' , val ) if section_match : cur_section = section_match . group ( ) [ 1 : - 1 ] template_dict [ cur_section ] = { } else : option... | Get the sections and options of a file returned as a dictionary |
32,069 | def Dependencies ( tools ) : dependencies = [ ] if tools : path_dirs = PathDirs ( ) man = Template ( join ( path_dirs . meta_dir , 'plugin_manifest.cfg' ) ) for section in man . sections ( ) [ 1 ] : running = man . option ( section , 'running' ) if not running [ 0 ] or running [ 1 ] != 'yes' : continue t_name = man . o... | Takes in a list of tools that are being updated and returns any tools that depend on linking to them |
32,070 | def repo_tools ( self , branch ) : tools = [ ] m_helper = Tools ( ) repo = self . parentApp . repo_value [ 'repo' ] version = self . parentApp . repo_value [ 'versions' ] [ branch ] status = m_helper . repo_tools ( repo , branch , version ) if status [ 0 ] : r_tools = status [ 1 ] for tool in r_tools : tools . append (... | Set the appropriate repo dir and get the tools available of it |
32,071 | def create ( self ) : self . add_handlers ( { '^Q' : self . quit } ) self . add ( npyscreen . TitleText , name = 'Select which tools to add from each branch selected:' , editable = False ) self . add ( npyscreen . Textfield , value = 'NOTE tools you have already installed will be ignored' , color = 'STANDOUT' , editabl... | Update with current tools for each branch at the version chosen |
32,072 | def on_ok ( self ) : def diff ( first , second ) : second = set ( second ) return [ item for item in first if item not in second ] def popup ( original_tools , branch , thr , title ) : thr . start ( ) tool_str = 'Adding tools...' npyscreen . notify_wait ( tool_str , title = title ) while thr . is_alive ( ) : tools = di... | Take the tool selections and add them as plugins |
32,073 | def while_waiting ( self ) : time . sleep ( 0.1 ) self . addfield . value = Timestamp ( ) self . addfield . display ( ) self . addfield2 . value = Uptime ( ) self . addfield2 . display ( ) self . addfield3 . value = str ( len ( Containers ( ) ) ) + ' running' if len ( Containers ( ) ) > 0 : self . addfield3 . labelColo... | Update fields periodically if nothing is happening |
32,074 | def add_form ( self , form , form_name , form_args ) : self . parentApp . addForm ( form_name , form , ** form_args ) self . parentApp . change_form ( form_name ) return | Add new form and switch to it |
32,075 | def remove_forms ( self , form_names ) : for form in form_names : try : self . parentApp . removeForm ( form ) except Exception as e : pass return | Remove all forms supplied |
32,076 | def perform_action ( self , action ) : form = ToolForm s_action = form_action = action . split ( '_' ) [ 0 ] form_name = s_action . title ( ) + ' tools' cores = False a_type = 'containers' forms = [ action . upper ( ) + 'TOOLS' ] form_args = { 'color' : 'CONTROL' , 'names' : [ s_action ] , 'name' : form_name , 'action_... | Perform actions in the api from the CLI |
32,077 | def system_commands ( self , action ) : if action == 'backup' : status = self . api_action . backup ( ) if status [ 0 ] : notify_confirm ( 'Vent backup successful' ) else : notify_confirm ( 'Vent backup could not be completed' ) elif action == 'start' : status = self . api_action . start ( ) if status [ 0 ] : notify_co... | Perform system commands |
32,078 | def Logger ( name , ** kargs ) : path_dirs = PathDirs ( ** kargs ) logging . captureWarnings ( True ) logger = logging . getLogger ( name ) logger . setLevel ( logging . INFO ) handler = logging . handlers . WatchedFileHandler ( os . path . join ( path_dirs . meta_dir , 'vent.log' ) ) handler . setLevel ( logging . INF... | Create and return logger |
32,079 | def create ( self ) : if self . vent_cfg : self . add ( npyscreen . Textfield , value = '# when configuring external' ' services make sure to do so' , editable = False ) self . add ( npyscreen . Textfield , value = '# in the form of Service = {"setting": "value"}' , editable = False ) self . add ( npyscreen . Textfield... | Create multi - line widget for editing |
32,080 | def locate_arcgis ( ) : try : key = _winreg . OpenKey ( _winreg . HKEY_LOCAL_MACHINE , 'SOFTWARE\\Wow6432Node\\ESRI\\ArcGIS' , 0 ) version = _winreg . QueryValueEx ( key , "RealVersion" ) [ 0 ] [ : 4 ] key_string = "SOFTWARE\\Wow6432Node\\ESRI\\Desktop{0}" . format ( version ) desktop_key = _winreg . OpenKey ( _winreg ... | Find the path to the ArcGIS Desktop installation . |
32,081 | def pop ( self ) : method_frame , header , body = self . server . basic_get ( queue = self . key ) if body : return self . _decode_request ( body ) | Pop a request |
32,082 | def change_dir ( ) : try : d = os . environ [ 'HADOOPY_CHDIR' ] sys . stderr . write ( 'HADOOPY: Trying to chdir to [%s]\n' % d ) except KeyError : pass else : try : os . chdir ( d ) except OSError : sys . stderr . write ( 'HADOOPY: Failed to chdir to [%s]\n' % d ) | Change the local directory if the HADOOPY_CHDIR environmental variable is provided |
32,083 | def disable_stdout_buffering ( ) : stdout_orig = sys . stdout sys . stdout = os . fdopen ( sys . stdout . fileno ( ) , 'w' , 0 ) return stdout_orig | This turns off stdout buffering so that outputs are immediately materialized and log messages show up before the program exits |
32,084 | def counter ( group , counter , amount = 1 , err = None ) : if not err : err = _err err ( "reporter:counter:%s,%s,%s\n" % ( group , counter , str ( amount ) ) ) | Output a counter update that is displayed in the Hadoop web interface |
32,085 | def rewriteInstallNameCommand ( self , loadcmd ) : if self . id_cmd is not None : self . rewriteDataForCommand ( self . id_cmd , loadcmd ) return True return False | Rewrite the load command of this dylib |
32,086 | def rewriteLoadCommands ( self , changefunc ) : data = changefunc ( self . parent . filename ) changed = False if data is not None : if self . rewriteInstallNameCommand ( data . encode ( sys . getfilesystemencoding ( ) ) ) : changed = True for idx , name , filename in self . walkRelocatables ( ) : data = changefunc ( f... | Rewrite the load commands based upon a change dictionary |
32,087 | def sizeof ( s ) : if hasattr ( s , '_size_' ) : return s . _size_ elif isinstance ( s , bytes ) : return len ( s ) raise ValueError ( s ) | Return the size of an object when packed |
32,088 | def pypackable ( name , pytype , format ) : size , items = _formatinfo ( format ) return type ( Packable ) ( name , ( pytype , Packable ) , { '_format_' : format , '_size_' : size , '_items_' : items , } ) | Create a mix - in class with a python type and a Packable with the given struct format |
32,089 | def _formatinfo ( format ) : size = struct . calcsize ( format ) return size , len ( struct . unpack ( format , B ( '\x00' ) * size ) ) | Calculate the size and number of items in a struct format . |
32,090 | def addSuffixToExtensions ( toc ) : new_toc = TOC ( ) for inm , fnm , typ in toc : if typ in ( 'EXTENSION' , 'DEPENDENCY' ) : binext = os . path . splitext ( fnm ) [ 1 ] if not os . path . splitext ( inm ) [ 1 ] == binext : inm = inm + binext new_toc . append ( ( inm , fnm , typ ) ) return new_toc | Returns a new TOC with proper library suffix for EXTENSION items . |
32,091 | def _check_guts_eq ( attr , old , new , last_build ) : if old != new : logger . info ( "building because %s changed" , attr ) return True return False | rebuild is required if values differ |
32,092 | def _check_guts_toc_mtime ( attr , old , toc , last_build , pyc = 0 ) : for ( nm , fnm , typ ) in old : if mtime ( fnm ) > last_build : logger . info ( "building because %s changed" , fnm ) return True elif pyc and mtime ( fnm [ : - 1 ] ) > last_build : logger . info ( "building because %s changed" , fnm [ : - 1 ] ) re... | rebuild is required if mtimes of files listed in old toc are newer than ast_build |
32,093 | def _check_guts_toc ( attr , old , toc , last_build , pyc = 0 ) : return ( _check_guts_eq ( attr , old , toc , last_build ) or _check_guts_toc_mtime ( attr , old , toc , last_build , pyc = pyc ) ) | rebuild is required if either toc content changed if mtimes of files listed in old toc are newer than ast_build |
32,094 | def set_dependencies ( analysis , dependencies , path ) : for toc in ( analysis . binaries , analysis . datas ) : for i , tpl in enumerate ( toc ) : if not tpl [ 1 ] in dependencies . keys ( ) : logger . info ( "Adding dependency %s located in %s" % ( tpl [ 1 ] , path ) ) dependencies [ tpl [ 1 ] ] = path else : dep_pa... | Syncronize the Analysis result with the needed dependencies . |
32,095 | def get_guts ( self , last_build , missing = 'missing or bad' ) : try : data = _load_data ( self . out ) except : logger . info ( "building because %s %s" , os . path . basename ( self . out ) , missing ) return None if len ( data ) != len ( self . GUTS ) : logger . info ( "building because %s is bad" , self . outnm ) ... | returns None if guts have changed |
32,096 | def fixMissingPythonLib ( self , binaries ) : if is_aix : names = ( 'libpython%d.%d.a' % sys . version_info [ : 2 ] , ) elif is_unix : names = ( 'libpython%d.%d.so' % sys . version_info [ : 2 ] , ) elif is_darwin : names = ( 'Python' , 'libpython%d.%d.dylib' % sys . version_info [ : 2 ] ) else : return for ( nm , fnm ,... | Add the Python library if missing from the binaries . |
32,097 | def gen_random_key ( size = 32 ) : import os if hasattr ( os , "urandom" ) : return os . urandom ( size ) try : from Crypto . Util . randpool import RandomPool from Crypto . Hash import SHA256 return RandomPool ( hash = SHA256 ) . get_bytes ( size ) except ImportError : print >> sys . stderr , "WARNING: The generated k... | Generate a cryptographically - secure random key . This is done by using Python 2 . 4 s os . urandom or PyCrypto . |
32,098 | def display ( self , mode = 'dot' ) : if mode == 'neato' : self . save_dot ( self . temp_neo ) neato_cmd = "%s -o %s %s" % ( self . neato , self . temp_dot , self . temp_neo ) os . system ( neato_cmd ) else : self . save_dot ( self . temp_dot ) plot_cmd = "%s %s" % ( self . dotty , self . temp_dot ) os . system ( plot_... | Displays the current graph via dotty |
32,099 | def node_style ( self , node , ** kwargs ) : if node not in self . edges : self . edges [ node ] = { } self . nodes [ node ] = kwargs | Modifies a node style to the dot representation . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.