What's the zonefile inventory vector for this peer?
    Return None if not defined
182936
def atlas_peer_get_zonefile_inventory( peer_hostport, peer_table=None ):
    
    inv = None

    with AtlasPeerTableLocked(peer_table) as ptbl:
        if peer_hostport not in ptbl.keys():
            return None

        inv = ptbl[peer_hostport]['zonefile_inv']

    return inv
122807
def item(p_queue, queue_id, host=None):
    if host is not None:
        return os.path.join(_path(host, _c.FSQ_QUEUE, root=hosts(p_queue)),
                            valid_name(queue_id))
    ''''''
    return os.path.join(_path(p_queue, _c.FSQ_QUEUE), valid_name(queue_id))
28784
def loadZone(self, zone, callback=None, errback=None):
        
        import ns1.zones
        zone = ns1.zones.Zone(self.config, zone)
        return zone.load(callback=callback, errback=errback)
826882
def get_zonefile_inventory(hostport, offset, count, timeout=30, my_hostport=None, proxy=None):
    
    
    assert hostport or proxy, 'Need either hostport or proxy'

    inv_schema = {
        'type': 'object',
        'properties': {
            'inv': {
                'type': 'string',
                'pattern': OP_BASE64_EMPTY_PATTERN
            },
        },
        'required': [
            'inv'
        ]
    }

    schema = json_response_schema( inv_schema )

    if proxy is None:
        proxy = connect_hostport(hostport)

    zf_inv = None
    try:
        zf_inv = proxy.get_zonefile_inventory(offset, count)
        zf_inv = json_validate(schema, zf_inv)
        if json_is_error(zf_inv):
            return zf_inv

        # decode
        zf_inv['inv'] = base64.b64decode(str(zf_inv['inv']))

        # make sure it corresponds to this range
        assert len(zf_inv['inv']) <= count, 'Zonefile inventory in is too long (got {} bytes)'.format(len(zf_inv['inv']))

    except ValidationError as ve:
        if BLOCKSTACK_DEBUG:
            log.exception(ve)

        resp = {'error': 'Server response did not match expected schema.  You are likely communicating with an out-of-date Blockstack node.', 'http_status': 502}
        return resp

    except AssertionError as ae:
        if BLOCKSTACK_DEBUG:
            log.exception(ae)

        resp = {'error': 'Server replied an invalid zone file inventory vector'}
        return resp

    except socket.timeout:
        log.error("Connection timed out")
        resp = {'error': 'Connection to remote host timed out.', 'http_status': 503}
        return resp

    except socket.error as se:
        log.error("Connection error {}".format(se.errno))
        resp = {'error': 'Connection to remote host failed.', 'http_status': 502}
        return resp

    except Exception as ee:
        if BLOCKSTACK_DEBUG:
            log.exception(ee)

        log.error("Caught exception while connecting to Blockstack node: {}".format(ee))
        resp = {'error': 'Failed to contact Blockstack node.  Try again with `--debug`.', 'http_status': 500}
        return resp

    return zf_inv
1098742
def get_zonefile_data( self, zonefile_hash, zonefile_dir ):
        
        # check cache
        atlas_zonefile_data = get_atlas_zonefile_data( zonefile_hash, zonefile_dir, check=False )
        if atlas_zonefile_data is not None:
            # check hash
            zfh = get_zonefile_data_hash( atlas_zonefile_data )
            if zfh != zonefile_hash:
                log.debug("Invalid local zonefile %s" % zonefile_hash )
                remove_atlas_zonefile_data( zonefile_hash, zonefile_dir )

            else:
                log.debug("Zonefile %s is local" % zonefile_hash)
                return atlas_zonefile_data

        return None
22670
def remove_from_vmware_inventory(self, vmx_path):
        

        with (yield from self._vmware_inventory_lock):
            inventory_path = self.get_vmware_inventory_path()
            if os.path.exists(inventory_path):
                try:
                    inventory_pairs = self.parse_vmware_file(inventory_path)
                except OSError as e:
                    log.warning('Could not read VMware inventory file "{}": {}'.format(inventory_path, e))
                    return

                vmlist_entry = None
                for name, value in inventory_pairs.items():
                    if value == vmx_path:
                        vmlist_entry = name.split(".", 1)[0]
                        break

                if vmlist_entry is not None:
                    for name in inventory_pairs.copy().keys():
                        if name.startswith(vmlist_entry):
                            del inventory_pairs[name]

                try:
                    self.write_vmware_file(inventory_path, inventory_pairs)
                except OSError as e:
                    raise VMwareError('Could not write VMware inventory file "{}": {}'.format(inventory_path, e))
192843
def get_parcel(resource_root, product, version, cluster_name="default"):
  
  return _get_parcel(resource_root, PARCEL_PATH % (cluster_name, product, version))
287570
def GET_zonefile(self, path_info, zonefile_hash):
        
        if not check_string(zonefile_hash, pattern=OP_ZONEFILE_HASH_PATTERN):
            return self._reply_json({'error': 'Invalid zone file hash'}, status_code=400)

        blockstackd_url = get_blockstackd_url()
        resp = blockstackd_client.get_zonefiles(blockstackd_url, [str(zonefile_hash)])
        if json_is_error(resp):
            log.error("Failed to get {}: {}".format(zonefile_hash, resp['error']))
            return self._reply_json({'error': resp['error']}, status_code=resp.get('http_status', 502))

        if str(zonefile_hash) not in resp['zonefiles']:
            return self._reply_json({'error': 'Blockstack node does not have this zonefile.  Try again later.'}, status_code=404)

        self._send_headers(status_code=200, content_type='application/octet-stream')
        self.wfile.write(resp['zonefiles'][str(zonefile_hash)])
        return
909242
def decode_name_zonefile(name, zonefile_txt):
    

    user_zonefile = None
    try:
        # by default, it's a zonefile-formatted text file
        user_zonefile_defaultdict = blockstack_zones.parse_zone_file(zonefile_txt)

        # force dict
        user_zonefile = dict(user_zonefile_defaultdict)

    except (IndexError, ValueError, blockstack_zones.InvalidLineException):
        # might be legacy profile
        log.debug('WARN: failed to parse user zonefile; trying to import as legacy')
        try:
            user_zonefile = json.loads(zonefile_txt)
            if not isinstance(user_zonefile, dict):
                log.debug('Not a legacy user zonefile')
                return None

        except Exception as e:
            log.error('Failed to parse non-standard zonefile')
            return None

    except Exception as e:
        if BLOCKSTACK_DEBUG:
            log.exception(e)

        log.error('Failed to parse zonefile')
        return None

    if user_zonefile is None:
        return None 

    return user_zonefile
555196
def RelayDirectly(self, inventory):
        
        relayed = False

        self.RelayCache[inventory.Hash.ToBytes()] = inventory

        for peer in self.Peers:
            relayed |= peer.Relay(inventory)

        if len(self.Peers) == 0:
            if type(BC.Default()) is TestLevelDBBlockchain:
                # mock a true result for tests
                return True

            logger.info("no connected peers")

        return relayed
283240
def atlasdb_get_zonefile( zonefile_hash, con=None, path=None ):
    
    ret = None

    with AtlasDBOpen(con=con, path=path) as dbcon:

        sql = "SELECT * FROM zonefiles WHERE zonefile_hash = ? ORDER BY inv_index;"
        args = (zonefile_hash,)

        cur = dbcon.cursor()
        res = atlasdb_query_execute( cur, sql, args )

        ret = {
            'zonefile_hash': zonefile_hash,
            'indexes': [],
            'block_heights': [],
            'present': False,
            'tried_storage': False
        }

        for zfinfo in res:
            ret['indexes'].append( zfinfo['inv_index'] )
            ret['block_heights'].append( zfinfo['block_height'] )
            ret['present'] = ret['present'] or zfinfo['present']
            ret['tried_storage'] = ret['tried_storage'] or zfinfo['tried_storage']

    return ret
572900
def import_(zone, path):
    '''
    
    '''
    ret = {'status': True}

    # create from file
    _dump_cfg(path)
    res = __salt__['cmd.run_all']('zonecfg -z {zone} -f {path}'.format(
        zone=zone,
        path=path,
    ))
    ret['status'] = res['retcode'] == 0
    ret['message'] = res['stdout'] if ret['status'] else res['stderr']
    if ret['message'] == '':
        del ret['message']
    else:
        ret['message'] = _clean_message(ret['message'])

    return ret
51330
def find_usedby(self, depslock_file_path, property_validate=True):
        
        if depslock_file_path is None:
            self._raw = [self._params]
            self._raw[0]['repo'] = None
            self._raw[0]['server'] = None
        else:
            self._raw = [x for x in self._downloader.common_parser.iter_packages_params(depslock_file_path)]
        self.packages = self._downloader.get_usedby_packages({'raw': self._raw},
                                                             property_validate=property_validate)
905582
def inventory(uri, format):
    """"""
    base_uri = dtoolcore.utils.sanitise_uri(uri)
    info = _base_uri_info(base_uri)

    if format is None:
        _cmd_line_report(info)
    elif format == "csv":
        _csv_tsv_report(info, ",")
    elif format == "tsv":
        _csv_tsv_report(info, "\t")
    elif format == "html":
        _html_report(info)
1098920
def atlas_zonefile_find_push_peers( zonefile_hash, peer_table=None, zonefile_bits=None, con=None, path=None ):
    

    if zonefile_bits is None:
        zonefile_bits = atlasdb_get_zonefile_bits( zonefile_hash, path=path, con=con )
        if len(zonefile_bits) == 0:
            # we don't even know about it
            return []

    push_peers = []
    
    with AtlasPeerTableLocked(peer_table) as ptbl:
        for peer_hostport in ptbl.keys():
            zonefile_inv = atlas_peer_get_zonefile_inventory( peer_hostport, peer_table=ptbl )
            res = atlas_inventory_test_zonefile_bits( zonefile_inv, zonefile_bits )
            if res:
                push_peers.append( peer_hostport )

    return push_peers
812138
def atlas_zonefile_push_dequeue( zonefile_queue=None ):
    
    ret = None
    with AtlasZonefileQueueLocked(zonefile_queue) as zfq:
        if len(zfq) > 0:
            ret = zfq.pop(0)

    return ret
459386
def atlas_peer_has_zonefile( peer_hostport, zonefile_hash, zonefile_bits=None, con=None, path=None, peer_table=None ):
    

    bits = None
    if zonefile_bits is None:
        bits = atlasdb_get_zonefile_bits( zonefile_hash, con=con, path=path )
        if len(bits) == 0:
            return None

    else:
        bits = zonefile_bits

    zonefile_inv = None

    with AtlasPeerTableLocked(peer_table) as ptbl:
        if peer_hostport not in ptbl.keys():
            return False

        zonefile_inv = atlas_peer_get_zonefile_inventory( peer_hostport, peer_table=ptbl )
    
    res = atlas_inventory_test_zonefile_bits( zonefile_inv, bits )
    return res