Handles received version data.

        :param data: Version string to parse
        :type data: string
1485
def _handle_version(self, data):
        

        _, version_string = data.split(':')
        version_parts = version_string.split(',')

        self.serial_number = version_parts[0]
        self.version_number = version_parts[1]
        self.version_flags = version_parts[2]
217722
def getVersion(data):
    
    data = data.splitlines()
    return next((
        v
        for v, u in zip(data, data[1:])  # v = version, u = underline
        if len(v) == len(u) and allSame(u) and hasDigit(v) and "." in v
    ))
1025348
public void parse(String version_string) {
        _version = 0;
        _revision = 0;
        _subrevision = 0;
        _suffix = "";
        int pos = 0;
        int startpos = 0;
        int endpos = version_string.length();
        while ( (pos < endpos) && Character.isDigit(version_string.charAt(pos))) {
            pos++;
        }
        _version = Integer.parseInt(version_string.substring(startpos,pos));
        if ((pos < endpos) && version_string.charAt(pos)=='.') {
            startpos = ++pos;
            while ( (pos < endpos) && Character.isDigit(version_string.charAt(pos))) {
                pos++;
            }
            _revision = Integer.parseInt(version_string.substring(startpos,pos));
        }
        if ((pos < endpos) && version_string.charAt(pos)=='.') {
            startpos = ++pos;
            while ( (pos < endpos) && Character.isDigit(version_string.charAt(pos))) {
                pos++;
            }
            _subrevision = Integer.parseInt(version_string.substring(startpos,pos));
        }
        if (pos < endpos) {
            _suffix = version_string.substring(pos);
        }
    }
592956
def _update_version_data(self, result, info):
        
        name = info.pop('name')
        version = info.pop('version')
        if version in result:
            dist = result[version]
            md = dist.metadata
        else:
            dist = make_dist(name, version, scheme=self.scheme)
            md = dist.metadata
        dist.digest = self._get_digest(info)
        if md.source_url != info['url']:
            md.source_url = self.prefer_url(md.source_url, info['url'])
        dist.locator = self
        result[version] = dist
725763
def _parse_upgrade_data(data):
    '''
    
    '''
    upgrade_result = {}
    upgrade_result['upgrade_data'] = None
    upgrade_result['succeeded'] = False
    upgrade_result['upgrade_required'] = False
    upgrade_result['upgrade_non_disruptive'] = False
    upgrade_result['upgrade_in_progress'] = False
    upgrade_result['installing'] = False
    upgrade_result['module_data'] = {}
    upgrade_result['error_data'] = None
    upgrade_result['backend_processing_error'] = False
    upgrade_result['invalid_command'] = False

    # Error handling
    if isinstance(data, string_types) and re.search('Code: 500', data):
        log.info('Detected backend processing error')
        upgrade_result['error_data'] = data
        upgrade_result['backend_processing_error'] = True
        return upgrade_result

    if isinstance(data, dict):
        if 'code' in data and data['code'] == '400':
            log.info('Detected client error')
            upgrade_result['error_data'] = data['cli_error']

            if re.search('install.*may be in progress', data['cli_error']):
                log.info('Detected install in progress...')
                upgrade_result['installing'] = True

            if re.search('Invalid command', data['cli_error']):
                log.info('Detected invalid command...')
                upgrade_result['invalid_command'] = True
        else:
            # If we get here then it's likely we lost access to the device
            # but the upgrade succeeded.  We lost the actual upgrade data so
            # set the flag such that impact data is used instead.
            log.info('Probable backend processing error')
            upgrade_result['backend_processing_error'] = True
        return upgrade_result

    # Get upgrade data for further parsing
    # Case 1: Command terminal dont-ask returns empty {} that we don't need.
    if isinstance(data, list) and len(data) == 2:
        data = data[1]
    # Case 2: Command terminal dont-ask does not get included.
    if isinstance(data, list) and len(data) == 1:
        data = data[0]

    log.info('Parsing NX-OS upgrade data')
    upgrade_result['upgrade_data'] = data
    for line in data.split('\n'):

        log.info('Processing line: (%s)', line)

        # Check to see if upgrade is disruptive or non-disruptive
        if re.search(r'non-disruptive', line):
            log.info('Found non-disruptive line')
            upgrade_result['upgrade_non_disruptive'] = True

        # Example:
        # Module  Image  Running-Version(pri:alt)  New-Version  Upg-Required
        # 1       nxos   7.0(3)I7(5a)              7.0(3)I7(5a)        no
        # 1       bios   v07.65(09/04/2018)        v07.64(05/16/2018)  no
        mo = re.search(r'(\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(yes|no)', line)
        if mo:
            log.info('Matched Module Running/New Version Upg-Req Line')
            bk = 'module_data'  # base key
            g1 = mo.group(1)
            g2 = mo.group(2)
            g3 = mo.group(3)
            g4 = mo.group(4)
            g5 = mo.group(5)
            mk = 'module {0}:image {1}'.format(g1, g2)  # module key
            upgrade_result[bk][mk] = {}
            upgrade_result[bk][mk]['running_version'] = g3
            upgrade_result[bk][mk]['new_version'] = g4
            if g5 == 'yes':
                upgrade_result['upgrade_required'] = True
                upgrade_result[bk][mk]['upgrade_required'] = True
            continue

        # The following lines indicate a successfull upgrade.
        if re.search(r'Install has been successful', line):
            log.info('Install successful line')
            upgrade_result['succeeded'] = True
            continue

        if re.search(r'Finishing the upgrade, switch will reboot in', line):
            log.info('Finishing upgrade line')
            upgrade_result['upgrade_in_progress'] = True
            continue

        if re.search(r'Switch will be reloaded for disruptive upgrade', line):
            log.info('Switch will be reloaded line')
            upgrade_result['upgrade_in_progress'] = True
            continue

        if re.search(r'Switching over onto standby', line):
            log.info('Switching over onto standby line')
            upgrade_result['upgrade_in_progress'] = True
            continue

    return upgrade_result
192486
def version
      logger.debug "Parsing version from output using #{description}"
      matches = output.match PARSE_VERSION_FROM_OUTPUT
      raise InvalidFormat.new output if matches.nil?
      matches.captures[0]
    end
1193985
def datagramReceived(self, data):
        
        try:
            obj = json.loads(data)
        except ValueError, e:
            log.err(e, 'Invalid JSON in stream: %r' % data)
            return

        if u'text' in obj:
            obj = Status.fromDict(obj)
        else:
            log.msg('Unsupported object %r' % obj)
            return

        self.callback(obj)
559011
def data_received(self, data):
        """"""
        data = data.decode()
        log.debug('received data: %s', data.strip())
        self.buffer += data
        self.handle_lines()
1281906
def version(request):
    
    version_json = import_string(version_callback)(settings.BASE_DIR)
    if version_json is None:
        return HttpResponseNotFound('version.json not found')
    else:
        return JsonResponse(version_json)
968748
private void parse(String version) {
        String[] tokens = StringUtil.tokenizeVersionString(version);
        this.major = Byte.valueOf(tokens[0]);
        this.minor = Byte.valueOf(tokens[1]);
        if (tokens.length > 3 && tokens[3] != null) {
            this.patch = Byte.valueOf(tokens[3]);
        }
    }
1165069
def data_received(self, data):
        '''
        
        '''
        self._buffered_data.extend(data)
        while self._buffered_data:
            size = len(self._buffered_data)
            if self._data_package is None:
                if size < DataPackage.struct_datapackage.size:
                    return None
                self._data_package = DataPackage(self._buffered_data)
            if size < self._data_package.length:
                return None
            try:
                self._data_package.extract_data_from(self._buffered_data)
            except KeyError as e:
                logging.error('Unsupported package received: {}'.format(e))
            except Exception as e:
                logging.exception(e)
                # empty the byte-array to recover from this error
                self._buffered_data.clear()
            else:
                self._on_package_received()
            self._data_package = None
170450
def parse_version_string(version_string):
    """"""
    string_parts =  version_string.split(".")
    version_parts = [
        int(re.match("([0-9]*)", string_parts[0]).group(0)),
        int(re.match("([0-9]*)", string_parts[1]).group(0)),
        int(re.match("([0-9]*)", string_parts[2]).group(0))
    ]
    return version_parts
188271
def _parse(self, data):
        
        super(Image, self)._parse(data)
        self.height = data['height']
        self.type = data['type']
        self.width = data['width']
372278
def _handle_message(self, data):
        

        try:
            data = data.decode('utf-8')
        except:
            raise InvalidMessageError('Decode failed for message: {0}'.format(data))

        if data is not None:
            data = data.lstrip('\0')

        if data is None or data == '':
            raise InvalidMessageError()

        msg = None
        header = data[0:4]

        if header[0] != '!' or header == '!KPM':
            msg = self._handle_keypad_message(data)

        elif header == '!EXP' or header == '!REL':
            msg = self._handle_expander_message(data)

        elif header == '!RFX':
            msg = self._handle_rfx(data)

        elif header == '!LRR':
            msg = self._handle_lrr(data)

        elif header == '!AUI':
            msg = self._handle_aui(data)

        elif data.startswith('!Ready'):
            self.on_boot()

        elif data.startswith('!CONFIG'):
            self._handle_config(data)

        elif data.startswith('!VER'):
            self._handle_version(data)

        elif data.startswith('!Sending'):
            self._handle_sending(data)

        return msg
856279
def handle_data(self, data):
        '''
            
        '''
        if data:
            inTag = self._inTag
            if len(inTag) > 0:
                inTag[-1].appendText(data)
            elif data.strip(): #and not self.getRoot():
                # Must be text prior to or after root node
                raise MultipleRootNodeException()
205179
def parse_version(cls, version_str):
        
        match = cls.VERSION_RE.match(version_str)
        if match:
            major = int(match.group('major'))
            minor = int(match.group('minor'))
            flags = set(match.group('flags') or '')
        else:
            major, minor, flags = None, None, set()
        return cls(major, minor, flags)
659034
def parse_object(self, data):
        
        for key, value in data.items():
            if isinstance(value, (str, type(u''))) and \
               self.strict_iso_match.match(value):
                data[key] = dateutil.parser.parse(value)
        return data