Analyse the line of local resource of ``drbdadm status``
337502
def _add_res(line):
    '''
    
    '''
    global resource
    fields = line.strip().split()

    if resource:
        ret.append(resource)
        resource = {}

    resource["resource name"] = fields[0]
    resource["local role"] = fields[1].split(":")[1]
    resource["local volumes"] = []
    resource["peer nodes"] = []
520455
function getOnlineStatus(serverUrlOrServerUrlOptions) {
    if (serverUrlOrServerUrlOptions === void 0) { serverUrlOrServerUrlOptions = init.initOptions.serverUrl; }
    var serverUrl;
    if (_.isString(serverUrlOrServerUrlOptions)) {
        serverUrl = serverUrlOrServerUrlOptions;
    }
    else if (serverUrlOrServerUrlOptions) {
        serverUrl = serverUrlOrServerUrlOptions.serverUrl;
    }
    return server.Server.getInstance(serverUrl).serverInfos;
}
692520
def system_info(host=None,
                admin_username=None, admin_password=None,
                module=None):
    '''
    
    '''
    cmd = __execute_ret('getsysinfo', host=host,
                        admin_username=admin_username,
                        admin_password=admin_password,
                        module=module)

    if cmd['retcode'] != 0:
        log.warning('racadm returned an exit code of %s', cmd['retcode'])
        return cmd

    return __parse_drac(cmd['stdout'])
510067
def _get_parent(self):
        """"""
        _dir = os.path.dirname(self.path)
        if is_repo(_dir):
            return Local(_dir)
        else:
            return None
437534
def get_info(self):
        ''''''
        if self._min_disk:
            for path in self._resource_paths:
                usage = psutil.disk_usage(path)

                yield ResourceInfo(path, usage.free, self._min_disk)

        if self._min_memory:
            usage = psutil.virtual_memory()

            yield ResourceInfo(None, usage.available, self._min_memory)
1305107
def info(gandi, resource, stat):
    
    output_keys = ['hostname', 'state', 'cores', 'memory', 'console',
                   'datacenter', 'ip']
    justify = 14
    if stat is True:
        sampler = {'unit': 'hours', 'value': 1, 'function': 'max'}
        time_range = 3600 * 24
        query_vif = 'vif.bytes.all'
        query_vbd = 'vbd.bytes.all'

    resource = sorted(tuple(set(resource)))
    datacenters = gandi.datacenter.list()
    ret = []
    for num, item in enumerate(resource):
        if num:
            gandi.separator_line()
        vm = gandi.iaas.info(item)
        output_vm(gandi, vm, datacenters, output_keys, justify)
        ret.append(vm)
        for disk in vm['disks']:
            gandi.echo('')
            disk_out_keys = ['label', 'kernel_version', 'name', 'size']
            output_image(gandi, disk, datacenters, disk_out_keys, justify,
                         warn_deprecated=False)
        if stat is True:
            metrics_vif = gandi.metric.query(vm['id'], time_range, query_vif,
                                             'vm', sampler)
            metrics_vbd = gandi.metric.query(vm['id'], time_range, query_vbd,
                                             'vm', sampler)
            gandi.echo('')
            gandi.echo('vm network stats')
            output_metric(gandi, metrics_vif, 'direction', justify)
            gandi.echo('disk network stats')
            output_metric(gandi, metrics_vbd, 'direction', justify)

    return ret
658844
def check(self):
        

        #for path in self.path.values():
        #    if not os.path.exists(path):
        #        raise RuntimeError("File '{}' is missing".format(path))

        for tool in ('cd-hit', 'prank', 'hmmbuild', 'hmmpress', 'hmmscan', 'phmmer', 'mafft', 'meme'):
            if not self.pathfinder.exists(tool):
                raise RuntimeError("Dependency {} is missing".format(tool))
793417
def collect(self):
        
        performance_indicators = {
            'ns': 'network_send',
            'nr': 'network_receive',
            'dw': 'disk_write',
            'dr': 'disk_read',
            'al': 'activity_log',
            'bm': 'bit_map',
            'lo': 'local_count',
            'pe': 'pending',
            'ua': 'unacknowledged',
            'ap': 'application_pending',
            'ep': 'epochs',
            'wo': 'write_order',
            'oos': 'out_of_sync',
            'cs': 'connection_state',
            'ro': 'roles',
            'ds': 'disk_states'
        }

        results = dict()
        try:
            statusfile = open('/proc/drbd', 'r')
            current_resource = ''
            for line in statusfile:
                if re.search('version', line) is None:
                    if re.search(r' \d: cs', line):
                        matches = re.match(r' (\d): (cs:\w+) (ro:\w+/\w+) '
                                           '(ds:\w+/\w+) (\w{1}) .*', line)
                        current_resource = matches.group(1)
                        results[current_resource] = dict()
                    elif re.search(r'\sns:', line):
                        metrics = line.strip().split(" ")
                        for metric in metrics:
                            item, value = metric.split(":")
                            results[current_resource][
                                performance_indicators[item]] = value

                else:
                    continue
            statusfile.close()
        except IOError as errormsg:
            self.log.error("Can't read DRBD status file: {}".format(errormsg))
            return

        for resource in results.keys():
            for metric_name, metric_value in results[resource].items():
                if metric_value.isdigit():
                    self.publish(resource + "." + metric_name, metric_value)
                else:
                    continue
905511
function checkDependencies(req, res) {
                    var modelName = req.params.modelName,
                        id = req.params.documentId,
                        models = _.pluck(registry.models, 'model');

                    dependencies.check(models, modelName, id, function (err, depPair) {
                        if (err) throw err;
                        if (_.isEmpty(depPair)) return res.json(200, []);
                        var deps = depPair[1];
                        var lines = dependencies.depsToLines(deps);
                        return res.json(200, lines);
                    });
                }
287147
def get_load(jid):
    '''
    
    '''
    conn, mdb = _get_conn(ret=None)
    return mdb.jobs.find_one({'jid': jid}, {'_id': 0})
437486
def list_aggregated_resources(uri_prefix, opts = {})
      data, _status_code, _headers = list_aggregated_resources_with_http_info(uri_prefix, opts)
      return data
    end
766144
def check(self, radl):
        """"""

        if not radl.get_system_by_name(self.id):
            raise RADLParseException("Invalid system id in the deploy.", line=self.line)

        if self.vm_number < 0:
            raise RADLParseException("Invalid number of virtual machines to deploy.",
                                     line=self.line)
1052212
def status(name):
    '''
    
    '''
    # Get volume status
    root = _gluster_xml('volume status {0}'.format(name))
    if not _gluster_ok(root):
        # Most probably non-existing volume, the error output is logged
        # This return value is easy to test and intuitive
        return None

    ret = {'bricks': {}, 'nfs': {}, 'healers': {}}

    def etree_legacy_wrap(t):
        ret = _etree_to_dict(t)
        ret['online'] = (ret['status'] == '1')
        ret['host'] = ret['hostname']
        return ret

    # Build a hash to map hostname to peerid
    hostref = {}
    for node in _iter(root, 'node'):
        peerid = node.find('peerid').text
        hostname = node.find('hostname').text
        if hostname not in ('NFS Server', 'Self-heal Daemon'):
            hostref[peerid] = hostname

    for node in _iter(root, 'node'):
        hostname = node.find('hostname').text
        if hostname not in ('NFS Server', 'Self-heal Daemon'):
            path = node.find('path').text
            ret['bricks'][
                '{0}:{1}'.format(hostname, path)] = etree_legacy_wrap(node)
        elif hostname == 'NFS Server':
            peerid = node.find('peerid').text
            true_hostname = hostref[peerid]
            ret['nfs'][true_hostname] = etree_legacy_wrap(node)
        else:
            peerid = node.find('peerid').text
            true_hostname = hostref[peerid]
            ret['healers'][true_hostname] = etree_legacy_wrap(node)

    return ret
525152
def _check_file_io(self):
        
        folder = 'Model' + str(self.flags['RUN_NUM']) + '/'
        folder_restore = 'Model' + str(self.flags['MODEL_RESTORE']) + '/'
        self.flags['RESTORE_DIRECTORY'] = self.flags['SAVE_DIRECTORY'] + self.flags[
            'MODEL_DIRECTORY'] + folder_restore
        self.flags['LOGGING_DIRECTORY'] = self.flags['SAVE_DIRECTORY'] + self.flags[
            'MODEL_DIRECTORY'] + folder
        self.make_directory(self.flags['LOGGING_DIRECTORY'])
        sys.stdout = Logger(self.flags['LOGGING_DIRECTORY'] + 'ModelInformation.log')
        print(self.flags)
491603
def analyze_traceback(tb, inspection_level=None, limit=None):
    
    info = []
    tb_level = tb
    extracted_tb = traceback.extract_tb(tb, limit=limit)
    for ii, (filepath, line, module, code) in enumerate(extracted_tb):
        func_source, func_lineno = inspect.getsourcelines(tb_level.tb_frame)

        d = {"File": filepath,
             "Error Line Number": line,
             "Module": module,
             "Error Line": code,
             "Module Line Number": func_lineno,
             "Custom Inspection": {},
             "Source Code": ''}
        if inspection_level is None or len(extracted_tb) - ii <= inspection_level:
            # Perform advanced inspection on the last `inspection_level` tracebacks.
            d['Source Code'] = ''.join(func_source)
            d['Local Variables'] = get_local_references(tb_level)
            d['Object Variables'] = get_object_references(tb_level, d['Source Code'])
        tb_level = getattr(tb_level, 'tb_next', None)
        info.append(d)

    return info
244564
function lookForExternalDependenciesRES( _def, resources, depFile ) {
  if ( !_def ) return;
  try {
    const def = convertExternalDependencyDefinition( _def );
    for ( const dep of Object.keys( def ) ) {
      if ( def[ dep ] === "" ) {
        // `res: { "bob/foo.png": "" }` is equivalent to
        // `res: { "bob/foo.png": "bob/foo.png" }`
        def[ dep ] = dep;
      }
      const
      srcDep = Project.srcOrLibPath( `mod/${dep}` ) ||
        Project.srcOrLibPath( dep );
      if ( !srcDep ) {
        Fatal.fire(
          `Unable to find dependency file "${dep}" nor "mod/${dep}"!`,
          depFile.getAbsoluteFilePath()
        );
      }
      resources[ srcDep ] = Project.wwwPath( def[ dep ] );
    }
  } catch ( ex ) {
    Fatal.fire(
      `Unable to parse RES dependencies: ${JSON.stringify(_def)}!\n${ex}`,
      depFile
    );
  }
}
661091
def ProcessClientResourcesStats(self, client_id, status):
    
    if hasattr(status, "child_session_id"):
      flow_path = status.child_session_id
    else:
      flow_path = "aff4:/%s/flows/%s" % (status.client_id, status.flow_id)

    resources = rdf_client_stats.ClientResources()
    resources.client_id = client_id
    resources.session_id = flow_path
    resources.cpu_usage.user_cpu_time = status.cpu_time_used.user_cpu_time
    resources.cpu_usage.system_cpu_time = status.cpu_time_used.system_cpu_time
    resources.network_bytes_sent = status.network_bytes_sent
    self.context.usage_stats.RegisterResources(resources)