id stringlengths 1 8 | text stringlengths 6 1.05M | dataset_id stringclasses 1
value |
|---|---|---|
3533666 | # -*- encoding: utf-8 -*-
#
# HTTP Host Test
# **************
#
# :authors: <NAME>
# :licence: see LICENSE
import json
from twisted.python import usage
from ooni.utils import log
from ooni.templates import httpt
class UsageOptions(usage.Options):
optParameters = [['backend', 'b', 'http://127.0.0.1:57001',
'URL of the test backend to use'],
['content', 'c', None,
'The file to read from containing the content of a block page']]
class HTTPHost(httpt.HTTPTest):
"""
This test is aimed at detecting the presence of a transparent HTTP proxy
and enumerating the sites that are being censored by it.
It places inside of the Host header field the hostname of the site that is
to be tested for censorship and then determines if the probe is behind a
transparent HTTP proxy (because the response from the backend server does
not match) and if the site is censorsed, by checking if the page that it
got back matches the input block page.
"""
name = "HTTP Host"
author = "<NAME>"
version = "0.2"
usageOptions = UsageOptions
inputFile = ['file', 'f', None,
'List of hostnames to test for censorship']
requiredOptions = ['backend']
def test_send_host_header(self):
"""
Stuffs the HTTP Host header field with the site to be tested for
censorship and does an HTTP request of this kind to our backend.
We randomize the HTTP User Agent headers.
"""
headers = {}
headers["Host"] = [self.input]
return self.doRequest(self.localOptions['backend'],
headers=headers)
def check_for_censorship(self, body):
"""
If we have specified what a censorship page looks like here we will
check if the page we are looking at matches it.
XXX this is not tested, though it is basically what was used to detect
censorship in the palestine case.
"""
if self.localOptions['content']:
self.report['censored'] = True
censorship_page = open(self.localOptions['content'])
response_page = iter(body.split("\n"))
for censorship_line in censorship_page.xreadlines():
response_line = response_page.next()
if response_line != censorship_line:
self.report['censored'] = False
break
censorship_page.close()
def processResponseBody(self, body):
"""
XXX this is to be filled in with either a domclass based classified or
with a rule that will allow to detect that the body of the result is
that of a censored site.
"""
# If we don't see a json array we know that something is wrong for
# sure
if not body.startswith("{"):
self.report['transparent_http_proxy'] = True
self.check_for_censorship(body)
return
try:
content = json.loads(body)
except:
log.debug("The json does not parse, this is not what we expected")
self.report['trans_http_proxy'] = True
self.check_for_censorship(body)
return
# We base the determination of the presence of a transparent HTTP
# proxy on the basis of the response containing the json that is to be
# returned by a HTTP Request Test Helper
if 'request_method' in content and \
'request_uri' in content and \
'request_headers' in content:
log.debug("Found the keys I expected in %s" % content)
self.report['trans_http_proxy'] = False
else:
log.debug("Did not find the keys I expected in %s" % content)
self.report['trans_http_proxy'] = True
self.check_for_censorship(body)
| StarcoderdataPython |
113202 | while True:
n = int(input())
if n == -1:
break
last_elapsed = 0
distance = 0
for _ in range(n):
s, t = map(int, input().split())
_t = t - last_elapsed
distance += s * _t
last_elapsed = t
print(distance, "miles")
| StarcoderdataPython |
4982471 | '''
<NAME>
<EMAIL>
Assignment11
Lab section: B56
CA name: <NAME>
Assignment #11 Part 1
Phone: 6079532749
'''
'''
This class represents a patron
A Patron has a name, a status and
zero or more books checked out
'''
#This one is just for my own use.
#I'm so confused as for what methods I have.
#I have this as an reminder for myself
all_attributes = ["Patron",
"can_check_out_books", "has_checked_out_books",
"get_name", "get_status","get_num_books_out",
"__update_status","increment", "decrement",
"__lt__","__eq__", "__str__"]
class Patron:
# Class Constants ----------------------------------------------------------
# Maximum number of books Patron can take out (int)
MAX_BOOKS_OUT = 3
# Current status of this Patron (str)
# Will be combined with name of Patron
STATUS = [" can borrow up to 3 books", " can borrow two more books", \
" can borrow one more book", " must return book(s)"]
# Constructor --------------------------------------------------------------
zero = 0
# params: name - name of Patron(str)
# initialize: self.__name (str), to parameter name,
# self.__num_books_out (int) to 0, and self.__status() (str)
# to STATUS with respect to number books out
def __init__(self, name):
# your code here
self.__name = name
self.__num_books_out = self.zero
self.__status = self.STATUS[self.__num_books_out]
# Predicates ---------------------------------------------------------------
# returns: True if less then max books checked out, False otherwise (bool)
def can_check_out_books(self):
# your code here
return self.__num_books_out < self.MAX_BOOKS_OUT
# returns: True if books checked out, False otherwise (bool)
def has_checked_out_books(self):
# your code here
return self.__num_books_out > 0
# Accessors ----------------------------------------------------------------
# returns: name (str)
def get_name(self):
# your code here
return str(self.__name)
# returns: status (str)
def get_status(self):
# your code here
return str(self.__status)
# returns: number of books out (int)
def get_num_books_out(self):
# your code here
return int(self.__num_books_out)
# Mutators -----------------------------------------------------------------
# set to STATUS indexed by number of books out
def __update_status(self):
# your code here
self.__status = self.STATUS[self.__num_books_out]
# Increases number of books out by one
# invokes: update_status()
def increment(self):
# your code here
self.__num_books_out+=1
self.__update_status()
# Decereases number of books out by one
# invokes update_status()
def decrement(self):
# your code here
self.__num_books_out -= 1
self.__update_status()
# Comparators --------------------------------------------------------------
# Already written for you:
# You will need to include these in order to sort Patron objects
# Shows how two Patrons can be compared with respect to the < relationship
# params: other - another Patron object
# invokes: type()
# returns: True when they are not the same Patron and other is a Patron
# object and name of this Patron is lexicographically less than
# name of other Patron, False otherwise (bool)
def __lt__(self, other):
return (not self is other) and (type(self) == type(other)) and \
self.__name < other.__name
# Shows how two Patrons can be compared with respect to the == relationship
# params: other - another Patron object
# invokes: type()
# returns: True when both are same Patron OR both are Patron objects AND
# all attributes are equal, False otherwise (bool)
def __eq__(self, other):
return self is other or \
(type(self) == type(other) and \
self.__name == other.__name and \
self.__status == other.__status and \
self.__num_books_out == other.__num_books_out)
# Convert to Str -----------------------------------------------------
# invokes: str()
# returns: str representation of Patron object (str)
def __str__(self):
# your code here
return "%s %s, %s book(s) out.\n"%(self.__name,self.__status, self.__num_books_out)
| StarcoderdataPython |
12849383 | from os.path import join as pjoin
# Format expected by setup.py and doc/source/conf.py: string of form "X.Y.Z"
_version_major = 0
_version_minor = 9
_version_micro = 8 # use '' for first of series, number for 1 and above
_version_extra = 'dev'
# _version_extra = '' # Uncomment this for full releases
# Construct full version string from these.
_ver = [_version_major, _version_minor]
if _version_micro:
_ver.append(_version_micro)
if _version_extra:
_ver.append(_version_extra)
__version__ = '.'.join(map(str, _ver))
CLASSIFIERS = ["Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Scientific/Engineering"]
# Description should be a one-liner:
description = "labdrivers: python drivers for lab instruments"
# Long description will go up on the pypi page
long_description = """
labdrivers
========
labdrivers is a collection of drivers for common research lab instruments.
It contains a suite of instrument-specific drivers which can be used to
interface measurement hardware with Python code, along with a set of
Jupyter notebooks demonstrating example use cases.
To get started using these components in your own software, please go to the
repository README_.
.. _README: https://github.com/masonlab/labdrivers/blob/master/README.md
License
=======
``labdrivers`` is licensed under the terms of the MIT license. See the file
"LICENSE" for information on the history of this software, terms & conditions
for usage, and a DISCLAIMER OF ALL WARRANTIES.
All trademarks referenced herein are property of their respective holders.
Copyright (c) 2016--, <NAME>.
"""
NAME = "labdrivers"
MAINTAINER = "<NAME>"
MAINTAINER_EMAIL = "<EMAIL>"
DESCRIPTION = description
LONG_DESCRIPTION = long_description
URL = "http://github.com/masonlab/labdrivers"
DOWNLOAD_URL = ""
LICENSE = "MIT"
AUTHOR = "<NAME>"
AUTHOR_EMAIL = "<EMAIL>"
PLATFORMS = "OS Independent"
MAJOR = _version_major
MINOR = _version_minor
MICRO = _version_micro
VERSION = __version__
PACKAGES = ['labdrivers',
'labdrivers.keithley',
'labdrivers.lakeshore',
'labdrivers.srs',
'labdrivers.quantumdesign',
'labdrivers.oxford',
'labdrivers.ni']
PACKAGE_DATA = {'labdrivers': [pjoin('data', '*')]}
REQUIRES = ["pyvisa", "PyDAQmx"]
| StarcoderdataPython |
11387173 | <filename>skidl/libs/rfcom_sklib.py<gh_stars>100-1000
from skidl import SKIDL, TEMPLATE, Part, Pin, SchLib
SKIDL_lib_version = '0.0.1'
rfcom = SchLib(tool=SKIDL).add_parts(*[
Part(name='BL652',dest=TEMPLATE,tool=SKIDL,keywords='Bluetooth Nordic nRF52',description='Bluetooth module',ref_prefix='U',num_units=1,fplist=['Laird*BL652*'],do_erc=True,pins=[
Pin(num='1',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='2',name='SIO_24',func=Pin.BIDIR,do_erc=True),
Pin(num='3',name='SIO_23',func=Pin.BIDIR,do_erc=True),
Pin(num='4',name='SIO_22',func=Pin.BIDIR,do_erc=True),
Pin(num='5',name='SWDIO',func=Pin.BIDIR,do_erc=True),
Pin(num='6',name='SWDCLK',func=Pin.BIDIR,do_erc=True),
Pin(num='7',name='SIO_21',func=Pin.BIDIR,do_erc=True),
Pin(num='8',name='SIO_20',func=Pin.BIDIR,do_erc=True),
Pin(num='9',name='SIO_18',func=Pin.BIDIR,do_erc=True),
Pin(num='10',name='SIO_16',func=Pin.BIDIR,do_erc=True),
Pin(num='20',name='SIO_05/AIN3',func=Pin.BIDIR,do_erc=True),
Pin(num='30',name='SIO_17',func=Pin.BIDIR,do_erc=True),
Pin(num='11',name='SIO_14',func=Pin.BIDIR,do_erc=True),
Pin(num='21',name='SIO_04/AIN2',func=Pin.BIDIR,do_erc=True),
Pin(num='31',name='SIO_19',func=Pin.BIDIR,do_erc=True),
Pin(num='12',name='SIO_12',func=Pin.BIDIR,do_erc=True),
Pin(num='22',name='SIO_03/AIN1',func=Pin.BIDIR,do_erc=True),
Pin(num='32',name='SIO_31/AIN7',func=Pin.BIDIR,do_erc=True),
Pin(num='13',name='SIO_11',func=Pin.BIDIR,do_erc=True),
Pin(num='23',name='SIO_02/AIN0',func=Pin.BIDIR,do_erc=True),
Pin(num='33',name='SIO_30/AIN6',func=Pin.BIDIR,do_erc=True),
Pin(num='14',name='SIO_10/NFC2',func=Pin.BIDIR,do_erc=True),
Pin(num='24',name='SIO_01',func=Pin.BIDIR,do_erc=True),
Pin(num='34',name='SIO_29/AIN5',func=Pin.BIDIR,do_erc=True),
Pin(num='15',name='SIO_09/NFC1',func=Pin.BIDIR,do_erc=True),
Pin(num='25',name='SIO_00',func=Pin.BIDIR,do_erc=True),
Pin(num='35',name='SIO_28/AIN4',func=Pin.BIDIR,do_erc=True),
Pin(num='16',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='26',name='VDD',func=Pin.PWRIN,do_erc=True),
Pin(num='36',name='SIO_27',func=Pin.BIDIR,do_erc=True),
Pin(num='17',name='SIO_08',func=Pin.BIDIR,do_erc=True),
Pin(num='27',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='37',name='SIO_26',func=Pin.BIDIR,do_erc=True),
Pin(num='18',name='SIO_07',func=Pin.BIDIR,do_erc=True),
Pin(num='28',name='SIO_13',func=Pin.BIDIR,do_erc=True),
Pin(num='38',name='SIO_25',func=Pin.BIDIR,do_erc=True),
Pin(num='19',name='SIO_06',func=Pin.BIDIR,do_erc=True),
Pin(num='29',name='SIO_15',func=Pin.BIDIR,do_erc=True),
Pin(num='39',name='GND',func=Pin.PWRIN,do_erc=True)]),
Part(name='BTM112',dest=TEMPLATE,tool=SKIDL,keywords='Bluetooth BT SPP Module',description='Bluetooth SPP Module, UART, Class 2',ref_prefix='U',num_units=1,do_erc=True,pins=[
Pin(num='1',name='PIO8',func=Pin.BIDIR,do_erc=True),
Pin(num='2',name='PIO9',func=Pin.BIDIR,do_erc=True),
Pin(num='3',name='PIO10',func=Pin.BIDIR,do_erc=True),
Pin(num='4',name='AIO0',func=Pin.PASSIVE,do_erc=True),
Pin(num='5',name='AIO1',func=Pin.PASSIVE,do_erc=True),
Pin(num='6',name='RESET',do_erc=True),
Pin(num='7',name='SPI_MISO',func=Pin.OUTPUT,do_erc=True),
Pin(num='8',name='~SPI_CSB~',do_erc=True),
Pin(num='9',name='SPI_CLK',do_erc=True),
Pin(num='10',name='SPI_MOSI',do_erc=True),
Pin(num='20',name='PCM_IN',do_erc=True),
Pin(num='30',name='PIO1',func=Pin.BIDIR,do_erc=True),
Pin(num='11',name='~UART_CTS',do_erc=True),
Pin(num='21',name='PCM_CLK',func=Pin.BIDIR,do_erc=True),
Pin(num='31',name='PIO0',func=Pin.BIDIR,do_erc=True),
Pin(num='12',name='UART_TX',func=Pin.OUTPUT,do_erc=True),
Pin(num='22',name='USB_D+',func=Pin.BIDIR,do_erc=True),
Pin(num='32',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='13',name='~UART_RTS',func=Pin.OUTPUT,do_erc=True),
Pin(num='23',name='USB_D-',func=Pin.BIDIR,do_erc=True),
Pin(num='33',name='RF',func=Pin.PASSIVE,do_erc=True),
Pin(num='14',name='UART_RX',do_erc=True),
Pin(num='24',name='~LINK~/PIO7',func=Pin.BIDIR,do_erc=True),
Pin(num='34',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='15',name='PIO11',func=Pin.BIDIR,do_erc=True),
Pin(num='25',name='CONN/PIO6',func=Pin.BIDIR,do_erc=True),
Pin(num='16',name='VCC',func=Pin.PWRIN,do_erc=True),
Pin(num='26',name='PIO5',func=Pin.BIDIR,do_erc=True),
Pin(num='17',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='27',name='BTN/PIO4',func=Pin.BIDIR,do_erc=True),
Pin(num='18',name='PCM_OUT',func=Pin.OUTPUT,do_erc=True),
Pin(num='28',name='PIO3',func=Pin.BIDIR,do_erc=True),
Pin(num='19',name='PCM_SYNC',func=Pin.BIDIR,do_erc=True),
Pin(num='29',name='PIO2',func=Pin.BIDIR,do_erc=True)]),
Part(name='BTM222',dest=TEMPLATE,tool=SKIDL,keywords='Bluetooth BT SPP Module',description='Bluetooth SPP Module, UART, Class 1',ref_prefix='U',num_units=1,do_erc=True,pins=[
Pin(num='1',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='2',name='PVCC',func=Pin.PWRIN,do_erc=True),
Pin(num='3',name='AIO0/SLEEPCLK',func=Pin.BIDIR,do_erc=True),
Pin(num='4',name='AIO1',func=Pin.BIDIR,do_erc=True),
Pin(num='5',name='PIO0/RXEN',func=Pin.BIDIR,do_erc=True),
Pin(num='6',name='PIO1/TXEN',func=Pin.BIDIR,do_erc=True),
Pin(num='7',name='PIO2/USB_PU/CLK_REQ_OUT',func=Pin.BIDIR,do_erc=True),
Pin(num='8',name='PIO3/USB_WKUP/CLK_REQ_IN',func=Pin.BIDIR,do_erc=True),
Pin(num='9',name='PIO4/USB_ON/BT_PRIOR',func=Pin.BIDIR,do_erc=True),
Pin(num='10',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='20',name='USB_D+',func=Pin.BIDIR,do_erc=True),
Pin(num='30',name='UART_CTS',do_erc=True),
Pin(num='11',name='PIO5/USB_DETACH/BT_ACT',func=Pin.BIDIR,do_erc=True),
Pin(num='21',name='USB_D-',func=Pin.BIDIR,do_erc=True),
Pin(num='31',name='SPI_MOSI',do_erc=True),
Pin(num='12',name='PIO6/CLK_REQ/WAN_ACT',func=Pin.BIDIR,do_erc=True),
Pin(num='22',name='PCM_SYNC',func=Pin.BIDIR,do_erc=True),
Pin(num='32',name='~SPI_CSB~',do_erc=True),
Pin(num='13',name='PIO7',func=Pin.BIDIR,do_erc=True),
Pin(num='23',name='PCM_IN',do_erc=True),
Pin(num='33',name='SPI_CLK',do_erc=True),
Pin(num='14',name='PIO8',func=Pin.BIDIR,do_erc=True),
Pin(num='24',name='PCM_OUT',func=Pin.OUTPUT,do_erc=True),
Pin(num='34',name='SPI_MISO',func=Pin.OUTPUT,do_erc=True),
Pin(num='15',name='PIO9',func=Pin.BIDIR,do_erc=True),
Pin(num='25',name='PCM_CLK',func=Pin.BIDIR,do_erc=True),
Pin(num='35',name='PIO11',func=Pin.BIDIR,do_erc=True),
Pin(num='16',name='~RESET~',do_erc=True),
Pin(num='26',name='UART_RX',do_erc=True),
Pin(num='36',name='PIO10',func=Pin.BIDIR,do_erc=True),
Pin(num='17',name='VCC',func=Pin.PWRIN,do_erc=True),
Pin(num='27',name='UART_TX',func=Pin.OUTPUT,do_erc=True),
Pin(num='37',name='RF',func=Pin.PASSIVE,do_erc=True),
Pin(num='18',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='28',name='UART_RTS',func=Pin.OUTPUT,do_erc=True),
Pin(num='38',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='19',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='29',name='GND',func=Pin.PWRIN,do_erc=True)]),
Part(name='CC1000',dest=TEMPLATE,tool=SKIDL,keywords='Low Power RF Transciever',description='Single Chip Low Power RF Transceiver, TSSOP28',ref_prefix='U',num_units=1,fplist=['TSSOP*'],do_erc=True,pins=[
Pin(num='1',name='AVDD',func=Pin.PWRIN,do_erc=True),
Pin(num='2',name='AGND',func=Pin.PWRIN,do_erc=True),
Pin(num='3',name='RF_IN',func=Pin.PASSIVE,do_erc=True),
Pin(num='4',name='RF_OUT',func=Pin.PASSIVE,do_erc=True),
Pin(num='5',name='AVDD',func=Pin.PWRIN,do_erc=True),
Pin(num='6',name='AGND',func=Pin.PWRIN,do_erc=True),
Pin(num='7',name='AGND',func=Pin.PWRIN,do_erc=True),
Pin(num='8',name='AGND',func=Pin.PWRIN,do_erc=True),
Pin(num='9',name='AVDD',func=Pin.PWRIN,do_erc=True),
Pin(num='10',name='L1',func=Pin.PASSIVE,do_erc=True),
Pin(num='20',name='DGND',func=Pin.PWRIN,do_erc=True),
Pin(num='11',name='L2',func=Pin.PASSIVE,do_erc=True),
Pin(num='21',name='DVDD',func=Pin.PWRIN,do_erc=True),
Pin(num='12',name='CHP_OUT',func=Pin.PASSIVE,do_erc=True),
Pin(num='22',name='DGND',func=Pin.PWRIN,do_erc=True),
Pin(num='13',name='R_BIAS',func=Pin.PASSIVE,do_erc=True),
Pin(num='23',name='DIO',func=Pin.BIDIR,do_erc=True),
Pin(num='14',name='AGND',func=Pin.PWRIN,do_erc=True),
Pin(num='24',name='DCLK',func=Pin.OUTPUT,do_erc=True),
Pin(num='15',name='AVDD',func=Pin.PWRIN,do_erc=True),
Pin(num='25',name='PCLK',do_erc=True),
Pin(num='16',name='AGND',func=Pin.PWRIN,do_erc=True),
Pin(num='26',name='PDATA',func=Pin.BIDIR,do_erc=True),
Pin(num='17',name='XOSC_Q2',func=Pin.PASSIVE,do_erc=True),
Pin(num='27',name='PALE',do_erc=True),
Pin(num='18',name='XOSC_Q1',func=Pin.PASSIVE,do_erc=True),
Pin(num='28',name='RSSI/IF',func=Pin.PASSIVE,do_erc=True),
Pin(num='19',name='AGND',func=Pin.PWRIN,do_erc=True)]),
Part(name='CC1200',dest=TEMPLATE,tool=SKIDL,keywords='RF Tx Rx',description='Low-Power, High-Performance RF Transceiver',ref_prefix='U',num_units=1,fplist=['QFN-32-1EP_5x5mm_Pitch0.5mm', 'QFN-32-1EP_5x5mm_Pitch0.5mm*'],do_erc=True,pins=[
Pin(num='1',name='VDD_GUARD',func=Pin.PWRIN,do_erc=True),
Pin(num='2',name='~RESET~',do_erc=True),
Pin(num='3',name='GPIO3',func=Pin.BIDIR,do_erc=True),
Pin(num='4',name='GPIO2',func=Pin.BIDIR,do_erc=True),
Pin(num='5',name='DVDD',func=Pin.PWRIN,do_erc=True),
Pin(num='6',name='DCPL',func=Pin.PWROUT,do_erc=True),
Pin(num='7',name='SI',do_erc=True),
Pin(num='8',name='SCLK',do_erc=True),
Pin(num='9',name='SO(GPIO1)',func=Pin.BIDIR,do_erc=True),
Pin(num='10',name='GPIO0',func=Pin.BIDIR,do_erc=True),
Pin(num='20',name='LNA_N',func=Pin.PASSIVE,do_erc=True),
Pin(num='30',name='XOSC_Q1',func=Pin.PASSIVE,do_erc=True),
Pin(num='11',name='~CS~',do_erc=True),
Pin(num='21',name='DCPL_VCO',func=Pin.PWROUT,do_erc=True),
Pin(num='31',name='XOSC_Q2',func=Pin.PASSIVE,do_erc=True),
Pin(num='12',name='DVDD',func=Pin.PWRIN,do_erc=True),
Pin(num='22',name='AVDD_SYNTH1',func=Pin.PWRIN,do_erc=True),
Pin(num='32',name='EXT_XOSC',do_erc=True),
Pin(num='13',name='AVDD_IF',func=Pin.PWRIN,do_erc=True),
Pin(num='23',name='LPF0',func=Pin.PASSIVE,do_erc=True),
Pin(num='33',name='GND_EP',func=Pin.PWRIN,do_erc=True),
Pin(num='14',name='RBIAS',func=Pin.PASSIVE,do_erc=True),
Pin(num='24',name='LPF1',func=Pin.PASSIVE,do_erc=True),
Pin(num='15',name='AVDD_RF',func=Pin.PWRIN,do_erc=True),
Pin(num='25',name='AVDD_PFD_CHP',func=Pin.PWRIN,do_erc=True),
Pin(num='26',name='DCPL_PFD_CHP',func=Pin.PWROUT,do_erc=True),
Pin(num='17',name='PA',func=Pin.PASSIVE,do_erc=True),
Pin(num='27',name='AVDD_SYNTH2',func=Pin.PWRIN,do_erc=True),
Pin(num='18',name='TRX_SW',func=Pin.PASSIVE,do_erc=True),
Pin(num='28',name='AVDD_XOSC',func=Pin.PWRIN,do_erc=True),
Pin(num='19',name='LNA_P',func=Pin.PASSIVE,do_erc=True),
Pin(num='29',name='DCPL_XOSC',func=Pin.PWROUT,do_erc=True)]),
Part(name='CC2520',dest=TEMPLATE,tool=SKIDL,keywords='2.4GHz rf transceiver ZigBee 802.15.4',description='2.4 GHz ZigBee/IEEE 802.15.4 RF transceiver',ref_prefix='U',num_units=1,fplist=['*QFN*28*5x5mm*Pitch0.5mm*'],do_erc=True,pins=[
Pin(num='1',name='SO',func=Pin.OUTPUT,do_erc=True),
Pin(num='2',name='SI',do_erc=True),
Pin(num='3',name='~CS',do_erc=True),
Pin(num='4',name='GPIO5',func=Pin.BIDIR,do_erc=True),
Pin(num='5',name='GPIO4',func=Pin.BIDIR,do_erc=True),
Pin(num='6',name='GPIO3',func=Pin.BIDIR,do_erc=True),
Pin(num='7',name='GPIO2',func=Pin.BIDIR,do_erc=True),
Pin(num='8',name='DVDD',func=Pin.PWRIN,do_erc=True),
Pin(num='9',name='GPIO1',func=Pin.BIDIR,do_erc=True),
Pin(num='10',name='GPIO0',func=Pin.BIDIR,do_erc=True),
Pin(num='20',name='AVDD1',func=Pin.PWRIN,do_erc=True),
Pin(num='11',name='AVDD5',func=Pin.PWRIN,do_erc=True),
Pin(num='21',name='NC',func=Pin.NOCONNECT,do_erc=True),
Pin(num='12',name='XOSC_Q2',func=Pin.PASSIVE,do_erc=True),
Pin(num='22',name='AVDD4',func=Pin.PWRIN,do_erc=True),
Pin(num='13',name='XOSC_Q1',func=Pin.PASSIVE,do_erc=True),
Pin(num='23',name='RBIAS',func=Pin.PASSIVE,do_erc=True),
Pin(num='14',name='AVDD3',func=Pin.PWRIN,do_erc=True),
Pin(num='24',name='AVDD_GUARD',func=Pin.PWRIN,do_erc=True),
Pin(num='15',name='NC',func=Pin.NOCONNECT,do_erc=True),
Pin(num='25',name='~RESET',do_erc=True),
Pin(num='16',name='AVDD2',func=Pin.PWRIN,do_erc=True),
Pin(num='26',name='VREG_EN',do_erc=True),
Pin(num='17',name='RF_P',func=Pin.PASSIVE,do_erc=True),
Pin(num='27',name='DCOUPL',func=Pin.PASSIVE,do_erc=True),
Pin(num='28',name='SCLK',do_erc=True),
Pin(num='19',name='RF_N',func=Pin.PASSIVE,do_erc=True),
Pin(num='29',name='AGND',func=Pin.PWRIN,do_erc=True)]),
Part(name='HF-A11-SMT',dest=TEMPLATE,tool=SKIDL,keywords='WiFi IEEE802.11 b/g/n',description='WiFi IEEE802.11b/g/n with Ethernet Module, UART, GPIO',ref_prefix='U',num_units=1,do_erc=True,pins=[
Pin(num='1',name='3.3V',func=Pin.PWRIN,do_erc=True),
Pin(num='2',name='3.3V',func=Pin.PWRIN,do_erc=True),
Pin(num='3',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='4',name='UART_TXD',func=Pin.OUTPUT,do_erc=True),
Pin(num='5',name='UART_RXD',do_erc=True),
Pin(num='6',name='UART_RTS',func=Pin.OUTPUT,do_erc=True),
Pin(num='7',name='UART_CTS',do_erc=True),
Pin(num='8',name='TX+',func=Pin.PASSIVE,do_erc=True),
Pin(num='9',name='TX-',func=Pin.PASSIVE,do_erc=True),
Pin(num='10',name='RX+',func=Pin.PASSIVE,do_erc=True),
Pin(num='20',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='11',name='RX-',func=Pin.PASSIVE,do_erc=True),
Pin(num='21',name='UART1_RXD',do_erc=True),
Pin(num='22',name='UART1_TXD',func=Pin.OUTPUT,do_erc=True),
Pin(num='23',name='1.8VOUT',func=Pin.PWROUT,do_erc=True),
Pin(num='14',name='~LINK~',func=Pin.OUTPUT,do_erc=True),
Pin(num='24',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='15',name='~RESET~',do_erc=True),
Pin(num='25',name='RF',func=Pin.PASSIVE,do_erc=True),
Pin(num='16',name='~READY~',func=Pin.OUTPUT,do_erc=True),
Pin(num='26',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='17',name='~RELOAD~',do_erc=True),
Pin(num='18',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='19',name='GND',func=Pin.PWRIN,do_erc=True)]),
Part(name='MM002',dest=TEMPLATE,tool=SKIDL,keywords='IOT LoRa SIGFOX',description='NEMEUS Modem dual-mode LoRa/SIGFOX',ref_prefix='U',num_units=1,do_erc=True,pins=[
Pin(num='1',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='2',name='~NRST',do_erc=True),
Pin(num='3',name='PB9-IO/I2C-SDA',func=Pin.BIDIR,do_erc=True),
Pin(num='4',name='PB8-IO/I2C-SCL',func=Pin.BIDIR,do_erc=True),
Pin(num='5',name='BOOT',do_erc=True),
Pin(num='6',name='PB7-IO/UART1-RX',func=Pin.BIDIR,do_erc=True),
Pin(num='7',name='PB6-IO/UART1-TX',func=Pin.BIDIR,do_erc=True),
Pin(num='8',name='PB4-IO/NJTRST',do_erc=True),
Pin(num='9',name='PB3-IO/JTDO',func=Pin.BIDIR,do_erc=True),
Pin(num='10',name='PA15-IO/JTDI',func=Pin.BIDIR,do_erc=True),
Pin(num='20',name='PA5-IO/SPI-SCK',func=Pin.BIDIR,do_erc=True),
Pin(num='11',name='PA14-IO/JTCK/SWCLK',func=Pin.BIDIR,do_erc=True),
Pin(num='21',name='PA6-IO/SPI-MISO',func=Pin.BIDIR,do_erc=True),
Pin(num='12',name='PA13-IO/JTMS/SWDAT',func=Pin.BIDIR,do_erc=True),
Pin(num='22',name='PA4-IO/SPI-NSS',func=Pin.BIDIR,do_erc=True),
Pin(num='13',name='PA12-IO/UART1-RTS/USB-DP',func=Pin.BIDIR,do_erc=True),
Pin(num='23',name='PA3-IO/ADC/UART2-RX',func=Pin.BIDIR,do_erc=True),
Pin(num='14',name='PA11-IO/UART1-CTS/USB-DM',func=Pin.BIDIR,do_erc=True),
Pin(num='24',name='PA2-IO/ADC/UART2-TX',func=Pin.BIDIR,do_erc=True),
Pin(num='15',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='25',name='PA0-IO/ADC/UART2-CTS/WKUP',func=Pin.BIDIR,do_erc=True),
Pin(num='16',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='26',name='PA1-IO/ADC/UART2-RTS',func=Pin.BIDIR,do_erc=True),
Pin(num='17',name='ANT',func=Pin.BIDIR,do_erc=True),
Pin(num='27',name='VCC',func=Pin.PWRIN,do_erc=True),
Pin(num='18',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='28',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='19',name='PA7-IO/SPI-MOSI',func=Pin.BIDIR,do_erc=True)]),
Part(name='NRF24L01',dest=TEMPLATE,tool=SKIDL,keywords='Low Power RF Transciever',description='nRF24L01+, Ultra low power 2.4GHz RF Transceiver, QFN20 4x4mm',ref_prefix='U',num_units=1,fplist=['QFN*4x4*0.5mm*'],do_erc=True,aliases=['nRF24L01P'],pins=[
Pin(num='1',name='CE',do_erc=True),
Pin(num='2',name='CSN',do_erc=True),
Pin(num='3',name='SCK',do_erc=True),
Pin(num='4',name='MOSI',do_erc=True),
Pin(num='5',name='MISO',func=Pin.OUTPUT,do_erc=True),
Pin(num='6',name='IRQ',func=Pin.OUTPUT,do_erc=True),
Pin(num='7',name='VDD',func=Pin.PWRIN,do_erc=True),
Pin(num='8',name='VSS',func=Pin.PWRIN,do_erc=True),
Pin(num='9',name='XC2',func=Pin.PASSIVE,do_erc=True),
Pin(num='10',name='XC1',func=Pin.PASSIVE,do_erc=True),
Pin(num='20',name='VSS',func=Pin.PWRIN,do_erc=True),
Pin(num='11',name='VDD_PA',func=Pin.PWROUT,do_erc=True),
Pin(num='12',name='ANT1',func=Pin.PASSIVE,do_erc=True),
Pin(num='13',name='ANT2',func=Pin.PASSIVE,do_erc=True),
Pin(num='14',name='VSS',func=Pin.PWRIN,do_erc=True),
Pin(num='15',name='VDD',func=Pin.PWRIN,do_erc=True),
Pin(num='16',name='IREF',func=Pin.PASSIVE,do_erc=True),
Pin(num='17',name='VSS',func=Pin.PWRIN,do_erc=True),
Pin(num='18',name='VDD',func=Pin.PWRIN,do_erc=True),
Pin(num='19',name='DVDD',func=Pin.PWROUT,do_erc=True)]),
Part(name='NRF24L01_Breakout',dest=TEMPLATE,tool=SKIDL,keywords='Low Power RF Transciever breakout carrier',description='Ultra low power 2.4GHz RF Transceiver, Carrier PCB',ref_prefix='U',num_units=1,fplist=['nRF24L01*Breakout*'],do_erc=True,pins=[
Pin(num='1',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='2',name='VCC',func=Pin.PWRIN,do_erc=True),
Pin(num='3',name='CE',do_erc=True),
Pin(num='4',name='~CSN',do_erc=True),
Pin(num='5',name='SCK',do_erc=True),
Pin(num='6',name='MOSI',do_erc=True),
Pin(num='7',name='MISO',func=Pin.OUTPUT,do_erc=True),
Pin(num='8',name='IRQ',func=Pin.OUTPUT,do_erc=True)]),
Part(name='RN42',dest=TEMPLATE,tool=SKIDL,keywords='Bluetooth Module',description='Class 2 Bluetooth Module with on-board antenna',ref_prefix='U',num_units=1,do_erc=True,pins=[
Pin(num='1',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='2',name='SPI_MOSI',do_erc=True),
Pin(num='3',name='GPIO6',do_erc=True),
Pin(num='4',name='GPIO7',func=Pin.BIDIR,do_erc=True),
Pin(num='5',name='RESET',do_erc=True),
Pin(num='6',name='SPI_CLK',do_erc=True),
Pin(num='7',name='PCM_CLK',func=Pin.BIDIR,do_erc=True),
Pin(num='8',name='PCM_SYNC',func=Pin.BIDIR,do_erc=True),
Pin(num='9',name='PCM_IN',do_erc=True),
Pin(num='10',name='PCM_OUT',func=Pin.OUTPUT,do_erc=True),
Pin(num='20',name='GPIO3',do_erc=True),
Pin(num='30',name='AIO0',do_erc=True),
Pin(num='11',name='VDD',func=Pin.PWRIN,do_erc=True),
Pin(num='21',name='GPIO5',func=Pin.BIDIR,do_erc=True),
Pin(num='31',name='GPIO8',func=Pin.OUTPUT,do_erc=True),
Pin(num='12',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='22',name='GPIO4',func=Pin.BIDIR,do_erc=True),
Pin(num='32',name='GPIO9',func=Pin.BIDIR,do_erc=True),
Pin(num='13',name='UART_RX',do_erc=True),
Pin(num='23',name='SPI_CSB',do_erc=True),
Pin(num='33',name='GPIO10',func=Pin.BIDIR,do_erc=True),
Pin(num='14',name='UART_TX',func=Pin.OUTPUT,do_erc=True),
Pin(num='24',name='SPI_MISO',func=Pin.OUTPUT,do_erc=True),
Pin(num='34',name='GPIO11',func=Pin.BIDIR,do_erc=True),
Pin(num='15',name='UART_RTS',func=Pin.OUTPUT,do_erc=True),
Pin(num='35',name='AIO1',do_erc=True),
Pin(num='16',name='UART_CTS',do_erc=True),
Pin(num='36',name='SHIELD',do_erc=True),
Pin(num='17',name='USB_D+',func=Pin.BIDIR,do_erc=True),
Pin(num='18',name='USB_D-',func=Pin.BIDIR,do_erc=True),
Pin(num='28',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='19',name='GPIO2',func=Pin.BIDIR,do_erc=True),
Pin(num='29',name='GND',func=Pin.PWRIN,do_erc=True)]),
Part(name='RN42N',dest=TEMPLATE,tool=SKIDL,keywords='Bluetooth Module',description='Class 2 Bluetooth Module without antenna',ref_prefix='U',num_units=1,do_erc=True,pins=[
Pin(num='1',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='2',name='SPI_MOSI',do_erc=True),
Pin(num='3',name='GPIO6',do_erc=True),
Pin(num='4',name='GPIO7',func=Pin.BIDIR,do_erc=True),
Pin(num='5',name='RESET',do_erc=True),
Pin(num='6',name='SPI_CLK',do_erc=True),
Pin(num='7',name='PCM_CLK',func=Pin.BIDIR,do_erc=True),
Pin(num='8',name='PCM_SYNC',func=Pin.BIDIR,do_erc=True),
Pin(num='9',name='PCM_IN',do_erc=True),
Pin(num='10',name='PCM_OUT',func=Pin.OUTPUT,do_erc=True),
Pin(num='20',name='GPIO3',do_erc=True),
Pin(num='30',name='AIO0',do_erc=True),
Pin(num='11',name='VDD',func=Pin.PWRIN,do_erc=True),
Pin(num='21',name='GPIO5',func=Pin.BIDIR,do_erc=True),
Pin(num='31',name='GPIO8',func=Pin.OUTPUT,do_erc=True),
Pin(num='12',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='22',name='GPIO4',func=Pin.BIDIR,do_erc=True),
Pin(num='32',name='GPIO9',func=Pin.BIDIR,do_erc=True),
Pin(num='13',name='UART_RX',do_erc=True),
Pin(num='23',name='SPI_CSB',do_erc=True),
Pin(num='33',name='GPIO10',func=Pin.BIDIR,do_erc=True),
Pin(num='14',name='UART_TX',func=Pin.OUTPUT,do_erc=True),
Pin(num='24',name='SPI_MISO',func=Pin.OUTPUT,do_erc=True),
Pin(num='34',name='GPIO11',func=Pin.BIDIR,do_erc=True),
Pin(num='15',name='UART_RTS',func=Pin.OUTPUT,do_erc=True),
Pin(num='25',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='35',name='AIO1',do_erc=True),
Pin(num='16',name='UART_CTS',do_erc=True),
Pin(num='26',name='RF_ANT',func=Pin.BIDIR,do_erc=True),
Pin(num='36',name='SHIELD',do_erc=True),
Pin(num='17',name='USB_D+',func=Pin.BIDIR,do_erc=True),
Pin(num='27',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='18',name='USB_D-',func=Pin.BIDIR,do_erc=True),
Pin(num='28',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='19',name='GPIO2',func=Pin.BIDIR,do_erc=True),
Pin(num='29',name='GND',func=Pin.PWRIN,do_erc=True)]),
Part(name='SA605D',dest=TEMPLATE,tool=SKIDL,do_erc=True),
Part(name='SIM900',dest=TEMPLATE,tool=SKIDL,keywords='GSM GPRS Quad-Band SMS FAX',description='GSM Quad-Band Communication Module, GPRS, Audio Engine, AT Command Set',ref_prefix='U',num_units=1,do_erc=True,pins=[
Pin(num='1',name='PWRKEY',func=Pin.PASSIVE,do_erc=True),
Pin(num='2',name='PWRKEY_OUT',func=Pin.PASSIVE,do_erc=True),
Pin(num='3',name='DTR',func=Pin.OUTPUT,do_erc=True),
Pin(num='4',name='RI',func=Pin.OUTPUT,do_erc=True),
Pin(num='5',name='DCD',func=Pin.OUTPUT,do_erc=True),
Pin(num='6',name='DSR',func=Pin.OUTPUT,do_erc=True),
Pin(num='7',name='CTS',func=Pin.OUTPUT,do_erc=True),
Pin(num='8',name='RTS',do_erc=True),
Pin(num='9',name='TXD',func=Pin.OUTPUT,do_erc=True),
Pin(num='10',name='RXD',do_erc=True),
Pin(num='20',name='MIC_N',func=Pin.PASSIVE,do_erc=True),
Pin(num='30',name='SIM_VDD',func=Pin.PWROUT,do_erc=True),
Pin(num='40',name='GPIO1/KBR4',func=Pin.BIDIR,do_erc=True),
Pin(num='50',name='GPIO9/KBC1',func=Pin.BIDIR,do_erc=True),
Pin(num='60',name='RF_ANT',func=Pin.PASSIVE,do_erc=True),
Pin(num='11',name='DS_CLK',func=Pin.OUTPUT,do_erc=True),
Pin(num='21',name='SPK_P',func=Pin.PASSIVE,do_erc=True),
Pin(num='31',name='SIM_DATA',func=Pin.BIDIR,do_erc=True),
Pin(num='41',name='GPIO2/KBR3',func=Pin.BIDIR,do_erc=True),
Pin(num='51',name='GPIO10/KBC0',func=Pin.BIDIR,do_erc=True),
Pin(num='61',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='12',name='DS_DTA',func=Pin.BIDIR,do_erc=True),
Pin(num='22',name='SPK_N',func=Pin.PASSIVE,do_erc=True),
Pin(num='32',name='SIM_CLK',func=Pin.OUTPUT,do_erc=True),
Pin(num='42',name='GPIO3/KBR2',func=Pin.BIDIR,do_erc=True),
Pin(num='52',name='NETLIGHT',func=Pin.PASSIVE,do_erc=True),
Pin(num='62',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='13',name='DS_D/C',func=Pin.OUTPUT,do_erc=True),
Pin(num='23',name='LINE_R',func=Pin.PASSIVE,do_erc=True),
Pin(num='33',name='SIM_RST',func=Pin.OUTPUT,do_erc=True),
Pin(num='43',name='GPIO4/KBR1',func=Pin.BIDIR,do_erc=True),
Pin(num='53',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='63',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='14',name='DS_CS',func=Pin.OUTPUT,do_erc=True),
Pin(num='24',name='LINE_L',func=Pin.PASSIVE,do_erc=True),
Pin(num='34',name='SIM_PRESENCE',func=Pin.OUTPUT,do_erc=True),
Pin(num='44',name='GPIO5/KBR0',func=Pin.BIDIR,do_erc=True),
Pin(num='54',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='64',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='15',name='VDD_EXT',func=Pin.PWRIN,do_erc=True),
Pin(num='25',name='ADC',func=Pin.PASSIVE,do_erc=True),
Pin(num='35',name='PWM1',func=Pin.OUTPUT,do_erc=True),
Pin(num='45',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='55',name='VBAT',func=Pin.PWRIN,do_erc=True),
Pin(num='65',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='16',name='~RESET~',do_erc=True),
Pin(num='26',name='VRTC',func=Pin.PASSIVE,do_erc=True),
Pin(num='36',name='PWM2',func=Pin.OUTPUT,do_erc=True),
Pin(num='46',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='56',name='VBAT',func=Pin.PWRIN,do_erc=True),
Pin(num='66',name='STATUS',func=Pin.PASSIVE,do_erc=True),
Pin(num='17',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='27',name='DBG_TXD',func=Pin.OUTPUT,do_erc=True),
Pin(num='37',name='SDA',func=Pin.BIDIR,do_erc=True),
Pin(num='47',name='GPIO6/KBC4',func=Pin.BIDIR,do_erc=True),
Pin(num='57',name='VBAT',func=Pin.PWRIN,do_erc=True),
Pin(num='67',name='GPIO11',func=Pin.BIDIR,do_erc=True),
Pin(num='18',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='28',name='DBG_RXD',do_erc=True),
Pin(num='38',name='SCL',func=Pin.OUTPUT,do_erc=True),
Pin(num='48',name='GPIO7/KBC3',func=Pin.BIDIR,do_erc=True),
Pin(num='58',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='68',name='GPIO12',func=Pin.BIDIR,do_erc=True),
Pin(num='19',name='MIC_P',func=Pin.PASSIVE,do_erc=True),
Pin(num='29',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='39',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='49',name='GPIO8/KBC2',func=Pin.BIDIR,do_erc=True),
Pin(num='59',name='GND',func=Pin.PWRIN,do_erc=True)]),
Part(name='TD1205',dest=TEMPLATE,tool=SKIDL,keywords='IOT SIGFOX GPS',description='High-Performance, Low-Current SIGFOX™ Gateway And GPS Receiver With Integrated Antennas',ref_prefix='U',num_units=1,do_erc=True,pins=[
Pin(num='1',name='BAT-',func=Pin.PWRIN,do_erc=True),
Pin(num='2',name='BAT+',func=Pin.PWRIN,do_erc=True),
Pin(num='3',name='VDD',func=Pin.PWRIN,do_erc=True),
Pin(num='4',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='5',name='~RST',do_erc=True),
Pin(num='6',name='UART-TX',func=Pin.BIDIR,do_erc=True),
Pin(num='7',name='UART-RX',func=Pin.BIDIR,do_erc=True),
Pin(num='8',name='DB2-SWDIO',func=Pin.BIDIR,do_erc=True),
Pin(num='9',name='DB3-SWCLK',func=Pin.BIDIR,do_erc=True)]),
Part(name='TD1208',dest=TEMPLATE,tool=SKIDL,keywords='IOT SIGFOX',description='High-Performance, Low-Current SIGFOX™ Gateway',ref_prefix='U',num_units=1,do_erc=True,pins=[
Pin(num='1',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='2',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='3',name='Reserved',func=Pin.UNSPEC,do_erc=True),
Pin(num='4',name='USR4',func=Pin.BIDIR,do_erc=True),
Pin(num='5',name='DB3-SWCLK',func=Pin.BIDIR,do_erc=True),
Pin(num='6',name='DB2-SWDIO',func=Pin.BIDIR,do_erc=True),
Pin(num='7',name='SDA',func=Pin.BIDIR,do_erc=True),
Pin(num='8',name='SCL',func=Pin.BIDIR,do_erc=True),
Pin(num='9',name='VDD',func=Pin.PWRIN,do_erc=True),
Pin(num='10',name='USR2',func=Pin.BIDIR,do_erc=True),
Pin(num='20',name='ADC0',func=Pin.BIDIR,do_erc=True),
Pin(num='11',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='21',name='TIM2',func=Pin.BIDIR,do_erc=True),
Pin(num='12',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='22',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='13',name='USR3',func=Pin.BIDIR,do_erc=True),
Pin(num='23',name='RF_GND',func=Pin.PWRIN,do_erc=True),
Pin(num='14',name='~RST',do_erc=True),
Pin(num='24',name='RF',func=Pin.BIDIR,do_erc=True),
Pin(num='15',name='DAC0',func=Pin.BIDIR,do_erc=True),
Pin(num='25',name='RF_GND',func=Pin.PWRIN,do_erc=True),
Pin(num='16',name='USR0',func=Pin.BIDIR,do_erc=True),
Pin(num='17',name='USR1',func=Pin.BIDIR,do_erc=True),
Pin(num='18',name='UART-TX',func=Pin.BIDIR,do_erc=True),
Pin(num='19',name='UART-RX',func=Pin.BIDIR,do_erc=True)]),
Part(name='TR-52D',dest=TEMPLATE,tool=SKIDL,keywords='IQRF common transceiver, GMSK modulation',description='IQRF common transceiver, GMSK modulation',ref_prefix='IC',num_units=1,fplist=['IQRF?KON?SIM?01*'],do_erc=True,aliases=['TR-72D', 'DCTR-52D', 'DCTR-72D'],pins=[
Pin(num='1',name='RA0/AN0/C12IN0',func=Pin.BIDIR,do_erc=True),
Pin(num='2',name='RC2/Vout',func=Pin.BIDIR,do_erc=True),
Pin(num='3',name='Vin',func=Pin.PWRIN,do_erc=True),
Pin(num='4',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='5',name='RA5/RB4/RC6/AN4/AN11/TX/~SS~/C2OUT/CCP3',func=Pin.BIDIR,do_erc=True),
Pin(num='6',name='RC3/SCK/SCL',func=Pin.BIDIR,do_erc=True),
Pin(num='7',name='RC4/SDI/SDA',func=Pin.BIDIR,do_erc=True),
Pin(num='8',name='RC5/RC7/RX/SDO',func=Pin.BIDIR,do_erc=True),
Pin(num='9',name='GND',func=Pin.PWRIN,do_erc=True)]),
Part(name='XBee_SMT',dest=TEMPLATE,tool=SKIDL,keywords='Digi XBee',description='Digi Xbee SMT RF module',ref_prefix='U',num_units=1,fplist=['Digi*XBee*SMT*'],do_erc=True,pins=[
Pin(num='1',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='2',name='VCC',func=Pin.PWRIN,do_erc=True),
Pin(num='3',name='DIO13/UART_TX',func=Pin.BIDIR,do_erc=True),
Pin(num='4',name='DIO14/UART_RX/~CONFIG',func=Pin.BIDIR,do_erc=True),
Pin(num='5',name='DIO12',func=Pin.BIDIR,do_erc=True),
Pin(num='6',name='RESET/OD_OUT',func=Pin.BIDIR,do_erc=True),
Pin(num='7',name='DIO10/RSSI/PWM0',func=Pin.BIDIR,do_erc=True),
Pin(num='8',name='DIO11/PWM1',func=Pin.BIDIR,do_erc=True),
Pin(num='9',name='NC',func=Pin.NOCONNECT,do_erc=True),
Pin(num='10',name='DIO8/SLEEP_REQUEST',func=Pin.BIDIR,do_erc=True),
Pin(num='20',name='NC',func=Pin.NOCONNECT,do_erc=True),
Pin(num='30',name='DIO3/AD3',func=Pin.BIDIR,do_erc=True),
Pin(num='11',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='21',name='NC',func=Pin.NOCONNECT,do_erc=True),
Pin(num='31',name='DIO2/AD2',func=Pin.BIDIR,do_erc=True),
Pin(num='12',name='DIO19/SPI_~ATTN',func=Pin.OUTPUT,do_erc=True),
Pin(num='22',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='32',name='DIO1/AD1',func=Pin.BIDIR,do_erc=True),
Pin(num='13',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='23',name='NC',func=Pin.NOCONNECT,do_erc=True),
Pin(num='33',name='DIO0/AD0',func=Pin.BIDIR,do_erc=True),
Pin(num='14',name='DIO18/SPI_CLK',do_erc=True),
Pin(num='24',name='DIO4',func=Pin.BIDIR,do_erc=True),
Pin(num='34',name='NC',func=Pin.NOCONNECT,do_erc=True),
Pin(num='15',name='DIO17/SPI_~SSEL',do_erc=True),
Pin(num='25',name='DIO7/~CTS',func=Pin.BIDIR,do_erc=True),
Pin(num='35',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='16',name='DIO16/SPI_MOSI',do_erc=True),
Pin(num='26',name='DIO9/ON/~SLEEP',func=Pin.BIDIR,do_erc=True),
Pin(num='36',name='RF',func=Pin.BIDIR,do_erc=True),
Pin(num='17',name='DIO15/SPI_MISO',func=Pin.OUTPUT,do_erc=True),
Pin(num='27',name='VREF',func=Pin.PWRIN,do_erc=True),
Pin(num='37',name='NC',func=Pin.NOCONNECT,do_erc=True),
Pin(num='18',name='NC',func=Pin.NOCONNECT,do_erc=True),
Pin(num='28',name='DIO5/ASSOCIATE',func=Pin.BIDIR,do_erc=True),
Pin(num='19',name='NC',func=Pin.NOCONNECT,do_erc=True),
Pin(num='29',name='DIO6/~RTS',func=Pin.BIDIR,do_erc=True)]),
Part(name='iM880A',dest=TEMPLATE,tool=SKIDL,keywords='IOT LoRa',description='IMST Long Range Radio Module - LoRa Alliance Certified',ref_prefix='U',num_units=1,do_erc=True,aliases=['iM880B'],pins=[
Pin(num='1',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='2',name='P1-IO/JTCK/SWCLK',func=Pin.BIDIR,do_erc=True),
Pin(num='3',name='P2-IO/JTMS/SWDIO',func=Pin.BIDIR,do_erc=True),
Pin(num='4',name='P3-IO/JTDO',func=Pin.BIDIR,do_erc=True),
Pin(num='5',name='P4-IO/JTDI',func=Pin.BIDIR,do_erc=True),
Pin(num='6',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='7',name='~RST',do_erc=True),
Pin(num='8',name='P5-IO/UART-CTS',func=Pin.BIDIR,do_erc=True),
Pin(num='9',name='P6-IO/UART-RTS',func=Pin.BIDIR,do_erc=True),
Pin(num='10',name='NC',func=Pin.NOCONNECT,do_erc=True),
Pin(num='20',name='P11-IO',func=Pin.BIDIR,do_erc=True),
Pin(num='30',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='11',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='21',name='P12-IO/I2C-SCL',func=Pin.BIDIR,do_erc=True),
Pin(num='31',name='RF',func=Pin.BIDIR,do_erc=True),
Pin(num='12',name='P7-IO/SPI-MISO',func=Pin.BIDIR,do_erc=True),
Pin(num='22',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='32',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='13',name='P8-IO/SPI-MOSI',func=Pin.BIDIR,do_erc=True),
Pin(num='23',name='P13-IO/I2C-SDA',func=Pin.BIDIR,do_erc=True),
Pin(num='14',name='P9-IO/SPI-CLK',func=Pin.BIDIR,do_erc=True),
Pin(num='24',name='P14-IO/ADC',func=Pin.BIDIR,do_erc=True),
Pin(num='15',name='P10-IO/SPI-NSS',func=Pin.BIDIR,do_erc=True),
Pin(num='25',name='P15-IO/WKUP',func=Pin.BIDIR,do_erc=True),
Pin(num='16',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='26',name='BOOT',do_erc=True),
Pin(num='17',name='VDD',func=Pin.PWRIN,do_erc=True),
Pin(num='27',name='GND',func=Pin.PWRIN,do_erc=True),
Pin(num='18',name='RxD-IO/UART-RX',func=Pin.BIDIR,do_erc=True),
Pin(num='28',name='NC',func=Pin.NOCONNECT,do_erc=True),
Pin(num='19',name='TxD-IO/UART-TX',func=Pin.BIDIR,do_erc=True),
Pin(num='29',name='P17-IO/ADC',func=Pin.BIDIR,do_erc=True)])])
| StarcoderdataPython |
11393420 | <filename>devilry/devilry_admin/views/assignment/download_files/download_archive.py
# -*- coding: utf-8 -*-
from django.contrib.contenttypes.models import ContentType
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.views import generic
from django_cradmin import crapp
from devilry.apps.core import models as core_models
from devilry.devilry_compressionutil import models as archivemodels
from devilry.devilry_group.utils import download_response
from devilry.devilry_admin.views.assignment.download_files import batch_download_api
class CompressedAssignmentFileDownloadView(generic.TemplateView):
def get(self, request, *args, **kwargs):
assignment_id = kwargs.get('assignment_id')
assignment = get_object_or_404(core_models.Assignment, id=assignment_id)
if assignment != self.request.cradmin_role:
raise Http404()
archive_meta = archivemodels.CompressedArchiveMeta.objects\
.filter(content_object_id=assignment_id,
content_type=ContentType.objects.get_for_model(model=assignment),
deleted_datetime=None,
created_by=self.request.user,
created_by_role=archivemodels.CompressedArchiveMeta.CREATED_BY_ROLE_ADMIN)\
.order_by('-created_datetime').first()
if not archive_meta:
raise Http404()
return download_response.download_response(
content_path=archive_meta.archive_path,
content_name=archive_meta.archive_name,
content_type='application/zip',
content_size=archive_meta.archive_size,
streaming_response=True)
class App(crapp.App):
appurls = [
crapp.Url(
r'^assignment-file-download/(?P<assignment_id>[0-9]+)$',
CompressedAssignmentFileDownloadView.as_view(),
name='assignment-file-download'),
crapp.Url(
r'assignment-download-api/(?P<content_object_id>[0-9]+)$',
batch_download_api.BatchCompressionAPIAssignmentView.as_view(),
name='assignment-file-download-api'
)
] | StarcoderdataPython |
4940942 | # -*- coding:utf-8 -*-
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Class of ParzenEstimator."""
import numpy as np
from scipy.special import erf
EPS = 1e-12
class ParzenEstimator:
"""ParzenEstimator.
:param hyper_param_list: List[HyperParameter]
:type hyper_param_list: list
:param gamma: gamma.
:type gamma: int
:param left_forget: left_forget
:type left_forget: int
"""
def __init__(self, hyper_param_list, gamma=0.25, left_forget=25):
self.kdes = {"upper": [], "lower": []}
self.range_list = [
hyper_param.range for hyper_param in hyper_param_list
]
self.gamma = gamma
self.left_forget = left_forget
def fit(self, X, y):
"""Fit a model."""
if len(X) <= 1:
return self
num = X.shape[0]
dim = X.shape[1]
if dim != len(self.range_list):
raise ValueError(
"Variable `X's` column numbers should be consistent with the "
"number of hyper-parameters: {}!".format(len(self.range_list))
)
order = np.argsort(-y, kind="stable")
segmentation = int(np.ceil(self.gamma * np.sqrt(num)))
points_upper, points_lower = [], []
idxs_upper = set(order[:segmentation])
for idx in range(len(order)):
if idx in idxs_upper:
points_upper.append(X[idx])
else:
points_lower.append(X[idx])
points_upper, points_lower = np.asarray(points_upper), np.asarray(points_lower)
for index in range(dim):
range_ = self.range_list[index]
ori_mu, ori_sigma = sum(range_) / 2.0, abs(range_[0] - range_[1])
weights, mus, sigmas = self._generate_dim_info(
points_upper[:, index], ori_mu, ori_sigma
)
self._generate_kde(
"upper", range_, weights, mus, sigmas
)
weights, mus, sigmas = self._generate_dim_info(
points_lower[:, index], ori_mu, ori_sigma
)
self._generate_kde(
"lower", range_, weights, mus, sigmas
)
return self
def predict(self, X):
"""Predict a mean and std for input X.
:param X:
:return:
"""
output = np.zeros_like(X)
dim = output.shape[1]
for index in range(dim):
lx = self.kdes["upper"][index].score_samples(X[:, index:index + 1])
gx = self.kdes["lower"][index].score_samples(X[:, index:index + 1])
output[:, index] = lx - gx
mean = output.mean(axis=1)
std = output.std(axis=1)
return mean, std
def _generate_dim_info(self, points, ori_mu, ori_sigma):
"""Generate dim info."""
mus, sigmas, ori_pos, srt_order = self._generate_ordered_points(points, ori_mu, ori_sigma)
weights = self._generate_weights(len(points), ori_pos, srt_order)
upper_sigma = ori_sigma
lower_sigma = ori_sigma / (min(100.0, (1.0 + len(mus))))
sigmas = np.clip(sigmas, lower_sigma, upper_sigma)
sigmas[ori_pos] = ori_sigma
weights /= weights.sum()
return weights, mus, sigmas
def _generate_ordered_points(self, points, ori_mu, ori_sigma):
"""Generate ordered point."""
if len(points) >= 2:
srt_order = np.argsort(points)
srt_points = points[srt_order]
ori_pos = np.searchsorted(srt_points, ori_mu)
mus = np.hstack((srt_points[:ori_pos], ori_mu, srt_points[ori_pos:]))
points_diff = np.diff(mus)
sigmas = np.hstack((
mus[1] - mus[0],
np.maximum(points_diff[:-1], points_diff[1:]),
mus[-1] - mus[-2],
))
else:
srt_order = None
mus = np.asarray([ori_mu])
sigmas = np.asarray([ori_sigma])
if len(points) == 1:
if ori_mu > points[0]:
ori_pos = 1
else:
ori_pos = 0
mus = np.insert(mus, 1 - ori_pos, points[0])
sigmas = np.insert(sigmas, 1 - ori_pos, 0.5 * ori_sigma)
else:
ori_pos = 0
return mus, sigmas, ori_pos, srt_order
def _generate_weights(self, num, ori_pos=None, srt_order=None):
if num <= self.left_forget:
weights = np.ones((num + 1,))
else:
lf_weights = np.hstack(
(np.linspace(1.0 / num, 1.0, num - self.left_forget),
np.ones((self.left_forget,)))
)[srt_order]
weights = np.hstack(
(lf_weights[:ori_pos], 1.0, lf_weights[ori_pos:])
)
return weights
def _generate_kde(self, label, range_, weights, mus, sigmas):
kde = _KernelDensity(range_).fit(weights, mus, sigmas)
self.kdes[label].append(kde)
class _KernelDensity:
"""KernelDensity."""
def __init__(self, range_):
self.lb, self.ub = min(range_), max(range_)
def fit(self, weights, mus, sigmas):
"""Fit a model."""
self.weights = weights
self.mus = mus
self.sigmas = sigmas
return self
def score_samples(self, X):
"""Sample score."""
logpdf = _weighted_truncated_norm_lpdf(
X, self.lb, self.ub, self.mus, self.sigmas, self.weights
)
max_logpdf = np.max(logpdf, axis=1)
return \
np.log(
np.sum(np.exp(logpdf - max_logpdf[:, None]), axis=1)
) + max_logpdf
def _weighted_truncated_norm_lpdf(X, lower_bound, upper_bound, mus, sigmas, weights):
"""Get pdf according to lower_bound and upper_bound."""
sigmas = np.maximum(sigmas, EPS)
p_inside = (weights * (
_gauss_cdf(upper_bound, mus, sigmas) - _gauss_cdf(lower_bound, mus, sigmas)
)).sum()
standard_X = (X - mus) / sigmas
partition = np.sqrt(2 * np.pi) * sigmas
log_probs = -(standard_X)**2 / 2.0 + np.log(weights / p_inside / partition)
return log_probs
def _gauss_cdf(x, mu, sigma):
"""Get cdf."""
standard_x = (x - mu) / sigma
cdf = (1 + erf(standard_x / np.sqrt(2))) / 2.0
return cdf
| StarcoderdataPython |
9741973 | <filename>03-validador_e_gerador_CPF/validador_gerador_CPF.py
'''
Funções para validação e geração de CPF utilizando códigos simples
'''
def validacao_CPF(cpf):
cpf = str(cpf)
if len(cpf) != 11:
return False
cpf_9digitos = cpf[:9]
# variáveis para os loops dos laços e para somas
loop1 = 10
loop2 = 11
soma1 = soma2 = 0
# gerando dígito 1
for i in cpf_9digitos:
soma1 += int(i) * loop1
loop1 -= 1
result1 = 11 - (soma1 % 11)
digito1 = result1 if result1 <= 9 else 0
cpf_verificado = cpf_9digitos + str(digito1)
# gerando dígito 2
for j in cpf_verificado:
soma2 += int(j) * loop2
loop2 -= 1
result2 = 11 - (soma2 % 11)
digito2 = result2 if result2 <= 9 else 0
cpf_verificado += str(digito2)
return True if str(cpf) == str(cpf_verificado) else False
def gerar_CPF():
from random import randint
cpf = ''
for n in range(0, 9): # gerando nove primeiros números
n = str(randint(0, 9))
cpf += n
loop1 = 10
loop2 = 11
soma1 = soma2 = 0
for i in cpf: # gerando dígito 1
soma1 += int(i) * loop1
loop1 -= 1
d1 = 11 - (soma1 % 11)
digito1 = d1 if d1 <= 9 else 0
cpf += str(digito1)
for j in cpf: # gerando dígito 2
soma2 += int(j) * loop2
loop2 -= 1
d2 = 11 - (soma2 % 11)
digito2 = d2 if d2 <= 9 else 0
cpf += str(digito2)
return cpf
| StarcoderdataPython |
86160 | from __future__ import absolute_import, division, print_function
from six.moves import range
def intify(a):
return tuple([int(round(val)) for val in a])
def reference_map(sg, mi):
from cctbx import sgtbx
asu = sgtbx.reciprocal_space_asu(sg.type())
isym_ = []
mi_ = []
for hkl in mi:
found = False
for i_inv in range(sg.f_inv()):
for i_smx in range(sg.n_smx()):
rt_mx = sg(0, i_inv, i_smx)
hkl_ = intify(hkl * rt_mx.r())
if asu.is_inside(hkl_):
mi_.append(hkl_)
if i_inv:
isym_.append(- i_smx)
else:
isym_.append(i_smx)
found = True
break
if found:
continue
else:
assert(not sg.is_centric())
for i_inv in range(sg.f_inv()):
for i_smx in range(sg.n_smx()):
rt_mx = sg(0, i_inv, i_smx)
_hkl = [-h for h in hkl]
mhkl_ = intify(_hkl * rt_mx.r())
if asu.is_inside(mhkl_):
mi_.append(mhkl_)
isym_.append(- i_smx)
found = True
break
return mi_, isym_
def tst_map_to_asu_isym(anomalous_flag):
from cctbx import sgtbx
from cctbx.miller import map_to_asu_isym
from cctbx.array_family import flex
mi = flex.miller_index()
i = flex.int()
import random
nhkl = 1000
for j in range(nhkl):
hkl = [random.randint(-10, 10) for j in range(3)]
mi.append(hkl)
i.append(0)
spacegroup = sgtbx.space_group_symbols(195).hall()
sg = sgtbx.space_group(spacegroup)
mi_, isym_ = reference_map(sg, mi)
map_to_asu_isym(sg.type(), anomalous_flag, mi, i)
for j in range(nhkl):
assert(i[j] == isym_[j])
if __name__ == '__main__':
tst_map_to_asu_isym(True)
tst_map_to_asu_isym(False)
print('OK')
| StarcoderdataPython |
5128781 | from . import webdrivery # noqa
from . import action # noqa
from . import settings # noqa
| StarcoderdataPython |
9722159 | <filename>apps/dot_ext/views/authorization.py
import json
import logging
import waffle
from oauth2_provider.views.introspect import IntrospectTokenView as DotIntrospectTokenView
from oauth2_provider.views.base import AuthorizationView as DotAuthorizationView
from oauth2_provider.views.base import TokenView as DotTokenView
from oauth2_provider.views.base import RevokeTokenView as DotRevokeTokenView
from oauth2_provider.models import get_application_model
from oauth2_provider.exceptions import OAuthToolkitError
from apps.dot_ext.scopes import CapabilitiesScopes
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.debug import sensitive_post_parameters
from urllib.parse import urlparse, parse_qs
from ..signals import beneficiary_authorized_application
from ..forms import SimpleAllowForm
from ..loggers import (create_session_auth_flow_trace, cleanup_session_auth_flow_trace,
get_session_auth_flow_trace, set_session_auth_flow_trace,
set_session_auth_flow_trace_value, update_instance_auth_flow_trace_with_code)
from ..models import Approval
from ..utils import remove_application_user_pair_tokens_data_access
from ..utils import validate_app_is_active
from rest_framework.exceptions import PermissionDenied
from django.template.response import TemplateResponse
from django.shortcuts import HttpResponse
import apps.logging.request_logger as bb2logging
log = logging.getLogger(bb2logging.HHS_SERVER_LOGNAME_FMT.format(__name__))
class AuthorizationView(DotAuthorizationView):
"""
Override the base authorization view from dot to
use the custom AllowForm.
"""
version = None
form_class = SimpleAllowForm
login_url = "/mymedicare/login"
def __init__(self, version=1):
self.version = version
super().__init__()
def dispatch(self, request, *args, **kwargs):
"""
Override the base authorization view from dot to
initially create an AuthFlowUuid object for authorization
flow tracing in logs.
"""
# TODO: Should the client_id match a valid application here before continuing, instead of after matching to FHIR_ID?
if not kwargs.get('is_subclass_approvalview', False):
# Create new authorization flow trace UUID in session and AuthFlowUuid instance, if subclass is not ApprovalView
create_session_auth_flow_trace(request)
try:
validate_app_is_active(request)
except PermissionDenied as error:
return TemplateResponse(
request,
"app_inactive_403.html",
context={
"detail": error.detail,
},
status=error.status_code)
request.session['version'] = self.version
return super().dispatch(request, *args, **kwargs)
# TODO: Clean up use of the require-scopes feature flag and multiple templates, when no longer required.
def get_template_names(self):
if waffle.switch_is_active('require-scopes'):
return ["design_system/authorize_v2.html"]
else:
return ["design_system/authorize.html"]
def get_initial(self):
initial_data = super().get_initial()
initial_data["code_challenge"] = self.oauth2_data.get("code_challenge", None)
initial_data["code_challenge_method"] = self.oauth2_data.get("code_challenge_method", None)
return initial_data
def get(self, request, *args, **kwargs):
kwargs['code_challenge'] = request.GET.get('code_challenge', None)
kwargs['code_challenge_method'] = request.GET.get('code_challenge_method', None)
return super().get(request, *args, **kwargs)
def form_valid(self, form):
client_id = form.cleaned_data["client_id"]
application = get_application_model().objects.get(client_id=client_id)
credentials = {
"client_id": form.cleaned_data.get("client_id"),
"redirect_uri": form.cleaned_data.get("redirect_uri"),
"response_type": form.cleaned_data.get("response_type", None),
"state": form.cleaned_data.get("state", None),
"code_challenge": form.cleaned_data.get("code_challenge", None),
"code_challenge_method": form.cleaned_data.get("code_challenge_method", None),
}
scopes = form.cleaned_data.get("scope")
allow = form.cleaned_data.get("allow")
# Get beneficiary demographic scopes sharing choice
share_demographic_scopes = form.cleaned_data.get("share_demographic_scopes")
set_session_auth_flow_trace_value(self.request, 'auth_share_demographic_scopes', share_demographic_scopes)
# Get scopes list available to the application
application_available_scopes = CapabilitiesScopes().get_available_scopes(application=application)
# Set scopes to those available to application and beneficiary demographic info choices
scopes = ' '.join([s for s in scopes.split(" ")
if s in application_available_scopes])
# Init deleted counts
data_access_grant_delete_cnt = 0
access_token_delete_cnt = 0
refresh_token_delete_cnt = 0
try:
uri, headers, body, status = self.create_authorization_response(
request=self.request, scopes=scopes, credentials=credentials, allow=allow
)
except OAuthToolkitError as error:
response = self.error_response(error, application)
if allow is False:
(data_access_grant_delete_cnt,
access_token_delete_cnt,
refresh_token_delete_cnt) = remove_application_user_pair_tokens_data_access(application, self.request.user)
beneficiary_authorized_application.send(
sender=self,
request=self.request,
auth_status="FAIL",
auth_status_code=response.status_code,
user=self.request.user,
application=application,
share_demographic_scopes=share_demographic_scopes,
scopes=scopes,
allow=allow,
access_token_delete_cnt=access_token_delete_cnt,
refresh_token_delete_cnt=refresh_token_delete_cnt,
data_access_grant_delete_cnt=data_access_grant_delete_cnt)
return response
# Did the beneficiary choose not to share demographic scopes, or the application does not require them?
if share_demographic_scopes == "False" or (allow is True and application.require_demographic_scopes is False):
(data_access_grant_delete_cnt,
access_token_delete_cnt,
refresh_token_delete_cnt) = remove_application_user_pair_tokens_data_access(application, self.request.user)
beneficiary_authorized_application.send(
sender=self,
request=self.request,
auth_status="OK",
auth_status_code=None,
user=self.request.user,
application=application,
share_demographic_scopes=share_demographic_scopes,
scopes=scopes,
allow=allow,
access_token_delete_cnt=access_token_delete_cnt,
refresh_token_delete_cnt=refresh_token_delete_cnt,
data_access_grant_delete_cnt=data_access_grant_delete_cnt)
self.success_url = uri
log.debug("Success url for the request: {0}".format(self.success_url))
# Extract code from url
url_query = parse_qs(urlparse(self.success_url).query)
code = url_query.get('code', [None])[0]
# Get auth flow trace session values dict.
auth_dict = get_session_auth_flow_trace(self.request)
# We are done using auth_uuid, clear it from the session.
cleanup_session_auth_flow_trace(self.request)
# Update AuthFlowUuid instance with code.
update_instance_auth_flow_trace_with_code(auth_dict, code)
return self.redirect(self.success_url, application)
class ApprovalView(AuthorizationView):
"""
Override the base authorization view from dot to
use the custom AllowForm.
"""
version = None
form_class = SimpleAllowForm
login_url = "/mymedicare/login"
def __init__(self, version=1):
self.version = version
super().__init__()
def dispatch(self, request, uuid, *args, **kwargs):
# Get auth_uuid to set again after super() return. It gets cleared out otherwise.
auth_flow_dict = get_session_auth_flow_trace(request)
try:
approval = Approval.objects.get(uuid=uuid)
if approval.expired:
raise Approval.DoesNotExist
if approval.application\
and approval.application.client_id != request.GET.get('client_id', None)\
and approval.application.client_id != request.POST.get('client_id', None):
raise Approval.DoesNotExist
request.user = approval.user
except Approval.DoesNotExist:
pass
# Set flag to let super method know who's calling, so auth_uuid doesn't get reset.
kwargs['is_subclass_approvalview'] = True
request.session['version'] = self.version
result = super().dispatch(request, *args, **kwargs)
if hasattr(self, 'oauth2_data'):
application = self.oauth2_data.get('application', None)
if application is not None:
approval.application = self.oauth2_data.get('application', None)
approval.save()
# Set auth_uuid after super() return
if auth_flow_dict:
set_session_auth_flow_trace(request, auth_flow_dict)
return result
@method_decorator(csrf_exempt, name="dispatch")
class TokenView(DotTokenView):
@method_decorator(sensitive_post_parameters("password"))
def post(self, request, *args, **kwargs):
try:
validate_app_is_active(request)
except PermissionDenied as error:
return HttpResponse(json.dumps({"status_code": error.status_code,
"detail": error.detail, }),
status=error.status_code,
content_type='application/json')
return super().post(request, args, kwargs)
@method_decorator(csrf_exempt, name="dispatch")
class RevokeTokenView(DotRevokeTokenView):
@method_decorator(sensitive_post_parameters("password"))
def post(self, request, *args, **kwargs):
try:
validate_app_is_active(request)
except PermissionDenied as error:
return HttpResponse(json.dumps({"status_code": error.status_code,
"detail": error.detail, }),
status=error.status_code,
content_type='application/json')
return super().post(request, args, kwargs)
@method_decorator(csrf_exempt, name="dispatch")
class IntrospectTokenView(DotIntrospectTokenView):
def get(self, request, *args, **kwargs):
try:
validate_app_is_active(request)
except PermissionDenied as error:
return HttpResponse(json.dumps({"status_code": error.status_code,
"detail": error.detail, }),
status=error.status_code,
content_type='application/json')
return super(IntrospectTokenView, self).get(request, args, kwargs)
def post(self, request, *args, **kwargs):
try:
validate_app_is_active(request)
except PermissionDenied as error:
return HttpResponse(json.dumps({"status_code": error.status_code,
"detail": error.detail, }),
status=error.status_code,
content_type='application/json')
return super(IntrospectTokenView, self).post(request, args, kwargs)
| StarcoderdataPython |
99233 | n = int(input())
D = [list(map(int,input().split())) for i in range(n)]
D.sort(key = lambda t: t[0])
S = 0
for i in D:
S += i[1]
S = (S+1)//2
S2 = 0
for i in D:
S2 += i[1]
if S2 >= S:
print(i[0])
break | StarcoderdataPython |
1824875 | import os
import sys
sys.path.append("../") # go to parent dir
import glob
import time
import logging
import numpy as np
from scipy.sparse import linalg as spla
import matplotlib.pyplot as plt
import logging
from mpl_toolkits import mplot3d
from mayavi import mlab
from scipy.special import sph_harm
mlab.options.offscreen = False
#add path to data folder
input_folder = "/Volumes/ExtDrive/data"
output_folder = "plots"
dpi=300
cmap="coolwarm"
ind = 4500 #time ind
with np.load(os.path.join(input_folder, 'sphere113/output_%i.npz' %(ind))) as file:
om1 = file['om']
time = file['t'][0]
print('time=%f' %time)
with np.load(os.path.join(input_folder, 'sphere114/output_%i.npz' %(ind))) as file:
om2 = file['om']
time = file['t'][0]
print('time=%f' %time)
with np.load(os.path.join(input_folder, 'sphere115/output_%i.npz' %(ind))) as file:
om3 = file['om']
time = file['t'][0]
print('time=%f' %time)
with np.load(os.path.join(input_folder, 'sphere111/output_%i.npz' %(ind))) as file:
om4 = file['om']
time = file['t'][0]
print('time=%f' %time)
with np.load(os.path.join(input_folder, 'sphere109/output_%i.npz' %(ind))) as file:
om5 = file['om']
time = file['t'][0]
print('time=%f' %time)
with np.load(os.path.join(input_folder, 'sphere110/output_%i.npz' %(ind))) as file:
om6 = file['om']
time = file['t'][0]
print('time=%f' %time)
with np.load(os.path.join(input_folder, 'sphere116/output_%i.npz' %(ind))) as file:
om7 = file['om']
time = file['t'][0]
print('time=%f' %time)
with np.load(os.path.join(input_folder, 'sphere117/output_%i.npz' %(ind))) as file:
om8 = file['om']
time = file['t'][0]
print('time=%f' %time)
with np.load(os.path.join(input_folder, 'sphere118/output_%i.npz' %(ind))) as file:
phi = file['phi']
theta = file['theta']
om9 = file['om']
time = file['t'][0]
print('time=%f' %time)
#change phi
phi = np.linspace(0, 2*np.pi, len(phi))
# Create a sphere
r = 0.3
pi = np.pi
cos = np.cos
sin = np.sin
phiphi, thth = np.meshgrid(theta, phi-pi)
x = r * sin(phiphi) * cos(thth)
y = r * sin(phiphi) * sin(thth)
z = r * cos(phiphi)
#s = sph_harm(0, 10, theta, phi).real
mlab.figure(1, bgcolor=(0, 0, 0), fgcolor=(1, 1, 1), size=(800, 700))
mlab.clf()
cmin, cmax = -300, 300
dx = 0.7
m = mlab.mesh(x, y, z+2*dx, scalars=om1, colormap=cmap)
m = mlab.mesh(x+dx, y, z+2*dx, scalars=om2, colormap=cmap)
m = mlab.mesh(x+2*dx, y, z+2*dx, scalars=om3, colormap=cmap)
m = mlab.mesh(x, y, z+dx, scalars=om4, colormap=cmap)
m = mlab.mesh(x+dx, y, z+dx, scalars=om5, colormap=cmap)
m = mlab.mesh(x+2*dx, y, z+dx, scalars=om6, colormap=cmap)
m = mlab.mesh(x, y, z, scalars=om7, colormap=cmap)
m = mlab.mesh(x+dx, y, z, scalars=om8, colormap=cmap)
m = mlab.mesh(x+2*dx, y, z, scalars=om9, colormap=cmap)
mlab.view(-90, 90, distance=4)
#mlab.savefig("%s/mayavi.pdf" %(output_folder), magnification=100)
#mlab.show()
#mlab.figure(2, bgcolor=(0, 0, 0), fgcolor=(1, 1, 1), size=(700, 300))
#mlab.clf()
#m = mlab.mesh(x, y, z, scalars=om3, colormap=cmap)
#m = mlab.mesh(x+0.7, y, z, scalars=om6, colormap=cmap)
#m = mlab.mesh(x+1.4, y, z, scalars=om9, colormap=cmap)
#mlab.view(-90, 90, distance=1.5)
#mlab.savefig("%s/mayavi_front.pdf" %(output_folder), magnification=100)
mlab.show()
| StarcoderdataPython |
24503 | # node class for develping linked list
class Node:
def __init__(self, data=None, pointer=None):
self.data = data
self.pointer = pointer
def set_data(self, data):
self.data = data
def get_data(self):
return self.data
def set_pointer(self, pointer):
self.pointer = pointer
def get_pointer(self):
return self.pointer
def __str__(self):
return f'(data: {self.data} & pointer: {self.pointer})'
class Stack:
def __init__(self, buttom=None, top=None):
self.buttom = buttom
self.top = top
# push operation
def push(self, data):
if self.buttom == None:
self.buttom = self.top = Node(data)
else:
new_node = Node(data, self.top)
self.top = new_node
return self
# pop operation
def pop(self):
if self.top == None:
return None
data = self.top.get_data()
self.top = self.top.get_pointer()
return data
# peek operation
def peek(self):
return self.top.get_data()
# returns stack as list
def as_list(self):
curr_node = self.top
stack_list = list()
while curr_node.get_pointer() != None:
stack_list.append(curr_node.get_data())
curr_node = curr_node.get_pointer()
stack_list.append(curr_node.get_data())
return stack_list
# returns True if stack empty and False if its not
def is_empty(self):
if self.top:
return False
else:
return True
def __str__(self):
return f'top: {self.top} & buttom: {self.buttom}'
if __name__ == '__main__':
stack = Stack()
stack.push('Google')
stack.push('Udemy')
stack.push('Facebook')
# print(stack.peek())
stack.pop()
print(stack.peek())
print(stack.as_list())
| StarcoderdataPython |
3526725 | <reponame>jonathan-taylor/l0bnb
import numpy as np
import regreg.api as rr
from l0bnb.proximal import (perspective_bound_atom,
perspective_lagrange_atom,
perspective_bound_atom_conjugate,
perspective_lagrange_atom_conjugate)
def test_bound_solve():
n, p = 100, 50
v = np.random.standard_normal(100)
X = np.random.standard_normal((n, p))
Y = np.random.standard_normal(n)
lips, lam_2, M, C = 1.5, 0.02, 2, 5
atom = perspective_bound_atom((p,),
lam_2,
M,
C)
loss = rr.squared_error(X, Y)
problem = rr.simple_problem(loss, atom)
problem.solve(debug=True, tol=1e-7, min_its=50)
def test_lagrange_solve():
n, p = 100, 50
v = np.random.standard_normal(100)
X = np.random.standard_normal((n, p))
Y = np.random.standard_normal(n)
lips, lam_2, M, lam_0 = 1.5, 0.02, 2, 0.2
atom = perspective_lagrange_atom((p,),
lam_2,
M,
lam_0)
loss = rr.squared_error(X, Y)
problem = rr.simple_problem(loss, atom)
problem.solve(debug=True, tol=1e-7, min_its=50)
def test_bound_conjugate_solve():
n, p = 100, 50
v = np.random.standard_normal(100)
X = np.random.standard_normal((n, p))
Y = np.random.standard_normal(n)
lips, lam_2, M, C = 1.5, 0.02, 2, 5
atom = perspective_bound_atom_conjugate((p,),
lam_2,
M,
C)
loss = rr.squared_error(X, Y)
problem = rr.simple_problem(loss, atom)
problem.solve(debug=True, tol=1e-7, min_its=50)
def test_lagrange_conjugate_solve():
n, p = 100, 50
v = np.random.standard_normal(100)
X = np.random.standard_normal((n, p))
Y = np.random.standard_normal(n)
lips, lam_2, M, lam_0 = 1.5, 0.02, 2, 0.2
atom = perspective_lagrange_atom_conjugate((p,),
lam_2,
M,
lam_0)
loss = rr.squared_error(X, Y)
problem = rr.simple_problem(loss, atom)
problem.solve(debug=True, tol=1e-7, min_its=50)
| StarcoderdataPython |
3439926 | <gh_stars>1-10
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .logger import Logger, InternalLogger, DummyLogger, LogFormat
from .utils import convert_dottable, clone, set_seeds
__all__ = ["Logger", "InternalLogger", "DummyLogger", "LogFormat", "convert_dottable", "clone", "set_seeds"]
| StarcoderdataPython |
41134 | <reponame>happy-machine/ktrain<gh_stars>0
# Global version information
__version__ = "0.7.2"
| StarcoderdataPython |
302214 | from pymongo import MongoClient
class MongoDBConnectionManager:
def __init__(self, hostname, port):
self.hostname = hostname
self.port = port
self.connection = None
def __enter__(self):
self.connection = MongoClient(self.hostname, self.port)
return self
def __exit__(self, exc_type, exc_value, exc_traceback):
self.connection.close()
# connecting with a localhost
with MongoDBConnectionManager("localhost", 27017) as mongo:
collection = mongo.connection.SampleDb.test
data = collection.find({"_id": 1})
print(data.get("name"))
| StarcoderdataPython |
1982338 | <reponame>MTC-ETH/Federated-Learning-source
# Copyright 2021, ETH Zurich, Media Technology Center
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Worker Class. This Class gets the tasks from node_task_controller and fulfills it. It storas a local model in memory.
That is the model that all task are processed on. As soon as a task it finished it gives the task specific feedback
directly to the server. There are currently 4 tasks:
fetch_model: fetches the global model from the server and compiles it.
train_model: trains the local model with the provided training data and the parameters given in the model config.
Pings the global server when finished.
send_model: sends the local model to the global server
send_validation_loss: sends the evaluation loss to the server
"""
import os
import gc
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
import tensorflow as tf
import utils.RandomForest.forest as RandomForest
import utils.RandomForest.tree as DecisionTree
import logging
import copy
import json
import os
from sklearn.utils import resample
from math import isclose
import numpy as np
import xgboost as xgb
import pickle
from diffprivlib.mechanisms import GeometricTruncated
from sys import maxsize
from sklearn import metrics as skmetrics
from tensorflow import metrics as tfmetrics
class Model:
def __init__(self, config, wrapper):
self.config = config
self.data_generator = wrapper
self.model = None
self.global_model = None
def get_loss(self, data_type):
y_pred, y_true = self.predict(data_type)
performance = self.calculate_loss(y_pred=y_pred, y_true=y_true,
tf_metrics=self.config['training'].get('tfmetrics', []),
sk_metrics=self.config['training'].get('skmetrics', []))
return performance
@staticmethod
def calculate_loss(y_pred, y_true, tf_metrics, sk_metrics):
performance = {}
for metric in sk_metrics:
try:
performance[metric] = getattr(skmetrics, metric)(y_pred=y_pred, y_true=y_true)
except TypeError:
performance[metric] = getattr(skmetrics, metric)(y_score=y_pred, y_true=y_true)
except ValueError:
y_pred_rounded = []
for value in y_pred:
y_pred_rounded.append(1 if value > 0.5 else 0)
performance[metric] = getattr(skmetrics, metric)(y_pred=y_pred_rounded, y_true=y_true)
for metric in tf_metrics: # todo add params
m = getattr(tfmetrics, metric)()
try:
m.update_state(y_true=y_true, y_pred=y_pred)
except tf.errors.InvalidArgumentError:
temp=np.array([y_true,y_pred]).T
temp=temp[~np.isnan(temp[:, 1])]
m.update_state(y_true=temp[:,0], y_pred=temp[:,1])
performance[metric] = m.result().numpy()
return performance
def reset_model(self):
self.model = self.global_model
def load_model(self, model):
self.set_model(model)
self.global_model = self.model
def predict(self, data_type):
return 0, 0
def set_model(self, model):
return {}
class RF(Model):
def __init__(self, config, wrapper):
super().__init__(config, wrapper)
self.batch = None # todo ugly
def get_model_update(self):
model_update = json.dumps(self.model.model_update)
return model_update.encode('utf-8')
def set_model(self, model):
config = json.loads(model.model_definition)
self.model = RandomForest.RandomForestClassifier.from_json(config['model'])
# self._set_dataset()##todo ????????????why
# self._set_custom_training_config()
#
# self._set_preprocessing()
if self.batch is None:
generator = self.data_generator.generator("train")
batch = next(generator)
batch = np.concatenate((batch[0], batch[1].reshape((self.config['training']['batch_size'], 1))), axis=1)
import datetime
np.random.seed(datetime.datetime.now().microsecond)
np.random.shuffle(batch)
batch = batch[:self.config['training'].get('bootstrap_size', 1000)]
if self.config["training"].get("balanced_subsample", "no") == "yes":
batch_0 = batch[batch[:, -1] == 0]
batch_1 = batch[batch[:, -1] == 1]
# resample from both batches the same amount of samples and concatenate the two bootstrap samples
n_bootstrap_samples = int((len(batch_0) + len(batch_1)) / 2)
batch_0 = np.array(batch_0)
batch_1 = np.array(batch_1)
batch_0_btstrp = resample(batch_0, replace=True, n_samples=n_bootstrap_samples)
batch_1_btstrp = resample(batch_1, replace=True, n_samples=n_bootstrap_samples)
self.batch = np.append(batch_0_btstrp, batch_1_btstrp, axis=0)
else:
self.batch =batch # resample(self.batch, replace=True, stratify=self.batch[:, -1])
dict_forest = json.loads(model.model_parameters)
for tree in dict_forest['forest']:
self.model.forest.append(DecisionTree.DecisionTreeClassifier.from_json(tree))
def train_model(self):
"""Computes local histogram data for given information. Assumes RF_fetch_model is previously called
and that the following fields have been set by the server process in the model-configuration-file:
- current_condition_list
- current_feature_list
- random_state
This function then writes the result into the local model under the attribute model_update
NOTE: Function assumes positive-label=1, negative-label=0, need to incorporate how we can pass this information to the worker.
"""
histograms = self.RF_create_histograms()
self.model.model_update = histograms # store as string
gc.collect()
return True
def send_model(self, ):
# Send the model update to the server
return self.model
def predict(self, data_type):
generator = self.data_generator.generator(data_type)
train_X, train_y = next(generator)
y_pred = self.model.predict(train_X, )
if self.config['training'].get('cast_to_probabilities', False):
y_pred = 1.0 / (1.0 + np.exp(-y_pred))
return y_pred, train_y
@staticmethod
def _dp_histograms(hist_dict, feature_list, epsilon):
# NOTE: functiona assumes epsilon is a valid float value (>= 0)
hists = copy.deepcopy(hist_dict)
dp_mech = GeometricTruncated().set_epsilon(epsilon).set_sensitivity(1).set_bounds(0, maxsize)
# iterate over all histograms and make them differentially private
for f_idx in feature_list:
for i in range(len(hist_dict[f"{f_idx}"])):
hists[f"{f_idx}"][i]["n_pos"] = dp_mech.randomise(int(hist_dict[f"{f_idx}"][i]["n_pos"]))
hists[f"{f_idx}"][i]["n_neg"] = dp_mech.randomise(int(hist_dict[f"{f_idx}"][i]["n_neg"]))
# and filter out empty bins
hists[f"{f_idx}"] = list(filter(lambda x: not (x["n_pos"] == 0 and x["n_neg"] == 0), hists[f"{f_idx}"]))
return hists
def RF_create_histograms(self):
histograms = {}
# batch = np.concatenate((batch[0], batch[1].reshape((config['training']['batch_size'], 1))), axis=1)
batch=self.batch
if self.model.current_condition_list != [[]]:
for el in self.model.current_condition_list:
batch = batch[((batch[:, el['feature_index']] <= el['threshold']) == el['condition'])]
for feature_idx in self.model.current_feature_list:
histograms[f"{feature_idx}"] = []
unique_values = {}
for f_idx in self.model.current_feature_list:
if self.model.feature_information.get(f"col{feature_idx}", True) == False:
unique_values[f"{f_idx}"] = []
for el in batch:
for f_idx in self.model.current_feature_list:
if self.model.feature_information.get(f"col{feature_idx}", True) == False:
# handle the case that the feature is categorical
r_i = el[f_idx]
# change r_i if having differentially private data
# if config["training"]["differential_privacy"] == "data":
# dp_el = _make_datapoint_DP(el[0], config)
# r_i = dp_el[f_idx]
y_i = el[-1]
p_i = 0
n_i = 0
if y_i == 1:
p_i = 1
elif y_i == 0:
n_i = 1
else:
# There must be a mistake in the initialization, either we have more than 3 labels,
# or the labels must have been initialized wrong!
assert (False)
# add to existing bin if possible
if r_i in unique_values.get(f"{f_idx}", []):
extended = False
for bin_ in histograms[f"{f_idx}"]:
if bin_['bin_identifier'] == r_i:
bin_['n_pos'] = bin_['n_pos'] + p_i
bin_['n_neg'] = bin_['n_neg'] + n_i
extended = True
break
# make sure that the bin has been extended
assert (extended is True)
# else create new bin to append to the histogram
else:
curr_bin = {
'bin_identifier': r_i,
'n_pos': p_i,
'n_neg': n_i,
}
histograms[f"{f_idx}"].append(curr_bin)
histograms[f"{f_idx}"].sort(key=lambda x: x['bin_identifier'])
unique_values[f"{f_idx}"].append(r_i)
else:
# handle the case that the feature is continuous
r_i = el[f_idx]
# change r_i if having differentially private data
# if config["training"]["differential_privacy"] == "data":
# dp_el = _make_datapoint_DP(el[0], config)
# r_i = dp_el[f_idx]
y_i = el[-1]
p_i = 0
n_i = 0
if y_i == 1:
p_i = 1
elif y_i == 0:
n_i = 1
else:
# There must be a mistake in the initialization, either we have more than 3 labels,
# or the labels must have been initialized wrong!
assert (False)
current_bin = {
'bin_identifier': r_i,
'n_pos': p_i,
'n_neg': n_i,
}
# try to add current information to existing bin if possible
extended = False
for bin_ in histograms[f"{f_idx}"]:#changed this
if isclose(bin_['bin_identifier'], r_i, rel_tol=1e-10):
bin_['bin_identifier'] = r_i
bin_['n_pos'] = bin_['n_pos'] + p_i
bin_['n_neg'] = bin_['n_neg'] + n_i
extended = True
break
if not extended:
histograms[f"{f_idx}"].append(current_bin)
histograms[f"{f_idx}"].sort(key=lambda x: x['bin_identifier'])
# compress histogram by combining bins if needed
while (len(histograms[f"{f_idx}"]) > self.model.max_bins):
assert (self.model.max_bins >= 2)
# find two closest bins
idx_right = 1
min_dist = abs(histograms[f"{f_idx}"][1]['bin_identifier'] - histograms[f"{f_idx}"][0][
'bin_identifier'])
for j in range(2, len(histograms[f"{f_idx}"])):
curr_dist = abs(
histograms[f"{f_idx}"][j]['bin_identifier'] - histograms[f"{f_idx}"][j - 1][
'bin_identifier'])
if curr_dist < min_dist:
min_dist = curr_dist
idx_right = j
# combine two closest bins
right_bin = histograms[f"{f_idx}"].pop(idx_right)
r_l = histograms[f"{f_idx}"][idx_right - 1]['bin_identifier']
p_l = histograms[f"{f_idx}"][idx_right - 1]['n_pos']
n_l = histograms[f"{f_idx}"][idx_right - 1]['n_neg']
r_r = right_bin['bin_identifier']
p_r = right_bin['n_pos']
n_r = right_bin['n_neg']
histograms[f"{f_idx}"][idx_right - 1]['bin_identifier'] = ((p_l + n_l) * r_l + (
p_r + n_r) * r_r) / (p_l + p_r + n_l + n_r)
histograms[f"{f_idx}"][idx_right - 1]['n_pos'] = p_l + p_r
histograms[f"{f_idx}"][idx_right - 1]['n_neg'] = n_l + n_r
if self.config["training"].get("differential_privacy", {}).get("method", 'before') == 'after':
epsilon = self.config['preprocessing'].get('noise', {}).get('epsilon', 1000),
return self._dp_histograms(histograms, self.model.current_feature_list, epsilon)
return histograms
class P2P(Model):
def __init__(self, config, wrapper):
super().__init__(config, wrapper)
self.batch = None # todo ugly
def get_model_update(self):
model_dict = dict()
# save trees for visualization of the model
model_dict['trees'] = str(self.model.get_dump())
# save model object itself, str format. pickle returns bytes format, we transform it to str
model_dict['pickle'] = str(pickle.dumps(self.model))
return json.dumps(model_dict).encode('utf-8')
def set_model(self, model):
# self.config = json.loads(model.model_definition)
global_model = pickle.loads(eval(json.loads(model.model_parameters)['pickle']))
self.model = global_model # Booster object
def train_model(self):
generator = self.data_generator.generator("train")
train_X, train_y = next(generator)
train_data_local = xgb.DMatrix(train_X, label=train_y)
train_params_dict = self.config['compile']['model_params'].copy()
train_params_dict['nthread'] = self.config['training'].get('nthread', -1)
train_params_dict['verbosity'] = self.config['training'].get('verbosity', 0)
self.model = xgb.train(train_params_dict, train_data_local,
num_boost_round=self.config['training']['client_steps_per_round'],
xgb_model=self.model)
gc.collect()
return True
def send_model(self):
return self.model
def predict(self, data_type):
generator = self.data_generator.generator(data_type)
train_X, train_y = next(generator)
validation_data_local = xgb.DMatrix(train_X, label=train_y)
yhat_probs = self.model.predict(validation_data_local)
if self.config['training'].get('cast_to_probabilities', False):
yhat_probs = 1.0 / (1.0 + np.exp(-yhat_probs))
y_true = validation_data_local.get_label()
return yhat_probs, y_true
class NN(Model):
def __init__(self, config, wrapper):
super().__init__(config, wrapper)
self.global_weights = None
def get_model_update(self):
if int(os.getenv('SERVER', 1)):
gradient = self.get_gradient(self.get_weights(self.model), self.global_weights)
else:
gradient = self.global_weights
return self.array_to_bytes(gradient)
def set_model(self, model):
# self.config = json.loads(model.model_definition) #todo allow always changing config? if yes then split data/train config
if self.config["training"].get("differential_privacy", {}).get("method", 'before') not in ['after', 'before']:
raise Exception("Bad differential privacy method set")
self.model = tf.keras.models.model_from_json(json.dumps(self.config['model']))
self.model.compile(loss=tf.losses.get(self.config['compile']['loss']),
optimizer=self.get_NN_optimizer(),
metrics=[getattr(self.import_from_string(metric['module']),
metric['class_name']).from_config(metric["config"]) for
metric in self.config['compile']['metrics']],
loss_weights=self.config['compile'].get('loss_weights', None),
sample_weight_mode=self.config['compile'].get('sample_weight_mode', None),
weighted_metrics=self.config['compile'].get('weighted_metrics', None),
target_tensors=self.config['compile'].get('target_tensors', None)
)
self.global_weights = self.array_from_bytes(model.model_parameters)
self.model = self.set_weights(self.model, self.global_weights,
normalize=self.config['compile'].get("normalize", 0), )
def train_model(self):
self.model.fit(
self.data_generator.generator("train"),
epochs=self.config['training'].get("epochs", 1),
verbose=self.config['training'].get("verbose", 0),
callbacks=self.config['training'].get("callback", []),
shuffle=self.config['training'].get("shuffle", True),
class_weight={int(key): value for key, value in
self.config['training'].get("class_weight").items()} if
self.config['training'].get("class_weight", None) else None,
initial_epoch=self.config['training'].get("initial_epoch", 0),
steps_per_epoch=self.config['training'].get("steps_per_epoch", 12),
max_queue_size=self.config['training'].get("max_queue_size", 10),
workers=1, # self.config['training'].get("workers", 1),
use_multiprocessing=self.config['training'].get("use_multiprocessing", False),
)
tf.keras.backend.clear_session()
gc.collect()
return True
def send_model(self):
return self.model
def predict(self, data_type):
generator = self.data_generator.generator(data_type)
y_pred = []
y_true = []
for step in range(
self.config['training'].get(f"{data_type}_steps", self.config['training'].get("validation_steps", 12))):
try:
validation_batch = next(generator)
except StopIteration:
y_pred = [y[0] for y in y_pred]
return y_pred, y_true
y_true.extend(validation_batch[-1])
y_pred.extend(self.model.predict_on_batch(validation_batch, ))
y_pred = [y[0] for y in y_pred]
return y_pred, y_true
@staticmethod
def set_weights(model, weights, normalize=False):
for layer_index, layer in enumerate(model.layers):
cell_weights = []
for cell_index, _ in enumerate(layer.weights):
# if normalize != 0:
# # normalize weight
# norm = np.linalg.norm(weights[layer_index][cell_index])
# normalized_weigths = weights[layer_index][cell_index] / max([norm / normalize, 1])
# cell_weights.append(normalized_weigths)
# else:
cell_weights.append(weights[layer_index][cell_index])
layer.set_weights(cell_weights)
return model
@staticmethod
def array_to_bytes(array):
array_copy = copy.deepcopy(array)
for layer_index, layer in enumerate(array_copy):
for cell_index, _ in enumerate(layer):
array_copy[layer_index][cell_index] = array_copy[layer_index][cell_index].tolist()
return json.dumps(array_copy).encode('utf-8')
@staticmethod
def array_from_bytes(bytes_array):
array = json.loads(bytes_array)
for layer_index, layer in enumerate(array):
for cell_index, _ in enumerate(layer):
array[layer_index][cell_index] = np.array(array[layer_index][cell_index])
return array
@staticmethod
def get_weights(model, normalize=False):
weights = []
for layer_index, layer in enumerate(model.layers):
layer_weights = []
for cell_index, cell_weights in enumerate(layer.get_weights()):
# if normalize is True:
# # normalize weight
# norm = np.linalg.norm(cell_weights)
# normalized_weights = cell_weights / max([norm / normalize, 1])
# layer_weights.append(normalized_weights)
# else:
layer_weights.append(cell_weights)
weights.append(layer_weights)
return weights
@staticmethod
def get_gradient(gradient, global_weights):
for layer_index, _ in enumerate(gradient):
for cell_index, _ in enumerate(gradient[layer_index]):
try:
gradient[layer_index][cell_index] = gradient[layer_index][cell_index] - global_weights[layer_index][
cell_index]
except IndexError:
logging.warning(f"No inital weights found in global model. Set to 0.")
gradient[layer_index][cell_index] = gradient[layer_index][cell_index]
return gradient
@staticmethod
def import_from_string(name):
components = name.split('.')
mod = __import__(components[0])
for comp in components[1:]:
mod = getattr(mod, comp)
return mod
def get_NN_optimizer(self):
if self.config["training"].get("differential_privacy", {}).get("method", 'before') == 'before':
return tf.optimizers.get(self.config['compile']['optimizer'])
raise Exception("wrong differential_privacy set")
| StarcoderdataPython |
8006662 | import json
import random
import unittest
from model.firmware_error import FirmwareError, ErrorType
class FirmwareErrorTest(unittest.TestCase):
def test_given_a_firmware_error_then_it_is_serializable(self):
number = random.randint(400, 699)
task = 'test_task'
description = 'test_description'
firmware_error = FirmwareError(number, task, description)
self.assertEqual(firmware_error, FirmwareError.fromJson(firmware_error.toJson()))
| StarcoderdataPython |
1749089 | # Copyright 2022 Novel, Emerging Computing System Technologies Laboratory
# (NECSTLab), Politecnico di Milano
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from sklearn.datasets import load_iris
from sklearn.ensemble import GradientBoostingClassifier
import entree
import datetime
iris = load_iris()
X, y = iris.data, iris.target
clf = GradientBoostingClassifier(n_estimators=6, learning_rate=1.0,
max_depth=3, random_state=0).fit(X, y)
# Create an entree config
cfg = entree.backends.xilinxhls.auto_config()
# Set the output directory to something unique
cfg['ProjectName'] = 'iris_PDR_Vivado_GB'
cfg['OutputDir'] = 'prj_{}'.format(
# int(datetime.datetime.now().timestamp())
cfg['ProjectName']
)
cfg['XilinxPart'] = "xc7z020clg400-1"
cfg['XilinxBoard'] = "tul.com.tw:pynq-z2:part0:1.0"
cfg['ClockPeriod'] = "10"
cfg['PDR'] = True
cfg['Banks'] = "2"
cfg['TreesPerBank'] = "3"
model = entree.model(clf, entree.converters.sklearn,
entree.backends.xilinxhls, cfg)
model.compile()
# # Run HLS C Simulation and get the output
y_hls = model.decision_function(X)
y_skl = clf.decision_function(X)
# # Synthesize the model
model.build(export=True)
| StarcoderdataPython |
3284614 | # -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-05-11 19:00
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('entrance', '0043_auto_20170510_2044'),
]
operations = [
migrations.AlterField(
model_name='entrancelevel',
name='tasks',
field=models.ManyToManyField(blank=True, related_name='entrance_levels', to='entrance.EntranceExamTask'),
),
]
| StarcoderdataPython |
8031704 | master_doc = "index"
extensions = ["sphinx.ext.autodoc", "uqbar.sphinx.book"]
html_static_path = ["_static"]
| StarcoderdataPython |
3382438 | #!/usr/bin/env python3
# pylint: skip-file
from quickeys.__main__ import *
main()
| StarcoderdataPython |
1793652 | # Two-layer, sigmoid feedforward network
# trained using the "Extreme Learning Machine" algorithm.
# Adapted from https://gist.github.com/larsmans/2493300
# TODO: make it possible to use alternative linear classifiers instead
# of pinv2, e.g. SGDRegressor
# TODO: implement partial_fit and incremental learning
# TODO: tr
import numpy as np
from scipy.linalg import pinv2
from sklearn.base import BaseEstimator, ClassifierMixin, TransformerMixin
from sklearn.preprocessing import label_binarize
from sklearn.utils.multiclass import unique_labels
from sklearn.utils import check_random_state
from sklearn.utils.extmath import safe_sparse_dot
from sklearn.random_projection import sparse_random_matrix
def relu(X):
"""Rectified Linear Unit"""
return np.clip(X, 0, None)
class ELMClassifier(BaseEstimator, ClassifierMixin, TransformerMixin):
"""Extreme Learning Machine Classifier
Basically a 1 hidden layer MLP with fixed random weights on the input
to hidden layer.
TODO: document parameters and fitted attributes.
"""
activations = {
'tanh': np.tanh,
'relu': relu,
}
def __init__(self, n_hidden=1000, rank=None, activation='tanh',
random_state=None, density='auto'):
self.n_hidden = n_hidden
self.rank = rank
if activation is not None and activation not in self.activations:
raise ValueError(
"Invalid activation=%r, expected one of: '%s' or None"
% (activation, "', '".join(self.activations.keys())))
self.activation = activation
self.density = density
self.random_state = random_state
def fit(self, X, y):
if self.activation is None:
# Useful to quantify the impact of the non-linearity
self._activate = lambda x: x
else:
self._activate = self.activations[self.activation]
rng = check_random_state(self.random_state)
# one-of-K coding for output values
self.classes_ = unique_labels(y)
Y = label_binarize(y, self.classes_)
# set hidden layer parameters randomly
n_features = X.shape[1]
if self.rank is None:
if self.density == 1:
self.weights_ = rng.randn(n_features, self.n_hidden)
else:
self.weights_ = sparse_random_matrix(
self.n_hidden, n_features, density=self.density,
random_state=rng).T
else:
# Low rank weight matrix
self.weights_u_ = rng.randn(n_features, self.rank)
self.weights_v_ = rng.randn(self.rank, self.n_hidden)
self.biases_ = rng.randn(self.n_hidden)
# map the input data through the hidden layer
H = self.transform(X)
# fit the linear model on the hidden layer activation
self.beta_ = np.dot(pinv2(H), Y)
return self
def transform(self, X):
# compute hidden layer activation
if hasattr(self, 'weights_u_') and hasattr(self, 'weights_v_'):
projected = safe_sparse_dot(X, self.weights_u_, dense_output=True)
projected = safe_sparse_dot(projected, self.weights_v_)
else:
projected = safe_sparse_dot(X, self.weights_, dense_output=True)
return self._activate(projected + self.biases_)
def decision_function(self, X):
return np.dot(self.transform(X), self.beta_)
def predict(self, X):
return self.classes_[np.argmax(self.decision_function(X), axis=1)]
if __name__ == "__main__":
from sklearn.cross_validation import train_test_split
from time import time
from sklearn.datasets import load_digits
digits = load_digits()
X, y = digits.data, digits.target
# from sklearn.datasets import fetch_covtype
# covtype = fetch_covtype()
# X, y = covtype.data, covtype.target
# from sklearn.datasets import fetch_20newsgroups_vectorized
# twenty = fetch_20newsgroups_vectorized()
# X, y = twenty.data, twenty.target
# X = X[y < 4]
# y = y[y < 4]
X_train, X_test, y_train, y_test = train_test_split(X, y,
test_size=0.3, random_state=0)
for n_hidden in [100, 200, 500, 1000, 2000, 5000, 10000]:
print("Fitting ELM for n_hidden=%d..." % n_hidden)
tic = time()
model = ELMClassifier(n_hidden=n_hidden, rank=None, density='auto',
activation='relu')
model.fit(X_train, y_train)
toc = time()
print("done in %0.3fs: train accuracy=%0.3f, test accuracy=%0.3f"
% (toc - tic,
model.score(X_train, y_train),
model.score(X_test, y_test)))
| StarcoderdataPython |
3583006 | # pylint: disable=relative-beyond-top-level,import-outside-toplevel
import os
import unittest
from traceback import print_exc
from optimade.validator import ImplementationValidator
from .utils import SetClient
class ServerTestWithValidator(SetClient, unittest.TestCase):
server = "regular"
def test_with_validator(self):
validator = ImplementationValidator(client=self.client)
try:
validator.main()
except Exception:
print_exc()
self.assertTrue(validator.valid)
class IndexServerTestWithValidator(SetClient, unittest.TestCase):
server = "index"
def test_with_validator(self):
validator = ImplementationValidator(client=self.client, index=True)
try:
validator.main()
except Exception:
print_exc()
self.assertTrue(validator.valid)
def test_mongo_backend_package_used():
import pymongo
import mongomock
from optimade.server.entry_collections import client
force_mongo_env_var = os.environ.get("OPTIMADE_CI_FORCE_MONGO", None)
if force_mongo_env_var is None:
return
if int(force_mongo_env_var) == 1:
assert issubclass(client.__class__, pymongo.MongoClient)
elif int(force_mongo_env_var) == 0:
assert issubclass(client.__class__, mongomock.MongoClient)
else:
raise Exception(
"The environment variable OPTIMADE_CI_FORCE_MONGO cannot be parsed as an int."
)
class AsTypeTestsWithValidator(SetClient, unittest.TestCase):
server = "regular"
def test_as_type_with_validator(self):
test_urls = {
"http://example.org/v0/structures": "structures",
"http://example.org/v0/structures/mpf_1": "structure",
"http://example.org/v0/references": "references",
"http://example.org/v0/references/dijkstra1968": "reference",
"http://example.org/v0/info": "info",
"http://example.org/v0/links": "links",
}
with unittest.mock.patch(
"requests.get", unittest.mock.Mock(side_effect=self.client.get)
):
for url, as_type in test_urls.items():
validator = ImplementationValidator(
base_url=url, as_type=as_type, verbosity=5
)
try:
validator.main()
except Exception:
print_exc()
self.assertTrue(validator.valid)
| StarcoderdataPython |
1730315 | from unittest import TestCase
from xrpl.models.exceptions import XRPLModelException
from xrpl.models.transactions import NFTokenCreateOffer, NFTokenCreateOfferFlag
_ACCOUNT = "<KEY>"
_ANOTHER_ACCOUNT = "<KEY>"
_FEE = "0.00001"
_SEQUENCE = 19048
_NFTOKEN_ID = "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003"
class TestNFTokenCreateOffer(TestCase):
def test_nftoken_buy_offer_with_zero_amount(self):
with self.assertRaises(XRPLModelException):
NFTokenCreateOffer(
account=_ACCOUNT,
fee=_FEE,
sequence=_SEQUENCE,
owner=_ANOTHER_ACCOUNT,
nftoken_id=_NFTOKEN_ID,
amount="0",
)
def test_nftoken_buy_offer_with_negative_amount(self):
with self.assertRaises(XRPLModelException):
NFTokenCreateOffer(
account=_ACCOUNT,
fee=_FEE,
sequence=_SEQUENCE,
owner=_ANOTHER_ACCOUNT,
nftoken_id=_NFTOKEN_ID,
amount="-1",
)
def test_nftoken_buy_offer_with_positive_amount(self):
tx = NFTokenCreateOffer(
account=_ACCOUNT,
fee=_FEE,
sequence=_SEQUENCE,
owner=_ANOTHER_ACCOUNT,
nftoken_id=_NFTOKEN_ID,
amount="1",
)
self.assertTrue(tx.is_valid())
def test_nftoken_sell_offer_with_zero_amount(self):
tx = NFTokenCreateOffer(
account=_ACCOUNT,
fee=_FEE,
sequence=_SEQUENCE,
amount="0",
nftoken_id=_NFTOKEN_ID,
flags=[NFTokenCreateOfferFlag.TF_SELL_NFTOKEN],
)
self.assertTrue(tx.is_valid())
def test_nftoken_sell_offer_with_positive_amount(self):
tx = NFTokenCreateOffer(
account=_ACCOUNT,
fee=_FEE,
sequence=_SEQUENCE,
amount="1",
nftoken_id=_NFTOKEN_ID,
flags=[NFTokenCreateOfferFlag.TF_SELL_NFTOKEN],
)
self.assertTrue(tx.is_valid())
def test_destination_is_account(self):
with self.assertRaises(XRPLModelException):
NFTokenCreateOffer(
account=_ACCOUNT,
destination=_ACCOUNT,
fee=_FEE,
owner=_ANOTHER_ACCOUNT,
sequence=_SEQUENCE,
nftoken_id=_NFTOKEN_ID,
amount="1",
)
def test_nftoken_buy_offer_without_owner(self):
with self.assertRaises(XRPLModelException):
NFTokenCreateOffer(
account=_ACCOUNT,
fee=_FEE,
sequence=_SEQUENCE,
amount="1",
nftoken_id=_NFTOKEN_ID,
)
def test_nftoken_buy_offer_with_owner_is_account(self):
with self.assertRaises(XRPLModelException):
NFTokenCreateOffer(
account=_ACCOUNT,
owner=_ACCOUNT,
fee=_FEE,
sequence=_SEQUENCE,
amount="1",
nftoken_id=_NFTOKEN_ID,
)
def test_nftoken_sell_offer_with_owner(self):
with self.assertRaises(XRPLModelException):
NFTokenCreateOffer(
account=_ACCOUNT,
owner=_ANOTHER_ACCOUNT,
fee=_FEE,
sequence=_SEQUENCE,
amount="1",
flags=[NFTokenCreateOfferFlag.TF_SELL_NFTOKEN],
nftoken_id=_NFTOKEN_ID,
)
| StarcoderdataPython |
3429700 | import numpy as np
import tensorflow as tf
import time
import os
import pickle
import argparse
from utils import *
from model import Model
import random
import matplotlib.pyplot as plt
import svgwrite
from IPython.display import SVG, display
# main code (not in a main function since I want to run this script in IPython as well).
parser = argparse.ArgumentParser()
parser.add_argument('--filename', type=str, default='sample',
help='filename of .svg file to output, without .svg')
parser.add_argument('--sample_length', type=int, default=5000,
help='number of strokes to sample')
parser.add_argument('--scale_factor', type=int, default=1,
help='factor to scale down by for svg output. smaller means bigger output')
parser.add_argument('--model_dir', type=str, default='checkpoints',
help='directory to save model to')
parser.add_argument('--freeze_graph', dest='freeze_graph', action='store_true',
help='if true, freeze (replace variables with consts), prune (for inference) and save graph')
parser.add_argument('--texts', type=str, default='These are some sample texts',
help='texts to write, required for synthesis mode')
parser.add_argument('--bias', type=float, default=1.,
help='Positive float, indicates how wild the network '\
'should be during generating.')
parser.add_argument('--copy_style', type=int, default=None,
help='Copy the style from the training set.')
sample_args = parser.parse_args()
# add an empty char for specifying the start and ending
sample_args.texts = " " + sample_args.texts + " "
def erase_empty(c):
# temp method to erase the empty chars
l = c.shape[1]
for i in range(l-1, -1, -1):
if c[0, i, REV_VOCAB[" "]] == 1:
c = c[:, :i, :]
else:
return c
with open(os.path.join(sample_args.model_dir, 'config.pkl'), 'rb') as f:
saved_args = pickle.load(f)
if sample_args.copy_style is not None:
data_loader = DataLoader(1, saved_args.data_scale)
x, c = data_loader.load_sample(sample_args.copy_style)
saved_args.max_char_len = len(sample_args.texts) + erase_empty(c).shape[1]
else:
saved_args.max_char_len = len(sample_args.texts)
model = Model(saved_args, True, bias=sample_args.bias)
sess = tf.InteractiveSession()
saver = tf.train.Saver()
ckpt = tf.train.get_checkpoint_state(sample_args.model_dir)
print("loading model: ", ckpt.model_checkpoint_path)
saver.restore(sess, ckpt.model_checkpoint_path)
def sample_stroke(texts=None):
x_init = [[[0.,0.,1.]]]
ref_texts = None
if texts is not None:
texts = texts_prep_for_sampling(texts)
if sample_args.copy_style is not None:
ref_texts = erase_empty(c)
x_init = x
draw_strokes(x[0], factor=sample_args.scale_factor, svg_filename = sample_args.filename+'.normal_ref.svg')
print("Printing the following text: ")
print(''.join(rev_one_hot(texts[0])))
strokes, window_vecs = model.sample(
sess,
sample_args.sample_length,
initial_point=x_init,
texts=texts,
ref_texts=ref_texts
)
draw_strokes(strokes, factor=sample_args.scale_factor, svg_filename = sample_args.filename+'.normal.svg')
# draw_strokes_random_color(strokes, factor=sample_args.scale_factor, svg_filename = sample_args.filename+'.color.svg')
# draw_strokes_random_color(strokes, factor=sample_args.scale_factor, per_stroke_mode = False, svg_filename = sample_args.filename+'.multi_color.svg')
# draw_strokes_eos_weighted(strokes, params, factor=sample_args.scale_factor, svg_filename = sample_args.filename+'.eos_pdf.svg')
# draw_strokes_pdf(strokes, params, factor=sample_args.scale_factor, svg_filename = sample_args.filename+'.pdf.svg')
plot_window_vectors(window_vecs)
return strokes
def plot_window_vectors(window_vecs):
plt.imshow(np.squeeze(window_vecs).T, cmap='hot', aspect='auto')
plt.savefig("window.svg")
def freeze_and_save_graph(sess, folder, out_nodes, as_text=False):
## save graph definition
graph_raw = sess.graph_def
graph_frz = tf.graph_util.convert_variables_to_constants(sess, graph_raw, out_nodes)
ext = '.txt' if as_text else '.pb'
#tf.train.write_graph(graph_raw, folder, 'graph_raw'+ext, as_text=as_text)
tf.train.write_graph(graph_frz, folder, 'graph_frz'+ext, as_text=as_text)
if(sample_args.freeze_graph):
freeze_and_save_graph(sess, sample_args.model_dir, ['data_out_mdn', 'data_out_eos', 'state_out'], False)
if saved_args.mode == "synthesis":
strokes = sample_stroke(sample_args.texts)
else:
strokes = sample_stroke()
| StarcoderdataPython |
3419386 | <reponame>gpooja3/pyvcloud
# VMware vCloud Director Python SDK
# Copyright (c) 2018 VMware, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from pyvcloud.vcd.client import E
from pyvcloud.vcd.client import E_VMEXT
from pyvcloud.vcd.client import EntityType
from pyvcloud.vcd.client import NSMAP
from pyvcloud.vcd.client import QueryResultFormat
from pyvcloud.vcd.client import RelationType
from pyvcloud.vcd.client import ResourceType
from pyvcloud.vcd.exceptions import EntityNotFoundException
from pyvcloud.vcd.exceptions import InvalidParameterException
from pyvcloud.vcd.gateway import Gateway
from pyvcloud.vcd.platform import Platform
from pyvcloud.vcd.pvdc import PVDC
from pyvcloud.vcd.utils import get_admin_href
class ExternalNetwork(object):
def __init__(self, client, name=None, href=None, resource=None):
"""Constructor for External Network objects.
:param pyvcloud.vcd.client.Client client: the client that will be used
to make REST calls to vCD.
:param str name: name of the entity.
:param str href: URI of the entity.
:param lxml.objectify.ObjectifiedElement resource: object containing
EntityType.EXTERNAL_NETWORK XML data representing the external
network.
"""
self.client = client
self.name = name
if href is None and resource is None:
raise InvalidParameterException(
"External network initialization failed as arguments are "
"either invalid or None")
self.href = href
self.resource = resource
if resource is not None:
self.name = resource.get('name')
self.href = resource.get('href')
self.href_admin = get_admin_href(self.href)
def get_resource(self):
"""Fetches the XML representation of the external network from vCD.
Will serve cached response if possible.
:return: object containing EntityType.EXTERNAL_NETWORK XML data
representing the external network.
:rtype: lxml.objectify.ObjectifiedElement
"""
if self.resource is None:
self.reload()
return self.resource
def reload(self):
"""Reloads the resource representation of the external network.
This method should be called in between two method invocations on the
external network object, if the former call changes the representation
of the external network in vCD.
"""
self.resource = self.client.get_resource(self.href)
if self.resource is not None:
self.name = self.resource.get('name')
self.href = self.resource.get('href')
def add_subnet(self,
name,
gateway_ip,
netmask,
ip_ranges,
primary_dns_ip=None,
secondary_dns_ip=None,
dns_suffix=None):
"""Add subnet to an external network.
:param str name: Name of external network.
:param str gateway_ip: IP address of the gateway of the new network.
:param str netmask: Netmask of the gateway.
:param list ip_ranges: list of IP ranges used for static pool
allocation in the network. For example, [192.168.1.2-192.168.1.49,
192.168.1.100-192.168.1.149].
:param str primary_dns_ip: IP address of primary DNS server.
:param str secondary_dns_ip: IP address of secondary DNS Server.
:param str dns_suffix: DNS suffix.
:rtype: lxml.objectify.ObjectifiedElement
"""
if self.resource is None:
self.reload()
platform = Platform(self.client)
ext_net = platform.get_external_network(name)
config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
ip_scopes = config.IpScopes
ip_scope = E.IpScope()
ip_scope.append(E.IsInherited(False))
ip_scope.append(E.Gateway(gateway_ip))
ip_scope.append(E.Netmask(netmask))
if primary_dns_ip is not None:
ip_scope.append(E.Dns1(primary_dns_ip))
if secondary_dns_ip is not None:
ip_scope.append(E.Dns2(secondary_dns_ip))
if dns_suffix is not None:
ip_scope.append(E.DnsSuffix(dns_suffix))
ip_scope.append(E.IsEnabled(True))
e_ip_ranges = E.IpRanges()
for ip_range in ip_ranges:
e_ip_range = E.IpRange()
ip_range_token = ip_range.split('-')
e_ip_range.append(E.StartAddress(ip_range_token[0]))
e_ip_range.append(E.EndAddress(ip_range_token[1]))
e_ip_ranges.append(e_ip_range)
ip_scope.append(e_ip_ranges)
ip_scopes.append(ip_scope)
return self.client.put_linked_resource(
ext_net,
rel=RelationType.EDIT,
media_type=EntityType.EXTERNAL_NETWORK.value,
contents=ext_net)
def enable_subnet(self, gateway_ip, is_enabled=None):
"""Enable subnet of an external network.
:param str gateway_ip: IP address of the gateway of external network.
:param bool is_enabled: flag to enable/disable the subnet
:rtype: lxml.objectify.ObjectifiedElement
"""
ext_net = self.client.get_resource(self.href)
config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
ip_scopes = config.IpScopes
if is_enabled is not None:
for ip_scope in ip_scopes.IpScope:
if ip_scope.Gateway == gateway_ip:
if hasattr(ip_scope, 'IsEnabled'):
ip_scope['IsEnabled'] = E.IsEnabled(is_enabled)
return self.client. \
put_linked_resource(ext_net, rel=RelationType.EDIT,
media_type=EntityType.
EXTERNAL_NETWORK.value,
contents=ext_net)
return ext_net
def add_ip_range(self, gateway_ip, ip_ranges):
"""Add new ip range into a subnet of an external network.
:param str gateway_ip: IP address of the gateway of external network.
:param list ip_ranges: list of IP ranges used for static pool
allocation in the network. For example, [192.168.1.2-192.168.1.49,
192.168.1.100-192.168.1.149]
:rtype: lxml.objectify.ObjectifiedElement
"""
ext_net = self.client.get_resource(self.href)
config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
ip_scopes = config.IpScopes
for ip_scope in ip_scopes.IpScope:
if ip_scope.Gateway == gateway_ip:
existing_ip_ranges = ip_scope.IpRanges
break
for range in ip_ranges:
range_token = range.split('-')
e_ip_range = E.IpRange()
e_ip_range.append(E.StartAddress(range_token[0]))
e_ip_range.append(E.EndAddress(range_token[1]))
existing_ip_ranges.append(e_ip_range)
return self.client. \
put_linked_resource(ext_net, rel=RelationType.EDIT,
media_type=EntityType.
EXTERNAL_NETWORK.value,
contents=ext_net)
def modify_ip_range(self, gateway_ip, old_ip_range, new_ip_range):
"""Modify ip range of a subnet in external network.
:param str gateway_ip: IP address of the gateway of external
network.
:param str old_ip_range: existing ip range present in the static pool
allocation in the network. For example, [192.168.1.2-192.168.1.20]
:param str new_ip_range: new ip range to replace the existing ip range
present in the static pool allocation in the network.
:return: object containing vmext:VMWExternalNetwork XML element that
representing the external network.
:rtype: lxml.objectify.ObjectifiedElement
"""
if self.resource is None:
self.reload()
ext_net = self.resource
old_ip_addrs = old_ip_range.split('-')
new_ip_addrs = new_ip_range.split('-')
config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
ip_scopes = config.IpScopes
ip_range_found = False
for ip_scope in ip_scopes.IpScope:
if ip_scope.Gateway == gateway_ip:
for exist_ip_range in ip_scope.IpRanges.IpRange:
if exist_ip_range.StartAddress == \
old_ip_addrs[0] and \
exist_ip_range.EndAddress \
== old_ip_addrs[1]:
exist_ip_range['StartAddress'] = \
E.StartAddress(new_ip_addrs[0])
exist_ip_range['EndAddress'] = \
E.EndAddress(new_ip_addrs[1])
ip_range_found = True
break
if not ip_range_found:
raise EntityNotFoundException(
'IP Range \'%s\' not Found' % old_ip_range)
return self.client. \
put_linked_resource(ext_net, rel=RelationType.EDIT,
media_type=EntityType.
EXTERNAL_NETWORK.value,
contents=ext_net)
def delete_ip_range(self, gateway_ip, ip_ranges):
"""Delete ip range of a subnet in external network.
:param str gateway_ip: IP address of the gateway of external
network.
:param list ip_ranges: existing ip range present in the static pool
allocation in the network to be deleted.
For example, [192.168.1.2-192.168.1.20]
:return: object containing vmext:VMWExternalNetwork XML element that
representing the external network.
:rtype: lxml.objectify.ObjectifiedElement
"""
if self.resource is None:
self.reload()
ext_net = self.resource
config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
ip_scopes = config.IpScopes
for ip_scope in ip_scopes.IpScope:
if ip_scope.Gateway == gateway_ip:
exist_ip_ranges = ip_scope.IpRanges
self.__remove_ip_range_elements(exist_ip_ranges, ip_ranges)
return self.client. \
put_linked_resource(ext_net, rel=RelationType.EDIT,
media_type=EntityType.
EXTERNAL_NETWORK.value,
contents=ext_net)
def attach_port_group(self, vim_server_name, port_group_name):
"""Attach a portgroup to an external network.
:param str vc_name: name of vc where portgroup is present.
:param str pg_name: name of the portgroup to be attached to
external network.
return: object containing vmext:VMWExternalNetwork XML element that
representing the external network.
:rtype: lxml.objectify.ObjectifiedElement
"""
ext_net = self.get_resource()
platform = Platform(self.client)
if not vim_server_name or not port_group_name:
raise InvalidParameterException(
"Either vCenter Server name is none or portgroup name is none")
vc_record = platform.get_vcenter(vim_server_name)
vc_href = vc_record.get('href')
pg_moref_types = \
platform.get_port_group_moref_types(vim_server_name,
port_group_name)
if hasattr(ext_net, '{' + NSMAP['vmext'] + '}VimPortGroupRef'):
vim_port_group_refs = E_VMEXT.VimPortGroupRefs()
vim_object_ref1 = self.__create_vimobj_ref(
vc_href, pg_moref_types[0], pg_moref_types[1])
# Create a new VimObjectRef using vc href, portgroup moref and type
# from existing VimPortGroupRef. Add the VimObjectRef to
# VimPortGroupRefs and then delete VimPortGroupRef
# from external network.
vim_pg_ref = ext_net['{' + NSMAP['vmext'] + '}VimPortGroupRef']
vc2_href = vim_pg_ref.VimServerRef.get('href')
vim_object_ref2 = self.__create_vimobj_ref(
vc2_href, vim_pg_ref.MoRef.text, vim_pg_ref.VimObjectType.text)
vim_port_group_refs.append(vim_object_ref1)
vim_port_group_refs.append(vim_object_ref2)
ext_net.remove(vim_pg_ref)
ext_net.append(vim_port_group_refs)
else:
vim_port_group_refs = \
ext_net['{' + NSMAP['vmext'] + '}VimPortGroupRefs']
vim_object_ref1 = self.__create_vimobj_ref(
vc_href, pg_moref_types[0], pg_moref_types[1])
vim_port_group_refs.append(vim_object_ref1)
return self.client. \
put_linked_resource(ext_net, rel=RelationType.EDIT,
media_type=EntityType.
EXTERNAL_NETWORK.value,
contents=ext_net)
def __create_vimobj_ref(self, vc_href, pg_moref, pg_type):
"""Creates the VimObjectRef."""
vim_object_ref = E_VMEXT.VimObjectRef()
vim_object_ref.append(E_VMEXT.VimServerRef(href=vc_href))
vim_object_ref.append(E_VMEXT.MoRef(pg_moref))
vim_object_ref.append(E_VMEXT.VimObjectType(pg_type))
return vim_object_ref
def detach_port_group(self, vim_server_name, port_group_name):
"""Detach a portgroup from an external network.
:param str vim_server_name: name of vim server where
portgroup is present.
:param str port_group_name: name of the portgroup to be detached from
external network.
return: object containing vmext:VMWExternalNetwork XML element that
representing the external network.
:rtype: lxml.objectify.ObjectifiedElement
"""
ext_net = self.get_resource()
platform = Platform(self.client)
if not vim_server_name or not port_group_name:
raise InvalidParameterException(
"Either vCenter Server name is none or portgroup name is none")
vc_record = platform.get_vcenter(vim_server_name)
vc_href = vc_record.get('href')
if hasattr(ext_net, 'VimPortGroupRefs'):
pg_moref_types = \
platform.get_port_group_moref_types(vim_server_name,
port_group_name)
else:
raise \
InvalidParameterException("External network"
" has only one port group")
vim_port_group_refs = ext_net.VimPortGroupRefs
vim_obj_refs = vim_port_group_refs.VimObjectRef
for vim_obj_ref in vim_obj_refs:
if vim_obj_ref.VimServerRef.get('href') == vc_href \
and vim_obj_ref.MoRef == pg_moref_types[0] \
and vim_obj_ref.VimObjectType == pg_moref_types[1]:
vim_port_group_refs.remove(vim_obj_ref)
return self.client. \
put_linked_resource(ext_net, rel=RelationType.EDIT,
media_type=EntityType.
EXTERNAL_NETWORK.value,
contents=ext_net)
def list_provider_vdc(self, filter=None):
"""List associated provider vdcs.
:param str filter: filter to fetch the selected pvdc, e.g., name==pvdc*
:return: list of associated provider vdcs
:rtype: list
"""
pvdc_name_list = []
query = self.client.get_typed_query(
ResourceType.PROVIDER_VDC.value,
query_result_format=QueryResultFormat.RECORDS,
qfilter=filter)
records = query.execute()
if records is None:
raise EntityNotFoundException('No Provider Vdc found associated')
for record in records:
href = record.get('href')
pvdc_name = self._get_provider_vdc_name_for_provided_ext_nw(href)
if pvdc_name is not None:
pvdc_name_list.append(pvdc_name)
return pvdc_name_list
def _get_provider_vdc_name_for_provided_ext_nw(self, pvdc_href):
pvdc = PVDC(self.client, href=pvdc_href)
pvdc_resource = pvdc.get_resource()
if not hasattr(pvdc_resource, "AvailableNetworks") and hasattr(
pvdc_resource.AvailableNetworks, "Network"):
return None
networks = pvdc_resource.AvailableNetworks.Network
for network in networks:
pvdc_ext_nw_name = network.get("name")
if pvdc_ext_nw_name == self.name:
return pvdc_resource.get('name')
return None
def __remove_ip_range_elements(self, existing_ip_ranges, ip_ranges):
"""Removes the given IP ranges from existing IP ranges.
:param existing_ip_ranges: existing IP range present from the subnet
pool.
:param list ip_ranges: IP ranges that needs to be removed.
"""
for exist_range in existing_ip_ranges.IpRange:
for remove_range in ip_ranges:
address = remove_range.split('-')
start_addr = address[0]
end_addr = address[1]
if start_addr == exist_range.StartAddress and \
end_addr == exist_range.EndAddress:
existing_ip_ranges.remove(exist_range)
def list_extnw_gateways(self, filter=None):
"""List associated gateways.
:param str filter: filter to fetch the selected gateway, e.g.,
name==gateway*
:return: list of associated gateways
:rtype: list
"""
gateway_name_list = []
records = self.__execute_gateway_query_api(filter)
for record in records:
href = record.get('href')
gateway_name = self._get_gateway_name_for_provided_ext_nw(href)
if gateway_name is not None:
gateway_name_list.append(gateway_name)
return gateway_name_list
def _get_gateway_name_for_provided_ext_nw(self, gateway_href):
gateway_resource = self.__get_gateway_resource(gateway_href)
for gw_inf in gateway_resource.Configuration.GatewayInterfaces. \
GatewayInterface:
if gw_inf.InterfaceType == "uplink" and gw_inf.Name == self.name:
return gateway_resource.get('name')
return None
def list_allocated_ip_address(self, filter=None):
"""List allocated ip address of gateways.
:param str filter: filter to fetch the selected gateway, e.g.,
name==gateway*
:return: dict allocated ip address of associated gateways
:rtype: dict
"""
gateway_name_allocated_ip_dict = {}
records = self.__execute_gateway_query_api(filter)
for record in records:
href = record.get('href')
gateway_entry = self. \
_get_gateway_allocated_ip_for_provided_ext_nw(href)
if gateway_entry is not None:
gateway_name_allocated_ip_dict[gateway_entry[0]] = \
gateway_entry[1]
return gateway_name_allocated_ip_dict
def __execute_gateway_query_api(self, filter=None):
query = self.client.get_typed_query(
ResourceType.EDGE_GATEWAY.value,
query_result_format=QueryResultFormat.RECORDS,
qfilter=filter)
query_records = query.execute()
if query_records is None:
raise EntityNotFoundException('No Gateway found associated')
return query_records
def _get_gateway_allocated_ip_for_provided_ext_nw(self, gateway_href):
gateway_allocated_ip = []
gateway_resource = self.__get_gateway_resource(gateway_href)
for gw_inf in gateway_resource.Configuration.GatewayInterfaces. \
GatewayInterface:
if gw_inf.InterfaceType == "uplink" and gw_inf.Name == self.name:
gateway_allocated_ip.append(gateway_resource.get('name'))
gateway_allocated_ip. \
append(gw_inf.SubnetParticipation.IpAddress)
return gateway_allocated_ip
return None
def list_gateway_ip_suballocation(self, filter=None):
"""List gateway ip sub allocation.
:param str filter: filter to fetch the selected gateway, e.g.,
name==gateway*
:return: dict gateway ip sub allocation
:rtype: dict
"""
gateway_name_sub_allocated_ip_dict = {}
records = self.__execute_gateway_query_api(filter)
for record in records:
href = record.get('href')
gateway_entry = self. \
_get_gateway_sub_allocated_ip_for_provided_ext_nw(href)
if gateway_entry is not None:
gateway_name_sub_allocated_ip_dict[gateway_entry[0]] = \
gateway_entry[1]
return gateway_name_sub_allocated_ip_dict
def _get_gateway_sub_allocated_ip_for_provided_ext_nw(self, gateway_href):
gateway_sub_allocated_ip = []
allocation_range = ''
gateway_resource = self.__get_gateway_resource(gateway_href)
for gw_inf in gateway_resource.Configuration.GatewayInterfaces. \
GatewayInterface:
if gw_inf.InterfaceType == "uplink" and gw_inf.Name == self.name:
if hasattr(gw_inf.SubnetParticipation, 'IpRanges'):
for ip_range in gw_inf.SubnetParticipation. \
IpRanges.IpRange:
start_address = ip_range.StartAddress
end_address = ip_range.EndAddress
allocation_range += \
start_address + '-' + end_address + ','
gateway_sub_allocated_ip.append(gateway_resource.get('name'))
gateway_sub_allocated_ip.append(allocation_range)
return gateway_sub_allocated_ip
return None
def __get_gateway_resource(self, gateway_href):
gateway = Gateway(self.client, href=gateway_href)
return gateway.get_resource()
def list_associated_direct_org_vdc_networks(self, filter=None):
"""List associated direct org vDC networks.
:param str filter: filter to fetch the direct org vDC network,
e.g., connectedTo==Ext*
:return: list of direct org vDC networks
:rtype: list
:raises: EntityNotFoundException: if any direct org vDC network
cannot be found.
"""
query_filter = 'connectedTo==' + self.name
if filter:
query_filter += ';' + filter
query = self.client.get_typed_query(
ResourceType.ORG_VDC_NETWORK.value,
qfilter=query_filter,
query_result_format=QueryResultFormat.RECORDS)
records = list(query.execute())
direct_ovdc_network_names = [record.get('name') for record in records]
return direct_ovdc_network_names
def list_vsphere_network(self, filter=None):
"""List associated vSphere Networks.
:param str filter: filter to fetch the vSphere Networks,
e.g., networkName==Ext*
:return: list of associated vSphere networks
e.g.
[{'vCenter': 'vc1', 'Name': 'test-dvpg'}]
:rtype: list
"""
out_list = []
query_filter = 'networkName==' + self.name
if filter:
query_filter += ';' + filter
query = self.client.get_typed_query(
ResourceType.PORT_GROUP.value,
query_result_format=QueryResultFormat.RECORDS,
qfilter=query_filter)
records = query.execute()
for record in records:
vSphere_network_list = dict()
vSphere_network_list['vCenter'] = record.get('vcName')
vSphere_network_list['Name'] = record.get('name')
out_list.append(vSphere_network_list)
return out_list
| StarcoderdataPython |
5027956 | from . import _connector
Connections = _connector.Connections
Transaction = _connector.Transaction
| StarcoderdataPython |
368638 | class Defaults(object):
window_size = 7
filter_nums = [100, 100, 100]
filter_sizes = [3, 4, 5]
hidden_sizes = [1200]
hidden_activation = 'relu'
max_vocab_size = 1000000
optimizer = 'adam'
learning_rate = 1e-4
epochs = 20
iobes = True # Map tags to IOBES on input
max_tokens = None # Max dataset size in tokens
encoding = 'utf-8' # Data encoding
output_drop_prob = 0.75 # Dropout probablility prior to output
token_level_eval = False # Force token-level evaluation
verbosity = 1 # 0=quiet, 1=progress bar, 2=one line per epoch
fixed_wordvecs = True # Don't fine-tune word vectors
word_features = False
batch_size = 200
train_steps = 20000 #Amount of train steps, each of batch_size to train for
evaluate_every = 5000
evaluate_min = 0 #The minimum step to start evaluating from
viterbi = False
percent_keep = 1.0 #The percentage of the given training set that should be used for training
class CharDefaults(object):
word_length = 7
filter_nums = [25, 25, 25]
filter_sizes = [3, 4, 5]
hidden_sizes = [20]
hidden_activation = 'relu'
optimizer = 'adam'
learning_rate = 1e-4
epochs = 20
encoding = 'utf-8' # Data encoding
output_drop_prob = 0.0 # Dropout probablility prior to output
token_level_eval = False # Force token-level evaluation
verbosity = 1 # 0=quiet, 1=progress bar, 2=one line per epoch
fixed_wordvecs = True # Don't fine-tune word vectors
word_features = False
batch_size = 200
train_steps = 20000 #Amount of train steps, each of batch_size to train for
evaluate_every = 5000
evaluate_min = 0 #The minimum step to start evaluating from
viterbi = False
vocab = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,;.!?:/\|_@#$%&* +-=<>()[]{}"
#vocab = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,;.!?:/\|_@#$%&* +-=<>()[]{}"
| StarcoderdataPython |
283745 | <filename>Arquivo/2020-2/2020-2-uff-lrp/lista-2/ex-4.py
n = int(input())
if 0 <= n <= 100:
if n == 0:
print('E')
elif 1 <= n <= 35:
print('D')
elif 36 <= n <= 60:
print('C')
elif 61 <= n <= 85:
print('B')
elif 86 <= n <= 100:
print('A') | StarcoderdataPython |
1973321 | # Generated from Quil.g4 by ANTLR 4.7.1
from antlr4 import *
from io import StringIO
from typing.io import TextIO
import sys
def serializedATN():
with StringIO() as buf:
buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2J")
buf.write("\u0211\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7")
buf.write("\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r")
buf.write("\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23")
buf.write("\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30")
buf.write("\4\31\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36")
buf.write("\t\36\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4$\t$\4%\t%")
buf.write("\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4,\t,\4-\t-\4.")
buf.write("\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64")
buf.write("\t\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:")
buf.write("\4;\t;\4<\t<\4=\t=\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\t")
buf.write("C\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I\tI\3\2\3\2\3\2\3\2")
buf.write("\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3")
buf.write("\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\5\3\5\3\5\3\5")
buf.write("\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\b\3")
buf.write("\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t")
buf.write("\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3")
buf.write("\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3")
buf.write("\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3\16\3\16\3\16\3\16")
buf.write("\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20")
buf.write("\3\20\3\20\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21")
buf.write("\3\21\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\3\24\3\24")
buf.write("\3\24\3\24\3\24\3\25\3\25\3\25\3\25\3\25\3\25\3\26\3\26")
buf.write("\3\26\3\26\3\27\3\27\3\27\3\27\3\30\3\30\3\30\3\30\3\31")
buf.write("\3\31\3\31\3\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\34")
buf.write("\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\36\3\36\3\36\3\36")
buf.write("\3\36\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3 ")
buf.write("\3 \3 \3 \3 \3 \3 \3 \3!\3!\3!\3\"\3\"\3\"\3#\3#\3#\3")
buf.write("$\3$\3$\3%\3%\3%\3&\3&\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\3")
buf.write("\'\3(\3(\3(\3)\3)\3*\3*\3*\3*\3+\3+\3+\3+\3,\3,\3,\3,")
buf.write("\3,\3-\3-\3-\3-\3.\3.\3.\3.\3/\3/\3\60\3\60\3\61\3\61")
buf.write("\3\62\3\62\3\63\3\63\3\64\3\64\3\64\3\64\3\64\3\64\3\64")
buf.write("\3\64\3\64\3\64\3\64\3\65\3\65\3\65\3\65\3\65\3\65\3\65")
buf.write("\3\66\3\66\3\66\7\66\u01a5\n\66\f\66\16\66\u01a8\13\66")
buf.write("\3\66\5\66\u01ab\n\66\3\67\6\67\u01ae\n\67\r\67\16\67")
buf.write("\u01af\38\68\u01b3\n8\r8\168\u01b4\38\38\68\u01b9\n8\r")
buf.write("8\168\u01ba\58\u01bd\n8\38\38\58\u01c1\n8\38\68\u01c4")
buf.write("\n8\r8\168\u01c5\58\u01c8\n8\39\39\79\u01cc\n9\f9\169")
buf.write("\u01cf\139\39\39\3:\3:\3;\3;\3<\3<\3=\3=\3>\3>\3?\3?\3")
buf.write("@\3@\3A\3A\3B\3B\3C\3C\3D\3D\3E\3E\3E\3E\3E\3F\7F\u01ef")
buf.write("\nF\fF\16F\u01f2\13F\3F\5F\u01f5\nF\3F\3F\6F\u01f9\nF")
buf.write("\rF\16F\u01fa\3G\7G\u01fe\nG\fG\16G\u0201\13G\3G\3G\7")
buf.write("G\u0205\nG\fG\16G\u0208\13G\3G\3G\3H\3H\3H\3H\3I\3I\2")
buf.write("\2J\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r")
buf.write("\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30")
buf.write("/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'")
buf.write("M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66k\67m8o9q")
buf.write(":s;u<w=y>{?}@\177A\u0081B\u0083C\u0085D\u0087E\u0089F")
buf.write("\u008bG\u008dH\u008fI\u0091J\3\2\n\5\2C\\aac|\7\2//\62")
buf.write(";C\\aac|\6\2\62;C\\aac|\3\2\62;\4\2GGgg\4\2--//\4\2\f")
buf.write("\f\17\17\4\2\13\13\"\"\2\u0220\2\3\3\2\2\2\2\5\3\2\2\2")
buf.write("\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17")
buf.write("\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3")
buf.write("\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2")
buf.write("\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3")
buf.write("\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2")
buf.write("\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3")
buf.write("\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E")
buf.write("\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2")
buf.write("O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2U\3\2\2\2\2W\3\2\2\2")
buf.write("\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\2a\3\2\2")
buf.write("\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2")
buf.write("\2\2\2m\3\2\2\2\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3")
buf.write("\2\2\2\2w\3\2\2\2\2y\3\2\2\2\2{\3\2\2\2\2}\3\2\2\2\2\177")
buf.write("\3\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2\2\2\2\u0085\3\2\2")
buf.write("\2\2\u0087\3\2\2\2\2\u0089\3\2\2\2\2\u008b\3\2\2\2\2\u008d")
buf.write("\3\2\2\2\2\u008f\3\2\2\2\2\u0091\3\2\2\2\3\u0093\3\2\2")
buf.write("\2\5\u009b\3\2\2\2\7\u00a6\3\2\2\2\t\u00ae\3\2\2\2\13")
buf.write("\u00b4\3\2\2\2\r\u00b9\3\2\2\2\17\u00be\3\2\2\2\21\u00c8")
buf.write("\3\2\2\2\23\u00d4\3\2\2\2\25\u00da\3\2\2\2\27\u00df\3")
buf.write("\2\2\2\31\u00e3\3\2\2\2\33\u00eb\3\2\2\2\35\u00f2\3\2")
buf.write("\2\2\37\u00fa\3\2\2\2!\u0102\3\2\2\2#\u0109\3\2\2\2%\u010d")
buf.write("\3\2\2\2\'\u0111\3\2\2\2)\u0116\3\2\2\2+\u011c\3\2\2\2")
buf.write("-\u0120\3\2\2\2/\u0124\3\2\2\2\61\u0128\3\2\2\2\63\u012b")
buf.write("\3\2\2\2\65\u012f\3\2\2\2\67\u0133\3\2\2\29\u0137\3\2")
buf.write("\2\2;\u013b\3\2\2\2=\u0140\3\2\2\2?\u0149\3\2\2\2A\u0151")
buf.write("\3\2\2\2C\u0154\3\2\2\2E\u0157\3\2\2\2G\u015a\3\2\2\2")
buf.write("I\u015d\3\2\2\2K\u0160\3\2\2\2M\u0165\3\2\2\2O\u016b\3")
buf.write("\2\2\2Q\u016e\3\2\2\2S\u0170\3\2\2\2U\u0174\3\2\2\2W\u0178")
buf.write("\3\2\2\2Y\u017d\3\2\2\2[\u0181\3\2\2\2]\u0185\3\2\2\2")
buf.write("_\u0187\3\2\2\2a\u0189\3\2\2\2c\u018b\3\2\2\2e\u018d\3")
buf.write("\2\2\2g\u018f\3\2\2\2i\u019a\3\2\2\2k\u01aa\3\2\2\2m\u01ad")
buf.write("\3\2\2\2o\u01b2\3\2\2\2q\u01c9\3\2\2\2s\u01d2\3\2\2\2")
buf.write("u\u01d4\3\2\2\2w\u01d6\3\2\2\2y\u01d8\3\2\2\2{\u01da\3")
buf.write("\2\2\2}\u01dc\3\2\2\2\177\u01de\3\2\2\2\u0081\u01e0\3")
buf.write("\2\2\2\u0083\u01e2\3\2\2\2\u0085\u01e4\3\2\2\2\u0087\u01e6")
buf.write("\3\2\2\2\u0089\u01e8\3\2\2\2\u008b\u01f0\3\2\2\2\u008d")
buf.write("\u01ff\3\2\2\2\u008f\u020b\3\2\2\2\u0091\u020f\3\2\2\2")
buf.write("\u0093\u0094\7F\2\2\u0094\u0095\7G\2\2\u0095\u0096\7H")
buf.write("\2\2\u0096\u0097\7I\2\2\u0097\u0098\7C\2\2\u0098\u0099")
buf.write("\7V\2\2\u0099\u009a\7G\2\2\u009a\4\3\2\2\2\u009b\u009c")
buf.write("\7F\2\2\u009c\u009d\7G\2\2\u009d\u009e\7H\2\2\u009e\u009f")
buf.write("\7E\2\2\u009f\u00a0\7K\2\2\u00a0\u00a1\7T\2\2\u00a1\u00a2")
buf.write("\7E\2\2\u00a2\u00a3\7W\2\2\u00a3\u00a4\7K\2\2\u00a4\u00a5")
buf.write("\7V\2\2\u00a5\6\3\2\2\2\u00a6\u00a7\7O\2\2\u00a7\u00a8")
buf.write("\7G\2\2\u00a8\u00a9\7C\2\2\u00a9\u00aa\7U\2\2\u00aa\u00ab")
buf.write("\7W\2\2\u00ab\u00ac\7T\2\2\u00ac\u00ad\7G\2\2\u00ad\b")
buf.write("\3\2\2\2\u00ae\u00af\7N\2\2\u00af\u00b0\7C\2\2\u00b0\u00b1")
buf.write("\7D\2\2\u00b1\u00b2\7G\2\2\u00b2\u00b3\7N\2\2\u00b3\n")
buf.write("\3\2\2\2\u00b4\u00b5\7J\2\2\u00b5\u00b6\7C\2\2\u00b6\u00b7")
buf.write("\7N\2\2\u00b7\u00b8\7V\2\2\u00b8\f\3\2\2\2\u00b9\u00ba")
buf.write("\7L\2\2\u00ba\u00bb\7W\2\2\u00bb\u00bc\7O\2\2\u00bc\u00bd")
buf.write("\7R\2\2\u00bd\16\3\2\2\2\u00be\u00bf\7L\2\2\u00bf\u00c0")
buf.write("\7W\2\2\u00c0\u00c1\7O\2\2\u00c1\u00c2\7R\2\2\u00c2\u00c3")
buf.write("\7/\2\2\u00c3\u00c4\7Y\2\2\u00c4\u00c5\7J\2\2\u00c5\u00c6")
buf.write("\7G\2\2\u00c6\u00c7\7P\2\2\u00c7\20\3\2\2\2\u00c8\u00c9")
buf.write("\7L\2\2\u00c9\u00ca\7W\2\2\u00ca\u00cb\7O\2\2\u00cb\u00cc")
buf.write("\7R\2\2\u00cc\u00cd\7/\2\2\u00cd\u00ce\7W\2\2\u00ce\u00cf")
buf.write("\7P\2\2\u00cf\u00d0\7N\2\2\u00d0\u00d1\7G\2\2\u00d1\u00d2")
buf.write("\7U\2\2\u00d2\u00d3\7U\2\2\u00d3\22\3\2\2\2\u00d4\u00d5")
buf.write("\7T\2\2\u00d5\u00d6\7G\2\2\u00d6\u00d7\7U\2\2\u00d7\u00d8")
buf.write("\7G\2\2\u00d8\u00d9\7V\2\2\u00d9\24\3\2\2\2\u00da\u00db")
buf.write("\7Y\2\2\u00db\u00dc\7C\2\2\u00dc\u00dd\7K\2\2\u00dd\u00de")
buf.write("\7V\2\2\u00de\26\3\2\2\2\u00df\u00e0\7P\2\2\u00e0\u00e1")
buf.write("\7Q\2\2\u00e1\u00e2\7R\2\2\u00e2\30\3\2\2\2\u00e3\u00e4")
buf.write("\7K\2\2\u00e4\u00e5\7P\2\2\u00e5\u00e6\7E\2\2\u00e6\u00e7")
buf.write("\7N\2\2\u00e7\u00e8\7W\2\2\u00e8\u00e9\7F\2\2\u00e9\u00ea")
buf.write("\7G\2\2\u00ea\32\3\2\2\2\u00eb\u00ec\7R\2\2\u00ec\u00ed")
buf.write("\7T\2\2\u00ed\u00ee\7C\2\2\u00ee\u00ef\7I\2\2\u00ef\u00f0")
buf.write("\7O\2\2\u00f0\u00f1\7C\2\2\u00f1\34\3\2\2\2\u00f2\u00f3")
buf.write("\7F\2\2\u00f3\u00f4\7G\2\2\u00f4\u00f5\7E\2\2\u00f5\u00f6")
buf.write("\7N\2\2\u00f6\u00f7\7C\2\2\u00f7\u00f8\7T\2\2\u00f8\u00f9")
buf.write("\7G\2\2\u00f9\36\3\2\2\2\u00fa\u00fb\7U\2\2\u00fb\u00fc")
buf.write("\7J\2\2\u00fc\u00fd\7C\2\2\u00fd\u00fe\7T\2\2\u00fe\u00ff")
buf.write("\7K\2\2\u00ff\u0100\7P\2\2\u0100\u0101\7I\2\2\u0101 \3")
buf.write("\2\2\2\u0102\u0103\7Q\2\2\u0103\u0104\7H\2\2\u0104\u0105")
buf.write("\7H\2\2\u0105\u0106\7U\2\2\u0106\u0107\7G\2\2\u0107\u0108")
buf.write("\7V\2\2\u0108\"\3\2\2\2\u0109\u010a\7P\2\2\u010a\u010b")
buf.write("\7G\2\2\u010b\u010c\7I\2\2\u010c$\3\2\2\2\u010d\u010e")
buf.write("\7P\2\2\u010e\u010f\7Q\2\2\u010f\u0110\7V\2\2\u0110&\3")
buf.write("\2\2\2\u0111\u0112\7V\2\2\u0112\u0113\7T\2\2\u0113\u0114")
buf.write("\7W\2\2\u0114\u0115\7G\2\2\u0115(\3\2\2\2\u0116\u0117")
buf.write("\7H\2\2\u0117\u0118\7C\2\2\u0118\u0119\7N\2\2\u0119\u011a")
buf.write("\7U\2\2\u011a\u011b\7G\2\2\u011b*\3\2\2\2\u011c\u011d")
buf.write("\7C\2\2\u011d\u011e\7P\2\2\u011e\u011f\7F\2\2\u011f,\3")
buf.write("\2\2\2\u0120\u0121\7K\2\2\u0121\u0122\7Q\2\2\u0122\u0123")
buf.write("\7T\2\2\u0123.\3\2\2\2\u0124\u0125\7Z\2\2\u0125\u0126")
buf.write("\7Q\2\2\u0126\u0127\7T\2\2\u0127\60\3\2\2\2\u0128\u0129")
buf.write("\7Q\2\2\u0129\u012a\7T\2\2\u012a\62\3\2\2\2\u012b\u012c")
buf.write("\7C\2\2\u012c\u012d\7F\2\2\u012d\u012e\7F\2\2\u012e\64")
buf.write("\3\2\2\2\u012f\u0130\7U\2\2\u0130\u0131\7W\2\2\u0131\u0132")
buf.write("\7D\2\2\u0132\66\3\2\2\2\u0133\u0134\7O\2\2\u0134\u0135")
buf.write("\7W\2\2\u0135\u0136\7N\2\2\u01368\3\2\2\2\u0137\u0138")
buf.write("\7F\2\2\u0138\u0139\7K\2\2\u0139\u013a\7X\2\2\u013a:\3")
buf.write("\2\2\2\u013b\u013c\7O\2\2\u013c\u013d\7Q\2\2\u013d\u013e")
buf.write("\7X\2\2\u013e\u013f\7G\2\2\u013f<\3\2\2\2\u0140\u0141")
buf.write("\7G\2\2\u0141\u0142\7Z\2\2\u0142\u0143\7E\2\2\u0143\u0144")
buf.write("\7J\2\2\u0144\u0145\7C\2\2\u0145\u0146\7P\2\2\u0146\u0147")
buf.write("\7I\2\2\u0147\u0148\7G\2\2\u0148>\3\2\2\2\u0149\u014a")
buf.write("\7E\2\2\u014a\u014b\7Q\2\2\u014b\u014c\7P\2\2\u014c\u014d")
buf.write("\7X\2\2\u014d\u014e\7G\2\2\u014e\u014f\7T\2\2\u014f\u0150")
buf.write("\7V\2\2\u0150@\3\2\2\2\u0151\u0152\7G\2\2\u0152\u0153")
buf.write("\7S\2\2\u0153B\3\2\2\2\u0154\u0155\7I\2\2\u0155\u0156")
buf.write("\7V\2\2\u0156D\3\2\2\2\u0157\u0158\7I\2\2\u0158\u0159")
buf.write("\7G\2\2\u0159F\3\2\2\2\u015a\u015b\7N\2\2\u015b\u015c")
buf.write("\7V\2\2\u015cH\3\2\2\2\u015d\u015e\7N\2\2\u015e\u015f")
buf.write("\7G\2\2\u015fJ\3\2\2\2\u0160\u0161\7N\2\2\u0161\u0162")
buf.write("\7Q\2\2\u0162\u0163\7C\2\2\u0163\u0164\7F\2\2\u0164L\3")
buf.write("\2\2\2\u0165\u0166\7U\2\2\u0166\u0167\7V\2\2\u0167\u0168")
buf.write("\7Q\2\2\u0168\u0169\7T\2\2\u0169\u016a\7G\2\2\u016aN\3")
buf.write("\2\2\2\u016b\u016c\7r\2\2\u016c\u016d\7k\2\2\u016dP\3")
buf.write("\2\2\2\u016e\u016f\7k\2\2\u016fR\3\2\2\2\u0170\u0171\7")
buf.write("U\2\2\u0171\u0172\7K\2\2\u0172\u0173\7P\2\2\u0173T\3\2")
buf.write("\2\2\u0174\u0175\7E\2\2\u0175\u0176\7Q\2\2\u0176\u0177")
buf.write("\7U\2\2\u0177V\3\2\2\2\u0178\u0179\7U\2\2\u0179\u017a")
buf.write("\7S\2\2\u017a\u017b\7T\2\2\u017b\u017c\7V\2\2\u017cX\3")
buf.write("\2\2\2\u017d\u017e\7G\2\2\u017e\u017f\7Z\2\2\u017f\u0180")
buf.write("\7R\2\2\u0180Z\3\2\2\2\u0181\u0182\7E\2\2\u0182\u0183")
buf.write("\7K\2\2\u0183\u0184\7U\2\2\u0184\\\3\2\2\2\u0185\u0186")
buf.write("\7-\2\2\u0186^\3\2\2\2\u0187\u0188\7/\2\2\u0188`\3\2\2")
buf.write("\2\u0189\u018a\7,\2\2\u018ab\3\2\2\2\u018b\u018c\7\61")
buf.write("\2\2\u018cd\3\2\2\2\u018d\u018e\7`\2\2\u018ef\3\2\2\2")
buf.write("\u018f\u0190\7E\2\2\u0190\u0191\7Q\2\2\u0191\u0192\7P")
buf.write("\2\2\u0192\u0193\7V\2\2\u0193\u0194\7T\2\2\u0194\u0195")
buf.write("\7Q\2\2\u0195\u0196\7N\2\2\u0196\u0197\7N\2\2\u0197\u0198")
buf.write("\7G\2\2\u0198\u0199\7F\2\2\u0199h\3\2\2\2\u019a\u019b")
buf.write("\7F\2\2\u019b\u019c\7C\2\2\u019c\u019d\7I\2\2\u019d\u019e")
buf.write("\7I\2\2\u019e\u019f\7G\2\2\u019f\u01a0\7T\2\2\u01a0j\3")
buf.write("\2\2\2\u01a1\u01ab\t\2\2\2\u01a2\u01a6\t\2\2\2\u01a3\u01a5")
buf.write("\t\3\2\2\u01a4\u01a3\3\2\2\2\u01a5\u01a8\3\2\2\2\u01a6")
buf.write("\u01a4\3\2\2\2\u01a6\u01a7\3\2\2\2\u01a7\u01a9\3\2\2\2")
buf.write("\u01a8\u01a6\3\2\2\2\u01a9\u01ab\t\4\2\2\u01aa\u01a1\3")
buf.write("\2\2\2\u01aa\u01a2\3\2\2\2\u01abl\3\2\2\2\u01ac\u01ae")
buf.write("\t\5\2\2\u01ad\u01ac\3\2\2\2\u01ae\u01af\3\2\2\2\u01af")
buf.write("\u01ad\3\2\2\2\u01af\u01b0\3\2\2\2\u01b0n\3\2\2\2\u01b1")
buf.write("\u01b3\t\5\2\2\u01b2\u01b1\3\2\2\2\u01b3\u01b4\3\2\2\2")
buf.write("\u01b4\u01b2\3\2\2\2\u01b4\u01b5\3\2\2\2\u01b5\u01bc\3")
buf.write("\2\2\2\u01b6\u01b8\7\60\2\2\u01b7\u01b9\t\5\2\2\u01b8")
buf.write("\u01b7\3\2\2\2\u01b9\u01ba\3\2\2\2\u01ba\u01b8\3\2\2\2")
buf.write("\u01ba\u01bb\3\2\2\2\u01bb\u01bd\3\2\2\2\u01bc\u01b6\3")
buf.write("\2\2\2\u01bc\u01bd\3\2\2\2\u01bd\u01c7\3\2\2\2\u01be\u01c0")
buf.write("\t\6\2\2\u01bf\u01c1\t\7\2\2\u01c0\u01bf\3\2\2\2\u01c0")
buf.write("\u01c1\3\2\2\2\u01c1\u01c3\3\2\2\2\u01c2\u01c4\t\5\2\2")
buf.write("\u01c3\u01c2\3\2\2\2\u01c4\u01c5\3\2\2\2\u01c5\u01c3\3")
buf.write("\2\2\2\u01c5\u01c6\3\2\2\2\u01c6\u01c8\3\2\2\2\u01c7\u01be")
buf.write("\3\2\2\2\u01c7\u01c8\3\2\2\2\u01c8p\3\2\2\2\u01c9\u01cd")
buf.write("\7$\2\2\u01ca\u01cc\n\b\2\2\u01cb\u01ca\3\2\2\2\u01cc")
buf.write("\u01cf\3\2\2\2\u01cd\u01cb\3\2\2\2\u01cd\u01ce\3\2\2\2")
buf.write("\u01ce\u01d0\3\2\2\2\u01cf\u01cd\3\2\2\2\u01d0\u01d1\7")
buf.write("$\2\2\u01d1r\3\2\2\2\u01d2\u01d3\7\60\2\2\u01d3t\3\2\2")
buf.write("\2\u01d4\u01d5\7.\2\2\u01d5v\3\2\2\2\u01d6\u01d7\7*\2")
buf.write("\2\u01d7x\3\2\2\2\u01d8\u01d9\7+\2\2\u01d9z\3\2\2\2\u01da")
buf.write("\u01db\7]\2\2\u01db|\3\2\2\2\u01dc\u01dd\7_\2\2\u01dd")
buf.write("~\3\2\2\2\u01de\u01df\7<\2\2\u01df\u0080\3\2\2\2\u01e0")
buf.write("\u01e1\7\'\2\2\u01e1\u0082\3\2\2\2\u01e2\u01e3\7B\2\2")
buf.write("\u01e3\u0084\3\2\2\2\u01e4\u01e5\7$\2\2\u01e5\u0086\3")
buf.write("\2\2\2\u01e6\u01e7\7a\2\2\u01e7\u0088\3\2\2\2\u01e8\u01e9")
buf.write("\7\"\2\2\u01e9\u01ea\7\"\2\2\u01ea\u01eb\7\"\2\2\u01eb")
buf.write("\u01ec\7\"\2\2\u01ec\u008a\3\2\2\2\u01ed\u01ef\t\t\2\2")
buf.write("\u01ee\u01ed\3\2\2\2\u01ef\u01f2\3\2\2\2\u01f0\u01ee\3")
buf.write("\2\2\2\u01f0\u01f1\3\2\2\2\u01f1\u01f8\3\2\2\2\u01f2\u01f0")
buf.write("\3\2\2\2\u01f3\u01f5\7\17\2\2\u01f4\u01f3\3\2\2\2\u01f4")
buf.write("\u01f5\3\2\2\2\u01f5\u01f6\3\2\2\2\u01f6\u01f9\7\f\2\2")
buf.write("\u01f7\u01f9\7\17\2\2\u01f8\u01f4\3\2\2\2\u01f8\u01f7")
buf.write("\3\2\2\2\u01f9\u01fa\3\2\2\2\u01fa\u01f8\3\2\2\2\u01fa")
buf.write("\u01fb\3\2\2\2\u01fb\u008c\3\2\2\2\u01fc\u01fe\t\t\2\2")
buf.write("\u01fd\u01fc\3\2\2\2\u01fe\u0201\3\2\2\2\u01ff\u01fd\3")
buf.write("\2\2\2\u01ff\u0200\3\2\2\2\u0200\u0202\3\2\2\2\u0201\u01ff")
buf.write("\3\2\2\2\u0202\u0206\7%\2\2\u0203\u0205\n\b\2\2\u0204")
buf.write("\u0203\3\2\2\2\u0205\u0208\3\2\2\2\u0206\u0204\3\2\2\2")
buf.write("\u0206\u0207\3\2\2\2\u0207\u0209\3\2\2\2\u0208\u0206\3")
buf.write("\2\2\2\u0209\u020a\bG\2\2\u020a\u008e\3\2\2\2\u020b\u020c")
buf.write("\7\"\2\2\u020c\u020d\3\2\2\2\u020d\u020e\bH\2\2\u020e")
buf.write("\u0090\3\2\2\2\u020f\u0210\13\2\2\2\u0210\u0092\3\2\2")
buf.write("\2\23\2\u01a6\u01aa\u01af\u01b4\u01ba\u01bc\u01c0\u01c5")
buf.write("\u01c7\u01cd\u01f0\u01f4\u01f8\u01fa\u01ff\u0206\3\b\2")
buf.write("\2")
return buf.getvalue()
class QuilLexer(Lexer):
atn = ATNDeserializer().deserialize(serializedATN())
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
DEFGATE = 1
DEFCIRCUIT = 2
MEASURE = 3
LABEL = 4
HALT = 5
JUMP = 6
JUMPWHEN = 7
JUMPUNLESS = 8
RESET = 9
WAIT = 10
NOP = 11
INCLUDE = 12
PRAGMA = 13
DECLARE = 14
SHARING = 15
OFFSET = 16
NEG = 17
NOT = 18
TRUE = 19
FALSE = 20
AND = 21
IOR = 22
XOR = 23
OR = 24
ADD = 25
SUB = 26
MUL = 27
DIV = 28
MOVE = 29
EXCHANGE = 30
CONVERT = 31
EQ = 32
GT = 33
GE = 34
LT = 35
LE = 36
LOAD = 37
STORE = 38
PI = 39
I = 40
SIN = 41
COS = 42
SQRT = 43
EXP = 44
CIS = 45
PLUS = 46
MINUS = 47
TIMES = 48
DIVIDE = 49
POWER = 50
CONTROLLED = 51
DAGGER = 52
IDENTIFIER = 53
INT = 54
FLOAT = 55
STRING = 56
PERIOD = 57
COMMA = 58
LPAREN = 59
RPAREN = 60
LBRACKET = 61
RBRACKET = 62
COLON = 63
PERCENTAGE = 64
AT = 65
QUOTE = 66
UNDERSCORE = 67
TAB = 68
NEWLINE = 69
COMMENT = 70
SPACE = 71
INVALID = 72
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
modeNames = [ "DEFAULT_MODE" ]
literalNames = [ "<INVALID>",
"'DEFGATE'", "'DEFCIRCUIT'", "'MEASURE'", "'LABEL'", "'HALT'",
"'JUMP'", "'JUMP-WHEN'", "'JUMP-UNLESS'", "'RESET'", "'WAIT'",
"'NOP'", "'INCLUDE'", "'PRAGMA'", "'DECLARE'", "'SHARING'",
"'OFFSET'", "'NEG'", "'NOT'", "'TRUE'", "'FALSE'", "'AND'",
"'IOR'", "'XOR'", "'OR'", "'ADD'", "'SUB'", "'MUL'", "'DIV'",
"'MOVE'", "'EXCHANGE'", "'CONVERT'", "'EQ'", "'GT'", "'GE'",
"'LT'", "'LE'", "'LOAD'", "'STORE'", "'pi'", "'i'", "'SIN'",
"'COS'", "'SQRT'", "'EXP'", "'CIS'", "'+'", "'-'", "'*'", "'/'",
"'^'", "'CONTROLLED'", "'DAGGER'", "'.'", "','", "'('", "')'",
"'['", "']'", "':'", "'%'", "'@'", "'\"'", "'_'", "' '",
"' '" ]
symbolicNames = [ "<INVALID>",
"DEFGATE", "DEFCIRCUIT", "MEASURE", "LABEL", "HALT", "JUMP",
"JUMPWHEN", "JUMPUNLESS", "RESET", "WAIT", "NOP", "INCLUDE",
"PRAGMA", "DECLARE", "SHARING", "OFFSET", "NEG", "NOT", "TRUE",
"FALSE", "AND", "IOR", "XOR", "OR", "ADD", "SUB", "MUL", "DIV",
"MOVE", "EXCHANGE", "CONVERT", "EQ", "GT", "GE", "LT", "LE",
"LOAD", "STORE", "PI", "I", "SIN", "COS", "SQRT", "EXP", "CIS",
"PLUS", "MINUS", "TIMES", "DIVIDE", "POWER", "CONTROLLED", "DAGGER",
"IDENTIFIER", "INT", "FLOAT", "STRING", "PERIOD", "COMMA", "LPAREN",
"RPAREN", "LBRACKET", "RBRACKET", "COLON", "PERCENTAGE", "AT",
"QUOTE", "UNDERSCORE", "TAB", "NEWLINE", "COMMENT", "SPACE",
"INVALID" ]
ruleNames = [ "DEFGATE", "DEFCIRCUIT", "MEASURE", "LABEL", "HALT", "JUMP",
"JUMPWHEN", "JUMPUNLESS", "RESET", "WAIT", "NOP", "INCLUDE",
"PRAGMA", "DECLARE", "SHARING", "OFFSET", "NEG", "NOT",
"TRUE", "FALSE", "AND", "IOR", "XOR", "OR", "ADD", "SUB",
"MUL", "DIV", "MOVE", "EXCHANGE", "CONVERT", "EQ", "GT",
"GE", "LT", "LE", "LOAD", "STORE", "PI", "I", "SIN", "COS",
"SQRT", "EXP", "CIS", "PLUS", "MINUS", "TIMES", "DIVIDE",
"POWER", "CONTROLLED", "DAGGER", "IDENTIFIER", "INT",
"FLOAT", "STRING", "PERIOD", "COMMA", "LPAREN", "RPAREN",
"LBRACKET", "RBRACKET", "COLON", "PERCENTAGE", "AT", "QUOTE",
"UNDERSCORE", "TAB", "NEWLINE", "COMMENT", "SPACE", "INVALID" ]
grammarFileName = "Quil.g4"
def __init__(self, input=None, output:TextIO = sys.stdout):
super().__init__(input, output)
self.checkVersion("4.7.1")
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
self._actions = None
self._predicates = None
| StarcoderdataPython |
5081693 | <gh_stars>0
# # looks outdated & python2
#
# trj, psg = min_jerk(pos, dur, vel, acc, psg)
#
# Compute minimum-jerk trajectory through specified points
#
# INPUTS:
# pos: NxD array with the D-dimensional coordinates of N points
# dur: number of time steps (integer)
# vel: 2xD array with endpoint velocities, [] sets vel to 0
# acc: 2xD array with endpoint accelerations, [] sets acc to 0
# psg: (N-1)x1 array of via-point passage times (between 0 and dur);
# [] causes optimization over the passage times
#
# OUTPUTS
# trj: dur x D array with the minimum-jerk trajectory
# psg: (N-1)x1 array of passage times
#
# This is an implementation of the algorithm described in:
# <NAME>. and <NAME>. (1998) Smoothness maximization along
# a predefined path accurately predicts the speed profiles of
# complex arm movements. Journal of Neurophysiology 80(2): 696-714
# The paper is available online at www.cogsci.ucsd.edu/~todorov
# Copyright (C) <NAME>, 1998-2006
# Python implementation by <NAME>
import math
import numpy as np
import scipy.optimize
from numpy.linalg import inv
def min_jerk(pos=None, dur=None, vel=None, acc=None, psg=None):
N = pos.shape[0] # number of point
D = pos.shape[1] # dimensionality
if not vel:
vel = np.zeros((2, D)) # default endpoint vel is 0
if not acc:
acc = np.zeros((2, D)) # default endpoint acc is 0
t0 = np.array([[0], [dur]])
if not psg: # passage times unknown, optimize
if N > 2:
psg = np.arange(dur / (N - 1), dur - dur / (N - 1) + 1, dur / (N - 1)).T
func = lambda psg_: mjCOST(psg_, pos, vel, acc, t0)
psg = scipy.optimize.fmin(func=func, x0=psg)
else:
psg = []
# print(psg)
trj = mjTRJ(psg, pos, vel, acc, t0, dur)
return trj, psg
################################################################
###### Compute jerk cost
################################################################
def mjCOST(t, x, v0, a0, t0):
N = max(x.shape)
D = min(x.shape)
v, a = mjVelAcc(t, x, v0, a0, t0)
aa = np.concatenate(([a0[0][:]], a, [a0[1][:]]), axis=0)
aa0 = aa[0 : N - 1][:]
aa1 = aa[1:N][:]
vv = np.concatenate(([v0[0][:]], v, [v0[1][:]]), axis=0)
vv0 = vv[0 : N - 1][:]
vv1 = vv[1:N][:]
tt = np.concatenate((t0[0], t, t0[1]), axis=0)
T = np.diff(tt)[np.newaxis].T * np.ones((1, D))
xx0 = x[0 : N - 1][:]
xx1 = x[1:N][:]
j = (
3
* (
3 * aa0 ** 2 * T ** 4
- 2 * aa0 * aa1 * T ** 4
+ 3 * aa1 ** 2 * T ** 4
+ 24 * aa0 * T ** 3 * vv0
- 16 * aa1 * T ** 3 * vv0
+ 64 * T ** 2 * vv0 ** 2
+ 16 * aa0 * T ** 3 * vv1
- 24 * aa1 * T ** 3 * vv1
+ 112 * T ** 2 * vv0 * vv1
+ 64 * T ** 2 * vv1 ** 2
+ 40 * aa0 * T ** 2 * xx0
- 40 * aa1 * T ** 2 * xx0
+ 240 * T * vv0 * xx0
+ 240 * T * vv1 * xx0
+ 240 * xx0 ** 2
- 40 * aa0 * T ** 2 * xx1
+ 40 * aa1 * T ** 2 * xx1
- 240 * T * vv0 * xx1
- 240 * T * vv1 * xx1
- 480 * xx0 * xx1
+ 240 * xx1 ** 2
)
/ T ** 5
)
J = sum(sum(abs(j)))
return J
################################################################
###### Compute trajectory
################################################################
def mjTRJ(tx, x, v0, a0, t0, P):
N = max(x.shape)
D = min(x.shape)
X_list = []
if len(tx) > 0:
v, a = mjVelAcc(tx, x, v0, a0, t0)
aa = np.concatenate(([a0[0][:]], a, [a0[1][:]]), axis=0)
vv = np.concatenate(([v0[0][:]], v, [v0[1][:]]), axis=0)
tt = np.concatenate((t0[0], tx, t0[1]), axis=0)
else:
aa = a0
vv = v0
tt = t0
ii = 0
for i in range(1, int(P) + 1):
t = (i - 1) / (P - 1) * (t0[1] - t0[0]) + t0[0]
if t > tt[ii + 1]:
ii = ii + 1
T = (tt[ii + 1] - tt[ii]) * np.ones((1, D))
t = (t - tt[ii]) * np.ones((1, D))
aa0 = aa[ii][:]
aa1 = aa[ii + 1][:]
vv0 = vv[ii][:]
vv1 = vv[ii + 1][:]
xx0 = x[ii][:]
xx1 = x[ii + 1][:]
tmp = (
aa0 * t ** 2 / 2
+ t * vv0
+ xx0
+ t ** 4
* (
3 * aa0 * T ** 2 / 2
- aa1 * T ** 2
+ 8 * T * vv0
+ 7 * T * vv1
+ 15 * xx0
- 15 * xx1
)
/ T ** 4
+ t ** 5
* (
-(aa0 * T ** 2) / 2
+ aa1 * T ** 2 / 2
- 3 * T * vv0
- 3 * T * vv1
- 6 * xx0
+ 6 * xx1
)
/ T ** 5
+ t ** 3
* (
-3 * aa0 * T ** 2 / 2
+ aa1 * T ** 2 / 2
- 6 * T * vv0
- 4 * T * vv1
- 10 * xx0
+ 10 * xx1
)
/ T ** 3
)
X_list.append(tmp)
X = np.concatenate(X_list)
return X
################################################################
###### Compute intermediate velocities and accelerations
################################################################
def mjVelAcc(t, x, v0, a0, t0):
N = max(x.shape)
D = min(x.shape)
mat = np.zeros((2 * N - 4, 2 * N - 4))
vec = np.zeros((2 * N - 4, D))
tt = np.concatenate((t0[0], t, t0[1]), axis=0)
for i in range(1, 2 * N - 4 + 1, 2):
ii = int(math.ceil(i / 2.0))
T0 = tt[ii] - tt[ii - 1]
T1 = tt[ii + 1] - tt[ii]
tmp = [
-6 / T0,
-48 / T0 ** 2,
18 * (1 / T0 + 1 / T1),
72 * (1 / T1 ** 2 - 1 / T0 ** 2),
-6 / T1,
48 / T1 ** 2,
]
if i == 1:
le = 0
else:
le = -2
if i == 2 * N - 5:
ri = 1
else:
ri = 3
mat[i - 1][i + le - 1 : i + ri] = tmp[3 + le - 1 : 3 + ri]
vec[i - 1][:] = (
120 * (x[ii - 1][:] - x[ii][:]) / T0 ** 3
+ 120 * (x[ii + 1][:] - x[ii][:]) / T1 ** 3
)
for i in range(2, 2 * N - 4 + 1, 2):
ii = int(math.ceil(i / 2.0))
T0 = tt[ii] - tt[ii - 1]
T1 = tt[ii + 1] - tt[ii]
tmp = [
48 / T0 ** 2,
336 / T0 ** 3,
72 * (1 / T1 ** 2 - 1 / T0 ** 2),
384 * (1 / T1 ** 3 + 1 / T0 ** 3),
-48 / T1 ** 2,
336 / T1 ** 3,
]
if i == 2:
le = -1
else:
le = -3
if i == 2 * N - 4:
ri = 0
else:
ri = 2
mat[i - 1][i + le - 1 : i + ri] = tmp[4 + le - 1 : 4 + ri]
vec[i - 1][:] = (
720 * (x[ii][:] - x[ii - 1][:]) / T0 ** 4
+ 720 * (x[ii + 1][:] - x[ii][:]) / T1 ** 4
)
T0 = tt[1] - tt[0]
T1 = tt[N - 1] - tt[N - 2]
vec[0][:] = vec[0][:] + 6 / T0 * a0[0][:] + 48 / T0 ** 2 * v0[0][:]
vec[1][:] = vec[1][:] - 48 / T0 ** 2 * a0[0][:] - 336 / T0 ** 3 * v0[0][:]
vec[2 * N - 6][:] = vec[2 * N - 6][:] + 6 / T1 * a0[1][:] - 48 / T1 ** 2 * v0[1][:]
vec[2 * N - 5][:] = (
vec[2 * N - 5][:] + 48 / T1 ** 2 * a0[1][:] - 336 / T1 ** 3 * v0[1][:]
)
avav = inv(mat).dot(vec)
a = avav[0 : 2 * N - 4 : 2][:]
v = avav[1 : 2 * N - 4 : 2][:]
return v, a
| StarcoderdataPython |
328354 | import pytest
from brewtils import get_easy_client
from brewtils.schema_parser import SchemaParser
try:
from ..helper import RequestGenerator, setup_easy_client
except (ImportError, ValueError):
from helper import RequestGenerator, setup_easy_client
@pytest.fixture(scope="class")
def request_generator(request, system_spec):
request.cls.request_generator = RequestGenerator(**system_spec)
@pytest.fixture(scope="class")
def easy_client(request):
request.cls.easy_client = setup_easy_client()
return request.cls.easy_client
@pytest.fixture(scope="class")
def child_easy_client(request):
request.cls.child_easy_client = get_easy_client(
bg_host="localhost", bg_port=2347, ssl_enabled=False
)
return request.cls.child_easy_client
@pytest.fixture(scope="class")
def parser(request):
request.cls.parser = SchemaParser()
return request.cls.parser
| StarcoderdataPython |
1692794 | ######### imports #########
from ast import arg
from datetime import timedelta
import sys
sys.path.insert(0, "TP_model")
sys.path.insert(0, "TP_model/fit_and_forecast")
from Reff_constants import *
from Reff_functions import *
import glob
import os
from sys import argv
import arviz as az
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import matplotlib
from math import ceil
import pickle
from cmdstanpy import CmdStanModel
matplotlib.use("Agg")
from params import (
truncation_days,
start_date,
third_start_date,
alpha_start_date,
omicron_start_date,
omicron_only_date,
omicron_dominance_date,
pop_sizes,
num_forecast_days,
get_all_p_detect_old,
get_all_p_detect,
)
def process_vax_data_array(
data_date,
third_states,
third_end_date,
variant="Delta",
print_latest_date_in_ts=False,
):
"""
Processes the vaccination data to an array for either the Omicron or Delta strain.
"""
# Load in vaccination data by state and date
vaccination_by_state = pd.read_csv(
"data/vaccine_effect_timeseries_" + data_date.strftime("%Y-%m-%d") + ".csv",
parse_dates=["date"],
)
# there are a couple NA's early on in the time series but is likely due to slightly
# different start dates
vaccination_by_state.fillna(1, inplace=True)
vaccination_by_state = vaccination_by_state.loc[
vaccination_by_state["variant"] == variant
]
vaccination_by_state = vaccination_by_state[["state", "date", "effect"]]
if print_latest_date_in_ts:
# display the latest available date in the NSW data (will be the same date between states)
print(
"Latest date in vaccine data is {}".format(
vaccination_by_state[vaccination_by_state.state == "NSW"].date.values[-1]
)
)
# Get only the dates we need + 1 (this serves as the initial value)
vaccination_by_state = vaccination_by_state[
(
vaccination_by_state.date
>= pd.to_datetime(third_start_date) - timedelta(days=1)
)
& (vaccination_by_state.date <= third_end_date)
]
vaccination_by_state = vaccination_by_state[
vaccination_by_state["state"].isin(third_states)
] # Isolate fitting states
vaccination_by_state = vaccination_by_state.pivot(
index="state", columns="date", values="effect"
) # Convert to matrix form
# If we are missing recent vaccination data, fill it in with the most recent available data.
latest_vacc_data = vaccination_by_state.columns[-1]
if latest_vacc_data < pd.to_datetime(third_end_date):
vaccination_by_state = pd.concat(
[vaccination_by_state]
+ [
pd.Series(vaccination_by_state[latest_vacc_data], name=day)
for day in pd.date_range(start=latest_vacc_data, end=third_end_date)
],
axis=1,
)
# Convert to simple array only useful to pass to stan (index 1 onwards)
vaccination_by_state_array = vaccination_by_state.iloc[:, 1:].to_numpy()
return vaccination_by_state_array
def get_data_for_posterior(data_date):
"""
Read in the various datastreams and combine the samples into a dictionary that we then
dump to a pickle file.
"""
print("Performing inference on state level Reff")
data_date = pd.to_datetime(data_date) # Define data date
print("Data date is {}".format(data_date.strftime("%d%b%Y")))
fit_date = pd.to_datetime(data_date - timedelta(days=truncation_days))
print("Last date in fitting {}".format(fit_date.strftime("%d%b%Y")))
# * Note: 2020-09-09 won't work (for some reason)
# read in microdistancing survey data
surveys = pd.DataFrame()
path = "data/md/Barometer wave*.csv"
for file in glob.glob(path):
surveys = surveys.append(pd.read_csv(file, parse_dates=["date"]))
surveys = surveys.sort_values(by="date")
print("Latest Microdistancing survey is {}".format(surveys.date.values[-1]))
surveys["state"] = surveys["state"].map(states_initials).fillna(surveys["state"])
surveys["proportion"] = surveys["count"] / surveys.respondents
surveys.date = pd.to_datetime(surveys.date)
always = surveys.loc[surveys.response == "Always"].set_index(["state", "date"])
always = always.unstack(["state"])
# If you get an error here saying 'cannot create a new series when the index is not unique',
# then you have a duplicated md file.
idx = pd.date_range("2020-03-01", pd.to_datetime("today"))
always = always.reindex(idx, fill_value=np.nan)
always.index.name = "date"
# fill back to earlier and between weeks.
# Assume survey on day x applies for all days up to x - 6
always = always.fillna(method="bfill")
# assume values continue forward if survey hasn't completed
always = always.fillna(method="ffill")
always = always.stack(["state"])
# Zero out before first survey 20th March
always = always.reset_index().set_index("date")
always.loc[:"2020-03-20", "count"] = 0
always.loc[:"2020-03-20", "respondents"] = 0
always.loc[:"2020-03-20", "proportion"] = 0
always = always.reset_index().set_index(["state", "date"])
survey_X = pd.pivot_table(
data=always, index="date", columns="state", values="proportion"
)
survey_counts_base = (
pd.pivot_table(data=always, index="date", columns="state", values="count")
.drop(["Australia", "Other"], axis=1)
.astype(int)
)
survey_respond_base = (
pd.pivot_table(data=always, index="date", columns="state", values="respondents")
.drop(["Australia", "Other"], axis=1)
.astype(int)
)
# read in and process mask wearing data
mask_wearing = pd.DataFrame()
path = "data/face_coverings/face_covering_*_.csv"
for file in glob.glob(path):
mask_wearing = mask_wearing.append(pd.read_csv(file, parse_dates=["date"]))
mask_wearing = mask_wearing.sort_values(by="date")
print("Latest Mask wearing survey is {}".format(mask_wearing.date.values[-1]))
mask_wearing["state"] = (
mask_wearing["state"].map(states_initials).fillna(mask_wearing["state"])
)
mask_wearing["proportion"] = mask_wearing["count"] / mask_wearing.respondents
mask_wearing.date = pd.to_datetime(mask_wearing.date)
mask_wearing_always = mask_wearing.loc[
mask_wearing.face_covering == "Always"
].set_index(["state", "date"])
mask_wearing_always = mask_wearing_always.unstack(["state"])
idx = pd.date_range("2020-03-01", pd.to_datetime("today"))
mask_wearing_always = mask_wearing_always.reindex(idx, fill_value=np.nan)
mask_wearing_always.index.name = "date"
# fill back to earlier and between weeks.
# Assume survey on day x applies for all days up to x - 6
mask_wearing_always = mask_wearing_always.fillna(method="bfill")
# assume values continue forward if survey hasn't completed
mask_wearing_always = mask_wearing_always.fillna(method="ffill")
mask_wearing_always = mask_wearing_always.stack(["state"])
# Zero out before first survey 20th March
mask_wearing_always = mask_wearing_always.reset_index().set_index("date")
mask_wearing_always.loc[:"2020-03-20", "count"] = 0
mask_wearing_always.loc[:"2020-03-20", "respondents"] = 0
mask_wearing_always.loc[:"2020-03-20", "proportion"] = 0
mask_wearing_X = pd.pivot_table(
data=mask_wearing_always, index="date", columns="state", values="proportion"
)
mask_wearing_counts_base = pd.pivot_table(
data=mask_wearing_always, index="date", columns="state", values="count"
).astype(int)
mask_wearing_respond_base = pd.pivot_table(
data=mask_wearing_always, index="date", columns="state", values="respondents"
).astype(int)
df_Reff = pd.read_csv(
"results/EpyReff/Reff_delta" + data_date.strftime("%Y-%m-%d") + "tau_4.csv",
parse_dates=["INFECTION_DATES"],
)
df_Reff["date"] = df_Reff.INFECTION_DATES
df_Reff["state"] = df_Reff.STATE
df_Reff_omicron = pd.read_csv(
"results/EpyReff/Reff_omicron" + data_date.strftime("%Y-%m-%d") + "tau_4.csv",
parse_dates=["INFECTION_DATES"],
)
df_Reff_omicron["date"] = df_Reff_omicron.INFECTION_DATES
df_Reff_omicron["state"] = df_Reff_omicron.STATE
# relabel some of the columns to avoid replication in the merged dataframe
col_names_replace = {
"mean": "mean_omicron",
"lower": "lower_omicron",
"upper": "upper_omicron",
"top": "top_omicron",
"bottom": "bottom_omicron",
"std": "std_omicron",
}
df_Reff_omicron.rename(col_names_replace, axis=1, inplace=True)
# read in NNDSS/linelist data
# If this errors it may be missing a leading zero on the date.
df_state = read_in_cases(
case_file_date=data_date.strftime("%d%b%Y"),
apply_delay_at_read=True,
apply_inc_at_read=True,
)
# save the case file for convenience
df_state.to_csv("results/cases_" + data_date.strftime("%Y-%m-%d") + ".csv")
df_Reff = df_Reff.merge(
df_state,
how="left",
left_on=["state", "date"],
right_on=["STATE", "date_inferred"],
) # how = left to use Reff days, NNDSS missing dates
# merge in the omicron stuff
df_Reff = df_Reff.merge(
df_Reff_omicron,
how="left",
left_on=["state", "date"],
right_on=["state", "date"],
)
df_Reff["rho_moving"] = df_Reff.groupby(["state"])["rho"].transform(
lambda x: x.rolling(7, 1).mean()
) # minimum number of 1
# some days have no cases, so need to fillna
df_Reff["rho_moving"] = df_Reff.rho_moving.fillna(method="bfill")
# counts are already aligned with infection date by subtracting a random incubation period
df_Reff["local"] = df_Reff.local.fillna(0)
df_Reff["imported"] = df_Reff.imported.fillna(0)
######### Read in Google mobility results #########
sys.path.insert(0, "../")
df_google = read_in_google(moving=True, moving_window=7)
# df_google = read_in_google(moving=False)
df = df_google.merge(df_Reff[[
"date",
"state",
"mean",
"lower",
"upper",
"top",
"bottom",
"std",
"mean_omicron",
"lower_omicron",
"upper_omicron",
"top_omicron",
"bottom_omicron",
"std_omicron",
"rho",
"rho_moving",
"local",
"imported",
]],
on=["date", "state"],
how="inner",
)
######### Create useable dataset #########
# ACT and NT not in original estimates, need to extrapolated sorting keeps consistent
# with sort in data_by_state
# Note that as we now consider the third wave for ACT, we include it in the third
# wave fitting only!
states_to_fit_all_waves = sorted(
["NSW", "VIC", "QLD", "SA", "WA", "TAS", "ACT", "NT"]
)
first_states = sorted(["NSW", "VIC", "QLD", "SA", "WA", "TAS"])
fit_post_March = True
ban = "2020-03-20"
first_end_date = "2020-03-31"
# data for the first wave
first_date_range = {
"NSW": pd.date_range(start="2020-03-01", end=first_end_date).values,
"QLD": pd.date_range(start="2020-03-01", end=first_end_date).values,
"SA": pd.date_range(start="2020-03-01", end=first_end_date).values,
"TAS": pd.date_range(start="2020-03-01", end=first_end_date).values,
"VIC": pd.date_range(start="2020-03-01", end=first_end_date).values,
"WA": pd.date_range(start="2020-03-01", end=first_end_date).values,
}
# Second wave inputs
sec_states = sorted([
"NSW",
# "VIC",
])
sec_start_date = "2020-06-01"
sec_end_date = "2021-01-19"
# choose dates for each state for sec wave
sec_date_range = {
"NSW": pd.date_range(start="2020-06-01", end="2021-01-19").values,
# "VIC": pd.date_range(start="2020-06-01", end="2020-10-28").values,
}
# Third wave inputs
third_states = sorted([
"NSW",
"VIC",
"ACT",
"QLD",
"SA",
"TAS",
# "NT",
"WA",
])
# Subtract the truncation days to avoid right truncation as we consider infection dates
# and not symptom onset dates
third_end_date = data_date - pd.Timedelta(days=truncation_days)
# choose dates for each state for third wave
# Note that as we now consider the third wave for ACT, we include it in
# the third wave fitting only!
third_date_range = {
"ACT": pd.date_range(start="2021-08-15", end=third_end_date).values,
"NSW": pd.date_range(start="2021-06-25", end=third_end_date).values,
# "NT": pd.date_range(start="2021-12-20", end=third_end_date).values,
"QLD": pd.date_range(start="2021-07-30", end=third_end_date).values,
"SA": pd.date_range(start="2021-12-10", end=third_end_date).values,
"TAS": pd.date_range(start="2021-12-20", end=third_end_date).values,
"VIC": pd.date_range(start="2021-07-10", end=third_end_date).values,
"WA": pd.date_range(start="2022-01-01", end=third_end_date).values,
}
fit_mask = df.state.isin(first_states)
if fit_post_March:
fit_mask = (fit_mask) & (df.date >= start_date)
fit_mask = (fit_mask) & (df.date <= first_end_date)
second_wave_mask = df.state.isin(sec_states)
second_wave_mask = (second_wave_mask) & (df.date >= sec_start_date)
second_wave_mask = (second_wave_mask) & (df.date <= sec_end_date)
# Add third wave stuff here
third_wave_mask = df.state.isin(third_states)
third_wave_mask = (third_wave_mask) & (df.date >= third_start_date)
third_wave_mask = (third_wave_mask) & (df.date <= third_end_date)
predictors = mov_values.copy()
# predictors.extend(['driving_7days','transit_7days','walking_7days','pc'])
# remove residential to see if it improves fit
# predictors.remove("residential_7days")
df["post_policy"] = (df.date >= ban).astype(int)
dfX = df.loc[fit_mask].sort_values("date")
df2X = df.loc[second_wave_mask].sort_values("date")
df3X = df.loc[third_wave_mask].sort_values("date")
dfX["is_first_wave"] = 0
for state in first_states:
dfX.loc[dfX.state == state, "is_first_wave"] = (
dfX.loc[dfX.state == state]
.date.isin(first_date_range[state])
.astype(int)
.values
)
df2X["is_sec_wave"] = 0
for state in sec_states:
df2X.loc[df2X.state == state, "is_sec_wave"] = (
df2X.loc[df2X.state == state]
.date.isin(sec_date_range[state])
.astype(int)
.values
)
# used to index what dates are featured in omicron AND third wave
omicron_date_range = pd.date_range(start=omicron_start_date, end=third_end_date)
df3X["is_third_wave"] = 0
for state in third_states:
df3X.loc[df3X.state == state, "is_third_wave"] = (
df3X.loc[df3X.state == state]
.date.isin(third_date_range[state])
.astype(int)
.values
)
# condition on being in third wave AND omicron
df3X.loc[df3X.state == state, "is_omicron_wave"] = (
(
df3X.loc[df3X.state == state].date.isin(omicron_date_range)
* df3X.loc[df3X.state == state].date.isin(third_date_range[state])
)
.astype(int)
.values
)
data_by_state = {}
sec_data_by_state = {}
third_data_by_state = {}
for value in ["mean", "std", "local", "imported"]:
data_by_state[value] = pd.pivot(
dfX[["state", value, "date"]],
index="date",
columns="state",
values=value,
).sort_index(axis="columns")
# account for dates pre pre second wave
if df2X.loc[df2X.state == sec_states[0]].shape[0] == 0:
print("making empty")
sec_data_by_state[value] = pd.DataFrame(columns=sec_states).astype(float)
else:
sec_data_by_state[value] = pd.pivot(
df2X[["state", value, "date"]],
index="date",
columns="state",
values=value,
).sort_index(axis="columns")
# account for dates pre pre third wave
if df3X.loc[df3X.state == third_states[0]].shape[0] == 0:
print("making empty")
third_data_by_state[value] = pd.DataFrame(columns=third_states).astype(
float
)
else:
third_data_by_state[value] = pd.pivot(
df3X[["state", value, "date"]],
index="date",
columns="state",
values=value,
).sort_index(axis="columns")
# now add in the summary stats for Omicron Reff
for value in ["mean_omicron", "std_omicron"]:
if df3X.loc[df3X.state == third_states[0]].shape[0] == 0:
print("making empty")
third_data_by_state[value] = pd.DataFrame(columns=third_states).astype(
float
)
else:
third_data_by_state[value] = pd.pivot(
df3X[["state", value, "date"]],
index="date",
columns="state",
values=value,
).sort_index(axis="columns")
# FIRST PHASE
mobility_by_state = []
mobility_std_by_state = []
count_by_state = []
respond_by_state = []
mask_wearing_count_by_state = []
mask_wearing_respond_by_state = []
include_in_first_wave = []
# filtering survey responses to dates before this wave fitting
survey_respond = survey_respond_base.loc[: dfX.date.values[-1]]
survey_counts = survey_counts_base.loc[: dfX.date.values[-1]]
mask_wearing_respond = mask_wearing_respond_base.loc[: dfX.date.values[-1]]
mask_wearing_counts = mask_wearing_counts_base.loc[: dfX.date.values[-1]]
for state in first_states:
mobility_by_state.append(dfX.loc[dfX.state == state, predictors].values / 100)
mobility_std_by_state.append(
dfX.loc[dfX.state == state, [val + "_std" for val in predictors]].values / 100
)
count_by_state.append(survey_counts.loc[start_date:first_end_date, state].values)
respond_by_state.append(survey_respond.loc[start_date:first_end_date, state].values)
mask_wearing_count_by_state.append(
mask_wearing_counts.loc[start_date:first_end_date, state].values
)
mask_wearing_respond_by_state.append(
mask_wearing_respond.loc[start_date:first_end_date, state].values
)
include_in_first_wave.append(
dfX.loc[dfX.state == state, "is_first_wave"].values
)
# SECOND PHASE
sec_mobility_by_state = []
sec_mobility_std_by_state = []
sec_count_by_state = []
sec_respond_by_state = []
sec_mask_wearing_count_by_state = []
sec_mask_wearing_respond_by_state = []
include_in_sec_wave = []
# filtering survey responses to dates before this wave fitting
survey_respond = survey_respond_base.loc[: df2X.date.values[-1]]
survey_counts = survey_counts_base.loc[: df2X.date.values[-1]]
mask_wearing_respond = mask_wearing_respond_base.loc[: df2X.date.values[-1]]
mask_wearing_counts = mask_wearing_counts_base.loc[: df2X.date.values[-1]]
for state in sec_states:
sec_mobility_by_state.append(
df2X.loc[df2X.state == state, predictors].values / 100
)
sec_mobility_std_by_state.append(
df2X.loc[df2X.state == state, [val + "_std" for val in predictors]].values / 100
)
sec_count_by_state.append(
survey_counts.loc[sec_start_date:sec_end_date, state].values
)
sec_respond_by_state.append(
survey_respond.loc[sec_start_date:sec_end_date, state].values
)
sec_mask_wearing_count_by_state.append(
mask_wearing_counts.loc[sec_start_date:sec_end_date, state].values
)
sec_mask_wearing_respond_by_state.append(
mask_wearing_respond.loc[sec_start_date:sec_end_date, state].values
)
include_in_sec_wave.append(df2X.loc[df2X.state == state, "is_sec_wave"].values)
# THIRD WAVE
third_mobility_by_state = []
third_mobility_std_by_state = []
third_count_by_state = []
third_respond_by_state = []
third_mask_wearing_count_by_state = []
third_mask_wearing_respond_by_state = []
include_in_third_wave = []
include_in_omicron_wave = []
# filtering survey responses to dates before this wave fitting
survey_respond = survey_respond_base.loc[: df3X.date.values[-1]]
survey_counts = survey_counts_base.loc[: df3X.date.values[-1]]
mask_wearing_respond = mask_wearing_respond_base.loc[: df3X.date.values[-1]]
mask_wearing_counts = mask_wearing_counts_base.loc[: df3X.date.values[-1]]
for state in third_states:
third_mobility_by_state.append(
df3X.loc[df3X.state == state, predictors].values / 100
)
third_mobility_std_by_state.append(
df3X.loc[df3X.state == state, [val + "_std" for val in predictors]].values / 100
)
third_count_by_state.append(
survey_counts.loc[third_start_date:third_end_date, state].values
)
third_respond_by_state.append(
survey_respond.loc[third_start_date:third_end_date, state].values
)
third_mask_wearing_count_by_state.append(
mask_wearing_counts.loc[third_start_date:third_end_date, state].values
)
third_mask_wearing_respond_by_state.append(
mask_wearing_respond.loc[third_start_date:third_end_date, state].values
)
include_in_third_wave.append(
df3X.loc[df3X.state == state, "is_third_wave"].values
)
include_in_omicron_wave.append(
df3X.loc[df3X.state == state, "is_omicron_wave"].values
)
# policy boolean flag for after travel ban in each wave
policy = dfX.loc[
dfX.state == first_states[0], "post_policy"
] # this is the post ban policy
policy_sec_wave = [1] * df2X.loc[df2X.state == sec_states[0]].shape[0]
policy_third_wave = [1] * df3X.loc[df3X.state == third_states[0]].shape[0]
# read in the vaccination data
delta_vaccination_by_state_array = process_vax_data_array(
data_date=data_date,
third_states=third_states,
third_end_date=third_end_date,
variant="Delta",
print_latest_date_in_ts=True,
)
omicron_vaccination_by_state_array = process_vax_data_array(
data_date=data_date,
third_states=third_states,
third_end_date=third_end_date,
variant="Omicron",
)
# Make state by state arrays
state_index = {state: i + 1 for i, state in enumerate(states_to_fit_all_waves)}
# dates to apply alpha in the second wave (this won't allow for VIC to be added as
# the date_ranges are different)
apply_alpha_sec_wave = (
sec_date_range["NSW"] >= pd.to_datetime(alpha_start_date)
).astype(int)
omicron_start_day = (
pd.to_datetime(omicron_start_date) - pd.to_datetime(third_start_date)
).days
omicron_only_day = (
pd.to_datetime(omicron_only_date) - pd.to_datetime(third_start_date)
).days
heterogeneity_start_day = (
pd.to_datetime("2021-08-20") - pd.to_datetime(third_start_date)
).days
# number of days we fit the average VE over
tau_vax_block_size = 3
# get pop size array
pop_size_array = []
for s in states_to_fit_all_waves:
pop_size_array.append(pop_sizes[s])
p_detect = get_all_p_detect_old(
states=third_states,
end_date=third_end_date,
num_days=df3X.loc[df3X.state == "NSW"].shape[0],
)
df_p_detect = pd.DataFrame(p_detect, columns=third_states)
df_p_detect["date"] = third_date_range["NSW"]
df_p_detect.to_csv("results/CA_" + data_date.strftime("%Y-%m-%d") + ".csv")
# p_detect = get_all_p_detect(
# end_date=third_end_date,
# num_days=df3X.loc[df3X.state == "NSW"].shape[0],
# )
# input data block for stan model
input_data = {
"j_total": len(states_to_fit_all_waves),
"N_first": dfX.loc[dfX.state == first_states[0]].shape[0],
"K": len(predictors),
"j_first": len(first_states),
"Reff": data_by_state["mean"].values,
"mob": mobility_by_state,
"mob_std": mobility_std_by_state,
"sigma2": data_by_state["std"].values ** 2,
"policy": policy.values,
"local": data_by_state["local"].values,
"imported": data_by_state["imported"].values,
"N_sec": df2X.loc[df2X.state == sec_states[0]].shape[0],
"j_sec": len(sec_states),
"Reff_sec": sec_data_by_state["mean"].values,
"mob_sec": sec_mobility_by_state,
"mob_sec_std": sec_mobility_std_by_state,
"sigma2_sec": sec_data_by_state["std"].values ** 2,
"policy_sec": policy_sec_wave,
"local_sec": sec_data_by_state["local"].values,
"imported_sec": sec_data_by_state["imported"].values,
"apply_alpha_sec": apply_alpha_sec_wave,
"N_third": df3X.loc[df3X.state == "NSW"].shape[0],
"j_third": len(third_states),
"Reff_third": third_data_by_state["mean"].values,
"Reff_omicron": third_data_by_state["mean_omicron"].values,
"mob_third": third_mobility_by_state,
"mob_third_std": third_mobility_std_by_state,
"sigma2_third": third_data_by_state["std"].values ** 2,
"sigma2_omicron": third_data_by_state["std_omicron"].values ** 2,
"policy_third": policy_third_wave,
"local_third": third_data_by_state["local"].values,
"imported_third": third_data_by_state["imported"].values,
"count_md": count_by_state,
"respond_md": respond_by_state,
"count_md_sec": sec_count_by_state,
"respond_md_sec": sec_respond_by_state,
"count_md_third": third_count_by_state,
"respond_md_third": third_respond_by_state,
"count_masks": mask_wearing_count_by_state,
"respond_masks": mask_wearing_respond_by_state,
"count_masks_sec": sec_mask_wearing_count_by_state,
"respond_masks_sec": sec_mask_wearing_respond_by_state,
"count_masks_third": third_mask_wearing_count_by_state,
"respond_masks_third": third_mask_wearing_respond_by_state,
"map_to_state_index_first": [state_index[state] for state in first_states],
"map_to_state_index_sec": [state_index[state] for state in sec_states],
"map_to_state_index_third": [state_index[state] for state in third_states],
"total_N_p_sec": sum([sum(x) for x in include_in_sec_wave]).item(),
"total_N_p_third": sum([sum(x) for x in include_in_third_wave]).item(),
"include_in_first": include_in_first_wave,
"include_in_sec": include_in_sec_wave,
"include_in_third": include_in_third_wave,
"pos_starts_sec": np.cumsum([sum(x) for x in include_in_sec_wave]).astype(int).tolist(),
"pos_starts_third": np.cumsum(
[sum(x) for x in include_in_third_wave]
).astype(int).tolist(),
"ve_delta_data": delta_vaccination_by_state_array,
"ve_omicron_data": omicron_vaccination_by_state_array,
"omicron_start_day": omicron_start_day,
"omicron_only_day": omicron_only_day,
"include_in_omicron": include_in_omicron_wave,
"total_N_p_third_omicron": int(sum([sum(x) for x in include_in_omicron_wave]).item()),
"pos_starts_third_omicron": np.cumsum(
[sum(x) for x in include_in_omicron_wave]
).astype(int).tolist(),
'tau_vax_block_size': tau_vax_block_size,
'total_N_p_third_blocks': int(
sum([int(ceil(sum(x)/tau_vax_block_size)) for x in include_in_third_wave])
),
'pos_starts_third_blocks': np.cumsum(
[int(ceil(sum(x)/tau_vax_block_size)) for x in include_in_third_wave]
).astype(int),
'total_N_p_third_omicron_blocks': int(
sum([int(ceil(sum(x)/tau_vax_block_size)) for x in include_in_omicron_wave])
),
'pos_starts_third_omicron_blocks': np.cumsum(
[int(ceil(sum(x)/tau_vax_block_size)) for x in include_in_omicron_wave]
).astype(int),
"pop_size_array": pop_size_array,
"heterogeneity_start_day": heterogeneity_start_day,
"p_detect": p_detect,
}
# dump the dictionary to a json file
with open("results/stan_input_data.pkl", "wb") as f:
pickle.dump(input_data, f)
return None
def run_stan(
data_date,
num_chains=4,
num_samples=1000,
num_warmup_samples=500,
max_treedepth=12,
):
"""
Read the input_data.json in and run the stan model.
"""
data_date = pd.to_datetime(data_date)
# read in the input data as a dictionary
with open("results/stan_input_data.pkl", "rb") as f:
input_data = pickle.load(f)
# make results and figs dir
figs_dir = (
"figs/stan_fit/stan_fit_"
+ data_date.strftime("%Y-%m-%d")
+ "/"
)
results_dir = (
"results/"
+ data_date.strftime("%Y-%m-%d")
+ "/"
)
os.makedirs(figs_dir, exist_ok=True)
os.makedirs(results_dir, exist_ok=True)
# path to the stan model
# basic model with a switchover between Reffs
# rho_model_gamma = "TP_model/fit_and_forecast/stan_models/TP_switchover.stan"
# mixture model with basic susceptible depletion
# rho_model_gamma = "TP_model/fit_and_forecast/stan_models/TP_gamma_mix.stan"
# model that has a switchover but incorporates a waning in infection acquired immunity
rho_model_gamma = "TP_model/fit_and_forecast/stan_models/TP_switchover_waning_infection.stan"
# model that incorporates a waning in infection acquired immunity but is coded as a mixture
# rho_model_gamma = "TP_model/fit_and_forecast/stan_models/TP_gamma_mix_waning_infection.stan"
# model that has a switchover but incorporates a waning in infection acquired immunity
# rho_model_gamma = "TP_model/fit_and_forecast/stan_models/TP_switchover_waning_infection_single_md.stan"
# compile the stan model
model = CmdStanModel(stan_file=rho_model_gamma)
# obtain a posterior sample from the model conditioned on the data
fit = model.sample(
chains=num_chains,
iter_warmup=num_warmup_samples,
iter_sampling=num_samples,
data=input_data,
max_treedepth=max_treedepth,
refresh=10
)
# display convergence diagnostics for the current run
print("===========")
print(fit.diagnose())
print("===========")
# save output file to
fit.save_csvfiles(dir=results_dir)
df_fit = fit.draws_pd()
df_fit.to_csv(
results_dir
+ "posterior_sample_"
+ data_date.strftime("%Y-%m-%d")
+ ".csv"
)
# output a set of diagnostics
filename = (
figs_dir
+ "fit_summary_all_parameters"
+ data_date.strftime("%Y-%m-%d")
+ ".csv"
)
# save a summary file for all parameters; this involves ESS and ESS/s as well as summary stats
fit_summary = fit.summary()
fit_summary.to_csv(filename)
# now save a small summary to easily view key parameters
pars_of_interest = ["bet[" + str(i + 1) + "]" for i in range(5)]
pars_of_interest = pars_of_interest + ["R_Li[" + str(i + 1) + "]" for i in range(8)]
pars_of_interest = pars_of_interest + [
"R_I",
"R_L",
"theta_md",
"theta_masks",
"sig",
"voc_effect_alpha",
"voc_effect_delta",
"voc_effect_omicron",
]
pars_of_interest = pars_of_interest + [
col for col in df_fit if "phi" in col and "simplex" not in col
]
# save a summary for ease of viewing
# output a set of diagnostics
filename = (
figs_dir
+ "fit_summary_main_parameters"
+ data_date.strftime("%Y-%m-%d")
+ ".csv"
)
fit_summary.loc[pars_of_interest].to_csv(filename)
return None
def plot_and_save_posterior_samples(data_date):
"""
Runs the full suite of plotting.
"""
data_date = pd.to_datetime(data_date) # Define data date
figs_dir = (
"figs/stan_fit/stan_fit_"
+ data_date.strftime("%Y-%m-%d")
+ "/"
)
# read in the posterior sample
samples_mov_gamma = pd.read_csv(
"results/"
+ data_date.strftime("%Y-%m-%d")
+ "/posterior_sample_"
+ data_date.strftime("%Y-%m-%d")
+ ".csv"
)
# * Note: 2020-09-09 won't work (for some reason)
######### Read in microdistancing (md) surveys #########
surveys = pd.DataFrame()
path = "data/md/Barometer wave*.csv"
for file in glob.glob(path):
surveys = surveys.append(pd.read_csv(file, parse_dates=["date"]))
surveys = surveys.sort_values(by="date")
print("Latest Microdistancing survey is {}".format(surveys.date.values[-1]))
surveys["state"] = surveys["state"].map(states_initials).fillna(surveys["state"])
surveys["proportion"] = surveys["count"] / surveys.respondents
surveys.date = pd.to_datetime(surveys.date)
always = surveys.loc[surveys.response == "Always"].set_index(["state", "date"])
always = always.unstack(["state"])
# If you get an error here saying 'cannot create a new series when the index is not unique',
# then you have a duplicated md file.
idx = pd.date_range("2020-03-01", pd.to_datetime("today"))
always = always.reindex(idx, fill_value=np.nan)
always.index.name = "date"
# fill back to earlier and between weeks.
# Assume survey on day x applies for all days up to x - 6
always = always.fillna(method="bfill")
# assume values continue forward if survey hasn't completed
always = always.fillna(method="ffill")
always = always.stack(["state"])
# Zero out before first survey 20th March
always = always.reset_index().set_index("date")
always.loc[:"2020-03-20", "count"] = 0
always.loc[:"2020-03-20", "respondents"] = 0
always.loc[:"2020-03-20", "proportion"] = 0
always = always.reset_index().set_index(["state", "date"])
survey_X = pd.pivot_table(
data=always, index="date", columns="state", values="proportion"
)
survey_counts_base = (
pd.pivot_table(data=always, index="date", columns="state", values="count")
.drop(["Australia", "Other"], axis=1)
.astype(int)
)
survey_respond_base = (
pd.pivot_table(data=always, index="date", columns="state", values="respondents")
.drop(["Australia", "Other"], axis=1)
.astype(int)
)
## read in and process mask wearing data
mask_wearing = pd.DataFrame()
path = "data/face_coverings/face_covering_*_.csv"
for file in glob.glob(path):
mask_wearing = mask_wearing.append(pd.read_csv(file, parse_dates=["date"]))
mask_wearing = mask_wearing.sort_values(by="date")
print("Latest Mask wearing survey is {}".format(mask_wearing.date.values[-1]))
mask_wearing["state"] = (
mask_wearing["state"].map(states_initials).fillna(mask_wearing["state"])
)
mask_wearing["proportion"] = mask_wearing["count"] / mask_wearing.respondents
mask_wearing.date = pd.to_datetime(mask_wearing.date)
mask_wearing_always = mask_wearing.loc[
mask_wearing.face_covering == "Always"
].set_index(["state", "date"])
mask_wearing_always = mask_wearing_always.unstack(["state"])
idx = pd.date_range("2020-03-01", pd.to_datetime("today"))
mask_wearing_always = mask_wearing_always.reindex(idx, fill_value=np.nan)
mask_wearing_always.index.name = "date"
# fill back to earlier and between weeks.
# Assume survey on day x applies for all days up to x - 6
mask_wearing_always = mask_wearing_always.fillna(method="bfill")
# assume values continue forward if survey hasn't completed
mask_wearing_always = mask_wearing_always.fillna(method="ffill")
mask_wearing_always = mask_wearing_always.stack(["state"])
# Zero out before first survey 20th March
mask_wearing_always = mask_wearing_always.reset_index().set_index("date")
mask_wearing_always.loc[:"2020-03-20", "count"] = 0
mask_wearing_always.loc[:"2020-03-20", "respondents"] = 0
mask_wearing_always.loc[:"2020-03-20", "proportion"] = 0
mask_wearing_X = pd.pivot_table(
data=mask_wearing_always, index="date", columns="state", values="proportion"
)
mask_wearing_counts_base = pd.pivot_table(
data=mask_wearing_always, index="date", columns="state", values="count"
).astype(int)
mask_wearing_respond_base = pd.pivot_table(
data=mask_wearing_always, index="date", columns="state", values="respondents"
).astype(int)
df_Reff = pd.read_csv(
"results/EpyReff/Reff_delta" + data_date.strftime("%Y-%m-%d") + "tau_4.csv",
parse_dates=["INFECTION_DATES"],
)
df_Reff["date"] = df_Reff.INFECTION_DATES
df_Reff["state"] = df_Reff.STATE
df_Reff_omicron = pd.read_csv(
"results/EpyReff/Reff_omicron" + data_date.strftime("%Y-%m-%d") + "tau_4.csv",
parse_dates=["INFECTION_DATES"],
)
df_Reff_omicron["date"] = df_Reff_omicron.INFECTION_DATES
df_Reff_omicron["state"] = df_Reff_omicron.STATE
# relabel some of the columns to avoid replication in the merged dataframe
col_names_replace = {
"mean": "mean_omicron",
"lower": "lower_omicron",
"upper": "upper_omicron",
"top": "top_omicron",
"bottom": "bottom_omicron",
"std": "std_omicron",
}
df_Reff_omicron.rename(col_names_replace, axis=1, inplace=True)
# read in NNDSS/linelist data
# If this errors it may be missing a leading zero on the date.
df_state = read_in_cases(
case_file_date=data_date.strftime("%d%b%Y"),
apply_delay_at_read=True,
apply_inc_at_read=True,
)
df_Reff = df_Reff.merge(
df_state,
how="left",
left_on=["state", "date"],
right_on=["STATE", "date_inferred"],
) # how = left to use Reff days, NNDSS missing dates
# merge in the omicron stuff
df_Reff = df_Reff.merge(
df_Reff_omicron,
how="left",
left_on=["state", "date"],
right_on=["state", "date"],
)
df_Reff["rho_moving"] = df_Reff.groupby(["state"])["rho"].transform(
lambda x: x.rolling(7, 1).mean()
) # minimum number of 1
# some days have no cases, so need to fillna
df_Reff["rho_moving"] = df_Reff.rho_moving.fillna(method="bfill")
# counts are already aligned with infection date by subtracting a random incubation period
df_Reff["local"] = df_Reff.local.fillna(0)
df_Reff["imported"] = df_Reff.imported.fillna(0)
######### Read in Google mobility results #########
sys.path.insert(0, "../")
df_google = read_in_google(moving=True)
df = df_google.merge(
df_Reff[
[
"date",
"state",
"mean",
"lower",
"upper",
"top",
"bottom",
"std",
"mean_omicron",
"lower_omicron",
"upper_omicron",
"top_omicron",
"bottom_omicron",
"std_omicron",
"rho",
"rho_moving",
"local",
"imported",
]
],
on=["date", "state"],
how="inner",
)
# ACT and NT not in original estimates, need to extrapolated sorting keeps consistent
# with sort in data_by_state
# Note that as we now consider the third wave for ACT, we include it in the third
# wave fitting only!
states_to_fit_all_waves = sorted(
["NSW", "VIC", "QLD", "SA", "WA", "TAS", "ACT", "NT"]
)
first_states = sorted(["NSW", "VIC", "QLD", "SA", "WA", "TAS"])
fit_post_March = True
ban = "2020-03-20"
first_end_date = "2020-03-31"
# data for the first wave
first_date_range = {
"NSW": pd.date_range(start="2020-03-01", end=first_end_date).values,
"QLD": pd.date_range(start="2020-03-01", end=first_end_date).values,
"SA": pd.date_range(start="2020-03-01", end=first_end_date).values,
"TAS": pd.date_range(start="2020-03-01", end=first_end_date).values,
"VIC": pd.date_range(start="2020-03-01", end=first_end_date).values,
"WA": pd.date_range(start="2020-03-01", end=first_end_date).values,
}
# Second wave inputs
sec_states = sorted([
'NSW',
# 'VIC',
])
sec_start_date = "2020-06-01"
sec_end_date = "2021-01-19"
# choose dates for each state for sec wave
sec_date_range = {
"NSW": pd.date_range(start="2020-06-01", end="2021-01-19").values,
# "VIC": pd.date_range(start="2020-06-01", end="2020-10-28").values,
}
# Third wave inputs
third_states = sorted([
"NSW",
"VIC",
"ACT",
"QLD",
"SA",
"TAS",
# "NT",
"WA",
])
# Subtract the truncation days to avoid right truncation as we consider infection dates
# and not symptom onset dates
third_end_date = data_date - pd.Timedelta(days=truncation_days)
# choose dates for each state for third wave
# Note that as we now consider the third wave for ACT, we include it in
# the third wave fitting only!
third_date_range = {
"ACT": pd.date_range(start="2021-08-15", end=third_end_date).values,
"NSW": pd.date_range(start="2021-06-25", end=third_end_date).values,
# "NT": pd.date_range(start="2021-12-20", end=third_end_date).values,
"QLD": pd.date_range(start="2021-07-30", end=third_end_date).values,
"SA": pd.date_range(start="2021-12-10", end=third_end_date).values,
"TAS": pd.date_range(start="2021-12-20", end=third_end_date).values,
"VIC": pd.date_range(start="2021-07-10", end=third_end_date).values,
"WA": pd.date_range(start="2022-01-01", end=third_end_date).values,
}
fit_mask = df.state.isin(first_states)
if fit_post_March:
fit_mask = (fit_mask) & (df.date >= start_date)
fit_mask = (fit_mask) & (df.date <= first_end_date)
second_wave_mask = df.state.isin(sec_states)
second_wave_mask = (second_wave_mask) & (df.date >= sec_start_date)
second_wave_mask = (second_wave_mask) & (df.date <= sec_end_date)
# Add third wave stuff here
third_wave_mask = df.state.isin(third_states)
third_wave_mask = (third_wave_mask) & (df.date >= third_start_date)
third_wave_mask = (third_wave_mask) & (df.date <= third_end_date)
predictors = mov_values.copy()
# predictors.extend(['driving_7days','transit_7days','walking_7days','pc'])
# remove residential to see if it improves fit
# predictors.remove("residential_7days")
df["post_policy"] = (df.date >= ban).astype(int)
dfX = df.loc[fit_mask].sort_values("date")
df2X = df.loc[second_wave_mask].sort_values("date")
df3X = df.loc[third_wave_mask].sort_values("date")
dfX["is_first_wave"] = 0
for state in first_states:
dfX.loc[dfX.state == state, "is_first_wave"] = (
dfX.loc[dfX.state == state]
.date.isin(first_date_range[state])
.astype(int)
.values
)
df2X["is_sec_wave"] = 0
for state in sec_states:
df2X.loc[df2X.state == state, "is_sec_wave"] = (
df2X.loc[df2X.state == state]
.date.isin(sec_date_range[state])
.astype(int)
.values
)
# used to index what dates are also featured in omicron
omicron_date_range = pd.date_range(start=omicron_start_date, end=third_end_date)
df3X["is_third_wave"] = 0
for state in third_states:
df3X.loc[df3X.state == state, "is_third_wave"] = (
df3X.loc[df3X.state == state]
.date.isin(third_date_range[state])
.astype(int)
.values
)
# condition on being in third wave AND omicron
df3X.loc[df3X.state == state, "is_omicron_wave"] = (
(
df3X.loc[df3X.state == state].date.isin(omicron_date_range)
* df3X.loc[df3X.state == state].date.isin(third_date_range[state])
)
.astype(int)
.values
)
data_by_state = {}
sec_data_by_state = {}
third_data_by_state = {}
for value in ["mean", "std", "local", "imported"]:
data_by_state[value] = pd.pivot(
dfX[["state", value, "date"]], index="date", columns="state", values=value
).sort_index(axis="columns")
# account for dates pre pre second wave
if df2X.loc[df2X.state == sec_states[0]].shape[0] == 0:
print("making empty")
sec_data_by_state[value] = pd.DataFrame(columns=sec_states).astype(float)
else:
sec_data_by_state[value] = pd.pivot(
df2X[["state", value, "date"]],
index="date",
columns="state",
values=value,
).sort_index(axis="columns")
# account for dates pre pre third wave
if df3X.loc[df3X.state == third_states[0]].shape[0] == 0:
print("making empty")
third_data_by_state[value] = pd.DataFrame(columns=third_states).astype(
float
)
else:
third_data_by_state[value] = pd.pivot(
df3X[["state", value, "date"]],
index="date",
columns="state",
values=value,
).sort_index(axis="columns")
# now add in the summary stats for Omicron Reff
for value in ["mean_omicron", "std_omicron"]:
if df3X.loc[df3X.state == third_states[0]].shape[0] == 0:
print("making empty")
third_data_by_state[value] = pd.DataFrame(columns=third_states).astype(
float
)
else:
third_data_by_state[value] = pd.pivot(
df3X[["state", value, "date"]],
index="date",
columns="state",
values=value,
).sort_index(axis="columns")
# FIRST PHASE
mobility_by_state = []
mobility_std_by_state = []
count_by_state = []
respond_by_state = []
mask_wearing_count_by_state = []
mask_wearing_respond_by_state = []
include_in_first_wave = []
# filtering survey responses to dates before this wave fitting
survey_respond = survey_respond_base.loc[: dfX.date.values[-1]]
survey_counts = survey_counts_base.loc[: dfX.date.values[-1]]
mask_wearing_respond = mask_wearing_respond_base.loc[: dfX.date.values[-1]]
mask_wearing_counts = mask_wearing_counts_base.loc[: dfX.date.values[-1]]
for state in first_states:
mobility_by_state.append(dfX.loc[dfX.state == state, predictors].values / 100)
mobility_std_by_state.append(
dfX.loc[dfX.state == state, [val + "_std" for val in predictors]].values
/ 100
)
count_by_state.append(survey_counts.loc[start_date:first_end_date, state].values)
respond_by_state.append(survey_respond.loc[start_date:first_end_date, state].values)
mask_wearing_count_by_state.append(
mask_wearing_counts.loc[start_date:first_end_date, state].values
)
mask_wearing_respond_by_state.append(
mask_wearing_respond.loc[start_date:first_end_date, state].values
)
include_in_first_wave.append(
dfX.loc[dfX.state == state, "is_first_wave"].values
)
# SECOND PHASE
sec_mobility_by_state = []
sec_mobility_std_by_state = []
sec_count_by_state = []
sec_respond_by_state = []
sec_mask_wearing_count_by_state = []
sec_mask_wearing_respond_by_state = []
include_in_sec_wave = []
# filtering survey responses to dates before this wave fitting
survey_respond = survey_respond_base.loc[: df2X.date.values[-1]]
survey_counts = survey_counts_base.loc[: df2X.date.values[-1]]
mask_wearing_respond = mask_wearing_respond_base.loc[: df2X.date.values[-1]]
mask_wearing_counts = mask_wearing_counts_base.loc[: df2X.date.values[-1]]
for state in sec_states:
sec_mobility_by_state.append(
df2X.loc[df2X.state == state, predictors].values / 100
)
sec_mobility_std_by_state.append(
df2X.loc[df2X.state == state, [val + "_std" for val in predictors]].values
/ 100
)
sec_count_by_state.append(
survey_counts.loc[sec_start_date:sec_end_date, state].values
)
sec_respond_by_state.append(
survey_respond.loc[sec_start_date:sec_end_date, state].values
)
sec_mask_wearing_count_by_state.append(
mask_wearing_counts.loc[sec_start_date:sec_end_date, state].values
)
sec_mask_wearing_respond_by_state.append(
mask_wearing_respond.loc[sec_start_date:sec_end_date, state].values
)
include_in_sec_wave.append(df2X.loc[df2X.state == state, "is_sec_wave"].values)
# THIRD WAVE
third_mobility_by_state = []
third_mobility_std_by_state = []
third_count_by_state = []
third_respond_by_state = []
third_mask_wearing_count_by_state = []
third_mask_wearing_respond_by_state = []
include_in_third_wave = []
include_in_omicron_wave = []
# filtering survey responses to dates before this wave fitting
survey_respond = survey_respond_base.loc[: df3X.date.values[-1]]
survey_counts = survey_counts_base.loc[: df3X.date.values[-1]]
mask_wearing_respond = mask_wearing_respond_base.loc[: df3X.date.values[-1]]
mask_wearing_counts = mask_wearing_counts_base.loc[: df3X.date.values[-1]]
for state in third_states:
third_mobility_by_state.append(
df3X.loc[df3X.state == state, predictors].values / 100
)
third_mobility_std_by_state.append(
df3X.loc[df3X.state == state, [val + "_std" for val in predictors]].values
/ 100
)
third_count_by_state.append(
survey_counts.loc[third_start_date:third_end_date, state].values
)
third_respond_by_state.append(
survey_respond.loc[third_start_date:third_end_date, state].values
)
third_mask_wearing_count_by_state.append(
mask_wearing_counts.loc[third_start_date:third_end_date, state].values
)
third_mask_wearing_respond_by_state.append(
mask_wearing_respond.loc[third_start_date:third_end_date, state].values
)
include_in_third_wave.append(
df3X.loc[df3X.state == state, "is_third_wave"].values
)
include_in_omicron_wave.append(
df3X.loc[df3X.state == state, "is_omicron_wave"].values
)
# Make state by state arrays
state_index = {state: i for i, state in enumerate(states_to_fit_all_waves)}
# get pop size array
pop_size_array = []
for s in states_to_fit_all_waves:
pop_size_array.append(pop_sizes[s])
# First phase
# rho calculated at data entry
if isinstance(df_state.index, pd.MultiIndex):
df_state = df_state.reset_index()
states = sorted(["NSW", "QLD", "VIC", "TAS", "SA", "WA", "ACT", "NT"])
fig, ax = plt.subplots(figsize=(24, 9), ncols=len(states), sharey=True)
states_to_fitd = {state: i + 1 for i, state in enumerate(first_states)}
for i, state in enumerate(states):
if state in first_states:
dates = df_Reff.loc[
(df_Reff.date >= start_date)
& (df_Reff.state == state)
& (df_Reff.date <= first_end_date)
].date
rho_samples = samples_mov_gamma[
[
"brho[" + str(j + 1) + "," + str(states_to_fitd[state]) + "]"
for j in range(dfX.loc[dfX.state == first_states[0]].shape[0])
]
]
ax[i].plot(dates, rho_samples.median(), label="fit", color="C0")
ax[i].fill_between(
dates,
rho_samples.quantile(0.25),
rho_samples.quantile(0.75),
color="C0",
alpha=0.4,
)
ax[i].fill_between(
dates,
rho_samples.quantile(0.05),
rho_samples.quantile(0.95),
color="C0",
alpha=0.4,
)
else:
sns.lineplot(
x="date_inferred",
y="rho",
data=df_state.loc[
(df_state.date_inferred >= start_date)
& (df_state.STATE == state)
& (df_state.date_inferred <= first_end_date)
],
ax=ax[i],
color="C1",
label="data",
)
sns.lineplot(
x="date",
y="rho",
data=df_Reff.loc[
(df_Reff.date >= start_date)
& (df_Reff.state == state)
& (df_Reff.date <= first_end_date)
],
ax=ax[i],
color="C1",
label="data",
)
sns.lineplot(
x="date",
y="rho_moving",
data=df_Reff.loc[
(df_Reff.date >= start_date)
& (df_Reff.state == state)
& (df_Reff.date <= first_end_date)
],
ax=ax[i],
color="C2",
label="moving",
)
dates = dfX.loc[dfX.state == first_states[0]].date
ax[i].tick_params("x", rotation=90)
ax[i].xaxis.set_major_locator(plt.MaxNLocator(4))
ax[i].set_title(state)
ax[0].set_ylabel("Proportion of imported cases")
plt.legend()
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + "rho_first_phase.png", dpi=144
)
# Second phase
if df2X.shape[0] > 0:
fig, ax = plt.subplots(
figsize=(24, 9), ncols=len(sec_states), sharey=True, squeeze=False
)
states_to_fitd = {state: i + 1 for i, state in enumerate(sec_states)}
pos = 0
for i, state in enumerate(sec_states):
# Google mobility only up to a certain date, so take only up to that value
dates = df2X.loc[
(df2X.state == state) & (df2X.is_sec_wave == 1)
].date.values
rho_samples = samples_mov_gamma[
[
"brho_sec[" + str(j + 1) + "]"
for j in range(
pos, pos + df2X.loc[df2X.state == state].is_sec_wave.sum()
)
]
]
pos = pos + df2X.loc[df2X.state == state].is_sec_wave.sum()
ax[0, i].plot(dates, rho_samples.median(), label="fit", color="C0")
ax[0, i].fill_between(
dates,
rho_samples.quantile(0.25),
rho_samples.quantile(0.75),
color="C0",
alpha=0.4,
)
ax[0, i].fill_between(
dates,
rho_samples.quantile(0.05),
rho_samples.quantile(0.95),
color="C0",
alpha=0.4,
)
sns.lineplot(
x="date_inferred",
y="rho",
data=df_state.loc[
(df_state.date_inferred >= sec_start_date)
& (df_state.STATE == state)
& (df_state.date_inferred <= sec_end_date)
],
ax=ax[0, i],
color="C1",
label="data",
)
sns.lineplot(
x="date",
y="rho",
data=df_Reff.loc[
(df_Reff.date >= sec_start_date)
& (df_Reff.state == state)
& (df_Reff.date <= sec_end_date)
],
ax=ax[0, i],
color="C1",
label="data",
)
sns.lineplot(
x="date",
y="rho_moving",
data=df_Reff.loc[
(df_Reff.date >= sec_start_date)
& (df_Reff.state == state)
& (df_Reff.date <= sec_end_date)
],
ax=ax[0, i],
color="C2",
label="moving",
)
dates = dfX.loc[dfX.state == sec_states[0]].date
ax[0, i].tick_params("x", rotation=90)
ax[0, i].xaxis.set_major_locator(plt.MaxNLocator(4))
ax[0, i].set_title(state)
ax[0, 0].set_ylabel("Proportion of imported cases")
plt.legend()
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + "rho_sec_phase.png", dpi=144
)
df_rho_third_all_states = pd.DataFrame()
df_rho_third_tmp = pd.DataFrame()
# Third phase
if df3X.shape[0] > 0:
fig, ax = plt.subplots(
figsize=(9, 24), nrows=len(third_states), sharex=True, squeeze=False
)
states_to_fitd = {state: i + 1 for i, state in enumerate(third_states)}
pos = 0
for i, state in enumerate(third_states):
# Google mobility only up to a certain date, so take only up to that value
dates = df3X.loc[
(df3X.state == state) & (df3X.is_third_wave == 1)
].date.values
rho_samples = samples_mov_gamma[
[
"brho_third[" + str(j + 1) + "]"
for j in range(
pos, pos + df3X.loc[df3X.state == state].is_third_wave.sum()
)
]
]
pos = pos + df3X.loc[df3X.state == state].is_third_wave.sum()
df_rho_third_tmp = rho_samples.T
df_rho_third_tmp["date"] = dates
df_rho_third_tmp["state"] = state
df_rho_third_all_states = pd.concat([df_rho_third_all_states, df_rho_third_tmp])
ax[i, 0].plot(dates, rho_samples.median(), label="fit", color="C0")
ax[i, 0].fill_between(
dates,
rho_samples.quantile(0.25),
rho_samples.quantile(0.75),
color="C0",
alpha=0.4,
)
ax[i, 0].fill_between(
dates,
rho_samples.quantile(0.05),
rho_samples.quantile(0.95),
color="C0",
alpha=0.4,
)
sns.lineplot(
x="date_inferred",
y="rho",
data=df_state.loc[
(df_state.date_inferred >= third_start_date)
& (df_state.STATE == state)
& (df_state.date_inferred <= third_end_date)
],
ax=ax[i, 0],
color="C1",
label="data",
)
sns.lineplot(
x="date",
y="rho",
data=df_Reff.loc[
(df_Reff.date >= third_start_date)
& (df_Reff.state == state)
& (df_Reff.date <= third_end_date)
],
ax=ax[i, 0],
color="C1",
label="data",
)
sns.lineplot(
x="date",
y="rho_moving",
data=df_Reff.loc[
(df_Reff.date >= third_start_date)
& (df_Reff.state == state)
& (df_Reff.date <= third_end_date)
],
ax=ax[i, 0],
color="C2",
label="moving",
)
dates = dfX.loc[dfX.state == third_states[0]].date
ax[i, 0].tick_params("x", rotation=90)
ax[i, 0].xaxis.set_major_locator(plt.MaxNLocator(4))
ax[i, 0].set_title(state)
ax[i, 0].set_ylabel("Proportion of imported cases")
plt.legend()
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + "rho_third_phase.png", dpi=144,
)
df_rho_third_all_states.to_csv(
"results/"
+ data_date.strftime("%Y-%m-%d")
+ "/rho_samples"
+ data_date.strftime("%Y-%m-%d")
+ ".csv"
)
# plotting
fig, ax = plt.subplots(figsize=(12, 9))
# sample from the priors for RL and RI
samples_mov_gamma["R_L_prior"] = np.random.gamma(
1.8 * 1.8 / 0.05, 0.05 / 1.8, size=samples_mov_gamma.shape[0]
)
samples_mov_gamma["R_I_prior"] = np.random.gamma(
0.5 ** 2 / 0.2, 0.2 / 0.5, size=samples_mov_gamma.shape[0]
)
samples_mov_gamma["R_L_national"] = np.random.gamma(
samples_mov_gamma.R_L.values ** 2 / samples_mov_gamma.sig.values,
samples_mov_gamma.sig.values / samples_mov_gamma.R_L.values,
)
sns.violinplot(
x="variable",
y="value",
data=pd.melt(
samples_mov_gamma[[
col for col in samples_mov_gamma
if "R" in col and col not in ("R_I0", "R_I0_omicron")
]]
),
ax=ax,
cut=0,
)
ax.set_yticks(
[1],
minor=True,
)
ax.set_yticks([0, 2, 3], minor=False)
ax.set_yticklabels([0, 2, 3], minor=False)
ax.set_ylim((0, 3))
# state labels in alphabetical
ax.set_xticklabels(
[
"R_I",
"R_I_omicron",
"R_L0 mean",
"R_L0 ACT",
"R_L0 NSW",
"R_L0 NT",
"R_L0 QLD",
"R_L0 SA",
"R_L0 TAS",
"R_L0 VIC",
"R_L0 WA",
"R_L0 prior",
"R_I prior",
"R_L0 national",
]
)
ax.set_xlabel("")
ax.set_ylabel("Effective reproduction number")
ax.tick_params("x", rotation=90)
ax.yaxis.grid(which="minor", linestyle="--", color="black", linewidth=2)
plt.tight_layout()
plt.savefig(figs_dir + data_date.strftime("%Y-%m-%d") + "R_priors.png", dpi=144)
# Making a new figure that doesn't include the priors
fig, ax = plt.subplots(figsize=(12, 9))
small_plot_cols = ["R_Li[" + str(i) + "]" for i in range(1, 9)] + ["R_I"]
sns.violinplot(
x="variable",
y="value",
data=pd.melt(samples_mov_gamma[small_plot_cols]),
ax=ax,
cut=0,
)
ax.set_yticks(
[1],
minor=True,
)
ax.set_yticks([0, 2, 3], minor=False)
ax.set_yticklabels([0, 2, 3], minor=False)
ax.set_ylim((0, 3))
# state labels in alphabetical
ax.set_xticklabels(
[
"$R_L0$ ACT",
"$R_L0$ NSW",
"$R_L0$ NT",
"$R_L0$ QLD",
"$R_L0$ SA",
"$R_L0$ TAS",
"$R_L0$ VIC",
"$R_L0$ WA",
"$R_I$",
]
)
ax.tick_params("x", rotation=90)
ax.set_xlabel("")
ax.set_ylabel("Effective reproduction number")
ax.yaxis.grid(which="minor", linestyle="--", color="black", linewidth=2)
plt.tight_layout()
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + "R_priors_(without_priors).png",
dpi=288,
)
# Making a new figure that doesn't include the priors
fig, ax = plt.subplots(figsize=(12, 9))
samples_mov_gamma["voc_effect_third_prior"] = np.random.gamma(
1.5 * 1.5 / 0.05, 0.05 / 1.5, size=samples_mov_gamma.shape[0]
)
small_plot_cols = [
"voc_effect_third_prior",
"voc_effect_delta",
"voc_effect_omicron",
]
sns.violinplot(
x="variable",
y="value",
data=pd.melt(samples_mov_gamma[small_plot_cols]),
ax=ax,
cut=0,
)
ax.set_yticks([1], minor=True)
# ax.set_yticks([0, 0.5, 1, 1.5, 2, 2.5, 3], minor=False)
# ax.set_yticklabels([0, 0.5, 1, 1.5, 2, 2.5, 3], minor=False)
# ax.set_ylim((0, 1))
# state labels in alphabetical
ax.set_xticklabels(["VoC (prior)", "VoC (Delta)", "VoC (Omicron)"])
# ax.tick_params('x', rotation=90)
ax.set_xlabel("")
ax.set_ylabel("value")
ax.yaxis.grid(which="minor", linestyle="--", color="black", linewidth=2)
plt.tight_layout()
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + "voc_effect_posteriors.png",
dpi=288,
)
posterior = samples_mov_gamma[["bet[" + str(i + 1) + "]" for i in range(len(predictors))]]
split = True
md = "power" # samples_mov_gamma.md.values
posterior.columns = [val for val in predictors]
long = pd.melt(posterior)
fig, ax2 = plt.subplots(figsize=(12, 9))
ax2 = sns.violinplot(x="variable", y="value", data=long, ax=ax2, color="C0")
ax2.plot([0] * len(predictors), linestyle="dashed", alpha=0.6, color="grey")
ax2.tick_params(axis="x", rotation=90)
ax2.set_title("Coefficients of mobility indices")
ax2.set_xlabel("Social mobility index")
ax2.set_xticklabels([var[:-6] for var in predictors])
ax2.set_xticklabels(
[
"Retail and Recreation",
"Grocery and Pharmacy",
"Parks",
"Transit Stations",
"Workplaces",
"Residential",
]
)
ax2.tick_params("x", rotation=15)
plt.tight_layout()
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + "mobility_posteriors.png",
dpi=288,
)
# plot the TP's
RL_by_state = {
state: samples_mov_gamma["R_Li[" + str(i + 1) + "]"].values
for state, i in state_index.items()
}
ax3 = predict_plot(
samples_mov_gamma,
df.loc[(df.date >= start_date) & (df.date <= first_end_date)],
moving=True,
grocery=True,
rho=first_states,
)
for ax in ax3:
for a in ax:
a.set_ylim((0, 2.5))
a.set_xlim((pd.to_datetime(start_date), pd.to_datetime(first_end_date)))
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + "Reff_first_phase.png",
dpi=144,
)
if df2X.shape[0] > 0:
df["is_sec_wave"] = 0
for state in sec_states:
df.loc[df.state == state, "is_sec_wave"] = (
df.loc[df.state == state]
.date.isin(sec_date_range[state])
.astype(int)
.values
)
# plot only if there is second phase data - have to have second_phase=True
ax4 = predict_plot(
samples_mov_gamma,
df.loc[(df.date >= sec_start_date) & (df.date <= sec_end_date)],
moving=True,
grocery=True,
rho=sec_states,
second_phase=True,
)
for ax in ax4:
for a in ax:
a.set_ylim((0, 2.5))
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + "Reff_sec_phase.png", dpi=144
)
# remove plots from memory
fig.clear()
plt.close(fig)
# Load in vaccination data by state and date
vaccination_by_state = pd.read_csv(
"data/vaccine_effect_timeseries_" + data_date.strftime("%Y-%m-%d") + ".csv",
parse_dates=["date"],
)
# there are a couple NA's early on in the time series but is likely due to slightly
# different start dates
vaccination_by_state.fillna(1, inplace=True)
# we take the whole set of estimates up to the end of the forecast period
# (with 10 days padding which won't be used in the forecast)
vaccination_by_state = vaccination_by_state[
(
vaccination_by_state.date
>= pd.to_datetime(third_start_date) - timedelta(days=1)
)
& (
vaccination_by_state.date
<= pd.to_datetime(data_date) + timedelta(days=num_forecast_days + 10)
)
]
vaccination_by_state_delta = vaccination_by_state.loc[
vaccination_by_state["variant"] == "Delta"
][["state", "date", "effect"]]
vaccination_by_state_omicron = vaccination_by_state.loc[
vaccination_by_state["variant"] == "Omicron"
][["state", "date", "effect"]]
vaccination_by_state_delta = vaccination_by_state_delta.pivot(
index="state", columns="date", values="effect"
) # Convert to matrix form
vaccination_by_state_omicron = vaccination_by_state_omicron.pivot(
index="state", columns="date", values="effect"
) # Convert to matrix form
# If we are missing recent vaccination data, fill it in with the most recent available data.
latest_vacc_data = vaccination_by_state_omicron.columns[-1]
if latest_vacc_data < pd.to_datetime(third_end_date):
vaccination_by_state_delta = pd.concat(
[vaccination_by_state_delta]
+ [
pd.Series(vaccination_by_state_delta[latest_vacc_data], name=day)
for day in pd.date_range(start=latest_vacc_data, end=third_end_date)
],
axis=1,
)
vaccination_by_state_omicron = pd.concat(
[vaccination_by_state_omicron]
+ [
pd.Series(vaccination_by_state_omicron[latest_vacc_data], name=day)
for day in pd.date_range(start=latest_vacc_data, end=third_end_date)
],
axis=1,
)
# get the dates for vaccination
dates = vaccination_by_state_delta.columns
third_days = {k: v.shape[0] for (k, v) in third_date_range.items()}
third_days_cumulative = np.append([0], np.cumsum([v for v in third_days.values()]))
delta_ve_idx_ranges = {
k: range(third_days_cumulative[i], third_days_cumulative[i + 1])
for (i, k) in enumerate(third_days.keys())
}
third_days_tot = sum(v for v in third_days.values())
# construct a range of dates for omicron which starts at the maximum of the start date
# for that state or the Omicron start date
third_omicron_date_range = {
k: pd.date_range(
start=max(v[0], pd.to_datetime(omicron_start_date)), end=v[-1]
).values
for (k, v) in third_date_range.items()
}
third_omicron_days = {k: v.shape[0] for (k, v) in third_omicron_date_range.items()}
third_omicron_days_cumulative = np.append(
[0], np.cumsum([v for v in third_omicron_days.values()])
)
omicron_ve_idx_ranges = {
k: range(third_omicron_days_cumulative[i], third_omicron_days_cumulative[i + 1])
for (i, k) in enumerate(third_omicron_days.keys())
}
third_omicron_days_tot = sum(v for v in third_omicron_days.values())
# extrac the samples
delta_ve_samples = samples_mov_gamma[
["ve_delta[" + str(j + 1) + "]" for j in range(third_days_tot)]
].T
omicron_ve_samples = samples_mov_gamma[
["ve_omicron[" + str(j + 1) + "]" for j in range(third_omicron_days_tot)]
].T
# now we plot and save the adjusted ve time series to be read in by the forecasting
plot_adjusted_ve(
data_date,
samples_mov_gamma,
states,
vaccination_by_state_delta,
third_states,
third_date_range,
delta_ve_samples,
delta_ve_idx_ranges,
figs_dir,
"delta",
)
plot_adjusted_ve(
data_date,
samples_mov_gamma,
states,
vaccination_by_state_omicron,
third_states,
third_omicron_date_range,
omicron_ve_samples,
omicron_ve_idx_ranges,
figs_dir,
"omicron",
)
if df3X.shape[0] > 0:
df["is_third_wave"] = 0
for state in third_states:
df.loc[df.state == state, "is_third_wave"] = (
df.loc[df.state == state]
.date.isin(third_date_range[state])
.astype(int)
.values
)
# plot only if there is third phase data - have to have third_phase=True
ax4 = macro_factor_plots(
samples_mov_gamma,
df.loc[(df.date >= third_start_date) & (df.date <= third_end_date)],
) # by states....
for ax in ax4:
for a in ax:
a.set_ylim((0, 1.25))
# a.set_xlim((start_date,end_date))
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + "macro_factor_comp.png",
dpi=144,
)
# remove plots from memory
fig.clear()
plt.close(fig)
df["is_third_wave"] = 0
for state in third_states:
df.loc[df.state == state, "is_third_wave"] = (
df.loc[df.state == state]
.date.isin(third_date_range[state])
.astype(int)
.values
)
# plot only if there is third phase data - have to have third_phase=True
ax4 = predict_plot(
samples_mov_gamma,
df.loc[(df.date >= third_start_date) & (df.date <= third_end_date)],
moving=True,
grocery=True,
rho=third_states,
third_phase=True,
) # by states....
for ax in ax4:
for a in ax:
a.set_ylim((0, 2.5))
# a.set_xlim((start_date,end_date))
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + "Reff_third_phase_combined.png",
dpi=144,
)
# remove plots from memory
fig.clear()
plt.close(fig)
# plot only if there is third phase data - have to have third_phase=True
ax4 = predict_plot(
samples_mov_gamma,
df.loc[(df.date >= third_start_date) & (df.date <= third_end_date)],
moving=True,
grocery=True,
rho=third_states,
third_phase=True,
third_plot_type="delta"
) # by states....
for ax in ax4:
for a in ax:
a.set_ylim((0, 2.5))
# a.set_xlim((start_date,end_date))
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + "Reff_third_phase_delta.png",
dpi=144,
)
# remove plots from memory
fig.clear()
plt.close(fig)
for param in ("micro", "macro", "susceptibility"):
# plot only if there is third phase data - have to have third_phase=True
ax4 = predict_multiplier_plot(
samples_mov_gamma,
df.loc[(df.date >= third_start_date) & (df.date <= third_end_date)],
param=param,
) # by states....
for ax in ax4:
for a in ax:
if param == "macro":
a.set_ylim((0, 1.25))
else:
a.set_ylim((0, 1.1))
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + param + "_factor.png",
dpi=144,
)
# remove plots from memory
fig.clear()
plt.close(fig)
if df3X.shape[0] > 0:
df["is_omicron_wave"] = 0
for state in third_states:
df.loc[df.state == state, "is_omicron_wave"] = (
df.loc[df.state == state]
.date.isin(third_omicron_date_range[state])
.astype(int)
.values
)
# plot only if there is third phase data - have to have third_phase=True
ax4 = predict_plot(
samples_mov_gamma,
df.loc[(df.date >= omicron_start_date) & (df.date <= third_end_date)],
moving=True,
grocery=True,
rho=third_states,
third_phase=True,
third_plot_type="omicron"
) # by states....
for ax in ax4:
for a in ax:
a.set_ylim((0, 2.5))
# a.set_xlim((start_date,end_date))
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + "Reff_third_phase_omicron.png",
dpi=144,
)
# remove plots from memory
fig.clear()
plt.close(fig)
# plot the omicron proportion
# create a range of dates from the beginning of Omicron to use for producing the Omicron
# proportion
omicron_date_range = pd.date_range(
omicron_start_date, pd.to_datetime(data_date) + timedelta(45)
)
prop_omicron_to_delta = np.array([])
# create array of times to plot against
t = np.tile(range(len(omicron_date_range)), (samples_mov_gamma.shape[0], 1)).T
fig, ax = plt.subplots(figsize=(15, 12), nrows=4, ncols=2, sharex=True, sharey=True)
for (i, state) in enumerate(third_states):
m0 = np.tile(samples_mov_gamma.loc[:, "m0[" + str(i + 1) + "]"], (len(omicron_date_range), 1))
m1 = np.tile(samples_mov_gamma.loc[:, "m1[" + str(i + 1) + "]"], (len(omicron_date_range), 1))
# m1 = 1.0
r = np.tile(samples_mov_gamma.loc[:, "r[" + str(i + 1) + "]"], (len(omicron_date_range), 1))
tau = np.tile(samples_mov_gamma.loc[:, "tau[" + str(i + 1) + "]"] , (len(omicron_date_range), 1))
omicron_start_date_tmp = max(
pd.to_datetime(omicron_start_date), third_date_range[state][0]
)
omicron_date_range_tmp = pd.date_range(
omicron_start_date_tmp, third_date_range[state][-1]
)
# if state in {"TAS", "WA", "NT"}:
# prop_omicron_to_delta_tmp = m1
# else:
# prop_omicron_to_delta_tmp = m0 + (m1 - m0) / (1 + np.exp(-r * (t - tau)))
prop_omicron_to_delta_tmp = m0 + (m1 - m0) / (1 + np.exp(-r * (t - tau)))
ax[i // 2, i % 2].plot(
omicron_date_range,
np.median(prop_omicron_to_delta_tmp, axis=1),
)
ax[i // 2, i % 2].fill_between(
omicron_date_range,
np.quantile(prop_omicron_to_delta_tmp, 0.05, axis=1),
np.quantile(prop_omicron_to_delta_tmp, 0.95, axis=1),
alpha=0.2,
)
ax[i // 2, i % 2].axvline(
omicron_date_range_tmp[0], ls="--", c="k", lw=1
)
ax[i // 2, i % 2].axvline(
omicron_date_range_tmp[-1], ls="--", c="k", lw=1
)
ax[i // 2, i % 2].set_title(state)
ax[i // 2, i % 2].xaxis.set_major_locator(plt.MaxNLocator(3))
ax[i // 2, 0].set_ylabel("Proportion of Omicron\ncases to Delta")
if len(prop_omicron_to_delta) == 0:
prop_omicron_to_delta = prop_omicron_to_delta_tmp[:, -len(omicron_date_range_tmp):]
else:
prop_omicron_to_delta = np.hstack(
(
prop_omicron_to_delta,
prop_omicron_to_delta_tmp[:, -len(omicron_date_range_tmp):],
)
)
fig.tight_layout()
plt.savefig(
figs_dir + data_date.strftime("%Y-%m-%d") + "omicron_proportion.png", dpi=144
)
# need to rotate to put into a good format
prop_omicron_to_delta = prop_omicron_to_delta.T
df_prop_omicron_to_delta = pd.DataFrame(
prop_omicron_to_delta,
columns=[
"prop_omicron_to_delta." + str(i+1) for i in range(prop_omicron_to_delta.shape[1])
]
)
df_prop_omicron_to_delta.to_csv(
"results/"
+ data_date.strftime("%Y-%m-%d")
+ "/prop_omicron_to_delta"
+ data_date.strftime("%Y-%m-%d")
+ ".csv"
)
# saving the final processed posterior samples to h5 for generate_RL_forecasts.py
var_to_csv = predictors
samples_mov_gamma[predictors] = samples_mov_gamma[
["bet[" + str(i + 1) + "]" for i in range(len(predictors))]
]
# var_to_csv = [
# "R_I",
# "R_I_omicron",
# "R_L",
# "sig",
# "theta_masks",
# "theta_md",
# "voc_effect_alpha",
# "voc_effect_delta",
# "voc_effect_omicron",
# "sus_dep_factor",
# ]
var_to_csv = [
"R_I",
"R_I_omicron",
"R_L",
"sig",
"theta_masks",
"theta_md",
"voc_effect_alpha",
"voc_effect_delta",
"voc_effect_omicron",
]
var_to_csv = var_to_csv + [col for col in samples_mov_gamma if "phi" in col]
var_to_csv = (
var_to_csv
+ predictors
+ ["R_Li[" + str(i + 1) + "]" for i in range(len(states_to_fit_all_waves))]
)
var_to_csv = var_to_csv + ["ve_delta[" + str(j + 1) + "]" for j in range(third_days_tot)]
var_to_csv = var_to_csv + [
"ve_omicron[" + str(j + 1) + "]" for j in range(third_omicron_days_tot)
]
var_to_csv = var_to_csv + ["r[" + str(j + 1) + "]" for j in range(len(third_states))]
var_to_csv = var_to_csv + ["tau[" + str(j + 1) + "]" for j in range(len(third_states))]
var_to_csv = var_to_csv + ["m0[" + str(j + 1) + "]" for j in range(len(third_states))]
var_to_csv = var_to_csv + ["m1[" + str(j + 1) + "]" for j in range(len(third_states))]
# save the posterior
samples_mov_gamma[var_to_csv].to_hdf(
"results/"
+ data_date.strftime("%Y-%m-%d")
+ "/soc_mob_posterior"
+ data_date.strftime("%Y-%m-%d")
+ ".h5",
key="samples",
)
return None
def main(data_date, run_flag=0):
"""
Runs the stan model in parts to cut down on memory. The run_flag enables us to run components
of the model as required and has the following settings:
run_flag=0 (default) : Run full inference and plotting procedures.
run_flag=1 : Generate the data, save it.
run_flag=2 : Using the data from 1, run the inference.
run_flag=3 : Run plotting methods.
"""
if run_flag in (0, 1):
get_data_for_posterior(data_date=data_date)
if run_flag in (0, 2):
num_chains = 4
num_warmup_samples = 500
num_samples = 1000
max_treedepth = 12
run_stan(
data_date=data_date,
num_chains=num_chains,
num_samples=num_samples,
num_warmup_samples=num_warmup_samples,
max_treedepth=max_treedepth,
)
if run_flag in (0, 3):
# remove the susceptibility depletion term from Reff
for strain in ("Delta", "Omicron"):
# remove_sus_from_Reff(strain=strain, data_date=data_date)
remove_sus_with_waning_from_Reff(strain=strain, data_date=data_date)
plot_and_save_posterior_samples(data_date=data_date)
return None
if __name__ == "__main__":
"""
If we are running the script here (which is always) then this ensures things run appropriately.
"""
data_date = argv[1]
try:
run_flag = int(argv[2])
except:
run_flag = 0
main(data_date, run_flag=run_flag) | StarcoderdataPython |
6422770 | import abc
import os
from multiprocessing import Process, Queue
class AbcDataPipeline(metaclass=abc.ABCMeta):
@abc.abstractmethod
def execute(self):
raise NotImplementedError
class TaskPipelineBase(AbcDataPipeline):
name = '单任务处理'
def __init__(self, in_data_path, out_data_path, process_num=4):
self.in_data_path = in_data_path
self.out_data_path = out_data_path
self.process_num = process_num
self._queue = Queue()
@abc.abstractmethod
def do_task(self, task):
raise NotImplementedError
def do_task_process_wrapper(self):
while True:
task = self._queue.get()
if task is None:
break
print("处理任务 {}".format(task))
self.do_task(task)
@abc.abstractmethod
def task_gen(self):
raise NotImplementedError
def execute(self):
print("模块: {} 数据处理开始".format(self.name))
precesses = [Process(target=self.do_task_process_wrapper) for i in range(0, self.process_num)]
[p.start() for p in precesses]
for task in self.task_gen():
self._queue.put(task)
for i in range(0, self.process_num):
self._queue.put(None)
[p.join() for p in precesses]
print("模块: {} 数据处理完成".format(self.name))
class SingleDataPipelineBase(TaskPipelineBase):
name = '单文件处理'
def __init__(self, in_data_path, out_data_path, process_num=4):
super().__init__(in_data_path, out_data_path, process_num)
def task_gen(self):
for root, dirs, files in os.walk(os.path.join(self.in_data_path)):
for file in files:
if file.endswith('.csv'):
yield os.path.join(root, file)
from .logic_time import LogicTime
from .logprice import LogPrice
from .move_data import MoveData
from .splite_instruments import SplitInstruments
from .main_instrument import MainInstrument
| StarcoderdataPython |
1678716 | """Face Autoencoder used in:
IMPROVING CROSS-DATASET PERFORMANCE OF FACE PRESENTATION ATTACK DETECTION SYSTEMS USING FACE RECOGNITION DATASETS,
Mohammadi, <NAME> Bhattacharjee, Sushil and <NAME>, ICASSP 2020
"""
import tensorflow as tf
from bob.learn.tensorflow.models.densenet import densenet161
def _get_l2_kw(weight_decay):
l2_kw = {}
if weight_decay is not None:
l2_kw = {"kernel_regularizer": tf.keras.regularizers.l2(weight_decay)}
return l2_kw
def ConvDecoder(
z_dim,
decoder_layers=(
(512, 7, 7, 0),
(256, 4, 2, 1),
(128, 4, 2, 1),
(64, 4, 2, 1),
(32, 4, 2, 1),
(16, 4, 2, 1),
(3, 1, 1, 0),
),
weight_decay=1e-5,
last_act="tanh",
name="Decoder",
**kwargs,
):
"""The decoder similar to the one in
https://github.com/google/compare_gan/blob/master/compare_gan/architectures/sndcgan.py
"""
z_dim = z_dim
data_format = "channels_last"
l2_kw = _get_l2_kw(weight_decay)
layers = [
tf.keras.layers.Reshape(
(1, 1, z_dim), input_shape=(z_dim,), name=f"{name}/reshape"
)
]
for i, (filters, kernel_size, strides, cropping) in enumerate(decoder_layers):
dconv = tf.keras.layers.Conv2DTranspose(
filters,
kernel_size,
strides=strides,
use_bias=i == len(decoder_layers) - 1,
data_format=data_format,
name=f"{name}/dconv_{i}",
**l2_kw,
)
crop = tf.keras.layers.Cropping2D(
cropping=cropping, data_format=data_format, name=f"{name}/crop_{i}"
)
if i == len(decoder_layers) - 1:
act = tf.keras.layers.Activation(
f"{last_act}", name=f"{name}/{last_act}_{i}"
)
bn = None
else:
act = tf.keras.layers.Activation("relu", name=f"{name}/relu_{i}")
bn = tf.keras.layers.BatchNormalization(
scale=False, fused=False, name=f"{name}/bn_{i}"
)
if bn is not None:
layers.extend([dconv, crop, bn, act])
else:
layers.extend([dconv, crop, act])
return tf.keras.Sequential(layers, name=name, **kwargs)
class Autoencoder(tf.keras.Model):
"""
A class defining a simple convolutional autoencoder.
Attributes
----------
data_format : str
channels_last is only supported
decoder : object
The encoder part
encoder : object
The decoder part
"""
def __init__(self, encoder, decoder, name="Autoencoder", **kwargs):
super().__init__(name=name, **kwargs)
self.encoder = encoder
self.decoder = decoder
def call(self, x, training=None):
z = self.encoder(x, training=training)
x_hat = self.decoder(z, training=training)
return z, x_hat
def autoencoder_face(z_dim=256, weight_decay=1e-10, decoder_last_act="tanh"):
encoder = densenet161(
output_classes=z_dim, weight_decay=weight_decay, weights=None, name="DenseNet"
)
decoder = ConvDecoder(
z_dim=z_dim,
weight_decay=weight_decay,
last_act=decoder_last_act,
name="Decoder",
)
autoencoder = Autoencoder(encoder, decoder, name="Autoencoder")
return autoencoder
if __name__ == "__main__":
import pkg_resources # noqa: F401
from tabulate import tabulate
from bob.learn.tensorflow.utils import model_summary
model = ConvDecoder(z_dim=256, weight_decay=1e-9, last_act="tanh", name="Decoder")
model.summary()
rows = model_summary(model, do_print=True)
del rows[-2]
print(tabulate(rows, headers="firstrow", tablefmt="latex"))
| StarcoderdataPython |
12832124 | <reponame>gavinIRL/RHBotArray
import os
import cv2
import time
import math
import ctypes
import random
import win32ui
import win32gui
import warnings
import win32con
import threading
import subprocess
import pytesseract
import numpy as np
import pydirectinput
from fuzzywuzzy import process
from custom_input import CustomInput
from win32api import GetSystemMetrics
os.chdir(os.path.dirname(os.path.abspath(__file__)))
warnings.simplefilter("ignore", DeprecationWarning)
class HsvFilter:
def __init__(self, hMin=None, sMin=None, vMin=None, hMax=None, sMax=None, vMax=None,
sAdd=None, sSub=None, vAdd=None, vSub=None):
self.hMin = hMin
self.sMin = sMin
self.vMin = vMin
self.hMax = hMax
self.sMax = sMax
self.vMax = vMax
self.sAdd = sAdd
self.sSub = sSub
self.vAdd = vAdd
self.vSub = vSub
class WindowCapture:
w = 0
h = 0
hwnd = None
cropped_x = 0
cropped_y = 0
offset_x = 0
offset_y = 0
def __init__(self, window_name=None, custom_rect=None):
self.custom_rect = custom_rect
if window_name is None:
self.hwnd = win32gui.GetDesktopWindow()
else:
self.hwnd = win32gui.FindWindow(None, window_name)
if not self.hwnd:
raise Exception('Window not found: {}'.format(window_name))
# Declare all the class variables
self.w, self.h, self.cropped_x, self.cropped_y
self.offset_x, self.offset_y
self.update_window_position()
def get_screenshot(self):
# get the window image data
wDC = win32gui.GetWindowDC(self.hwnd)
dcObj = win32ui.CreateDCFromHandle(wDC)
cDC = dcObj.CreateCompatibleDC()
dataBitMap = win32ui.CreateBitmap()
dataBitMap.CreateCompatibleBitmap(dcObj, self.w, self.h)
cDC.SelectObject(dataBitMap)
cDC.BitBlt((0, 0), (self.w, self.h), dcObj,
(self.cropped_x, self.cropped_y), win32con.SRCCOPY)
# convert the raw data into a format opencv can read
signedIntsArray = dataBitMap.GetBitmapBits(True)
img = np.fromstring(signedIntsArray, dtype='uint8')
img.shape = (self.h, self.w, 4)
# free resources
dcObj.DeleteDC()
cDC.DeleteDC()
win32gui.ReleaseDC(self.hwnd, wDC)
win32gui.DeleteObject(dataBitMap.GetHandle())
# drop the alpha channel
img = img[..., :3]
# make image C_CONTIGUOUS
img = np.ascontiguousarray(img)
return img
def focus_window(self):
win32gui.SetForegroundWindow(self.hwnd)
def update_window_position(self, border=True):
self.window_rect = win32gui.GetWindowRect(self.hwnd)
self.w = self.window_rect[2] - self.window_rect[0]
self.h = self.window_rect[3] - self.window_rect[1]
border_pixels = 8
titlebar_pixels = 30
if self.custom_rect is None:
if border:
self.w = self.w - (border_pixels * 2)
self.h = self.h - titlebar_pixels - border_pixels
self.cropped_x = border_pixels
self.cropped_y = titlebar_pixels
else:
self.cropped_x = 0
self.cropped_y = 0
self.w += 3
else:
self.w = self.custom_rect[2] - self.custom_rect[0]
self.h = self.custom_rect[3] - self.custom_rect[1]
self.cropped_x = self.custom_rect[0]
self.cropped_y = self.custom_rect[1]
self.offset_x = self.window_rect[0] + self.cropped_x
self.offset_y = self.window_rect[1] + self.cropped_y
# WARNING: need to call the update_window_position function to prevent errors
# That would come from moving the window after starting the bot
def get_screen_position(self, pos):
return (pos[0] + self.offset_x, pos[1] + self.offset_y)
class BotUtils:
def grab_online_servers():
output = subprocess.run("arp -a", capture_output=True).stdout.decode()
list_ips = []
with open("servers.txt", "r") as f:
lines = f.readlines()
for ip in lines:
if ip.strip() in output:
list_ips.append(ip.strip())
return list_ips
def grab_current_lan_ip():
output = subprocess.run(
"ipconfig", capture_output=True).stdout.decode()
_, output = output.split("IPv4 Address. . . . . . . . . . . : 169")
output, _ = output.split("Subnet Mask", maxsplit=1)
current_lan_ip = "169" + output.strip()
return current_lan_ip
def start_server_threads(list_servers):
for server in list_servers:
t = threading.Thread(target=server.main_loop)
t.start()
def grab_closest(rel_list: list):
closest_index = False
smallest_dist = 100000
for i, pair in enumerate(rel_list):
x = abs(pair[0])
y = abs(pair[1])
hypot = math.hypot(x, y)
if hypot < smallest_dist:
smallest_dist = hypot
closest_index = i
return closest_index
def grab_order_closeness(relatives):
dists = []
for x, y in relatives:
dists.append(math.hypot(x, y))
return sorted(range(len(dists)), key=dists.__getitem__)
def grab_order_lowest_y(coords):
y_only = []
for _, y in coords:
y_only.append(y)
return sorted(range(len(y_only)), key=y_only.__getitem__)
# Angle is left->right travel of room angle, north being 0deg
def move_diagonal(gamename, x, y, angle=90, speed=20, rel=False):
# If not a direct relative move command
if not rel:
if not BotUtils.detect_bigmap_open(gamename):
BotUtils.try_toggle_map()
player_pos = BotUtils.grab_player_pos(gamename)
start_time = time.time()
while not player_pos:
time.sleep(0.05)
if not BotUtils.detect_bigmap_open(gamename):
BotUtils.try_toggle_map()
time.sleep(0.05)
player_pos = BotUtils.grab_player_pos(gamename)
if time.time() - start_time > 5:
print("Error with finding player")
os._exit(1)
BotUtils.close_map_and_menu(gamename)
relx = player_pos[0] - int(x)
rely = int(y) - player_pos[1]
while abs(relx) > 100 or abs(rely > 100):
CustomInput.press_key(CustomInput.key_map["right"], "right")
CustomInput.release_key(CustomInput.key_map["right"], "right")
time.sleep(0.02)
player_pos = BotUtils.grab_player_pos(gamename)
relx = player_pos[0] - int(x)
rely = int(y) - player_pos[1]
# Otherwise treat x,y as direct commands
else:
relx = x
rely = y
mult = 0.707
if relx > 0:
keyx = "left"
CustomInput.press_key(CustomInput.key_map["left"], "left")
timeleftx = float("{:.4f}".format(abs(relx/(speed*mult))))
elif relx < 0:
keyx = "right"
CustomInput.press_key(CustomInput.key_map["right"], "right")
timeleftx = float("{:.4f}".format(abs(relx/(speed*mult))))
else:
timeleftx = 0
mult = 1
if rely > 0:
keyy = "down"
CustomInput.press_key(CustomInput.key_map["down"], "down")
timelefty = float("{:.4f}".format(abs(rely/(speed*mult))))
elif rely < 0:
keyy = "up"
CustomInput.press_key(CustomInput.key_map["up"], "up")
timelefty = float("{:.4f}".format(abs(rely/(speed*mult))))
else:
timelefty = 0
if relx != 0:
timeleftx = float("{:.4f}".format(abs(relx/speed)))
first_sleep = min([timeleftx, timelefty])
second_sleep = max([timeleftx, timelefty])
first_key = [keyx, keyy][[timeleftx, timelefty].index(first_sleep)]
second_key = [keyx, keyy][[timeleftx, timelefty].index(second_sleep)]
if first_sleep < 0.009:
if second_sleep < 0.009:
pass
else:
time.sleep(second_sleep-0.009)
CustomInput.release_key(
CustomInput.key_map[second_key], second_key)
elif timelefty == timeleftx:
time.sleep(first_sleep-0.009)
CustomInput.release_key(CustomInput.key_map[first_key], first_key)
CustomInput.release_key(
CustomInput.key_map[second_key], second_key)
else:
time.sleep(first_sleep - 0.009)
CustomInput.release_key(CustomInput.key_map[first_key], first_key)
time.sleep((second_sleep-first_sleep-0.009)*mult)
CustomInput.release_key(
CustomInput.key_map[second_key], second_key)
def move_towards(value, dir):
if dir == "x":
if value > 0:
key = "left"
else:
key = "right"
elif dir == "y":
if value > 0:
key = "down"
else:
key = "up"
CustomInput.press_key(CustomInput.key_map[key], key)
def move_to(gamename, x, y, angle=90, yfirst=True, speed=22.5, loot=False, plyr=False, rel=False):
if not rel:
if not BotUtils.detect_bigmap_open(gamename):
BotUtils.try_toggle_map()
player_pos = BotUtils.grab_player_pos(gamename)
start_time = time.time()
while not player_pos:
time.sleep(0.05)
if not BotUtils.detect_bigmap_open(gamename):
BotUtils.try_toggle_map()
time.sleep(0.05)
player_pos = BotUtils.grab_player_pos(gamename)
if time.time() - start_time > 5:
print("Error with finding player")
os._exit(1)
BotUtils.close_map_and_menu(gamename)
relx = player_pos[0] - int(x)
rely = int(y) - player_pos[1]
while abs(relx) > 100 or abs(rely > 100):
CustomInput.press_key(CustomInput.key_map["right"], "right")
CustomInput.release_key(CustomInput.key_map["right"], "right")
time.sleep(0.02)
player_pos = BotUtils.grab_player_pos(gamename)
relx = player_pos[0] - int(x)
rely = int(y) - player_pos[1]
else:
relx = x
rely = y
if not yfirst:
if not loot:
BotUtils.resolve_dir_v2(relx, "x", speed)
BotUtils.resolve_dir_v2(rely, "y", speed)
else:
lootfound = BotUtils.resolve_dir_with_looting(
relx, "x", speed, gamename)
if lootfound:
Looting.grab_all_visible_loot(gamename, plyr)
# Continue to destination without further looting (prevent stuck)
BotUtils.move_to(gamename, x, y, angle, yfirst, speed)
# When at destination check for loot again
if Looting.check_for_loot(gamename):
Looting.grab_all_visible_loot(gamename, plyr)
# If needs be return to destination
BotUtils.move_to(gamename, x, y, angle, yfirst, speed)
else:
lootfound = BotUtils.resolve_dir_with_looting(
rely, "y", speed, gamename)
if lootfound:
Looting.grab_all_visible_loot(gamename, plyr)
# Continue to destination without further looting (prevent stuck)
BotUtils.move_to(gamename, x, y, angle, yfirst, speed)
# When at destination check for loot again
if Looting.check_for_loot(gamename):
Looting.grab_all_visible_loot(gamename, plyr)
# If needs be return to destination
BotUtils.move_to(
gamename, x, y, angle, yfirst, speed)
else:
if not loot:
BotUtils.resolve_dir_v2(rely, "y", speed)
BotUtils.resolve_dir_v2(relx, "x", speed)
else:
lootfound = BotUtils.resolve_dir_with_looting(
rely, "y", speed, gamename)
if lootfound:
Looting.grab_all_visible_loot(gamename, plyr)
# Continue to destination without further looting (prevent stuck)
BotUtils.move_to(gamename, x, y, angle, yfirst, speed)
# When at destination check for loot again
if Looting.check_for_loot(gamename):
Looting.grab_all_visible_loot(gamename, plyr)
# If needs be return to destination
BotUtils.move_to(gamename, x, y, angle, yfirst, speed)
else:
lootfound = BotUtils.resolve_dir_with_looting(
relx, "x", speed, gamename)
if lootfound:
Looting.grab_all_visible_loot(gamename, plyr)
# Continue to destination without further looting (prevent stuck)
BotUtils.move_to(gamename, x, y, angle, yfirst, speed)
# When at destination check for loot again
if Looting.check_for_loot(gamename):
Looting.grab_all_visible_loot(gamename, plyr)
# If needs be return to destination
BotUtils.move_to(
gamename, x, y, angle, yfirst, speed)
def resolve_dir_v2(value, dir, speed):
if dir == "x":
if value > 0:
key = "left"
else:
key = "right"
elif dir == "y":
if value > 0:
key = "down"
else:
key = "up"
time_reqd = abs(value/speed)
if time_reqd > 0.003:
CustomInput.press_key(CustomInput.key_map[key], key)
time.sleep(time_reqd-0.003)
CustomInput.release_key(CustomInput.key_map[key], key)
def resolve_dir_with_looting(value, dir, speed, gamename):
if dir == "x":
if value > 0:
key = "left"
else:
key = "right"
elif dir == "y":
if value > 0:
key = "down"
else:
key = "up"
time_reqd = abs(value/speed)
start_time = time.time()
if time_reqd > 0.003:
CustomInput.press_key(CustomInput.key_map[key], key)
# Maximum lootcheck time is about 0.3secs worst case
# Nominal is about 0.2s
if time_reqd < 2:
time.sleep(time_reqd-0.003)
CustomInput.release_key(CustomInput.key_map[key], key)
else:
BotUtils.close_map(gamename)
loops = math.floor(time_reqd/2)
for i in range(loops):
time.sleep(1.65)
result = Looting.check_for_loot(gamename)
if result:
CustomInput.release_key(CustomInput.key_map[key], key)
return True
time_left = start_time+time_reqd-time.time()
time.sleep(time_left)
CustomInput.release_key(CustomInput.key_map[key], key)
return Looting.check_for_loot(gamename)
def resolve_single_direction(speed, value, dir, PAG=False):
if not PAG:
sleep_time = 0.003
else:
sleep_time = 0.1
if dir == "x":
if value > 0:
key = "left"
else:
key = "right"
elif dir == "y":
if value > 0:
key = "down"
else:
key = "up"
time_reqd = abs(value/speed)
key_map = CustomInput.grab_key_dict()
if not PAG:
CustomInput.press_key(key_map[key], key)
else:
pydirectinput.keyDown(key)
try:
time.sleep(time_reqd-sleep_time)
except:
pass
if not PAG:
CustomInput.release_key(key_map[key], key)
else:
pydirectinput.keyDown(key)
def list_window_names():
def winEnumHandler(hwnd, ctx):
if win32gui.IsWindowVisible(hwnd):
print(hex(hwnd), win32gui.GetWindowText(hwnd))
win32gui.EnumWindows(winEnumHandler, None)
def grab_hpbar_locations(gamename=False):
if gamename:
wincap = WindowCapture(gamename, [100, 135, 1223, 688])
original_image = wincap.get_screenshot()
else:
original_image = cv2.imread(os.path.dirname(
os.path.abspath(__file__)) + "/testimages/healthbars.jpg")
filter = HsvFilter(20, 174, 245, 26, 193, 255, 0, 0, 0, 0)
output_image = BotUtils.filter_blackwhite_invert(
filter, original_image, True)
output_image = cv2.blur(output_image, (2, 2))
_, thresh = cv2.threshold(output_image, 127, 255, 0)
contours, _ = cv2.findContours(
thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
contours = sorted(contours, key=cv2.contourArea, reverse=True)
if len(contours) < 2:
return False
contours.pop(0)
rectangles = []
for contour in contours:
(x, y), _ = cv2.minEnclosingCircle(contour)
rectangles.append([x-10, y, 20, 5])
rectangles.append([x-10, y, 20, 5])
rectangles, _ = cv2.groupRectangles(
rectangles, groupThreshold=1, eps=0.8)
points = []
for (x, y, w, h) in rectangles:
center_x = x + int(w/2)
center_y = y + int(h/2)
points.append((center_x, center_y))
return points
def grab_character_location(player_name, gamename=False):
player_chars = "".join(set(player_name))
if gamename:
wincap = WindowCapture(gamename, [200, 235, 1123, 688])
original_image = wincap.get_screenshot()
else:
original_image = cv2.imread(os.path.dirname(
os.path.abspath(__file__)) + "/testimages/test_sensitive.jpg")
filter = HsvFilter(0, 0, 119, 179, 49, 255, 0, 0, 0, 0)
output_image = BotUtils.filter_blackwhite_invert(
filter, original_image, return_gray=True)
rgb = cv2.cvtColor(output_image, cv2.COLOR_GRAY2RGB)
tess_config = '--psm 6 --oem 3 -c tessedit_char_whitelist=' + player_chars
results = pytesseract.image_to_data(
rgb, output_type=pytesseract.Output.DICT, lang='eng', config=tess_config)
try:
best_match, _ = process.extractOne(
player_name, results["text"], score_cutoff=0.8)
i = results["text"].index(best_match)
x = int(results["left"][i] + (results["width"][i]/2))
y = int(results["top"][i] + (results["height"][i]/2))
# Account for the rect
x += 200
y += 235
return x, y
except:
return 640, 382
def shift_channel(c, amount):
if amount > 0:
lim = 255 - amount
c[c >= lim] = 255
c[c < lim] += amount
elif amount < 0:
amount = -amount
lim = amount
c[c <= lim] = 0
c[c > lim] -= amount
return c
def filter_blackwhite_invert(filter: HsvFilter, existing_image, return_gray=False, threshold=67, max=255):
hsv = cv2.cvtColor(existing_image, cv2.COLOR_BGR2HSV)
hsv_filter = filter
# add/subtract saturation and value
h, s, v = cv2.split(hsv)
s = BotUtils.shift_channel(s, hsv_filter.sAdd)
s = BotUtils.shift_channel(s, -hsv_filter.sSub)
v = BotUtils.shift_channel(v, hsv_filter.vAdd)
v = BotUtils.shift_channel(v, -hsv_filter.vSub)
hsv = cv2.merge([h, s, v])
# Set minimum and maximum HSV values to display
lower = np.array([hsv_filter.hMin, hsv_filter.sMin, hsv_filter.vMin])
upper = np.array([hsv_filter.hMax, hsv_filter.sMax, hsv_filter.vMax])
# Apply the thresholds
mask = cv2.inRange(hsv, lower, upper)
result = cv2.bitwise_and(hsv, hsv, mask=mask)
# convert back to BGR
img = cv2.cvtColor(result, cv2.COLOR_HSV2BGR)
# now change it to greyscale
grayImage = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# now change it to black and white
(thresh, blackAndWhiteImage) = cv2.threshold(
grayImage, threshold, max, cv2.THRESH_BINARY)
# now invert it
inverted = (255-blackAndWhiteImage)
if return_gray:
return inverted
inverted = cv2.cvtColor(inverted, cv2.COLOR_GRAY2BGR)
return inverted
def convert_pynput_to_pag(button):
PYNPUT_SPECIAL_CASE_MAP = {
'alt_l': 'altleft',
'alt_r': 'altright',
'alt_gr': 'altright',
'caps_lock': 'capslock',
'ctrl_l': 'ctrlleft',
'ctrl_r': 'ctrlright',
'page_down': 'pagedown',
'page_up': 'pageup',
'shift_l': 'shiftleft',
'shift_r': 'shiftright',
'num_lock': 'numlock',
'print_screen': 'printscreen',
'scroll_lock': 'scrolllock',
}
# example: 'Key.F9' should return 'F9', 'w' should return as 'w'
cleaned_key = button.replace('Key.', '')
if cleaned_key in PYNPUT_SPECIAL_CASE_MAP:
return PYNPUT_SPECIAL_CASE_MAP[cleaned_key]
return cleaned_key
def detect_player_name(gamename):
plyrname_rect = [165, 45, 320, 65]
plyrname_wincap = WindowCapture(gamename, plyrname_rect)
plyrname_filt = HsvFilter(0, 0, 103, 89, 104, 255, 0, 0, 0, 0)
# get an updated image of the game
image = plyrname_wincap.get_screenshot()
# pre-process the image
image = BotUtils.apply_hsv_filter(
image, plyrname_filt)
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
results = pytesseract.image_to_data(
rgb, output_type=pytesseract.Output.DICT, lang='eng')
biggest = 0
name = False
for entry in results["text"]:
if len(entry) > biggest:
name = entry
biggest = len(entry)
return name
def detect_level_name(gamename):
wincap = WindowCapture(gamename, [1121, 31, 1248, 44])
existing_image = wincap.get_screenshot()
filter = HsvFilter(0, 0, 0, 169, 34, 255, 0, 0, 0, 0)
save_image = BotUtils.apply_hsv_filter(existing_image, filter)
gray_image = cv2.cvtColor(save_image, cv2.COLOR_BGR2GRAY)
(thresh, blackAndWhiteImage) = cv2.threshold(
gray_image, 129, 255, cv2.THRESH_BINARY)
# now invert it
inverted = (255-blackAndWhiteImage)
save_image = cv2.cvtColor(inverted, cv2.COLOR_GRAY2BGR)
rgb = cv2.cvtColor(save_image, cv2.COLOR_BGR2RGB)
tess_config = '--psm 7 --oem 3 -c tessedit_char_whitelist=01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
result = pytesseract.image_to_string(
rgb, lang='eng', config=tess_config)[:-2]
return result
def apply_hsv_filter(original_image, hsv_filter: HsvFilter):
# convert image to HSV
hsv = cv2.cvtColor(original_image, cv2.COLOR_BGR2HSV)
# add/subtract saturation and value
h, s, v = cv2.split(hsv)
s = BotUtils.shift_channel(s, hsv_filter.sAdd)
s = BotUtils.shift_channel(s, -hsv_filter.sSub)
v = BotUtils.shift_channel(v, hsv_filter.vAdd)
v = BotUtils.shift_channel(v, -hsv_filter.vSub)
hsv = cv2.merge([h, s, v])
# Set minimum and maximum HSV values to display
lower = np.array([hsv_filter.hMin, hsv_filter.sMin, hsv_filter.vMin])
upper = np.array([hsv_filter.hMax, hsv_filter.sMax, hsv_filter.vMax])
# Apply the thresholds
mask = cv2.inRange(hsv, lower, upper)
result = cv2.bitwise_and(hsv, hsv, mask=mask)
# convert back to BGR for imshow() to display it properly
img = cv2.cvtColor(result, cv2.COLOR_HSV2BGR)
return img
def detect_sect_clear(gamename=False):
if not gamename:
with open("gamename.txt") as f:
gamename = f.readline()
wincap = WindowCapture(gamename, custom_rect=[
464+156, 640, 464+261, 641])
image = wincap.get_screenshot()
a, b, c = [int(i) for i in image[0][0]]
d, e, f = [int(i) for i in image[0][-1]]
if a+b+c > 700:
if d+e+f > 700:
return True
return False
def detect_boss_healthbar(gamename=False):
if not gamename:
with open("gamename.txt") as f:
gamename = f.readline()
wincap = WindowCapture(gamename, custom_rect=[
415+97, 105+533, 415+98, 105+534])
image = wincap.get_screenshot()
# bgr
a, b, c = [int(i) for i in image[0][0]]
d, e, f = [int(i) for i in image[0][-1]]
if c+f > 440:
if a+b+d+e < 80:
return True
return False
def detect_xprompt(gamename=False):
if not gamename:
with open("gamename.txt") as f:
gamename = f.readline()
wincap = WindowCapture(gamename, custom_rect=[
1137, 694, 1163, 695])
image = wincap.get_screenshot()
a, b, c = [int(i) for i in image[0][0]]
d, e, f = [int(i) for i in image[0][-1]]
if a+b+d+e > 960 and c+f == 140:
return True
else:
return False
def grab_player_pos(gamename=False, map_rect=None, rect_rel=False):
if not gamename:
with open("gamename.txt") as f:
gamename = f.readline()
if not map_rect:
wincap = WindowCapture(gamename, [561, 282, 1111, 666])
else:
wincap = WindowCapture(gamename, map_rect)
filter = HsvFilter(34, 160, 122, 50, 255, 255, 0, 0, 0, 0)
image = wincap.get_screenshot()
save_image = BotUtils.filter_blackwhite_invert(filter, image)
vision = Vision('plyr.jpg')
rectangles = vision.find(
save_image, threshold=0.31, epsilon=0.5)
if len(rectangles) < 1:
return False, False
points = vision.get_click_points(rectangles)
x, y = points[0]
if not map_rect:
x += 561
y += 282
return x, y
elif rect_rel:
x += map_rect[0]
y += map_rect[1]
return x, y
else:
x += wincap.window_rect[0]
y += wincap.window_rect[1]
return x, y
def grab_level_rects():
rects = {}
# Load the translation from name to num
with open("lvl_name_num.txt") as f:
num_names = f.readlines()
for i, entry in enumerate(num_names):
num_names[i] = entry.split("-")
# Load the num to rect catalogue
with open("catalogue.txt") as f:
nums_rects = f.readlines()
for i, entry in enumerate(nums_rects):
nums_rects[i] = entry.split("-")
# Then add each rect to the rects dict against name
for number, name in num_names:
for num, area, rect in nums_rects:
if area == "FM" and num == number:
rects[name.rstrip().replace(" ", "")] = rect.rstrip()
if "1" in name:
rects[name.rstrip().replace(
" ", "").replace("1", "L")] = rect.rstrip()
if "ri" in name:
rects[name.rstrip().replace(
" ", "").replace("ri", "n").replace("1", "L")] = rect.rstrip()
break
return rects
def grab_level_rects_and_speeds():
rects = {}
speeds = {}
# Load the translation from name to num
with open("lvl_name_num.txt") as f:
num_names = f.readlines()
for i, entry in enumerate(num_names):
num_names[i] = entry.split("-")
# Load the num to rect catalogue
with open("catalogue.txt") as f:
nums_rects = f.readlines()
for i, entry in enumerate(nums_rects):
nums_rects[i] = entry.split("-")
# Finally load the level speeds
with open("lvl_speed.txt") as f:
num_speeds = f.readlines()
for i, entry in enumerate(num_speeds):
num_speeds[i] = entry.split("|")
# Then add each rect to the rects dict against name
# Also add each speed to the speed dict against name
for number, name in num_names:
for num, area, rect in nums_rects:
if area == "FM" and num == number:
rects[name.rstrip().replace(" ", "")] = rect.rstrip()
if "1" in name:
rects[name.rstrip().replace(
" ", "").replace("1", "L")] = rect.rstrip()
if "ri" in name:
rects[name.rstrip().replace(
" ", "").replace("ri", "n").replace("1", "L")] = rect.rstrip()
break
for num, speed in num_speeds:
if num == number:
speeds[name.rstrip().replace(
" ", "")] = float(speed.rstrip())
if "1" in name:
speeds[name.rstrip().replace(
" ", "").replace("1", "L")] = float(speed.rstrip())
if "ri" in name:
speeds[name.rstrip().replace(
" ", "").replace("ri", "n").replace("1", "L")] = float(speed.rstrip())
break
return rects, speeds
def string_to_rect(string: str):
# This converts the rect from catalogue into int list
return [int(i) for i in string.split(',')]
def move_mouse_centre(gamename=False):
if not gamename:
with open("gamename.txt") as f:
gamename = f.readline()
wincap = WindowCapture(gamename)
centre_x = int(0.5 * wincap.w +
wincap.window_rect[0])
centre_y = int(0.5 * wincap.h +
wincap.window_rect[1])
ctypes.windll.user32.SetCursorPos(centre_x, centre_y)
def detect_bigmap_open(gamename=False):
if not gamename:
with open("gamename.txt") as f:
gamename = f.readline()
wincap = WindowCapture(gamename, custom_rect=[819, 263, 855, 264])
image = wincap.get_screenshot()
a, b, c = [int(i) for i in image[0][0]]
d, e, f = [int(i) for i in image[0][-2]]
if a+b+c < 30:
if d+e+f > 700:
return True
return False
def detect_menu_open(gamename=False):
if not gamename:
with open("gamename.txt") as f:
gamename = f.readline()
wincap = WindowCapture(gamename, custom_rect=[595, 278, 621, 281])
image = wincap.get_screenshot()
a, b, c = [int(i) for i in image[0][0]]
d, e, f = [int(i) for i in image[0][-1]]
if a+b+c > 700:
if d+e+f > 700:
return True
return False
def convert_list_to_rel(item_list, playerx, playery, yoffset=0):
return_list = []
for item in item_list:
relx = playerx - item[0]
rely = item[1] - playery - yoffset
return_list.append((relx, rely))
return return_list
def close_map_and_menu(gamename=False):
if not gamename:
with open("gamename.txt") as f:
gamename = f.readline()
game_wincap = WindowCapture(gamename)
if BotUtils.detect_menu_open(gamename):
BotUtils.close_esc_menu(game_wincap)
if BotUtils.detect_bigmap_open(gamename):
BotUtils.close_map(game_wincap)
def try_toggle_map():
pydirectinput.keyDown("m")
time.sleep(0.05)
pydirectinput.keyUp("m")
time.sleep(0.08)
def try_toggle_map_clicking(gamename=False):
if not gamename:
with open("gamename.txt") as f:
gamename = f.readline()
game_wincap = WindowCapture(gamename)
pydirectinput.click(
int(1262+game_wincap.window_rect[0]), int(64+game_wincap.window_rect[1]))
def close_map(game_wincap=False):
if not game_wincap:
with open("gamename.txt") as f:
gamename = f.readline()
game_wincap = WindowCapture(gamename)
pydirectinput.click(
int(859+game_wincap.window_rect[0]), int(260+game_wincap.window_rect[1]))
def close_esc_menu(game_wincap=False):
if not game_wincap:
with open("gamename.txt") as f:
gamename = f.readline()
game_wincap = WindowCapture(gamename)
pydirectinput.click(
int(749+game_wincap.window_rect[0]), int(280+game_wincap.window_rect[1]))
def get_monitor_scaling():
scaleFactor = ctypes.windll.shcore.GetScaleFactorForDevice(0) / 100
return float(scaleFactor)
def grab_res_scroll_left(gamename):
wincap = WindowCapture(gamename, [112, 130, 125, 143])
image = wincap.get_screenshot()
filter = HsvFilter(0, 0, 0, 179, 18, 255, 0, 0, 0, 0)
image = BotUtils.apply_hsv_filter(image, filter)
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
tess_config = '--psm 7 --oem 3 -c tessedit_char_whitelist=1234567890'
result = pytesseract.image_to_string(
rgb, lang='eng', config=tess_config)[:-2]
return int(result)
def read_mission_name(gamename):
wincap = WindowCapture(gamename, [749, 152, 978, 170])
image = wincap.get_screenshot()
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
tess_config = '--psm 7 --oem 3 -c tessedit_char_whitelist=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
result = pytesseract.image_to_string(
rgb, lang='eng', config=tess_config)[:-2]
return result
def convert_click_to_ratio(gamename, truex, truey):
wincap = WindowCapture(gamename)
wincap.update_window_position(border=False)
scaling = BotUtils.get_monitor_scaling()
# print(scaling)
relx = (truex - (wincap.window_rect[0] * scaling))
rely = (truey - (wincap.window_rect[1] * scaling))
# print("relx, rely, w, h: {},{},{},{}".format(
# relx, rely, wincap.w, wincap.h))
ratx = relx/(wincap.w * scaling)
raty = rely/(wincap.h * scaling)
return ratx, raty
def convert_ratio_to_click(ratx, raty, gamename=False):
if not gamename:
with open("gamename.txt") as f:
gamename = f.readline()
wincap = WindowCapture(gamename)
relx = int(ratx * wincap.w)
rely = int(raty * wincap.h)
truex = int((relx + wincap.window_rect[0]))
truey = int((rely + wincap.window_rect[1]))
return truex, truey
def convert_true_to_window(gamename, truex, truey):
scaling = BotUtils.get_monitor_scaling()
wincap = WindowCapture(gamename)
relx = (truex/scaling) - wincap.window_rect[0]
rely = (truey/scaling) - wincap.window_rect[1]
return relx, rely
def convert_window_to_true(gamename, relx, rely):
wincap = WindowCapture(gamename)
truex = int(relx + wincap.window_rect[0])
truey = int(rely + wincap.window_rect[1])
return truex, truey
def find_other_player(gamename, all=False):
othr_plyr_vision = Vision("otherplayerinvert.jpg")
othr_plyr_wincap = WindowCapture(gamename, [1100, 50, 1260, 210])
image = othr_plyr_wincap.get_screenshot()
filter = HsvFilter(24, 194, 205, 31, 255, 255, 0, 0, 0, 0)
image = cv2.blur(image, (4, 4))
image = BotUtils.filter_blackwhite_invert(filter, image)
rectangles = othr_plyr_vision.find(
image, threshold=0.61, epsilon=0.5)
points = othr_plyr_vision.get_click_points(rectangles)
if len(points) >= 1:
if not all:
relx = points[0][0] - 0
rely = 0 - points[0][1]
return relx, rely
else:
return points
return False
def find_enemy(gamename, all=False):
othr_plyr_vision = Vision("otherplayerinvert.jpg")
othr_plyr_wincap = WindowCapture(gamename, [1100, 50, 1260, 210])
image = othr_plyr_wincap.get_screenshot()
filter = HsvFilter(0, 198, 141, 8, 255, 255, 0, 0, 0, 0)
image = cv2.blur(image, (4, 4))
image = BotUtils.filter_blackwhite_invert(filter, image)
rectangles = othr_plyr_vision.find(
image, threshold=0.41, epsilon=0.5)
points = othr_plyr_vision.get_click_points(rectangles)
if len(points) >= 1:
if not all:
relx = points[0][0] - 0
rely = 0 - points[0][1]
return relx, rely
else:
return points
return False
def find_midlevel_event(gamename=False, playerx=False, playery=False):
if not gamename:
with open("gamename.txt") as f:
gamename = f.readline()
if not playerx:
playerx, playery = BotUtils.grab_player_pos(
gamename, [1100, 50, 1260, 210], True)
filter = HsvFilter(76, 247, 170, 100, 255, 255, 0, 0, 0, 0)
vision = Vision("otherplayerinvert.jpg")
wincap = WindowCapture(gamename, [1100, 50, 1260, 210])
image = wincap.get_screenshot()
image = cv2.blur(image, (4, 4))
image = BotUtils.filter_blackwhite_invert(filter, image)
rectangles = vision.find(
image, threshold=0.61, epsilon=0.5)
points = vision.get_click_points(rectangles)
if len(points) >= 1:
relx = points[0][0] - playerx
rely = playery - points[0][1]
return relx, rely
return False, False
def stop_movement(follower=False):
if follower:
follower.pressed_keys = []
for key in ["up", "down", "left", "right"]:
CustomInput.release_key(CustomInput.key_map[key], key)
class Looting:
def loot_current_room(gamename, player_name, search_points=False):
# Start by picking up loot already in range
BotUtils.close_map_and_menu(gamename)
Looting.grab_nearby_loot(gamename)
# Then try grabbing all visible far loot
Looting.grab_all_visible_loot(gamename, player_name)
# Then once that is exhausted cycle through the searchpoints
if search_points:
for point in search_points:
x, y, first_dir = point
BotUtils.move_to(gamename, x, y, yfirst=first_dir == "y")
Looting.grab_nearby_loot(gamename)
BotUtils.close_map_and_menu(gamename)
Looting.grab_all_visible_loot(gamename, player_name)
def grab_nearby_loot(gamename):
count = 0
while BotUtils.detect_xprompt(gamename):
if count > 12:
break
pydirectinput.press("x")
count += 1
time.sleep(0.09)
CustomInput.press_key(CustomInput.key_map["right"], "right")
CustomInput.release_key(CustomInput.key_map["right"], "right")
def grab_all_visible_loot(gamename, player_name):
start_time = time.time()
while True:
if time.time() - start_time > 20:
break
outcome = Looting.try_find_and_grab_loot(
gamename, player_name)
if outcome == "noloot":
break
elif outcome == "noplayer":
pydirectinput.press("right")
outcome = Looting.try_find_and_grab_loot(
gamename, player_name)
if outcome == "noplayer":
break
elif outcome == "falsepos":
break
elif outcome == True:
count = 0
while BotUtils.detect_xprompt(gamename):
if count > 12:
break
pydirectinput.press("x")
count += 1
time.sleep(0.09)
def check_for_loot(gamename):
# This will be a lightweight check for any positive loot ident
# Meant to be used when moving and normal looting has ceased
# i.e. opportunistic looting
data = Looting.grab_farloot_locations(
gamename, return_image=True)
if not data:
return False
else:
loot_list, image, xoff, yoff = data
confirmed = False
try:
for _, coords in enumerate(loot_list):
x, y = coords
x -= xoff
y -= yoff
rgb = image[y-22:y+22, x-75:x+75]
filter = HsvFilter(0, 0, 131, 151, 255, 255, 0, 0, 0, 0)
rgb = BotUtils.apply_hsv_filter(rgb, filter)
tess_config = '--psm 7 --oem 3 -c tessedit_char_whitelist=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
result = pytesseract.image_to_string(
rgb, lang='eng', config=tess_config)[:-2]
if len(result) > 3:
return True
except:
return False
if not confirmed:
return False
def try_find_and_grab_loot(gamename, player_name, loot_lowest=True, printout=False):
# First need to close anything that might be in the way
BotUtils.close_map_and_menu(gamename)
# Then grab loot locations
loot_list = Looting.grab_farloot_locations(gamename)
if not loot_list:
# print("No loot found")
return "noloot"
# else:
# print("Loot found")
playerx, playery = BotUtils.grab_character_location(
player_name, gamename)
# If didn't find player then try once more
if not playerx:
playerx, playery = BotUtils.grab_character_location(
player_name, gamename)
if not playerx:
return "noplayer"
# if want to always loot the nearest first despite the cpu hit
if not loot_lowest:
# Then convert lootlist to rel_pos list
relatives = BotUtils.convert_list_to_rel(
loot_list, playerx, playery, 275)
# Grab the indexes in ascending order of closesness
order = BotUtils.grab_order_closeness(relatives)
# Then reorder the lootlist to match
loot_list = [x for _, x in sorted(zip(order, loot_list))]
# Otherwise if want to loot from bottom of screen to top
# Typically better as see all loot then in y direction
# but potentially miss loot in x direction
else:
# Grab the indexes in ascending order of distance from
# bottom of the screen
order = BotUtils.grab_order_lowest_y(loot_list)
# Then reorder the lootlist to match
loot_list = [x for _, x in sorted(zip(order, loot_list))]
# print(len(loot_list))
confirmed = False
for index, coords in enumerate(loot_list):
x, y = coords
wincap = WindowCapture(gamename, [x-95, y-50, x+95, y+50])
rgb = wincap.get_screenshot()
filter = HsvFilter(0, 0, 131, 151, 255, 255, 0, 0, 0, 0)
rgb = BotUtils.apply_hsv_filter(rgb, filter)
# cv2.imwrite("testytest.jpg", rgb)
tess_config = '--psm 5 --oem 3 -c tessedit_char_whitelist=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
result = pytesseract.image_to_string(
rgb, lang='eng', config=tess_config)[:-2]
if len(result) > 3:
if printout:
print(result)
confirmed = loot_list[index]
break
if not confirmed:
# print("Lootname not confirmed or detected")
return "noloot"
relx = playerx - confirmed[0]
rely = confirmed[1] - playery - 275
rect = [confirmed[0]-100, confirmed[1] -
30, confirmed[0]+100, confirmed[1]+30]
BotUtils.move_towards(relx, "x")
loop_time = time.time()
time_remaining = 0.1
time.sleep(0.01)
while time_remaining > 0:
time.sleep(0.003)
if BotUtils.detect_xprompt(gamename):
break
try:
newx, newy = Looting.grab_farloot_locations(gamename, rect)[
0]
time_taken = time.time() - loop_time
movementx = confirmed[0] - newx
speed = movementx/time_taken
if speed != 0:
time_remaining = abs(
relx/speed) - time_taken
rect = [newx-100, newy-30, newx+100, newy+30]
except:
try:
time.sleep(time_remaining)
break
except:
return False
for key in ["left", "right"]:
CustomInput.release_key(CustomInput.key_map[key], key)
BotUtils.move_towards(rely, "y")
start_time = time.time()
if rely < 0:
expected_time = abs(rely/7.5)
else:
expected_time = abs(rely/5.5)
while not BotUtils.detect_xprompt(gamename):
time.sleep(0.005)
# After moving in opposite direction
if time.time() - start_time > 10:
# If have moved opposite with no result for equal amount
if time.time() - start_time > 10 + 2*(1 + expected_time):
for key in ["up", "down"]:
CustomInput.release_key(CustomInput.key_map[key], key)
# Return falsepos so that it will ignore this detection
return "falsepos"
# If no result for 3 seconds
elif time.time() - start_time > 1 + expected_time:
# Try moving in the opposite direction
for key in ["up", "down"]:
CustomInput.release_key(CustomInput.key_map[key], key)
BotUtils.move_towards(-1*rely, "y")
start_time -= 8.5
for key in ["up", "down"]:
CustomInput.release_key(CustomInput.key_map[key], key)
pydirectinput.press("x")
return True
def grab_farloot_locations(gamename=False, rect=False, return_image=False):
if gamename:
if not rect:
rect1 = [100, 160, 1223, 688]
wincap = WindowCapture(gamename, rect1)
else:
wincap = WindowCapture(gamename, rect)
original_image = wincap.get_screenshot()
else:
original_image = cv2.imread(os.path.dirname(
os.path.abspath(__file__)) + "/testimages/lootscene.jpg")
filter = HsvFilter(15, 180, 0, 20, 255, 63, 0, 0, 0, 0)
output_image = BotUtils.filter_blackwhite_invert(
filter, original_image, True, 0, 180)
output_image = cv2.blur(output_image, (8, 1))
output_image = cv2.blur(output_image, (8, 1))
output_image = cv2.blur(output_image, (8, 1))
_, thresh = cv2.threshold(output_image, 127, 255, 0)
contours, _ = cv2.findContours(
thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
contours = sorted(contours, key=cv2.contourArea, reverse=True)
if len(contours) < 2:
return False
contours.pop(0)
rectangles = []
for contour in contours:
(x, y), _ = cv2.minEnclosingCircle(contour)
rectangles.append([x-50, y, 100, 5])
rectangles.append([x-50, y, 100, 5])
rectangles, _ = cv2.groupRectangles(
rectangles, groupThreshold=1, eps=0.9)
if len(rectangles) < 1:
return False
points = []
for (x, y, w, h) in rectangles:
# Account for the rect
if rect:
# Account for the rect
x += rect[0]
y += rect[1]
else:
x += 100
y += 135
center_x = x + int(w/2)
center_y = y + int(h/2)
points.append((center_x, center_y))
if return_image:
if rect:
return points, original_image, rect[0], rect[1]
else:
return points, original_image, rect1[0], rect1[1]
return points
class Events:
def choose_random_reward(gamename):
wincap = WindowCapture(gamename)
posx = wincap.window_rect[0] + (460+(180*random.randint(0, 2)))
posy = wincap.window_rect[1] + (200+(132*random.randint(0, 3)))
pydirectinput.click(int(posx), int(posy))
time.sleep(0.1)
# Now accept the reward
pydirectinput.click(
wincap.window_rect[0]+750, wincap.window_rect[1]+720)
def detect_reward_choice_open(gamename):
wincap = WindowCapture(gamename, [503, 90, 535, 92])
image = wincap.get_screenshot()
a, b, c = [int(i) for i in image[0][0]]
d, e, f = [int(i) for i in image[0][-1]]
if a + d > 400:
if b + e > 500:
if c + f < 105:
return True
return False
def detect_move_reward_screen(gamename):
wincap = WindowCapture(gamename, [581, 270, 593, 272])
image = wincap.get_screenshot()
a, b, c = [int(i) for i in image[0][0]]
d, e, f = [int(i) for i in image[0][-1]]
if a + d > 360 and a + d < 400:
if b + e > 360 and b + e < 400:
if c + f < 10:
return True
return False
def detect_endlevel_chest(gamename):
wincap = WindowCapture(gamename, [454, 250, 525, 252])
image = wincap.get_screenshot()
a, b, c = [int(i) for i in image[0][0]]
d, e, f = [int(i) for i in image[0][-1]]
if a + d < 50:
if b + e > 480:
if c + f > 290 and c+f < 320:
return True
return False
def detect_endlevel_bonus_area(gamename):
wincap = WindowCapture(gamename, [503, 487, 514, 589])
image = wincap.get_screenshot()
a, b, c = [int(i) for i in image[0][0]]
d, e, f = [int(i) for i in image[0][-1]]
if a + d > 400:
if b + e > 400:
if c + f > 400:
return True
return False
def detect_in_dungeon(wincap=False):
if not wincap:
with open("gamename.txt") as f:
gamename = f.readline()
wincap = WindowCapture(gamename, [1090, 331, 1092, 353])
image = wincap.get_screenshot()
a, b, c = [int(i) for i in image[0][0]]
d, e, f = [int(i) for i in image[-1][0]]
if d < 20:
if a + b + e > 400 and a+b+e < 500:
if c + f > 480:
return True
return False
def detect_go(gamename):
wincap = WindowCapture(gamename, [623, 247, 628, 249])
image = wincap.get_screenshot()
a, b, c = [int(i) for i in image[0][0]]
if a < 30:
if b > 240:
if c > 140:
return True
return False
def detect_one_card(gamename):
# Cards only show up once one has been picked
# Therefore need to check against bronze, gold, silver
wincap = WindowCapture(gamename, [833, 44, 835, 46])
image = wincap.get_screenshot()
a, b, c = [int(i) for i in image[0][0]]
# Bronze
if a == 27:
if b == 48:
if c == 87:
return True
# Silver
if a == 139:
if b == 139:
if c == 139:
return True
# Gold
if a == 38:
if b == 129:
if c == 160:
return True
return False
def detect_yes_no(gamename):
wincap = WindowCapture(gamename, [516, 426, 541, 441])
image = wincap.get_screenshot()
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
tess_config = '--psm 7 --oem 3 -c tessedit_char_whitelist=Yes'
result = pytesseract.image_to_string(
rgb, lang='eng', config=tess_config)[:-2]
if result == "Yes":
return True
return False
def detect_resurrect_prompt(gamename):
wincap = WindowCapture(gamename, [763, 490, 818, 492])
image = wincap.get_screenshot()
a, b, c = [int(i) for i in image[0][0]]
d, e, f = [int(i) for i in image[-1][0]]
if a + d > 500:
if b + e > 500:
if c + f > 500:
return True
return False
def detect_store(gamename=False):
if not gamename:
with open("gamename.txt") as f:
gamename = f.readline()
wincap = WindowCapture(gamename, [1084, 265, 1099, 267])
image = wincap.get_screenshot()
a, b, c = [int(i) for i in image[0][0]]
d, e, f = [int(i) for i in image[-1][0]]
if a + d > 500:
if b + e > 500:
if c + f > 500:
return True
return False
class RHClick:
def click_yes(gamename):
wincap = WindowCapture(gamename)
pydirectinput.click(
wincap.window_rect[0]+528, wincap.window_rect[1]+433)
def click_no(gamename):
wincap = WindowCapture(gamename)
pydirectinput.click(
wincap.window_rect[0]+763, wincap.window_rect[1]+433)
def click_otherworld_ok(gamename):
wincap = WindowCapture(gamename)
pydirectinput.click(
wincap.window_rect[0]+503, wincap.window_rect[1]+487)
def click_otherworld_no(gamename):
wincap = WindowCapture(gamename)
pydirectinput.click(
wincap.window_rect[0]+778, wincap.window_rect[1]+487)
def click_choose_map(gamename):
wincap = WindowCapture(gamename)
pydirectinput.click(
wincap.window_rect[0]+1150, wincap.window_rect[1]+210)
def click_explore_again(gamename):
wincap = WindowCapture(gamename)
pydirectinput.click(
wincap.window_rect[0]+1150, wincap.window_rect[1]+152)
def click_back_to_town(gamename):
wincap = WindowCapture(gamename)
pydirectinput.click(
wincap.window_rect[0]+1150, wincap.window_rect[1]+328)
def click_map_number(gamename, mapnum):
wincap = WindowCapture(gamename)
map_to_clickpoints = {
5: (728, 521),
6: (640, 631),
7: (605, 455),
8: (542, 350),
9: (293, 297),
10: (777, 406),
11: (140, 370),
12: (500, 246),
13: (500, 672),
14: (419, 478),
15: (423, 263),
16: (563, 562),
17: (642, 432),
18: (249, 325)
}
x, y = map_to_clickpoints[mapnum]
pydirectinput.click(wincap.window_rect[0]+x, wincap.window_rect[1]+y)
def choose_difficulty_and_enter(gamename, diff):
wincap = WindowCapture(gamename)
num_clicks = 0
if diff == "N":
num_clicks = 0
elif diff == "H":
num_clicks = 1
elif diff == "VH":
num_clicks == 2
elif diff == "BM":
num_clicks == 3
for i in range(num_clicks):
pydirectinput.click(
wincap.window_rect[0]+618, wincap.window_rect[1]+333)
time.sleep(0.3)
# Then click on enter dungeon
pydirectinput.click(
wincap.window_rect[0]+1033, wincap.window_rect[1]+736)
def go_to_change_character(gamename):
if not BotUtils.detect_menu_open(gamename):
pydirectinput.press('esc')
wincap = WindowCapture(gamename)
pydirectinput.click(
wincap.window_rect[0]+640, wincap.window_rect[1]+363)
def exit_game(gamename):
if not BotUtils.detect_menu_open(gamename):
pydirectinput.press('esc')
wincap = WindowCapture(gamename)
pydirectinput.click(
wincap.window_rect[0]+640, wincap.window_rect[1]+480)
time.sleep(0.2)
pydirectinput.click(
wincap.window_rect[0]+640, wincap.window_rect[1]+428)
def choose_character(gamename, charnum):
wincap = WindowCapture(gamename)
char_clickpoints = {
1: (1100, 140),
2: (1100, 210),
3: (1100, 280),
4: (1100, 350),
5: (1100, 420),
6: (1100, 490),
7: (1100, 560),
8: (1100, 630)
}
if charnum > 8:
pydirectinput.click(
wincap.window_rect[0]+1165, wincap.window_rect[1]+680)
x, y = char_clickpoints[charnum-8]
else:
pydirectinput.click(
wincap.window_rect[0]+1035, wincap.window_rect[1]+680)
x, y = char_clickpoints[charnum]
time.sleep(0.2)
pydirectinput.click(wincap.window_rect[0]+x, wincap.window_rect[1]+y)
time.sleep(0.2)
pydirectinput.click(
wincap.window_rect[0]+640, wincap.window_rect[1]+765)
class Vision:
def __init__(self, needle_img_path, method=cv2.TM_CCOEFF_NORMED):
self.needle_img = cv2.imread(needle_img_path, cv2.IMREAD_UNCHANGED)
self.needle_w = self.needle_img.shape[1]
self.needle_h = self.needle_img.shape[0]
# TM_CCOEFF, TM_CCOEFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_SQDIFF, TM_SQDIFF_NORMED
self.method = method
def find(self, haystack_img, threshold=0.7, max_results=15, epsilon=0.5):
result = cv2.matchTemplate(haystack_img, self.needle_img, self.method)
locations = np.where(result >= threshold)
locations = list(zip(*locations[::-1]))
if not locations:
return np.array([], dtype=np.int32).reshape(0, 4)
rectangles = []
for loc in locations:
rect = [int(loc[0]), int(loc[1]), self.needle_w, self.needle_h]
rectangles.append(rect)
rectangles.append(rect)
rectangles, weights = cv2.groupRectangles(
rectangles, groupThreshold=1, eps=epsilon)
return rectangles
def get_click_points(self, rectangles):
points = []
for (x, y, w, h) in rectangles:
center_x = x + int(w/2)
center_y = y + int(h/2)
points.append((center_x, center_y))
return points
def draw_rectangles(self, haystack_img, rectangles):
# BGR
line_color = (0, 255, 0)
line_type = cv2.LINE_4
for (x, y, w, h) in rectangles:
top_left = (x, y)
bottom_right = (x + w, y + h)
cv2.rectangle(haystack_img, top_left, bottom_right,
line_color, lineType=line_type)
return haystack_img
def draw_crosshairs(self, haystack_img, points):
# BGR
marker_color = (255, 0, 255)
marker_type = cv2.MARKER_CROSS
for (center_x, center_y) in points:
cv2.drawMarker(haystack_img, (center_x, center_y),
marker_color, marker_type)
return haystack_img
class DynamicFilter:
TRACKBAR_WINDOW = "Trackbars"
# create gui window with controls for adjusting arguments in real-time
def __init__(self, needle_img_path, method=cv2.TM_CCOEFF_NORMED):
self.needle_img = cv2.imread(needle_img_path, cv2.IMREAD_UNCHANGED)
self.needle_w = self.needle_img.shape[1]
self.needle_h = self.needle_img.shape[0]
# TM_CCOEFF, TM_CCOEFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_SQDIFF, TM_SQDIFF_NORMED
self.method = method
def find(self, haystack_img, threshold=0.7, epsilon=0.5):
result = cv2.matchTemplate(haystack_img, self.needle_img, self.method)
locations = np.where(result >= threshold)
locations = list(zip(*locations[::-1]))
if not locations:
return np.array([], dtype=np.int32).reshape(0, 4)
rectangles = []
for loc in locations:
rect = [int(loc[0]), int(loc[1]), self.needle_w, self.needle_h]
rectangles.append(rect)
rectangles.append(rect)
rectangles, weights = cv2.groupRectangles(
rectangles, groupThreshold=1, eps=epsilon)
return rectangles
def get_click_points(self, rectangles):
points = []
for (x, y, w, h) in rectangles:
center_x = x + int(w/2)
center_y = y + int(h/2)
points.append((center_x, center_y))
return points
def draw_rectangles(self, haystack_img, rectangles):
# BGR
line_color = (0, 255, 0)
line_type = cv2.LINE_4
for (x, y, w, h) in rectangles:
top_left = (x, y)
bottom_right = (x + w, y + h)
cv2.rectangle(haystack_img, top_left, bottom_right,
line_color, lineType=line_type)
return haystack_img
def draw_crosshairs(self, haystack_img, points):
# BGR
marker_color = (255, 0, 255)
marker_type = cv2.MARKER_CROSS
for (center_x, center_y) in points:
cv2.drawMarker(haystack_img, (center_x, center_y),
marker_color, marker_type)
return haystack_img
def init_control_gui(self):
cv2.namedWindow(self.TRACKBAR_WINDOW, cv2.WINDOW_NORMAL)
cv2.resizeWindow(self.TRACKBAR_WINDOW, 350, 700)
# required callback. we'll be using getTrackbarPos() to do lookups
# instead of using the callback.
def nothing(position):
pass
# create trackbars for bracketing.
# OpenCV scale for HSV is H: 0-179, S: 0-255, V: 0-255
cv2.createTrackbar('HMin', self.TRACKBAR_WINDOW, 0, 179, nothing)
cv2.createTrackbar('SMin', self.TRACKBAR_WINDOW, 0, 255, nothing)
cv2.createTrackbar('VMin', self.TRACKBAR_WINDOW, 0, 255, nothing)
cv2.createTrackbar('HMax', self.TRACKBAR_WINDOW, 0, 179, nothing)
cv2.createTrackbar('SMax', self.TRACKBAR_WINDOW, 0, 255, nothing)
cv2.createTrackbar('VMax', self.TRACKBAR_WINDOW, 0, 255, nothing)
# Set default value for Max HSV trackbars
cv2.setTrackbarPos('HMax', self.TRACKBAR_WINDOW, 179)
cv2.setTrackbarPos('SMax', self.TRACKBAR_WINDOW, 255)
cv2.setTrackbarPos('VMax', self.TRACKBAR_WINDOW, 255)
# trackbars for increasing/decreasing saturation and value
cv2.createTrackbar('SAdd', self.TRACKBAR_WINDOW, 0, 255, nothing)
cv2.createTrackbar('SSub', self.TRACKBAR_WINDOW, 0, 255, nothing)
cv2.createTrackbar('VAdd', self.TRACKBAR_WINDOW, 0, 255, nothing)
cv2.createTrackbar('VSub', self.TRACKBAR_WINDOW, 0, 255, nothing)
# returns an HSV filter object based on the control GUI values
def get_hsv_filter_from_controls(self):
# Get current positions of all trackbars
hsv_filter = HsvFilter()
hsv_filter.hMin = cv2.getTrackbarPos('HMin', self.TRACKBAR_WINDOW)
hsv_filter.sMin = cv2.getTrackbarPos('SMin', self.TRACKBAR_WINDOW)
hsv_filter.vMin = cv2.getTrackbarPos('VMin', self.TRACKBAR_WINDOW)
hsv_filter.hMax = cv2.getTrackbarPos('HMax', self.TRACKBAR_WINDOW)
hsv_filter.sMax = cv2.getTrackbarPos('SMax', self.TRACKBAR_WINDOW)
hsv_filter.vMax = cv2.getTrackbarPos('VMax', self.TRACKBAR_WINDOW)
hsv_filter.sAdd = cv2.getTrackbarPos('SAdd', self.TRACKBAR_WINDOW)
hsv_filter.sSub = cv2.getTrackbarPos('SSub', self.TRACKBAR_WINDOW)
hsv_filter.vAdd = cv2.getTrackbarPos('VAdd', self.TRACKBAR_WINDOW)
hsv_filter.vSub = cv2.getTrackbarPos('VSub', self.TRACKBAR_WINDOW)
return hsv_filter
def apply_hsv_filter(self, original_image, hsv_filter=None):
hsv = cv2.cvtColor(original_image, cv2.COLOR_BGR2HSV)
if not hsv_filter:
hsv_filter = self.get_hsv_filter_from_controls()
h, s, v = cv2.split(hsv)
s = BotUtils.shift_channel(s, hsv_filter.sAdd)
s = BotUtils.shift_channel(s, -hsv_filter.sSub)
v = BotUtils.shift_channel(v, hsv_filter.vAdd)
v = BotUtils.shift_channel(v, -hsv_filter.vSub)
hsv = cv2.merge([h, s, v])
lower = np.array([hsv_filter.hMin, hsv_filter.sMin, hsv_filter.vMin])
upper = np.array([hsv_filter.hMax, hsv_filter.sMax, hsv_filter.vMax])
mask = cv2.inRange(hsv, lower, upper)
result = cv2.bitwise_and(hsv, hsv, mask=mask)
img = cv2.cvtColor(result, cv2.COLOR_HSV2BGR)
return img
class SellRepair():
def __init__(self, rarity_cutoff=1, last_row_protect=True) -> None:
# rarities are as follows:
# nocolour=0, green=1, blue=2
self.cutoff = rarity_cutoff
# this is for whether lastrow in equip is protected
# useful for characters levelling with next upgrades ready
self.last_row_protect = last_row_protect
with open("gamename.txt") as f:
self.gamename = f.readline()
self.inventory_wincap = WindowCapture(
self.gamename, [512, 277, 775, 430])
# This is for correct mouse positioning
self.game_wincap = WindowCapture(self.gamename)
self.shop_check_wincap = WindowCapture(
self.gamename, [274, 207, 444, 208])
# These are for holding reference rgb values
# Using sets as can then compare easily to other sets
self.empty = {41, 45, 50}
self.rar_green = {2, 204, 43}
self.rar_blue = {232, 144, 5}
self.rar_none = {24, 33, 48}
self.junk_list = self.grab_junk_list()
def grab_junk_list(self):
jl = []
with open("itemrgb.txt") as f:
lines = f.readlines()
for line in lines:
_, rgb = line.split("|")
r, g, b = rgb.split(",")
jl.append({int(r), int(g), int(b)})
return jl
def ident_sell_repair(self):
self.game_wincap.update_window_position(border=False)
self.shop_check_wincap.update_window_position(border=False)
self.open_store_if_necessary()
# First go through all the equipment
self.change_tab("Equipment")
# time.sleep(0.2)
# self.hover_mouse_all()
time.sleep(0.3)
screenshot = self.inventory_wincap.get_screenshot()
non_empty = self.remove_empty(screenshot)
junk_list = self.identify_rarities_equip(non_empty, screenshot)
self.sell(junk_list, "Equipment")
# Then go through all the other loot
self.change_tab("Other")
# time.sleep(0.2)
# self.hover_mouse_all()
time.sleep(0.3)
screenshot = self.inventory_wincap.get_screenshot()
non_empty = self.remove_empty(screenshot)
junk_list = self.identify_items_other(non_empty, screenshot)
self.sell(junk_list)
# and finally repair gear
self.repair()
# and now go through all the steps again minus repair to make sure
self.change_tab("Equipment")
time.sleep(0.3)
screenshot = self.inventory_wincap.get_screenshot()
non_empty = self.remove_empty(screenshot)
junk_list = self.identify_rarities_equip(non_empty, screenshot)
self.sell(junk_list, "Equipment")
self.change_tab("Other")
time.sleep(0.3)
screenshot = self.inventory_wincap.get_screenshot()
non_empty = self.remove_empty(screenshot)
junk_list = self.identify_items_other(non_empty, screenshot)
self.sell(junk_list)
def open_store_if_necessary(self):
# This will search to see if the inventory is open
# in the correct spot and then click shop if not
screenshot = self.shop_check_wincap.get_screenshot()
pix1 = screenshot[0, 0]
pix1 = int(pix1[0]) + int(pix1[1]) + int(pix1[2])
pix2 = screenshot[0, 169]
pix2 = int(pix2[0]) + int(pix2[1]) + int(pix2[2])
if pix1 == 103 and pix2 == 223:
pass
else:
# need to open the store
self.game_wincap.update_window_position(border=False)
offsetx = self.game_wincap.window_rect[0] + 534
offsety = self.game_wincap.window_rect[1] + 277
ctypes.windll.user32.SetCursorPos(offsetx+610, offsety-10)
ctypes.windll.user32.mouse_event(
0x0002, 0, 0, 0, 0)
ctypes.windll.user32.mouse_event(
0x0004, 0, 0, 0, 0)
def change_tab(self, name):
self.game_wincap.update_window_position(border=False)
x = self.game_wincap.window_rect[0] + 534-60
if name == "Equipment":
y = self.game_wincap.window_rect[1] + 277 - 15
elif name == "Other":
y = self.game_wincap.window_rect[1] + 277 + 44
ctypes.windll.user32.SetCursorPos(x, y)
ctypes.windll.user32.mouse_event(
0x0002, 0, 0, 0, 0)
ctypes.windll.user32.mouse_event(
0x0004, 0, 0, 0, 0)
def hover_mouse_all(self):
self.game_wincap.update_window_position(border=False)
offsetx = self.game_wincap.window_rect[0] + 534
offsety = self.game_wincap.window_rect[1] + 277
for i in range(4):
for j in range(6):
x = offsetx+j*44
y = offsety+i*44
ctypes.windll.user32.SetCursorPos(x-10, y)
time.sleep(0.03)
ctypes.windll.user32.SetCursorPos(x, y)
time.sleep(0.03)
ctypes.windll.user32.SetCursorPos(x+10, y)
ctypes.windll.user32.SetCursorPos(offsetx, offsety-70)
# ctypes.windll.user32.SetCursorPos(offsetx+610, offsety-10)
def remove_empty(self, screenshot):
non_empty = []
for i in range(4):
for j in range(6):
colour = set(screenshot[i*44, 22+j*44])
if colour != self.empty:
non_empty.append([i, j])
# format will be as follows of return list
# x,y,r,g,b
return non_empty
def identify_rarities_equip(self, rowcol_list, screenshot):
junk = []
for rowcol in rowcol_list:
colour = set(screenshot[rowcol[0]*44, rowcol[1]*44])
if colour == self.rar_none:
junk.append([rowcol[0], rowcol[1]])
elif colour == self.rar_green:
if self.cutoff >= 1:
junk.append([rowcol[0], rowcol[1]])
elif colour == self.rar_green:
if self.cutoff >= 2:
junk.append([rowcol[0], rowcol[1]])
# format will be as follows of return list
# x,y corresponding to row,col
return junk
def identify_items_other(self, rowcol_list, screenshot):
junk = []
for rowcol in rowcol_list:
colour = set(screenshot[rowcol[0]*44, 22+rowcol[1]*44])
if colour in self.junk_list:
junk.append([rowcol[0], rowcol[1]])
# format will be as follows of return list
# x,y corresponding to row,col
return junk
def sell(self, rowcol_list, tab="Other"):
offsetx = self.game_wincap.window_rect[0] + 534
offsety = self.game_wincap.window_rect[1] + 277
for item in rowcol_list:
if tab == "Equipment":
if self.last_row_protect:
if item[0] == 3:
continue
x = offsetx+item[1]*44
y = offsety+item[0]*44
ctypes.windll.user32.SetCursorPos(x, y)
time.sleep(0.1)
ctypes.windll.user32.mouse_event(
0x0008, 0, 0, 0, 0)
time.sleep(0.01)
ctypes.windll.user32.mouse_event(
0x0010, 0, 0, 0, 0)
# Then click a second time to be sure
time.sleep(0.01)
ctypes.windll.user32.mouse_event(
0x0008, 0, 0, 0, 0)
time.sleep(0.01)
ctypes.windll.user32.mouse_event(
0x0010, 0, 0, 0, 0)
def repair(self):
self.game_wincap.update_window_position(border=False)
offsetx = self.game_wincap.window_rect[0] + 534
offsety = self.game_wincap.window_rect[1] + 277
ctypes.windll.user32.SetCursorPos(offsetx-310, offsety+325)
ctypes.windll.user32.mouse_event(
0x0002, 0, 0, 0, 0)
ctypes.windll.user32.mouse_event(
0x0004, 0, 0, 0, 0)
ctypes.windll.user32.SetCursorPos(offsetx+0, offsety+180)
ctypes.windll.user32.mouse_event(
0x0002, 0, 0, 0, 0)
ctypes.windll.user32.mouse_event(
0x0004, 0, 0, 0, 0)
# this is if everything is already repaired
ctypes.windll.user32.SetCursorPos(offsetx+100, offsety+180)
ctypes.windll.user32.mouse_event(
0x0002, 0, 0, 0, 0)
ctypes.windll.user32.mouse_event(
0x0004, 0, 0, 0, 0)
class QuestHandle():
def __init__(self) -> None:
with open("gamename.txt") as f:
gamename = f.readline()
self.game_wincap = WindowCapture(gamename)
self.white_text_filter = HsvFilter(
0, 0, 102, 45, 65, 255, 0, 0, 0, 0)
self.yellow_text_filter = HsvFilter(
16, 71, 234, 33, 202, 255, 0, 0, 0, 0)
self.blue_text_filter = HsvFilter(
83, 126, 85, 102, 255, 255, 0, 0, 0, 0)
self.all_text_filter = HsvFilter(
0, 0, 61, 78, 255, 255, 0, 255, 0, 0)
self.vision = Vision('xprompt67filtv2.jpg')
self.accept_rect = [725, 525, 925, 595]
self.accept_wincap = WindowCapture(gamename, self.accept_rect)
self.skip_rect = [730, 740, 890, 780]
self.skip_wincap = WindowCapture(gamename, self.skip_rect)
self.next_rect = [880, 740, 1040, 780]
self.next_wincap = WindowCapture(gamename, self.next_rect)
self.quest_rect = [310, 160, 1055, 650]
self.quest_wincap = WindowCapture(gamename, self.quest_rect)
self.questlist_rect = [740, 240, 1050, 580]
self.questlist_wincap = WindowCapture(gamename, self.questlist_rect)
self.complete_wincap = WindowCapture(gamename, self.next_rect)
self.xprompt_rect = [1130, 670, 1250, 720]
self.xprompt_wincap = WindowCapture(gamename, self.xprompt_rect)
def start_quest_handle(self):
start_time = time.time()
while time.time() < start_time + 2:
if self.check_for_accept():
break
def convert_and_click(self, x, y, rect):
self.game_wincap.update_window_position(border=False)
truex = int(x + self.game_wincap.window_rect[0] + rect[0])
truey = int(y + self.game_wincap.window_rect[1] + rect[1])
ctypes.windll.user32.SetCursorPos(truex, truey)
ctypes.windll.user32.mouse_event(
0x0002, 0, 0, 0, 0)
ctypes.windll.user32.mouse_event(
0x0004, 0, 0, 0, 0)
def check_for_accept(self):
image = self.accept_wincap.get_screenshot()
image = self.vision.apply_hsv_filter(
image, self.white_text_filter)
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
results = pytesseract.image_to_data(
rgb, output_type=pytesseract.Output.DICT, lang='eng')
detection = False
for i in range(0, len(results["text"])):
if "Accept" in results["text"][i]:
x = results["left"][i] + (results["width"][i]/2)
y = results["top"][i] + (results["height"][i]/2)
self.convert_and_click(x, y, self.accept_rect)
detection = True
break
if not detection:
return self.check_for_skip()
else:
return True
def check_for_skip(self):
image = self.skip_wincap.get_screenshot()
image = self.vision.apply_hsv_filter(
image, self.white_text_filter)
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
results = pytesseract.image_to_data(
rgb, output_type=pytesseract.Output.DICT, lang='eng')
detection = False
for i in range(0, len(results["text"])):
if "Skip" in results["text"][i]:
x = results["left"][i] + (results["width"][i]/2)
y = results["top"][i] + (results["height"][i]/2)
self.convert_and_click(x, y, self.skip_rect)
detection = True
break
if not detection:
return self.check_for_next()
else:
return True
def check_for_next(self):
image = self.next_wincap.get_screenshot()
image = self.vision.apply_hsv_filter(
image, self.white_text_filter)
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
results = pytesseract.image_to_data(
rgb, output_type=pytesseract.Output.DICT, lang='eng')
detection = False
for i in range(0, len(results["text"])):
if "Next" in results["text"][i]:
x = results["left"][i] + (results["width"][i]/2)
y = results["top"][i] + (results["height"][i]/2)
self.convert_and_click(x, y, self.next_rect)
detection = True
break
if not detection:
return self.check_for_quest()
else:
return True
def check_for_quest(self):
image = self.quest_wincap.get_screenshot()
image = self.vision.apply_hsv_filter(
image, self.white_text_filter)
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
tess_config = '--psm 6 --oem 3 -c tessedit_char_whitelist=Quest'
results = pytesseract.image_to_data(
rgb, output_type=pytesseract.Output.DICT, lang='eng', config=tess_config)
detection = False
for i in range(0, len(results["text"])):
if "Quest" in results["text"][i]:
x = results["left"][i] + (results["width"][i]/2)
y = results["top"][i] + (results["height"][i]/2)
self.convert_and_click(x, y, self.quest_rect)
detection = True
break
if not detection:
return self.check_for_questlist()
else:
return True
def check_for_questlist(self):
image = self.questlist_wincap.get_screenshot()
image = self.vision.apply_hsv_filter(
image, self.all_text_filter)
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
results = pytesseract.image_to_data(
rgb, output_type=pytesseract.Output.DICT, lang='eng')
detection = False
for i in range(0, len(results["text"])):
if "LV" in results["text"][i]:
# at this point need to grab the centre of the rect
x = results["left"][i] + (results["width"][i]/2)
y = results["top"][i] + (results["height"][i]/2)
# and then click at this position
self.convert_and_click(x, y, self.questlist_rect)
detection = True
break
if not detection:
return self.check_for_complete()
else:
return True
def check_for_complete(self):
image = self.complete_wincap.get_screenshot()
image = self.vision.apply_hsv_filter(
image, self.white_text_filter)
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
results = pytesseract.image_to_data(
rgb, output_type=pytesseract.Output.DICT, lang='eng')
detection = False
for i in range(0, len(results["text"])):
if "Com" in results["text"][i]:
x = results["left"][i] + (results["width"][i]/2)
y = results["top"][i] + (results["height"][i]/2)
self.convert_and_click(x, y, self.next_rect)
detection = True
break
if not detection:
return self.check_for_xprompt()
else:
return True
def check_for_xprompt(self):
image = self.xprompt_wincap.get_screenshot()
image = self.vision.apply_hsv_filter(
image, self.blue_text_filter)
rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
results = pytesseract.image_to_data(
rgb, output_type=pytesseract.Output.DICT, lang='eng')
detection = False
for i in range(0, len(results["text"])):
if "Press" in results["text"][i]:
pydirectinput.keyDown("x")
time.sleep(0.1)
pydirectinput.keyUp("x")
detection = True
break
if not detection:
return False
else:
return True
class Follower():
def __init__(self) -> None:
self.pressed_keys = []
self.relx = 0
self.rely = 0
def navigate_towards(self, x, y):
self.relx = x
self.rely = y
if self.relx > 1:
# Check if opposite key held down
if "left" in self.pressed_keys:
self.pressed_keys.remove("left")
CustomInput.release_key(CustomInput.key_map["left"], "left")
# Check that not already being held down
if "right" not in self.pressed_keys:
self.pressed_keys.append("right")
# Hold the key down
CustomInput.press_key(CustomInput.key_map["right"], "right")
elif self.relx < -1:
# Check if opposite key held down
if "right" in self.pressed_keys:
self.pressed_keys.remove("right")
CustomInput.release_key(CustomInput.key_map["right"], "right")
# Check that not already being held down
if "left" not in self.pressed_keys:
self.pressed_keys.append("left")
# Hold the key down
CustomInput.press_key(CustomInput.key_map["left"], "left")
else:
# Handling for case where = 0, need to remove both keys
if "right" in self.pressed_keys:
self.pressed_keys.remove("right")
CustomInput.release_key(CustomInput.key_map["right"], "right")
if "left" in self.pressed_keys:
self.pressed_keys.remove("left")
CustomInput.release_key(CustomInput.key_map["left"], "left")
# Handling for y-dir next
if self.rely > 1:
# Check if opposite key held down
if "down" in self.pressed_keys:
self.pressed_keys.remove("down")
CustomInput.release_key(CustomInput.key_map["down"], "down")
# Check that not already being held down
if "up" not in self.pressed_keys:
self.pressed_keys.append("up")
# Hold the key down
CustomInput.press_key(CustomInput.key_map["up"], "up")
elif self.rely < -1:
# Check if opposite key held down
if "up" in self.pressed_keys:
self.pressed_keys.remove("up")
CustomInput.release_key(CustomInput.key_map["up"], "up")
# Check that not already being held down
if "down" not in self.pressed_keys:
self.pressed_keys.append("down")
# Hold the key down
CustomInput.press_key(CustomInput.key_map["down"], "down")
else:
# Handling for case where = 0, need to remove both keys
if "up" in self.pressed_keys:
self.pressed_keys.remove("up")
CustomInput.release_key(CustomInput.key_map["up"], "up")
if "down" in self.pressed_keys:
self.pressed_keys.remove("down")
CustomInput.release_key(CustomInput.key_map["down"], "down")
if __name__ == "__main__":
time.sleep(2)
with open("gamename.txt") as f:
gamename = f.readline()
# start = time.time()
# BotUtils.detect_xprompt(gamename)
# print("Time taken: {}s".format(time.time()-start))
BotUtils.close_map_and_menu(gamename)
| StarcoderdataPython |
6551826 | <gh_stars>1-10
""" A workbench. """
# Standard library imports.
import six.moves.cPickle
import logging
import os
# Enthought library imports.
from traits.etsconfig.api import ETSConfig
from pyface.api import NO
from traits.api import Bool, Callable, Event, HasTraits, provides
from traits.api import Instance, List, Unicode, Vetoable
from traits.api import VetoableEvent
# Local imports.
from .i_editor_manager import IEditorManager
from .i_workbench import IWorkbench
from .user_perspective_manager import UserPerspectiveManager
from .workbench_window import WorkbenchWindow
from .window_event import WindowEvent, VetoableWindowEvent
# Logging.
logger = logging.getLogger(__name__)
@provides(IWorkbench)
class Workbench(HasTraits):
""" A workbench.
There is exactly *one* workbench per application. The workbench can create
any number of workbench windows.
"""
#### 'IWorkbench' interface ###############################################
# The active workbench window (the last one to get focus).
active_window = Instance(WorkbenchWindow)
# The editor manager is used to create/restore editors.
editor_manager = Instance(IEditorManager)
# The optional application scripting manager.
script_manager = Instance('apptools.appscripting.api.IScriptManager')
# A directory on the local file system that we can read and write to at
# will. This is used to persist window layout information, etc.
state_location = Unicode
# The optional undo manager.
undo_manager = Instance('apptools.undo.api.IUndoManager')
# The user-defined perspectives manager.
user_perspective_manager = Instance(UserPerspectiveManager)
# All of the workbench windows created by the workbench.
windows = List(WorkbenchWindow)
#### Workbench lifecycle events ###########################################
# Fired when the workbench is about to exit.
#
# This can be caused by either:-
#
# a) The 'exit' method being called.
# b) The last open window being closed.
#
exiting = VetoableEvent
# Fired when the workbench has exited.
exited = Event
#### Window lifecycle events ##############################################
# Fired when a workbench window has been created.
window_created = Event(WindowEvent)
# Fired when a workbench window is opening.
window_opening = Event(VetoableWindowEvent)
# Fired when a workbench window has been opened.
window_opened = Event(WindowEvent)
# Fired when a workbench window is closing.
window_closing = Event(VetoableWindowEvent)
# Fired when a workbench window has been closed.
window_closed = Event(WindowEvent)
#### 'Workbench' interface ################################################
# The factory that is used to create workbench windows. This is used in
# the default implementation of 'create_window'. If you override that
# method then you obviously don't need to set this trait!
window_factory = Callable
#### Private interface ####################################################
# An 'explicit' exit is when the the 'exit' method is called.
# An 'implicit' exit is when the user closes the last open window.
_explicit_exit = Bool(False)
###########################################################################
# 'IWorkbench' interface.
###########################################################################
def create_window(self, **kw):
""" Factory method that creates a new workbench window. """
window = self.window_factory(workbench=self, **kw)
# Add on any user-defined perspectives.
window.perspectives.extend(self.user_perspective_manager.perspectives)
# Restore the saved window memento (if there is one).
self._restore_window_layout(window)
# Listen for the window being activated/opened/closed etc. Activated in
# this context means 'gets the focus'.
#
# NOTE: 'activated' is not fired on a window when the window first
# opens and gets focus. It is only fired when the window comes from
# lower in the stack to be the active window.
window.on_trait_change(self._on_window_activated, 'activated')
window.on_trait_change(self._on_window_opening, 'opening')
window.on_trait_change(self._on_window_opened, 'opened')
window.on_trait_change(self._on_window_closing, 'closing')
window.on_trait_change(self._on_window_closed, 'closed')
# Event notification.
self.window_created = WindowEvent(window=window)
return window
def exit(self):
""" Exits the workbench.
This closes all open workbench windows.
This method is not called when the user clicks the close icon. Nor when
they do an Alt+F4 in Windows. It is only called when the application
menu File->Exit item is selected.
Returns True if the exit succeeded, False if it was vetoed.
"""
logger.debug('**** exiting the workbench ****')
# Event notification.
self.exiting = event = Vetoable()
if not event.veto:
# This flag is checked in '_on_window_closing' to see what kind of
# exit is being performed.
self._explicit_exit = True
if len(self.windows) > 0:
exited = self._close_all_windows()
# The degenerate case where no workbench windows have ever been
# created!
else:
# Trait notification.
self.exited = self
exited = True
# Whether the exit succeeded or not, we are no longer in the
# process of exiting!
self._explicit_exit = False
else:
exited = False
if not exited:
logger.debug('**** exit of the workbench vetoed ****')
return exited
#### Convenience methods on the active window #############################
def edit(self, obj, kind=None, use_existing=True):
""" Edit an object in the active workbench window. """
return self.active_window.edit(obj, kind, use_existing)
def get_editor(self, obj, kind=None):
""" Return the editor that is editing an object.
Returns None if no such editor exists.
"""
if self.active_window is None:
return None
return self.active_window.get_editor(obj, kind)
def get_editor_by_id(self, id):
""" Return the editor with the specified Id.
Returns None if no such editor exists.
"""
return self.active_window.get_editor_by_id(id)
#### Message dialogs ####
def confirm(self, message, title=None, cancel=False, default=NO):
""" Convenience method to show a confirmation dialog. """
return self.active_window.confirm(message, title, cancel, default)
def information(self, message, title='Information'):
""" Convenience method to show an information message dialog. """
return self.active_window.information(message, title)
def warning(self, message, title='Warning'):
""" Convenience method to show a warning message dialog. """
return self.active_window.warning(message, title)
def error(self, message, title='Error'):
""" Convenience method to show an error message dialog. """
return self.active_window.error(message, title)
###########################################################################
# 'Workbench' interface.
###########################################################################
#### Initializers #########################################################
def _state_location_default(self):
""" Trait initializer. """
# It would be preferable to base this on GUI.state_location.
state_location = os.path.join(
ETSConfig.application_home,
'pyface',
'workbench',
ETSConfig.toolkit
)
if not os.path.exists(state_location):
os.makedirs(state_location)
logger.debug('workbench state location is %s', state_location)
return state_location
def _undo_manager_default(self):
""" Trait initializer. """
# We make sure the undo package is entirely optional.
try:
from apptools.undo.api import UndoManager
except ImportError:
return None
return UndoManager()
def _user_perspective_manager_default(self):
""" Trait initializer. """
return UserPerspectiveManager(state_location=self.state_location)
###########################################################################
# Protected 'Workbench' interface.
###########################################################################
def _create_window(self, **kw):
""" Factory method that creates a new workbench window. """
raise NotImplementedError
###########################################################################
# Private interface.
###########################################################################
def _close_all_windows(self):
""" Closes all open windows.
Returns True if all windows were closed, False if the user changed
their mind ;^)
"""
# We take a copy of the windows list because as windows are closed
# they are removed from it!
windows = self.windows[:]
windows.reverse()
for window in windows:
# We give the user chance to cancel the exit as each window is
# closed.
if not window.close():
all_closed = False
break
else:
all_closed = True
return all_closed
def _restore_window_layout(self, window):
""" Restore the window layout. """
filename = os.path.join(self.state_location, 'window_memento')
if os.path.exists(filename):
try:
# If the memento class itself has been modified then there
# is a chance that the unpickle will fail. If so then we just
# carry on as if there was no memento!
f = open(filename, 'rb')
memento = six.moves.cPickle.load(f)
f.close()
# The memento doesn't actually get used until the window is
# opened, so there is nothing to go wrong in this step!
window.set_memento(memento)
# If *anything* goes wrong then simply log the error and carry on
# with no memento!
except:
logger.exception('restoring window layout from %s', filename)
return
def _save_window_layout(self, window):
""" Save the window layout. """
# Save the window layout.
f = open(os.path.join(self.state_location, 'window_memento'), 'wb')
six.moves.cPickle.dump(window.get_memento(), f)
f.close()
return
#### Trait change handlers ################################################
def _on_window_activated(self, window, trait_name, event):
""" Dynamic trait change handler. """
logger.debug('window %s activated', window)
self.active_window = window
return
def _on_window_opening(self, window, trait_name, event):
""" Dynamic trait change handler. """
# Event notification.
self.window_opening = window_event = VetoableWindowEvent(window=window)
if window_event.veto:
event.veto = True
return
def _on_window_opened(self, window, trait_name, event):
""" Dynamic trait change handler. """
# We maintain a list of all open windows so that (amongst other things)
# we can detect when the user is attempting to close the last one.
self.windows.append(window)
# This is necessary because the activated event is not fired when a
# window is first opened and gets focus. It is only fired when the
# window comes from lower in the stack to be the active window.
self.active_window = window
# Event notification.
self.window_opened = WindowEvent(window=window)
return
def _on_window_closing(self, window, trait_name, event):
""" Dynamic trait change handler. """
# Event notification.
self.window_closing = window_event = VetoableWindowEvent(window=window)
if window_event.veto:
event.veto = True
else:
# Is this the last open window?
if len(self.windows) == 1:
# If this is an 'implicit exit' then make sure that we fire the
# appropriate workbench lifecycle events.
if not self._explicit_exit:
# Event notification.
self.exiting = window_event = Vetoable()
if window_event.veto:
event.veto = True
if not event.veto:
# Save the window size, position and layout.
self._save_window_layout(window)
return
def _on_window_closed(self, window, trait_name, event):
""" Dynamic trait change handler. """
self.windows.remove(window)
# Event notification.
self.window_closed = WindowEvent(window=window)
# Was this the last window?
if len(self.windows) == 0:
# Event notification.
self.exited = self
return
#### EOF ######################################################################
| StarcoderdataPython |
332292 | #Special Pythagorean triplet
def Euler9(sum):
for a in range(1,sum):
for b in range(1,sum):
c=sum-a-b
#print(str(a)+'\t\t'+str(b)+'\t\t'+str(c))
if (a*a+b*b)==(c*c):
return (a,b,c,a*b*c)
for i in range(1000,1001):
print(str(i)+'\t\t'+str(Euler9(i))) | StarcoderdataPython |
181311 | import logging
from typing import Dict
from threading import Lock
from prometheus_network_exporter.devices.basedevice import Device
__version__ = "1.1.2"
GLOBAL_GUARD: Lock = Lock()
CONNECTION_POOL: Dict[str, Device] = {}
COUNTER_DIR = ".tmp"
MAX_WAIT_SECONDS_BEFORE_SHUTDOWN = 60
MAX_WORKERS = 90
APP_LOGGER = logging.getLogger("network_exporter")
APP_LOGGER.setLevel(logging.INFO)
| StarcoderdataPython |
3207773 | <gh_stars>0
flowers = ['Lily', 'Snapdragon', 'Rose', 'Tulip']
# large_flowers = ['a large ' + f for f in flowers]
# print(large_flowers)
large_flowers = list()
for f in flowers:
large_flowers.append('a large ' + f)
# print(large_flowers)
family = { 'mother': 'Margaret', 'father': 'Reginald', 'sister': 'Jenny'}
my_family = {'my ' + k + ' is ' + v for (k,v) in family.items()}
# print(my_family)
possible_ratings = set(range(100))
funky_ratings = {r/2 for r in possible_ratings}
# print(funky_ratings) | StarcoderdataPython |
5051933 | # Generated by Django 3.1.3 on 2020-11-17 15:20
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('equipments', '0007_auto_20201117_1457'),
]
operations = [
migrations.RemoveField(
model_name='connection',
name='after',
),
migrations.AddField(
model_name='connection',
name='direction',
field=models.CharField(choices=[('left', 'Entrada'), ('right', 'Saída'), ('exchange', 'Bi-direcional')], default='left', max_length=8, verbose_name='Direção do Tráfego'),
),
migrations.AlterField(
model_name='connection',
name='before',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='connection', to='equipments.equipment'),
),
]
| StarcoderdataPython |
9710797 | <reponame>strzelcu/vehicletyperecognizer<gh_stars>0
import argparse
import datetime
import os
import sys
from configparser import RawConfigParser
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
from imutils import paths
from sklearn.metrics import accuracy_score
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.preprocessing import LabelEncoder
sys.path.insert(0, os.getcwd())
from preprocessing.simplepreprocessor import SimplePreprocessor
from datasetloading.simpledatasetloader import SimpleDatasetLoader
# Construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-d", "--dataset", required=True, help="path to input dataset")
ap.add_argument("-k", "--neighbors", type=int, default=1, help="# of nearest neighbors for classification")
ap.add_argument("-j", "--jobs", type=int, default=-1, help="# of jobs for k-NN distance (-1 uses all available cores)")
args = vars(ap.parse_args())
NEIGHBORS = args['neighbors']
# Parse config file
config = RawConfigParser()
properties_file = Path("resources/project.properties")
if not properties_file.exists():
properties_file = Path("resources/default.properties")
config.read(properties_file.absolute(), encoding="utf-8")
# Prepare variables
verbose_checkpoint = int(config.get("ImageDatasetLoad", "image.verbose"))
image_size = int(config.get("ImagePreprocess", "image.size"))
# Grab the list of images that we'll be describing
print("[INFO] Start of processing at {}".format(datetime.datetime.now()))
print("[INFO] loading images...")
imagePaths = list(paths.list_images(args["dataset"]))
# Initialize the image preprocessor, load the dataset from disk and reshape the data matrix
sp = SimplePreprocessor(image_size, image_size)
sdl = SimpleDatasetLoader(preprocessors=[sp])
(data, labels) = sdl.load(imagePaths, verbose=verbose_checkpoint)
data = data.reshape((data.shape[0], (image_size * image_size * 3)))
# Show some information on memory consumption of the images
print("[INFO] features matrix: {:.1f}MB".format(data.nbytes / (1024 * 1000.0)))
# Encode the labels as integers
le = LabelEncoder()
labels = le.fit_transform(labels)
# Partition the data into training and testing splits using 75%
# of the data for training and the remaining 25% for testing
(trainX, testX, trainY, testY) = train_test_split(data, labels, test_size=0.25, random_state=42)
# Train and evaluate a k-NN classifier on the raw pixel intensities
print("[INFO] {} evaluating k-NN classifier for {} nearest neighbors...".format(datetime.datetime.now(), NEIGHBORS))
error_rate = []
score_rate = []
for i in range(1, NEIGHBORS+1):
print("[INFO] {} Start of processing iteration {}".format(datetime.datetime.now(), i))
model = KNeighborsClassifier(n_neighbors=i, n_jobs=args["jobs"])
model.fit(trainX, trainY)
predY = model.predict(testX)
error_rate.append(np.mean(predY != testY))
score_rate.append(accuracy_score(testY, predY))
print(classification_report(testY, predY, target_names=le.classes_))
print(accuracy_score(testY, predY))
print(confusion_matrix(testY, predY))
print("[INFO] {} Finish of processing iteration {}".format(datetime.datetime.now(), i))
plt.figure(figsize=(10, 6))
plt.plot(range(0, NEIGHBORS), error_rate, color='blue', linestyle='dashed', marker='o',
markerfacecolor='red', markersize=10)
plt.xticks(range(0, NEIGHBORS))
plt.title('Error Rate vs. K Value')
plt.xlabel('K')
plt.ylabel('Error Rate')
plt.show()
plt.figure(figsize=(10, 6))
plt.plot(range(0, NEIGHBORS), score_rate, color='blue', linestyle='dashed', marker='o',
markerfacecolor='red', markersize=10)
plt.xticks(range(0, NEIGHBORS))
plt.title('Score Rate vs. K Value')
plt.xlabel('K')
plt.ylabel('Score Rate')
plt.show()
print("[INFO] Finish of processing at {}".format(datetime.datetime.now()))
| StarcoderdataPython |
1832210 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'graph.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
from pyqtgraph import PlotWidget, plot
import pyqtgraph as pg
import pyqtgraph.exporters
from givecolumns import *
class Ui_showGraph(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("Ratio/Time")
MainWindow.resize(800, 600)
MainWindow.setMinimumSize(QtCore.QSize(520, 600))
palette = QtGui.QPalette()
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(58, 58, 58))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(58, 58, 58))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
brush = QtGui.QBrush(QtGui.QColor(58, 58, 58))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
brush = QtGui.QBrush(QtGui.QColor(58, 58, 58))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
MainWindow.setPalette(palette)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("moxa_main.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.scrollArea = QtWidgets.QScrollArea(self.centralwidget)
self.scrollArea.setFrameShape(QtWidgets.QFrame.NoFrame)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 780, 539))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.gridLayout_2 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents)
self.gridLayout_2.setObjectName("gridLayout_2")
self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents)
palette = QtGui.QPalette()
brush = QtGui.QBrush(QtGui.QColor(255, 85, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255, 128))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.PlaceholderText, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 85, 0))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255, 128))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.PlaceholderText, brush)
brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128))
brush.setStyle(QtCore.Qt.SolidPattern)
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.PlaceholderText, brush)
self.label.setPalette(palette)
font = QtGui.QFont()
font.setFamily("Stereofunk")
font.setPointSize(30)
self.label.setFont(font)
self.label.setObjectName("label")
self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.gridLayout.addWidget(self.scrollArea, 0, 0, 1, 1)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.gridLayout.addWidget(self.scrollArea, 0, 0, 1, 1)
self.graphWidget = pg.PlotWidget()
self.graphWidget_2 = pg.PlotWidget()
self.gridLayout.addWidget(self.graphWidget)
self.gridLayout.addWidget(self.graphWidget_2)
self.graphWidget.setBackground('#000000')
self.graphWidget_2.setBackground('#000000')
self.graphWidget.showGrid(x=True, y=True)
self.graphWidget_2.showGrid(x=True, y=True)
styles = {'color':'#ffffff', 'font-size':'12px'}
self.graphWidget.setLabel('left', 'mask', **styles)
self.graphWidget.setLabel('bottom', 'no mask', **styles)
self.graphWidget_2.setLabel('left', 'ratio', **styles)
self.graphWidget_2.setLabel('bottom', 'time', **styles)
# generate something to export
self.graphWidget_2.plot(time , ratio)
self.graphWidget.plot(nomask, mask)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("Analytics", "Analytics"))
self.label.setText(_translate("Analytics", "Graphs:"))
# if __name__ == "__main__":
# import sys
# app = QtWidgets.QApplication(sys.argv)
# MainWindow = QtWidgets.QMainWindow()
# ui = Ui_showGraph()
# ui.setupUi(MainWindow)
# sys.exit(app.exec_())
| StarcoderdataPython |
6481430 | <reponame>pgfeldman/RCSNN
from rcsnn.base.BaseController import BaseController
from rcsnn.base.DataDictionary import DataDictionary
from rcsnn.base.CommandObject import CommandObject
from rcsnn.base.Commands import Commands
from rcsnn.base.ResponseObject import ResponseObject
from rcsnn.base.Responses import Responses
from rcsnn.base.States import States
from rcsnn.base.DataDictionary import DataDictionary, DictionaryEntry, DictionaryTypes
import random
class CruiserController(BaseController):
target_pos:DictionaryEntry
missile_cmd_obj:CommandObject
nav_cmd_obj:CommandObject
missile_rsp_obj:ResponseObject
nav_rsp_obj:ResponseObject
def __init__(self, name: str, ddict: DataDictionary):
super().__init__(name, ddict)
self.heading = DictionaryEntry("target_pos", DictionaryTypes.LIST, [(0, 0), (1, 1)])
self.ddict.add_entry(self.heading)
def pre_process(self):
self.nav_cmd_obj = self.ddict.get_entry("CMD_ship-controller_to_navigate-controller").data
self.missile_cmd_obj = self.ddict.get_entry("CMD_ship-controller_to_missile-controller").data
self.nav_rsp_obj = self.ddict.get_entry("RSP_navigate-controller_to_ship-controller").data
self.missile_rsp_obj = self.ddict.get_entry("RSP_missile-controller_to_ship-controller").data
def run_task(self):
# S0: ask MissileControler how far away a 90% accuracy shot is
# S1: Plot a destination and ask the NavigateController for the time to reach
# S3: Jump forward in time and ask the MissileController to fire a missile and if it hit
# S4: Evaluate and re-fire as needed
# S5: Report back success or failure
print("{} run_task(): elapsed = {})".format(self.name, self.elapsed))
if self.cur_state == States.NEW_COMMAND:
print("{} is running".format(self.name))
self.nav_cmd_obj.set(Commands.MOVE_TO_TARGET, self.nav_cmd_obj.next_serial())
self.target_ships()
self.cur_state = States.S0
self.elapsed = 0
self.rsp.set(Responses.EXECUTING, self.cmd.serial)
elif self.cur_state == States.S0 and self.nav_rsp_obj.get() == Responses.DONE:
self.cur_state = States.S1
self.missile_cmd_obj.set(Commands.TARGET_SHIPS, self.missile_cmd_obj.next_serial())
elif self.cur_state == States.S1 and self.nav_rsp_obj.get() == Responses.DONE:
self.cur_state = States.NOP
self.rsp.set(Responses.DONE, self.cmd.serial)
def target_ships(self):
scalar = 10
self.heading.data = [
((random.random()-0.5) * scalar, (random.random()-0.5) * scalar),
((random.random()-0.5) * scalar, (random.random()-0.5) * scalar)
] | StarcoderdataPython |
3542168 | <reponame>CodedLadiesInnovateTech/-python-challenge-solutions
# program to create a bytearray from a lis
print()
nums = [10, 20, 56, 35, 17, 99]
# Create bytearray from list of integers.
values = bytearray(nums)
for x in values: print(x)
print()
| StarcoderdataPython |
9712644 | <filename>nba/baseclient.py
import requests
from requests.adapters import HTTPAdapter
class BaseClient(object):
def __init__(self):
self.url = "http://stats.nba.com/stats/"
self.session = requests.Session()
self.session.mount("http://stats.nba.com", HTTPAdapter(max_retries=1))
self.current_season = "2019-20"
@property
def headers(self):
"""Set headers to be used in API requests."""
return {
"Content-Type": "application/json",
"User-Agent": (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
"AppleWebKit/537.36 (KHTML, like Gecko)"
"Chrome/81.0.4044.129 Safari/537.36"
),
"Host": "stats.nba.com",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8",
"x-nba-stats-origin": "stats",
"x-nba-stats-token": "true",
}
| StarcoderdataPython |
6530834 | <gh_stars>1-10
from django import forms
from dicoms.models import Search, Session, Series
from os.path import basename, normpath
from django.utils.translation import ugettext_lazy as _
from bootstrap_datepicker_plus import DatePickerInput
from drf_braces.serializers.form_serializer import FormSerializer
import json
class SearchForm(forms.ModelForm):
class Meta:
model = Search
fields = "__all__"
labels = {
'subject_search': _('Patient ID'),
'study_search': _('Study Description'),
'date_range_alpha': _('Start date'),
'date_range_omega': _('End date')
}
help_texts = {
'date_range_alpha': _('Enter study start date in format YYYY-MM-DD (Not required)'),
'date_range_omega': _('Enter study end date in format YYYY-MM-DD (Not required)'),
'multi_search': _('Search for multiple subjects by uploading a .txt file with one patient ID per line')
}
widgets = {
'date_range_alpha': DatePickerInput(format='%Y-%m-%d'),
'date_range_omega': DatePickerInput(format='%Y-%m-%d')
}
class SerializedSearchForm(FormSerializer):
class Meta(object):
form = SearchForm
def make_conversion_form(session_id):
"""
This is a form class generator, but I'm not sure if it's the best way to make dynamic
forms.
I'm going to attempt to create a dynamic form more directly below in
ConversionForm2
:param session_id:
:return:
"""
if Series.objects.filter(Session=session_id).exists():
series_from_session = Series.objects.filter(Session=session_id)
# loading choices for scan types from bidspec
with open("dicoms/static/jss/bids_spec.json") as infile:
bidspec = json.load(infile)
scan_choices = bidspec['anat'] + bidspec['func'] + bidspec['fmap']
scan_choices.sort()
# creating a tuple list to pass to our form's select widget
# django requires a tuple so we're making one
tuple_scan_choices = [(scan, scan) for scan in scan_choices]
fields = {}
list_of_series = []
# cleaning up path to get last dir/series name
for each in series_from_session:
list_of_series.append(each.Path)
cleaned_series = [basename(normpath(single_series)) for single_series in list_of_series]
cleaned_series_set = set(cleaned_series)
cleaned_series = list(cleaned_series_set)
for series in cleaned_series:
fields[series] = forms.Select(choices=tuple_scan_choices)
return type("ConversionForm", (forms.BaseForm,), {'base_fields': fields})
else:
return None
class ConversionForm2(forms.Form):
name = forms.CharField(max_length=255)
def __init__(self, session):
super(ConversionForm2, self).__init__(session)
series_from_session = Series.objects.filter(Session=session)
bidspec = json.load(open("dicoms/bids_spec.json"))
scan_choices = bidspec['anat'] + bidspec['func'] + bidspec['fmap']
scan_choices.sort()
# creating a tuple list to pass to our form's select widget
# django requires a tuple so we're making one
tuple_scan_choices = [(scan, scan) for scan in scan_choices]
fields = {}
list_of_series = []
# cleaning up path to get last dir/series name
for each in series_from_session:
list_of_series.append(each.Path)
cleaned_series = [basename(normpath(single_series)) for single_series in list_of_series]
cleaned_series_set = set(cleaned_series)
cleaned_series = list(cleaned_series_set)
# for series in cleaned_series:
# fields[series] = forms.Select(tuple_scan_choices)
# self.fields = fields
| StarcoderdataPython |
5155537 | # *****************************************************************************
# © Copyright IBM Corp. 2018. All Rights Reserved.
#
# This program and the accompanying materials
# are made available under the terms of the Apache V2.0 license
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
#
# *****************************************************************************
import datetime as dt
import json
import pandas as pd
import numpy as np
import logging
from sqlalchemy import Column, Integer, String, Float, DateTime, Boolean, func
from iotfunctions.base import BaseTransformer
from iotfunctions.metadata import EntityType
from iotfunctions.db import Database
from iotfunctions import ui
from iotfunctions.enginelog import EngineLogging
EngineLogging.configure_console_logging(logging.DEBUG)
'''
You can test functions locally before registering them on the server to
understand how they work.
In this script I am using a function from iotfunctions, but you can
do this with any function derived from the iotfunctions base classes.
'''
with open('credentials_as_dev.json', encoding='utf-8') as F:
credentials = json.loads(F.read())
db_schema = None
db = Database(credentials=credentials)
'''
Import and instantiate the functions to be tested
The local test will generate data instead of using server data.
By default it will assume that the input data items are numeric.
Required data items will be inferred from the function inputs.
The function below executes an expression involving a column called x1
The local test function will generate data dataframe containing the column x1
By default test results are written to a file named df_test_entity_for_<function_name>
This file will be written to the working directory.
'''
from iotfunctions.bif import AlertExpression
fn = AlertExpression(expression='df["x1"] > 1', alert_name='is_high_x1')
fn.execute_local_test(db=db, db_schema=db_schema)
from iotfunctions.bif import DateDifference
fn = DateDifference(date_1='d1', date_2='d2', num_days='difference')
'''
This function requires date imputs. To indicate that the function should
be tested using date inputs declare two date columns as below.
'''
fn.execute_local_test(columns=[Column('d1', DateTime), Column('d2', DateTime)])
'''
If the function that you are testing requires assess to server resources,
pass a Database object
'''
from iotfunctions.bif import SaveCosDataFrame
fn = SaveCosDataFrame(filename='test_df_write', columns=['x1', 'x2'], output_item='wrote_df')
fn.execute_local_test(db=db, db_schema=db_schema)
| StarcoderdataPython |
1651433 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
1634 = 14 + 64 + 34 + 44
8208 = 84 + 24 + 04 + 84
9474 = 94 + 44 + 74 + 44
As 1 = 14 is not a sum it is not included.
The sum of these numbers is 1634 + 8208 + 9474 = 19316.
Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.
"""
import math
def main():
power = 5
result = 0
for n in range(2, 1000000):
if n == sum([math.pow(int(x), power) for x in str(n)]):
print n
result += n
print result
if __name__ == '__main__':
main()
| StarcoderdataPython |
3555311 | import warnings
warnings.simplefilter(action="ignore", category=FutureWarning)
import osmnx as ox
import pandas as pd
import numpy as np
import geopandas as gpd
import networkx as nx
import math
from math import sqrt
import ast
import functools
from shapely.geometry import Point, LineString
pd.set_option("display.precision", 3)
pd.options.mode.chained_assignment = None
from .utilities import *
from .angles import angle_line_geometries
## Obtaining graphs ###############
def graph_fromGDF(nodes_gdf, edges_gdf, nodeID = "nodeID"):
"""
From two GeoDataFrames (nodes and edges), it creates a NetworkX undirected Graph.
Parameters
----------
nodes_gdf: Point GeoDataFrame
nodes (junctions) GeoDataFrame
edges_gdf: LineString GeoDataFrame
street segments GeoDataFrame
nodeID: str
column name that indicates the node identifier column (if different from "nodeID")
Returns
-------
G: NetworkX.Graph
the undirected street network graph
"""
nodes_gdf.set_index(nodeID, drop = False, inplace = True, append = False)
nodes_gdf.index.name = None
G = nx.Graph()
G.add_nodes_from(nodes_gdf.index)
attributes = nodes_gdf.to_dict()
# ignore fields containing values of type list
a = (nodes_gdf.applymap(type) == list).sum()
if len(a[a>0]):
to_ignore = a[a>0].index[0]
else:
to_ignore = []
for attribute_name in nodes_gdf.columns:
if attribute_name in to_ignore:
continue
# only add this attribute to nodes which have a non-null value for it
else:
attribute_values = {k: v for k, v in attributes[attribute_name].items() if pd.notnull(v)}
nx.set_node_attributes(G, name=attribute_name, values=attribute_values)
# add the edges and attributes that are not u, v (as they're added separately) or null
for _, row in edges_gdf.iterrows():
attrs = {}
for label, value in row.iteritems():
if (label not in ['u', 'v']) and (isinstance(value, list) or pd.notnull(value)):
attrs[label] = value
G.add_edge(row['u'], row['v'], **attrs)
return G
def multiGraph_fromGDF(nodes_gdf, edges_gdf, nodeIDcolumn):
"""
From two GeoDataFrames (nodes and edges), it creates a NetworkX.MultiGraph.
Parameters
----------
nodes_gdf: Point GeoDataFrame
nodes (junctions) GeoDataFrame
edges_gdf: LineString GeoDataFrame
street segments GeoDataFrame
nodeIDcolumn: string
column name that indicates the node identifier column.
Returns
-------
G: NetworkX.MultiGraph
the street network graph
"""
nodes_gdf.set_index(nodeIDcolumn, drop = False, inplace = True, append = False)
nodes_gdf.index.name = None
Mg = nx.MultiGraph()
Mg.add_nodes_from(nodes_gdf.index)
attributes = nodes_gdf.to_dict()
a = (nodes_gdf.applymap(type) == list).sum()
if len(a[a>0]):
to_ignore = a[a>0].index[0]
else: to_ignore = []
for attribute_name in nodes_gdf.columns:
if attribute_name in to_ignore:
continue
# only add this attribute to nodes which have a non-null value for it
attribute_values = {k:v for k, v in attributes[attribute_name].items() if pd.notnull(v)}
nx.set_node_attributes(Mg, name=attribute_name, values=attribute_values)
# add the edges and attributes that are not u, v, key (as they're added separately) or null
for _, row in edges_gdf.iterrows():
attrs = {}
for label, value in row.iteritems():
if (label not in ['u', 'v', 'key']) and (isinstance(value, list) or pd.notnull(value)):
attrs[label] = value
Mg.add_edge(row['u'], row['v'], key=row['key'], **attrs)
return Mg
## Building geo-dataframes for dual graph representation ###############
def dual_gdf(nodes_gdf, edges_gdf, epsg, oneway = False, angle = None):
"""
It creates two dataframes that are later exploited to generate the dual graph of a street network. The nodes_dual gdf contains edges
centroids; the edges_dual gdf, instead, contains links between the street segment centroids. Those dual edges link real street segments
that share a junction. The centroids are stored with the original edge edgeID, while the dual edges are associated with several
attributes computed on the original street segments (distance between centroids, deflection angle).
Parameters
----------
nodes_gdf: Point GeoDataFrame
nodes (junctions) GeoDataFrame
edges_gdf: LineString GeoDataFrame
street segments GeoDataFrame
epsg: int
epsg of the area considered
oneway: boolean
if true, the function takes into account the direction and therefore it may ignore certain links whereby vehichular movement is not allowed in a certain direction
angle: string {'degree', 'radians'}
it indicates how to express the angle of deflection
Returns
-------
nodes_dual, edges_dual: tuple of GeoDataFrames
the dual nodes and edges GeoDataFrames
"""
if list(edges_gdf.index.values) != list(edges_gdf.edgeID.values):
edges_gdf.index = edges_gdf.edgeID
edges_gdf.index.name = None
# computing centroids
centroids_gdf = edges_gdf.copy()
centroids_gdf['centroid'] = centroids_gdf['geometry'].centroid
centroids_gdf['intersecting'] = None
# find_intersecting segments and storing them in the centroids gdf
centroids_gdf['intersecting'] = centroids_gdf.apply(lambda row: list(centroids_gdf.loc[(centroids_gdf['u'] == row['u'])|(centroids_gdf['u'] == row['v'])|
(centroids_gdf['v'] == row['v'])|(centroids_gdf['v'] == row['u'])].index), axis=1)
if oneway:
centroids_gdf['intersecting'] = centroids_gdf.apply(lambda row: list(centroids_gdf.loc[(centroids_gdf['u'] == row['v']) | ((centroids_gdf['v'] == row['v']) & (centroids_gdf['oneway'] == 0))].index)
if row['oneway'] == 1 else list(centroids_gdf.loc[(centroids_gdf['u'] == row['v']) | ((centroids_gdf['v'] == row['v']) & (centroids_gdf['oneway'] == 0)) |
(centroids_gdf['u'] == row['u']) | ((centroids_gdf['v'] == row['u']) & (centroids_gdf['oneway'] == 0))].index), axis = 1)
# creating vertexes representing street segments (centroids)
centroids_data = centroids_gdf.drop(['geometry', 'centroid'], axis = 1)
if epsg is None:
crs = nodes_gdf.crs
else: crs = {'init': 'epsg:' + str(epsg)}
nodes_dual = gpd.GeoDataFrame(centroids_data, crs=crs, geometry=centroids_gdf['centroid'])
nodes_dual['x'], nodes_dual['y'] = [x.coords.xy[0][0] for x in centroids_gdf['centroid']],[y.coords.xy[1][0] for y in centroids_gdf['centroid']]
nodes_dual.index = nodes_dual.edgeID
nodes_dual.index.name = None
# creating fictious links between centroids
edges_dual = pd.DataFrame(columns=['u','v', 'geometry', 'length'])
ix_length = nodes_dual.columns.get_loc('length')+1
ix_intersecting = nodes_dual.columns.get_loc('intersecting')+1
ix_geo = nodes_dual.columns.get_loc('geometry')+1
# connecting nodes which represent street segments share a linked in the actual street network
processed = []
for row in nodes_dual.itertuples():
# intersecting segments: # i is the edgeID
for intersecting in row[ix_intersecting]:
if ((row.Index == intersecting) | ((row.Index, intersecting) in processed) | ((intersecting, row.Index) in processed)):
continue
length_intersecting = nodes_dual.loc[intersecting]['length']
distance = (row[ix_length]+length_intersecting)/2
# from the first centroid to the centroid intersecting segment
ls = LineString([row[ix_geo], nodes_dual.loc[intersecting]['geometry']])
edges_dual.loc[-1] = [row.Index, intersecting, ls, distance]
edges_dual.index = edges_dual.index + 1
processed.append((row.Index, intersecting))
edges_dual = edges_dual.sort_index(axis=0)
edges_dual = gpd.GeoDataFrame(edges_dual[['u', 'v', 'length']], crs=crs, geometry=edges_dual['geometry'])
# setting angle values in degrees and radians
if (angle is None) | (angle == 'degree') | (angle != 'radians'):
edges_dual['deg'] = edges_dual.apply(lambda row: angle_line_geometries(edges_gdf.loc[row['u']].geometry, edges_gdf.loc[row['v']].geometry, degree = True, deflection = True), axis = 1)
else: edges_dual['rad'] = edges_dual.apply(lambda row: angle_line_geometries(edges_gdf.loc[row['u']].geometry, edges_gdf.loc[row['v']].geometry, degree = False, deflection = True), axis = 1)
return nodes_dual, edges_dual
def dual_graph_fromGDF(nodes_dual, edges_dual):
"""
The function generates a NetworkX.Graph from dual-nodes and -edges GeoDataFrames.
Parameters
----------
nodes_dual: Point GeoDataFrame
the GeoDataFrame of the dual nodes, namely the street segments' centroids
edges_dual: LineString GeoDataFrame
the GeoDataFrame of the dual edges, namely the links between street segments' centroids
Returns
-------
Dg: NetworkX.Graph
the dual graph of the street network
"""
nodes_dual.set_index('edgeID', drop = False, inplace = True, append = False)
nodes_dual.index.name = None
edges_dual.u, edges_dual.v = edges_dual.u.astype(int), edges_dual.v.astype(int)
Dg = nx.Graph()
Dg.add_nodes_from(nodes_dual.index)
attributes = nodes_dual.to_dict()
a = (nodes_dual.applymap(type) == list).sum()
if len(a[a>0]):
to_ignore = a[a>0].index[0]
else: to_ignore = []
for attribute_name in nodes_dual.columns:
# only add this attribute to nodes which have a non-null value for it
if attribute_name in to_ignore:
continue
attribute_values = {k:v for k, v in attributes[attribute_name].items() if pd.notnull(v)}
nx.set_node_attributes(Dg, name=attribute_name, values=attribute_values)
# add the edges and attributes that are not u, v, key (as they're added
# separately) or null
for _, row in edges_dual.iterrows():
attrs = {}
for label, value in row.iteritems():
if (label not in ['u', 'v']) and (isinstance(value, list) or pd.notnull(value)):
attrs[label] = value
Dg.add_edge(row['u'], row['v'], **attrs)
return Dg
def dual_id_dict(dict_values, G, node_attribute):
"""
It can be used when one deals with a dual graph and wants to link analyses conducted on this representation to
the primal graph. For instance, it takes the dictionary containing the betweennes-centrality values of the
nodes in the dual graph, and associates these variables to the corresponding edgeID.
Parameters
----------
dict_values: dictionary
it should be in the form {nodeID: value} where values is a measure that has been computed on the graph, for example
G: networkx graph
the graph that was used to compute or to assign values to nodes or edges
node_attribute: string
the attribute of the node to link to the edges GeoDataFrame
Returns
-------
ed_dict: dictionary
a dictionary where each item consists of a edgeID (key) and centrality values (for example) or other attributes (values)
"""
view = dict_values.items()
ed_list = list(view)
ed_dict = {}
for p in ed_list:
ed_dict[G.nodes[p[0]][node_attribute]] = p[1] # attribute and measure
return ed_dict
def nodes_degree(edges_gdf):
"""
It returns a dictionary where keys are nodes identifier (e.g. "nodeID") and values their degree.
Parameters
----------
edges_gdf: LineString GeoDataFrame
street segments GeoDataFrame
Returns
-------
dd: dictionary
a dictionary where each item consists of a nodeID (key) and degree values (values)
"""
dd_u = dict(edges_gdf['u'].value_counts())
dd_v = dict(edges_gdf['v'].value_counts())
dd = {k: dd_u.get(k, 0) + dd_v.get(k, 0) for k in set(dd_u) | set(dd_v)}
return dd | StarcoderdataPython |
323297 | import pandas as pd
from pathlib import Path, PosixPath
import pickle
import dill
import os
from typing import Type, Any
import yaml
class DataInterfaceBase:
"""
Govern how a data type is saved and loaded. This class is a base class for all DataInterfaces.
"""
file_extension = None
@classmethod
def save(cls, data: Any, file_name: str, file_dir_path: str, mode: str = None, **kwargs) -> str:
file_path = cls.construct_file_path(file_name, file_dir_path)
if mode is None:
cls._interface_specific_save(data, file_path, **kwargs)
else:
cls._interface_specific_save(data, file_path, mode, **kwargs)
return file_path
@classmethod
def construct_file_path(cls, file_name: str, file_dir_path: str) -> str:
root, ext = os.path.splitext(file_name)
if ext == '':
return str(Path(file_dir_path, "{}.{}".format(file_name, cls.file_extension)))
else:
return str(Path(file_dir_path, file_name))
@classmethod
def _interface_specific_save(cls, data: Any, file_path, mode: str = None, **kwargs) -> None:
raise NotImplementedError
@classmethod
def load(cls, file_path: str, **kwargs) -> Any:
file_path = Path(file_path)
if not file_path.exists():
raise FileNotFoundError(file_path)
return cls._interface_specific_load(str(file_path), **kwargs)
@classmethod
def _interface_specific_load(cls, file_path, **kwargs) -> Any:
raise NotImplementedError
class TextDataInterface(DataInterfaceBase):
file_extension = 'txt'
@classmethod
def _interface_specific_save(cls, data, file_path, mode='w', **kwargs):
with open(file_path, mode, **kwargs) as f:
f.write(data)
@classmethod
def _interface_specific_load(cls, file_path, **kwargs):
with open(file_path, 'r', **kwargs) as f:
file = f.read()
return file
class PickleDataInterface(DataInterfaceBase):
file_extension = 'pkl'
@classmethod
def _interface_specific_save(cls, data: Any, file_path, mode='wb+', **kwargs) -> None:
with open(file_path, mode, **kwargs) as f:
pickle.dump(data, f)
@classmethod
def _interface_specific_load(cls, file_path, **kwargs) -> Any:
with open(file_path, "rb+", **kwargs) as f:
return pickle.load(f)
class DillDataInterface(DataInterfaceBase):
file_extension = 'dill'
@classmethod
def _interface_specific_save(cls, data: Any, file_path, mode='wb+', **kwargs) -> None:
with open(file_path, mode, **kwargs) as f:
dill.dump(data, f)
@classmethod
def _interface_specific_load(cls, file_path, **kwargs) -> Any:
with open(file_path, "rb+", **kwargs) as f:
return dill.load(f)
class CSVDataInterface(DataInterfaceBase):
file_extension = 'csv'
@classmethod
def _interface_specific_save(cls, data, file_path, mode=None, **kwargs):
data.to_csv(file_path, **kwargs)
@classmethod
def _interface_specific_load(cls, file_path, **kwargs):
return pd.read_csv(file_path, **kwargs)
class ExcelDataInterface(DataInterfaceBase):
file_extension = 'xlsx'
@classmethod
def _interface_specific_save(cls, data, file_path, mode=None, **kwargs):
data.to_excel(file_path, **kwargs)
@classmethod
def _interface_specific_load(cls, file_path, **kwargs):
return pd.read_excel(file_path, **kwargs)
class ParquetDataInterface(DataInterfaceBase):
file_extension = 'parquet'
@classmethod
def _interface_specific_save(cls, data, file_path, mode=None, **kwargs):
try:
data.to_parquet(file_path, **kwargs)
except ImportError as import_error:
raise ImportError('Parquet engine must be installed separately. See ImportError from pandas:'
'\n{}'.format(import_error))
@classmethod
def _interface_specific_load(cls, file_path, **kwargs):
try:
data = pd.read_parquet(file_path, **kwargs)
except ImportError as import_error:
raise ImportError('Parquet engine must be installed separately. See ImportError from pandas:'
'\n{}'.format(import_error))
return data
class PDFDataInterface(DataInterfaceBase):
file_extension = 'pdf'
@classmethod
def _interface_specific_save(cls, doc, file_path, mode=None, **kwargs):
doc.save(file_path, garbage=4, deflate=True, clean=True, **kwargs)
@classmethod
def _interface_specific_load(cls, file_path, **kwargs):
import fitz
return fitz.open(file_path, **kwargs)
class YAMLDataInterface(DataInterfaceBase):
file_extension = 'yaml'
@classmethod
def _interface_specific_save(cls, data, file_path, mode='w', **kwargs):
with open(file_path, mode, **kwargs) as f:
yaml.dump(data, f, default_flow_style=False)
@classmethod
def _interface_specific_load(cls, file_path, **kwargs):
with open(file_path, 'r', **kwargs) as f:
data = yaml.safe_load(f)
return data
class TestingDataInterface(DataInterfaceBase):
"""Test class that doesn't make interactions with the file system, for use in unit tests"""
file_extension = 'test'
@classmethod
def _interface_specific_save(cls, data, file_path, mode='wb+', **kwargs) -> None:
return
@classmethod
def _interface_specific_load(cls, file_path, **kwargs):
return {'data': 42}
class MagicDataInterfaceBase:
def __init__(self):
self.registered_interfaces = {}
def save(self, data: Any, file_path: str, mode: str = None, **kwargs) -> str:
file_dir_path = os.path.dirname(file_path)
file_name = os.path.basename(file_path)
data_interface = self.select_data_interface(file_name)
saved_file_path = data_interface.save(data, file_name, file_dir_path, mode=mode, **kwargs)
return saved_file_path
def load(self, file_path: str, data_interface_hint: str = None, **kwargs) -> Any:
if data_interface_hint is None:
data_interface = self.select_data_interface(file_path)
else:
data_interface = self.select_data_interface(data_interface_hint)
print('Loading {}'.format(file_path))
return data_interface.load(file_path, **kwargs)
def register_data_interface(self, data_interface: Type[DataInterfaceBase]) -> None:
self.registered_interfaces[data_interface.file_extension] = data_interface
def select_data_interface(self, file_hint: str, default_file_type=None) -> DataInterfaceBase:
"""
Select the appropriate data interface based on the file_hint.
Args:
file_hint: May be a file name with an extension, or just a file extension.
default_file_type: default file type to use, if the file_hint doesn't specify.
Returns: A DataInterface.
"""
file_hint = self._parse_file_hint(file_hint)
if file_hint in self.registered_interfaces:
return self._instantiate_data_interface(file_hint)
elif default_file_type is not None:
return self._instantiate_data_interface(default_file_type)
else:
raise ValueError("File hint {} not recognized. Supported file types include {}".format(
file_hint, list(self.registered_interfaces.keys())))
def _instantiate_data_interface(self, file_type: str) -> DataInterfaceBase:
if file_type in self.registered_interfaces:
return self.registered_interfaces[file_type]()
else:
raise ValueError("File type {} not recognized. Supported file types include {}".format(
file_type, list(self.registered_interfaces.keys())))
@staticmethod
def _parse_file_hint(file_hint: str) -> str:
if type(file_hint) is PosixPath:
file_hint = file_hint.__str__()
if '.' in file_hint:
file_name, file_extension = file_hint.split('.')
return file_extension
else:
return file_hint
all_live_interfaces = [
PickleDataInterface,
DillDataInterface,
CSVDataInterface,
ParquetDataInterface,
ExcelDataInterface,
TextDataInterface,
TextDataInterface,
PDFDataInterface,
YAMLDataInterface,
]
MagicDataInterface = MagicDataInterfaceBase()
for interface in all_live_interfaces:
MagicDataInterface.register_data_interface(interface)
TestMagicDataInterface = MagicDataInterfaceBase()
TestMagicDataInterface.register_data_interface(TestingDataInterface)
| StarcoderdataPython |
1722762 | # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import logging
from toscaparser.entity_template import EntityTemplate
from toscaparser.properties import Property
log = logging.getLogger('tosca')
class RelationshipTemplate(EntityTemplate):
'''Relationship template.'''
SECTIONS = (DERIVED_FROM, PROPERTIES, REQUIREMENTS,
INTERFACES, TYPE, DEFAULT_FOR) = \
('derived_from', 'properties', 'requirements', 'interfaces',
'type', 'default_for')
ANY = 'ANY'
def __init__(self, relationship_template, name, custom_def=None,
target=None, source=None):
super(RelationshipTemplate, self).__init__(name,
relationship_template,
'relationship_type',
custom_def)
self.name = name
self.target = target
self.source = source
self.capability = None
self.default_for = self.entity_tpl.get(self.DEFAULT_FOR)
def get_matching_capabilities(self, targetNodeTemplate, capability_name=None):
# return the capabilities on the given targetNodeTemplate that matches this relationship
capabilitiesDict = targetNodeTemplate.get_capabilities()
# if capability_name is set, make sure the target node has a capability
# that matching it as a name or or as a type
if capability_name:
capability = capabilitiesDict.get(capability_name)
if capability:
# just test the capability that matches the symbolic name
capabilities = [capability]
else:
# name doesn't match a symbolic name, see if its a valid type name
capabilities = [cap for cap in capabilitiesDict.values() if cap.is_derived_from(capability_name)]
else:
capabilities = list(capabilitiesDict.values())
# if valid_target_types is set, make sure the matching capabilities are compatible
capabilityTypes = self.type_definition.valid_target_types
if capabilityTypes:
capabilities = [cap for cap in capabilities
if any(cap.is_derived_from(capType) for capType in capabilityTypes)]
elif not capability_name and len(capabilities) > 1:
# find the best match for the targetNodeTemplate
# if no capability was specified and there are more than one to choose from, choose the most generic
featureCap = capabilitiesDict.get("feature")
if featureCap:
return [featureCap]
return capabilities
| StarcoderdataPython |
1837053 | <filename>start_up/start_up_uems.py<gh_stars>1-10
from copy import deepcopy
from modelling.devices import transmission_lines
from configuration.configuration_time_line import default_look_ahead_time_step
def start_up(microgrid, microgrid_middle, microgrid_long):
"""
Start up of universal energy management system, which is depended on the start up of local energy management system.
:param microgrid: short-term information model
:param microgrid_middle: middle-term information model
:param microgrid_long: long-term information model
:return:
"""
microgrid = deepcopy(microgrid)
microgrid["LINE"] = deepcopy(transmission_lines.Line)
T_middle = default_look_ahead_time_step[
"Look_ahead_time_ed_time_step"] # The look ahead time step for middle term operation
T_long = default_look_ahead_time_step[
"Look_ahead_time_uc_time_step"] # The look ahead time step for long term operation
microgrid_middle = deepcopy(microgrid_middle)
microgrid_middle["LINE"] = deepcopy(transmission_lines.Line)
microgrid_middle["LINE"] = [microgrid_middle["LINE"]["STATUS"]] * T_middle
microgrid_long = deepcopy(microgrid_long)
microgrid_long["LINE"] = deepcopy(transmission_lines.Line)
microgrid_long["LINE"] = [microgrid_long["LINE"]["STATUS"]] * T_long
return microgrid,microgrid_middle,microgrid_long | StarcoderdataPython |
26738 | <filename>setup.py<gh_stars>10-100
#!/usr/bin/python
from distutils.core import setup
setup(
name = 'payment_processor',
version = '0.2.0',
description = 'A simple payment gateway api wrapper',
author = '<NAME>',
author_email = '<EMAIL>',
url = 'https://launchpad.net/python-payment',
download_url = 'https://launchpad.net/python-payment/+download',
packages = (
'payment_processor',
'payment_processor.gateways',
'payment_processor.methods',
'payment_processor.exceptions',
'payment_processor.utils'
)
)
| StarcoderdataPython |
5091033 | expected_output = {
"route-information": {
"route-table": [
{
"active-route-count": "929",
"destination-count": "929",
"hidden-route-count": "0",
"holddown-route-count": "0",
"rt": [
{
"rt-announced-count": "1",
"rt-destination": "0.0.0.0/0",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "101",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "150",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int Ext",
"rt-tag": "0",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {"#text": "KRT in-kernel 0.0.0.0/0 -> {10.169.14.121}"},
},
{
"rt-announced-count": "1",
"rt-destination": "10.1.0.0/24",
"rt-entry": {
"age": {"#text": "3w2d 4:43:35"},
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"inactive-reason": "Route Preference",
"local-as": "65171",
"metric": "20",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "150",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Int Ext",
"rt-tag": "0",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "2", "@junos:format": "2 entries"},
"rt-state": "FlashAll",
},
{
"rt-announced-count": "1",
"rt-destination": "10.36.3.3/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.36.3.3/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.16.0.0/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:26"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1200",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.16.0.0/30 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.100.5.5/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:26"},
"announce-bits": "2",
"announce-tasks": "0-KRT 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1201",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.100.5.5/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.19.198.28/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:56"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1005",
"nh": [
{
"nh-string": "Next hop",
"session": "140",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0x1",
}
],
"nh-address": "0xdbe48d4",
"nh-index": "614",
"nh-reference-count": "6",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.19.198.28/30 -> {10.189.5.94}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.19.198.239/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "1w5d 22:11:35"},
"announce-bits": "2",
"announce-tasks": "0-KRT 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1001",
"nh": [
{
"nh-string": "Next hop",
"session": "1ae",
"to": "10.19.198.26",
"via": "ge-0/0/2.0",
"weight": "0x1",
}
],
"nh-address": "0xdbc0d54",
"nh-index": "605",
"nh-reference-count": "4",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.19.198.239/32 -> {10.19.198.26}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.174.132.237/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "150",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "150",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int Ext",
"rt-tag": "0",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.174.132.237/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.34.2.200/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:26"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "205",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.34.2.200/30 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.34.2.250/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:26"},
"announce-bits": "2",
"announce-tasks": "0-KRT 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "200",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.34.2.250/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.34.2.251/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:26"},
"announce-bits": "2",
"announce-tasks": "0-KRT 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "205",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.34.2.251/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.15.0.0/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "1w5d 22:11:35"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1001",
"nh": [
{
"nh-string": "Next hop",
"session": "1ae",
"to": "10.19.198.26",
"via": "ge-0/0/2.0",
"weight": "0x1",
}
],
"nh-address": "0xdbc0d54",
"nh-index": "605",
"nh-reference-count": "4",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.15.0.0/30 -> {10.19.198.26}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.64.0.0/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1201",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.64.0.0/30 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.196.212/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:26"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1200",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.169.196.212/30 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.196.216/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:26"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1205",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.169.196.216/30 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.196.241/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "2",
"announce-tasks": "0-KRT 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1201",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.169.196.241/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.14.16/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "105",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.169.14.16/30 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.14.32/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 5:30:23"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "225",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.169.14.32/30 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.14.128/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:56"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "125",
"nh": [
{
"nh-string": "Next hop",
"session": "140",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0x1",
}
],
"nh-address": "0xdbe48d4",
"nh-index": "614",
"nh-reference-count": "6",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.169.14.128/30 -> {10.189.5.94}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.14.156/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:28"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "200",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.169.14.156/30 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.14.240/32",
"rt-entry": {
"age": {"#text": "3w2d 4:43:35"},
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"inactive-reason": "Route Preference",
"local-as": "65171",
"metric": "100",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "2", "@junos:format": "2 entries"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.169.14.240/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.14.241/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "2",
"announce-tasks": "0-KRT 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "105",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.169.14.241/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.14.242/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "100",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.169.14.242/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.14.243/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "105",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.169.14.243/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "10.189.5.253/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:56"},
"announce-bits": "2",
"announce-tasks": "0-KRT 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "5",
"nh": [
{
"nh-string": "Next hop",
"session": "140",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0x1",
}
],
"nh-address": "0xdbe48d4",
"nh-index": "614",
"nh-reference-count": "6",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 10.189.5.253/32 -> {10.189.5.94}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.0/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:26"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1200",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.0/30 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.0/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.0/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.1/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.1/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.2/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.2/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.3/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.3/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.4/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.4/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.5/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.5/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.6/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.6/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.7/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.7/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.8/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.8/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.9/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.9/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.10/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.10/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.11/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.11/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.12/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.12/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.13/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.13/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.14/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.14/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.15/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.15/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.16/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.16/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.17/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.17/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.18/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.18/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.19/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.19/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.20/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.20/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.21/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.21/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.22/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.22/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.23/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.23/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.24/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.24/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.25/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.25/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.26/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.26/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.27/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.27/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.28/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.28/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.29/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.29/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.30/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.30/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.31/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.31/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.32/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.32/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.33/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.33/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.34/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.34/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.35/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.35/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.36/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.36/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.37/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.37/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.38/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.38/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.39/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.39/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.40/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.40/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.41/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.41/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.42/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.42/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.43/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.43/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.44/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.44/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.45/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.45/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.46/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.46/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.47/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.47/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.48/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.48/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.49/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.49/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.50/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.50/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.51/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.51/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.52/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.52/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.53/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.53/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.54/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.54/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.55/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.55/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.56/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.56/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.57/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.57/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.58/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.58/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.59/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.59/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.60/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.60/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.61/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.61/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.62/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.62/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.63/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.63/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.64/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.64/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.65/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.65/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.66/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.66/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.67/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.67/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.68/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.68/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.69/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.69/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.70/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.70/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.71/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.71/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.72/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.72/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.73/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.73/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.74/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.74/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.75/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.75/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.76/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.76/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.77/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.77/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.78/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.78/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.79/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.79/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.80/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.80/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.81/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.81/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.82/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.82/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.83/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.83/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.84/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.84/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.85/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.85/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.86/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.86/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.87/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.87/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.88/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.88/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.89/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.89/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.90/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.90/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.91/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.91/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.92/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.92/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.93/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.93/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.94/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.94/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.95/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.95/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.96/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.96/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.97/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.97/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.98/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.98/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.99/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.99/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.100/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.100/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.101/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.101/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.102/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.102/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.103/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.103/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.104/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.104/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.105/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.105/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.106/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.106/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.107/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.107/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.108/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.108/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.109/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.109/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.110/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.110/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.111/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.111/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.112/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.112/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.113/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.113/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.114/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.114/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.115/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.115/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.116/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.116/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.117/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.117/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.118/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.118/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.119/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.119/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.120/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.120/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.121/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.121/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.122/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.122/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.123/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.123/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.124/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.124/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.125/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.125/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.126/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.126/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.127/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.127/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.128/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.128/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.129/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.129/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.130/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.130/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.131/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.131/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.132/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.132/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.133/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.133/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.134/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.134/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.135/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.135/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.136/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.136/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.137/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.137/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.138/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.138/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.139/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.139/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.140/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.140/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.141/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.141/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.142/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.142/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.143/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.143/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.144/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.144/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.145/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.145/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.146/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.146/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.147/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.147/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.148/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.148/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.149/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.149/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.150/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.150/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.151/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.151/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.152/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.152/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.153/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.153/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.154/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.154/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.155/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.155/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.156/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.156/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.157/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.157/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.158/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.158/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.159/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.159/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.160/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.160/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.161/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.161/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.162/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.162/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.163/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.163/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.164/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.164/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.165/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.165/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.166/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.166/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.167/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.167/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.168/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.168/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.169/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.169/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.170/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.170/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.171/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.171/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.172/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.172/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.173/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.173/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.174/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.174/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.175/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.175/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.176/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.176/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.177/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.177/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.178/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.178/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.179/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.179/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.180/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.180/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.181/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.181/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.182/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.182/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.183/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.183/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.184/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.184/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.185/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.185/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.186/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.186/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.187/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.187/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.188/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.188/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.189/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.189/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.190/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.190/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.191/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.191/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.192/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.192/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.193/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.193/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.194/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.194/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.195/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.195/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.196/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.196/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.197/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.197/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.198/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.198/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.199/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.199/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.220.200/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1202",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.220.200/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.111.0/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:31"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1201",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.111.0/30 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.4.0/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:06"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1201",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.4.0/30 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.100.0/25",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w5d 16:18:45"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "32000",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "150",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int Ext",
"rt-tag": "65000500",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "2", "@junos:format": "2 entries"},
"tsi": {
"#text": "KRT in-kernel 192.168.100.0/25 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.100.252/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w5d 16:18:45"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "32000",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "150",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int Ext",
"rt-tag": "65000500",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "2", "@junos:format": "2 entries"},
"tsi": {
"#text": "KRT in-kernel 192.168.100.252/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.36.48/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "10100",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.36.48/30 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.36.56/30",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "10100",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.36.56/30 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.36.119/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "10101",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.36.119/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "192.168.36.120/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "10101",
"nh": [
{
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfa7934",
"nh-index": "613",
"nh-reference-count": "458",
"nh-type": "Router",
"preference": "10",
"preference2": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 192.168.36.120/32 -> {10.169.14.121}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "172.16.31.10/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "29w5d 23:06:46"},
"announce-bits": "3",
"announce-tasks": "0-KRT 5-LDP 7-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1",
"nh-address": "0xbb66cd4",
"nh-index": "0",
"nh-reference-count": "9",
"nh-type": "MultiRecv",
"preference": "10",
"protocol-name": "OSPF",
"rt-entry-state": "Active NoReadvrt Int",
"task-name": "OSPF I/O./var/run/ppmd_control",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {"#text": "KRT in-kernel 172.16.31.10/32 -> {}"},
},
],
"table-name": "inet.0",
"total-route-count": "1615",
},
{
"active-route-count": "11",
"destination-count": "11",
"hidden-route-count": "0",
"holddown-route-count": "0",
"rt": [
{
"rt-announced-count": "1",
"rt-destination": "10.100.5.5/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 5:30:11"},
"announce-bits": "2",
"announce-tasks": "3-Resolve tree 1 4-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1201",
"nh": [
{
"label-element": "0xc5f6ec0",
"label-element-childcount": "1",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "2",
"label-ttl-action": "no-prop-ttl",
"load-balance-label": "Label 17000: None;",
"mpls-label": "Push 17000",
"nh-string": "Next hop",
"session": "0",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
},
{
"label-element": "0xc5c9a00",
"label-element-childcount": "1",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "2",
"label-ttl-action": "no-prop-ttl, no-prop-ttl, no-prop-ttl(top)",
"load-balance-label": "Label 17000: None; Label 1650: None; Label 1913: None;",
"mpls-label": "Push 17000, Push 1650, Push 1913(top)",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc14594",
"nh-index": "0",
"nh-reference-count": "1",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
},
{
"rt-announced-count": "1",
"rt-destination": "10.19.198.239/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "1w5d 22:11:26"},
"announce-bits": "2",
"announce-tasks": "3-Resolve tree 1 4-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1001",
"nh": [
{
"label-element": "0xc5cda38",
"label-element-childcount": "10",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "14",
"nh-string": "Next hop",
"session": "0",
"to": "10.19.198.26",
"via": "ge-0/0/2.0",
"weight": "0x1",
},
{
"label-element": "0xc5ee888",
"label-element-childcount": "1",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "2",
"label-ttl-action": "no-prop-ttl",
"load-balance-label": "Label 16073: None;",
"mpls-label": "Push 16073",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc14714",
"nh-index": "0",
"nh-reference-count": "1",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
},
{
"rt-announced-count": "1",
"rt-destination": "10.34.2.250/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:26"},
"announce-bits": "2",
"announce-tasks": "3-Resolve tree 1 4-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "200",
"nh": [
{
"label-element": "0xc5f6e20",
"label-element-childcount": "1",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "2",
"label-ttl-action": "no-prop-ttl",
"load-balance-label": "Label 16061: None;",
"mpls-label": "Push 16061",
"nh-string": "Next hop",
"session": "0",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfadab4",
"nh-index": "0",
"nh-reference-count": "1",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
},
{
"rt-announced-count": "1",
"rt-destination": "10.34.2.251/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:26"},
"announce-bits": "2",
"announce-tasks": "3-Resolve tree 1 4-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "205",
"nh": [
{
"label-element": "0xc5f6df8",
"label-element-childcount": "1",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "2",
"label-ttl-action": "no-prop-ttl",
"load-balance-label": "Label 16062: None;",
"mpls-label": "Push 16062",
"nh-string": "Next hop",
"session": "0",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xbb6ba14",
"nh-index": "0",
"nh-reference-count": "1",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.196.241/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:26"},
"announce-bits": "2",
"announce-tasks": "3-Resolve tree 1 4-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1201",
"nh": [
{
"label-element": "0xc5c8128",
"label-element-childcount": "1",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "2",
"label-ttl-action": "no-prop-ttl",
"load-balance-label": "Label 16063: None;",
"mpls-label": "Push 16063",
"nh-string": "Next hop",
"session": "0",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
},
{
"label-element": "0xc5f70f0",
"label-element-childcount": "1",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "2",
"label-ttl-action": "no-prop-ttl, no-prop-ttl, no-prop-ttl(top)",
"load-balance-label": "Label 16063: None; Label 1650: None; Label 1913: None;",
"mpls-label": "Push 16063, Push 1650, Push 1913(top)",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc14c14",
"nh-index": "0",
"nh-reference-count": "1",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.14.240/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:51"},
"announce-bits": "3",
"announce-tasks": "3-Resolve tree 1 4-Resolve tree 3 6-Resolve_IGP_FRR task",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "100",
"nh": [
{
"label-element": "0xc5cda38",
"label-element-childcount": "10",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "14",
"nh-string": "Next hop",
"session": "0",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
},
{
"label-element": "0xc5ee6f8",
"label-element-childcount": "5",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "6",
"label-ttl-action": "no-prop-ttl, no-prop-ttl(top)",
"load-balance-label": "Label 16051: None; Label 1913: None;",
"mpls-label": "Push 16051, Push 1913(top)",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc1bd14",
"nh-index": "0",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
},
{
"rt-announced-count": "1",
"rt-destination": "10.169.14.241/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "2",
"announce-tasks": "3-Resolve tree 1 4-Resolve tree 3",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "105",
"nh": [
{
"label-element": "0xc5f6d80",
"label-element-childcount": "1",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "2",
"label-ttl-action": "no-prop-ttl",
"load-balance-label": "Label 16052: None;",
"mpls-label": "Push 16052",
"nh-string": "Next hop",
"session": "0",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfb0bd4",
"nh-index": "0",
"nh-reference-count": "1",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
},
{
"rt-announced-count": "1",
"rt-destination": "10.189.5.253/32",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:56"},
"announce-bits": "3",
"announce-tasks": "3-Resolve tree 1 4-Resolve tree 3 6-Resolve_IGP_FRR task",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "5",
"nh": [
{
"label-element": "0xc5cda38",
"label-element-childcount": "10",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "14",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0x1",
}
],
"nh-address": "0xdfb2af4",
"nh-index": "0",
"nh-reference-count": "4",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
},
],
"table-name": "inet.3",
"total-route-count": "11",
},
{
"active-route-count": "44",
"destination-count": "44",
"hidden-route-count": "0",
"holddown-route-count": "0",
"rt": [
{
"rt-announced-count": "1",
"rt-destination": "2567",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "1w6d 20:26:02"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "0",
"nh": [
{
"label-element": "0xc5cd8a8",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "0",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
},
{
"label-element": "0xc5f4b98",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "3",
"label-ttl-action": "no-prop-ttl, no-prop-ttl(top)",
"load-balance-label": "Label 16051: None; Label 1913: None;",
"mpls-label": "Swap 16051, Push 1913(top)",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc32314",
"nh-index": "0",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {
"#text": "KRT in-kernel 2567 /52 -> {list:Pop , Swap 16051, Push 1913(top)}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "2567(S=0)",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "1w6d 20:26:02"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "0",
"nh": [
{
"label-element": "0xc5cd8d0",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "0",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
},
{
"label-element": "0xc5f4b98",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "3",
"label-ttl-action": "no-prop-ttl, no-prop-ttl(top)",
"load-balance-label": "Label 16051: None; Label 1913: None;",
"mpls-label": "Swap 16051, Push 1913(top)",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc1d894",
"nh-index": "0",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {
"#text": "KRT in-kernel 2567 /56 -> {list:Pop , Swap 16051, Push 1913(top)}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "2568",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "0",
"nh": [
{
"label-element": "0xc5cd8a8",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfaa1b4",
"nh-index": "603",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {"#text": "KRT in-kernel 2568 /52 -> {Pop }"},
},
{
"rt-announced-count": "1",
"rt-destination": "2568(S=0)",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "0",
"nh": [
{
"label-element": "0xc5cd8d0",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfadc34",
"nh-index": "618",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {"#text": "KRT in-kernel 2568 /56 -> {Pop }"},
},
{
"rt-announced-count": "1",
"rt-destination": "16051",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:51"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "100",
"nh": [
{
"label-element": "0xc5cd8a8",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "0",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
},
{
"label-element": "0xc5f4b98",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "3",
"label-ttl-action": "no-prop-ttl, no-prop-ttl(top)",
"load-balance-label": "Label 16051: None; Label 1913: None;",
"mpls-label": "Swap 16051, Push 1913(top)",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc32314",
"nh-index": "0",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {
"#text": "KRT in-kernel 16051 /52 -> {list:Pop , Swap 16051, Push 1913(top)}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "16051(S=0)",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:51"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "100",
"nh": [
{
"label-element": "0xc5cd8d0",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "0",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
},
{
"label-element": "0xc5f4b98",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "3",
"label-ttl-action": "no-prop-ttl, no-prop-ttl(top)",
"load-balance-label": "Label 16051: None; Label 1913: None;",
"mpls-label": "Swap 16051, Push 1913(top)",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc1d894",
"nh-index": "0",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {
"#text": "KRT in-kernel 16051 /56 -> {list:Pop , Swap 16051, Push 1913(top)}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "16052",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w2d 4:43:35"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "105",
"nh": [
{
"label-element": "0xc5f6d08",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "1",
"load-balance-label": "Label 16052: None;",
"mpls-label": "Swap 16052",
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdbdb334",
"nh-index": "626",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {"#text": "KRT in-kernel 16052 /52 -> {Swap 16052}"},
},
{
"rt-announced-count": "1",
"rt-destination": "16061",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:26"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "200",
"nh": [
{
"label-element": "0xc5f6cb8",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "1",
"load-balance-label": "Label 16061: None;",
"mpls-label": "Swap 16061",
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xdfadbd4",
"nh-index": "616",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {"#text": "KRT in-kernel 16061 /52 -> {Swap 16061}"},
},
{
"rt-announced-count": "1",
"rt-destination": "16062",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:26"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "205",
"nh": [
{
"label-element": "0xc5f6c90",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "1",
"load-balance-label": "Label 16062: None;",
"mpls-label": "Swap 16062",
"nh-string": "Next hop",
"session": "141",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
}
],
"nh-address": "0xbb6e474",
"nh-index": "619",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {"#text": "KRT in-kernel 16062 /52 -> {Swap 16062}"},
},
{
"rt-announced-count": "1",
"rt-destination": "16063",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "6d 17:15:26"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1201",
"nh": [
{
"label-element": "0xc5c8150",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "2",
"load-balance-label": "Label 16063: None;",
"mpls-label": "Swap 16063",
"nh-string": "Next hop",
"session": "0",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
},
{
"label-element": "0xc5f72d0",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "2",
"label-ttl-action": "no-prop-ttl, no-prop-ttl, no-prop-ttl(top)",
"load-balance-label": "Label 16063: None; Label 1650: None; Label 1913: None;",
"mpls-label": "Swap 16063, Push 1650, Push 1913(top)",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc14894",
"nh-index": "0",
"nh-reference-count": "1",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {
"#text": "KRT in-kernel 16063 /52 -> {list:Swap 16063, Swap 16063, Push 1650, Push 1913(top)}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "16072",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:56"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "5",
"nh": [
{
"label-element": "0xc5cd8a8",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "140",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0x1",
}
],
"nh-address": "0xe336114",
"nh-index": "622",
"nh-reference-count": "6",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {"#text": "KRT in-kernel 16072 /52 -> {Pop }"},
},
{
"rt-announced-count": "1",
"rt-destination": "16072(S=0)",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:56"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "5",
"nh": [
{
"label-element": "0xc5cd8d0",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "140",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0x1",
}
],
"nh-address": "0xe34b8f4",
"nh-index": "624",
"nh-reference-count": "6",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {"#text": "KRT in-kernel 16072 /56 -> {Pop }"},
},
{
"rt-announced-count": "1",
"rt-destination": "16073",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "1w5d 22:11:26"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1001",
"nh": [
{
"label-element": "0xc5cd8a8",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "0",
"to": "10.19.198.26",
"via": "ge-0/0/2.0",
"weight": "0x1",
},
{
"label-element": "0xc5ee928",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "3",
"load-balance-label": "Label 16073: None;",
"mpls-label": "Swap 16073",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc16b94",
"nh-index": "0",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {
"#text": "KRT in-kernel 16073 /52 -> {list:Pop , Swap 16073}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "16073(S=0)",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "1w5d 22:11:26"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1001",
"nh": [
{
"label-element": "0xc5cd8d0",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "0",
"to": "10.19.198.26",
"via": "ge-0/0/2.0",
"weight": "0x1",
},
{
"label-element": "0xc5ee928",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "3",
"load-balance-label": "Label 16073: None;",
"mpls-label": "Swap 16073",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc16c14",
"nh-index": "0",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {
"#text": "KRT in-kernel 16073 /56 -> {list:Pop , Swap 16073}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "17000",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 5:30:11"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1201",
"nh": [
{
"label-element": "0xc5f6d30",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "2",
"load-balance-label": "Label 17000: None;",
"mpls-label": "Swap 17000",
"nh-string": "Next hop",
"session": "0",
"to": "10.169.14.121",
"via": "ge-0/0/1.0",
"weight": "0x1",
},
{
"label-element": "0xc5f34a0",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "2",
"label-ttl-action": "no-prop-ttl, no-prop-ttl, no-prop-ttl(top)",
"load-balance-label": "Label 17000: None; Label 1650: None; Label 1913: None;",
"mpls-label": "Swap 17000, Push 1650, Push 1913(top)",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc14b94",
"nh-index": "0",
"nh-reference-count": "1",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {
"#text": "KRT in-kernel 17000 /52 -> {list:Swap 17000, Swap 17000, Push 1650, Push 1913(top)}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "28985",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:56"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "0",
"nh": [
{
"label-element": "0xc5cd8a8",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "140",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0x1",
}
],
"nh-address": "0xe336114",
"nh-index": "622",
"nh-reference-count": "6",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {"#text": "KRT in-kernel 28985 /52 -> {Pop }"},
},
{
"rt-announced-count": "1",
"rt-destination": "28985(S=0)",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:56"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "0",
"nh": [
{
"label-element": "0xc5cd8d0",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "140",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0x1",
}
],
"nh-address": "0xe34b8f4",
"nh-index": "624",
"nh-reference-count": "6",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {"#text": "KRT in-kernel 28985 /56 -> {Pop }"},
},
{
"rt-announced-count": "1",
"rt-destination": "28986",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:56"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "0",
"nh": [
{
"label-element": "0xc5cd8a8",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "140",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0x1",
}
],
"nh-address": "0xe336114",
"nh-index": "622",
"nh-reference-count": "6",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {"#text": "KRT in-kernel 28986 /52 -> {Pop }"},
},
{
"rt-announced-count": "1",
"rt-destination": "28986(S=0)",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:56"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "0",
"nh": [
{
"label-element": "0xc5cd8d0",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "140",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0x1",
}
],
"nh-address": "0xe34b8f4",
"nh-index": "624",
"nh-reference-count": "6",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {"#text": "KRT in-kernel 28986 /56 -> {Pop }"},
},
{
"rt-announced-count": "1",
"rt-destination": "167966",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "1w5d 22:11:26"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "0",
"nh": [
{
"label-element": "0xc5cd8a8",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "0",
"to": "10.19.198.26",
"via": "ge-0/0/2.0",
"weight": "0x1",
},
{
"label-element": "0xc5ee928",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "3",
"load-balance-label": "Label 16073: None;",
"mpls-label": "Swap 16073",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc16b94",
"nh-index": "0",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {
"#text": "KRT in-kernel 167966 /52 -> {list:Pop , Swap 16073}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "167966(S=0)",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "1w5d 22:11:26"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "0",
"nh": [
{
"label-element": "0xc5cd8d0",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "0",
"to": "10.19.198.26",
"via": "ge-0/0/2.0",
"weight": "0x1",
},
{
"label-element": "0xc5ee928",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "3",
"load-balance-label": "Label 16073: None;",
"mpls-label": "Swap 16073",
"nh-string": "Next hop",
"session": "0",
"to": "10.189.5.94",
"via": "ge-0/0/0.0",
"weight": "0xf000",
},
],
"nh-address": "0xbc16c14",
"nh-index": "0",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {
"#text": "KRT in-kernel 167966 /56 -> {list:Pop , Swap 16073}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "167967",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "1w5d 22:11:35"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "0",
"nh": [
{
"label-element": "0xc5cd8a8",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "1ae",
"to": "10.19.198.26",
"via": "ge-0/0/2.0",
"weight": "0x1",
}
],
"nh-address": "0xdbd53f4",
"nh-index": "655",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {"#text": "KRT in-kernel 167967 /52 -> {Pop }"},
},
{
"rt-announced-count": "1",
"rt-destination": "167967(S=0)",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "1w5d 22:11:35"},
"announce-bits": "1",
"announce-tasks": "1-KRT",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "0",
"nh": [
{
"label-element": "0xc5cd8d0",
"label-element-childcount": "0",
"label-element-lspid": "0",
"label-element-parent": "0x0",
"label-element-refcount": "7",
"load-balance-label": "None;",
"mpls-label": "Pop",
"nh-string": "Next hop",
"session": "1ae",
"to": "10.19.198.26",
"via": "ge-0/0/2.0",
"weight": "0x1",
}
],
"nh-address": "0xdbd5334",
"nh-index": "656",
"nh-reference-count": "2",
"nh-type": "Router",
"preference": "10",
"preference2": "5",
"protocol-name": "L-OSPF",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"tsi": {"#text": "KRT in-kernel 167967 /56 -> {Pop }"},
},
],
"table-name": "mpls.0",
"total-route-count": "44",
},
{
"active-route-count": "22",
"destination-count": "22",
"hidden-route-count": "0",
"holddown-route-count": "0",
"rt": [
{
"rt-announced-count": "1",
"rt-destination": "::/0",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:55"},
"announce-bits": "3",
"announce-tasks": "0-KRT 3-LDP 5-Resolve tree 5",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "101",
"nh": [
{
"nh-string": "Next hop",
"session": "144",
"to": "fe80::250:56ff:fe8d:72bd",
"via": "ge-0/0/1.0",
}
],
"nh-address": "0xe34bb94",
"nh-index": "628",
"nh-reference-count": "19",
"nh-type": "Router",
"preference": "150",
"protocol-name": "OSPF3",
"rt-entry-state": "Active Int Ext",
"rt-tag": "0",
"task-name": "OSPF3",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel ::/0 -> {fe80::250:56ff:fe8d:72bd}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "2001:db8:6aa8:6a53::1001/128",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:55"},
"announce-bits": "3",
"announce-tasks": "0-KRT 3-LDP 5-Resolve tree 5",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "150",
"nh": [
{
"nh-string": "Next hop",
"session": "144",
"to": "fe80::250:56ff:fe8d:72bd",
"via": "ge-0/0/1.0",
}
],
"nh-address": "0xe34bb94",
"nh-index": "628",
"nh-reference-count": "19",
"nh-type": "Router",
"preference": "150",
"protocol-name": "OSPF3",
"rt-entry-state": "Active Int Ext",
"rt-tag": "0",
"task-name": "OSPF3",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 2001:db8:6aa8:6a53::1001/128 -> {fe80::250:56ff:fe8d:72bd}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "2001:db8:b0f8:ca45::13/128",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:17"},
"announce-bits": "3",
"announce-tasks": "0-KRT 3-LDP 5-Resolve tree 5",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "200",
"nh": [
{
"nh-string": "Next hop",
"session": "144",
"to": "fe80::250:56ff:fe8d:72bd",
"via": "ge-0/0/1.0",
}
],
"nh-address": "0xe34bb94",
"nh-index": "628",
"nh-reference-count": "19",
"nh-type": "Router",
"preference": "10",
"protocol-name": "OSPF3",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF3",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 2001:db8:b0f8:ca45::13/128 -> {fe80::250:56ff:fe8d:72bd}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "2001:db8:b0f8:ca45::14/128",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:17"},
"announce-bits": "3",
"announce-tasks": "0-KRT 3-LDP 5-Resolve tree 5",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "205",
"nh": [
{
"nh-string": "Next hop",
"session": "144",
"to": "fe80::250:56ff:fe8d:72bd",
"via": "ge-0/0/1.0",
}
],
"nh-address": "0xe34bb94",
"nh-index": "628",
"nh-reference-count": "19",
"nh-type": "Router",
"preference": "10",
"protocol-name": "OSPF3",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF3",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 2001:db8:b0f8:ca45::14/128 -> {fe80::250:56ff:fe8d:72bd}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "2001:db8:b0f8:3ab::/64",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:17"},
"announce-bits": "3",
"announce-tasks": "0-KRT 3-LDP 5-Resolve tree 5",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "205",
"nh": [
{
"nh-string": "Next hop",
"session": "144",
"to": "fe80::250:56ff:fe8d:72bd",
"via": "ge-0/0/1.0",
}
],
"nh-address": "0xe34bb94",
"nh-index": "628",
"nh-reference-count": "19",
"nh-type": "Router",
"preference": "10",
"protocol-name": "OSPF3",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF3",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 2001:db8:b0f8:3ab::/64 -> {fe80::250:56ff:fe8d:72bd}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "2001:db8:eb18:ca45::1/128",
"rt-entry": {
"age": {"#text": "3w0d 18:21:55"},
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"inactive-reason": "Route Preference",
"local-as": "65171",
"metric": "100",
"nh": [
{
"nh-string": "Next hop",
"session": "144",
"to": "fe80::250:56ff:fe8d:72bd",
"via": "ge-0/0/1.0",
}
],
"nh-address": "0xe34bb94",
"nh-index": "628",
"nh-reference-count": "19",
"nh-type": "Router",
"preference": "10",
"protocol-name": "OSPF3",
"rt-entry-state": "Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF3",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "2", "@junos:format": "2 entries"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 2001:db8:eb18:ca45::1/128 -> {2001:db8:eb18:6337::1}\nOSPF3 realm ipv6-unicast area : 0.0.0.0, LSA ID : 0.0.0.1, LSA type : Extern"
},
},
{
"rt-announced-count": "1",
"rt-destination": "2001:db8:eb18:ca45::2/128",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:55"},
"announce-bits": "3",
"announce-tasks": "0-KRT 3-LDP 5-Resolve tree 5",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "105",
"nh": [
{
"nh-string": "Next hop",
"session": "144",
"to": "fe80::250:56ff:fe8d:72bd",
"via": "ge-0/0/1.0",
}
],
"nh-address": "0xe34bb94",
"nh-index": "628",
"nh-reference-count": "19",
"nh-type": "Router",
"preference": "10",
"protocol-name": "OSPF3",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF3",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 2001:db8:eb18:ca45::2/128 -> {fe80::250:56ff:fe8d:72bd}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "2001:db8:eb18:e26e::/64",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:21:55"},
"announce-bits": "3",
"announce-tasks": "0-KRT 3-LDP 5-Resolve tree 5",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "105",
"nh": [
{
"nh-string": "Next hop",
"session": "144",
"to": "fe80::250:56ff:fe8d:72bd",
"via": "ge-0/0/1.0",
}
],
"nh-address": "0xe34bb94",
"nh-index": "628",
"nh-reference-count": "19",
"nh-type": "Router",
"preference": "10",
"protocol-name": "OSPF3",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF3",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 2001:db8:eb18:e26e::/64 -> {fe80::250:56ff:fe8d:72bd}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "2001:db8:eb18:f5e6::/64",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 5:30:12"},
"announce-bits": "3",
"announce-tasks": "0-KRT 3-LDP 5-Resolve tree 5",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "225",
"nh": [
{
"nh-string": "Next hop",
"session": "144",
"to": "fe80::250:56ff:fe8d:72bd",
"via": "ge-0/0/1.0",
}
],
"nh-address": "0xe34bb94",
"nh-index": "628",
"nh-reference-count": "19",
"nh-type": "Router",
"preference": "10",
"protocol-name": "OSPF3",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF3",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 2001:db8:eb18:f5e6::/64 -> {fe80::250:56ff:fe8d:72bd}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "2001:db8:eb18:6d57::/64",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:22:00"},
"announce-bits": "3",
"announce-tasks": "0-KRT 3-LDP 5-Resolve tree 5",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "125",
"nh": [
{
"nh-string": "Next hop",
"session": "142",
"to": "fe80::250:56ff:fe8d:53c0",
"via": "ge-0/0/0.0",
}
],
"nh-address": "0xdfa4454",
"nh-index": "621",
"nh-reference-count": "4",
"nh-type": "Router",
"preference": "10",
"protocol-name": "OSPF3",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF3",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 2001:db8:eb18:6d57::/64 -> {fe80::250:56ff:fe8d:53c0}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "2001:db8:eb18:9627::/64",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "2w6d 6:10:17"},
"announce-bits": "3",
"announce-tasks": "0-KRT 3-LDP 5-Resolve tree 5",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "200",
"nh": [
{
"nh-string": "Next hop",
"session": "144",
"to": "fe80::250:56ff:fe8d:72bd",
"via": "ge-0/0/1.0",
}
],
"nh-address": "0xe34bb94",
"nh-index": "628",
"nh-reference-count": "19",
"nh-type": "Router",
"preference": "10",
"protocol-name": "OSPF3",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF3",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 2001:db8:eb18:9627::/64 -> {fe80::250:56ff:fe8d:72bd}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "2fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b/128",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "3w0d 18:22:00"},
"announce-bits": "3",
"announce-tasks": "0-KRT 3-LDP 5-Resolve tree 5",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "5",
"nh": [
{
"nh-string": "Next hop",
"session": "142",
"to": "fe80::250:56ff:fe8d:53c0",
"via": "ge-0/0/0.0",
}
],
"nh-address": "0xdfa4454",
"nh-index": "621",
"nh-reference-count": "4",
"nh-type": "Router",
"preference": "10",
"protocol-name": "OSPF3",
"rt-entry-state": "Active Int",
"rt-ospf-area": "0.0.0.8",
"task-name": "OSPF3",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {
"#text": "KRT in-kernel 2001:db8:223c:ca45::c/128 -> {fe80::250:56ff:fe8d:53c0}"
},
},
{
"rt-announced-count": "1",
"rt-destination": "fc00:db20:35b:7399::5/128",
"rt-entry": {
"active-tag": "*",
"age": {"#text": "29w5d 23:06:46"},
"announce-bits": "3",
"announce-tasks": "0-KRT 3-LDP 5-Resolve tree 5",
"as-path": "AS path: I",
"bgp-path-attributes": {
"attr-as-path-effective": {
"aspath-effective-string": "AS path:",
"attr-value": "I",
}
},
"local-as": "65171",
"metric": "1",
"nh-address": "0xbb66cd4",
"nh-index": "0",
"nh-reference-count": "9",
"nh-type": "MultiRecv",
"preference": "10",
"protocol-name": "OSPF3",
"rt-entry-state": "Active NoReadvrt Int",
"task-name": "OSPF3 I/O./var/run/ppmd_control",
"validation-state": "unverified",
},
"rt-entry-count": {"#text": "1", "@junos:format": "1 entry"},
"rt-state": "FlashAll",
"tsi": {"#text": "KRT in-kernel fc00:db20:35b:7399::5/128 -> {}"},
},
],
"table-name": "inet6.0",
"total-route-count": "23",
},
]
}
}
| StarcoderdataPython |
6433598 | """change category config options
Revision ID: 253ae54f5788
Revises: 36<PASSWORD>
Create Date: 2019-11-16 16:58:11.287152
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '36c<PASSWORD>'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('flicket_config', sa.Column('change_category', sa.BOOLEAN(), nullable=True))
op.add_column('flicket_config', sa.Column('change_category_only_admin_or_super_user', sa.BOOLEAN(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('flicket_config', 'change_category_only_admin_or_super_user')
op.drop_column('flicket_config', 'change_category')
# ### end Alembic commands ###
| StarcoderdataPython |
1871878 | # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
# See COPYING file distributed along with the PyMVPA package for the
# copyright and license terms.
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Collection of dummy (e.g. random) classifiers. Primarily for testing.
"""
__docformat__ = 'restructuredtext'
import numpy as np
import numpy.random as npr
from mvpa2.base.param import Parameter
from mvpa2.base.types import accepts_dataset_as_samples, is_datasetlike
from mvpa2.clfs.base import Classifier
__all__ = ['Classifier', 'SameSignClassifier', 'RandomClassifier',
'Less1Classifier']
#
# Few silly classifiers
#
class SameSignClassifier(Classifier):
"""Dummy classifier which reports +1 class if both features have
the same sign, -1 otherwise"""
__tags__ = ['notrain2predict']
def __init__(self, **kwargs):
Classifier.__init__(self, **kwargs)
def _train(self, data):
# we don't need that ;-)
pass
@accepts_dataset_as_samples
def _predict(self, data):
data = np.asanyarray(data)
datalen = len(data)
estimates = []
for d in data:
estimates.append(2*int( (d[0]>=0) == (d[1]>=0) )-1)
self.ca.predictions = estimates
self.ca.estimates = estimates # just for the sake of having estimates
return estimates
class RandomClassifier(Classifier):
"""Dummy classifier deciding on labels absolutely randomly
"""
__tags__ = ['random', 'non-deterministic']
same = Parameter(
False, constraints='bool',
doc="If a dataset arrives to predict, assign identical (but random) label "
"to all samples having the same label in original, thus mimiquing the "
"situation where testing samples are not independent.")
def __init__(self, **kwargs):
Classifier.__init__(self, **kwargs)
self._ulabels = None
def _train(self, data):
self._ulabels = data.sa[self.get_space()].unique
@accepts_dataset_as_samples
def _predict(self, data):
l = len(self._ulabels)
# oh those lovely random estimates, for now just an estimate
# per sample. Since we are random after all -- keep it random
self.ca.estimates = np.random.normal(size=len(data))
if is_datasetlike(data) and self.params.same:
# decide on mapping between original labels
labels_map = dict(
(t, rt) for t, rt in zip(self._ulabels,
self._ulabels[npr.randint(0, l, size=l)]))
return [labels_map[t] for t in data.sa[self.get_space()].value]
else:
# random one per each
return self._ulabels[npr.randint(0, l, size=len(data))]
class Less1Classifier(SameSignClassifier):
"""Dummy classifier which reports +1 class if abs value of max less than 1"""
def _predict(self, data):
datalen = len(data)
estimates = []
for d in data:
estimates.append(2*int(max(d)<=1)-1)
self.predictions = estimates
return estimates
| StarcoderdataPython |
8016999 | <reponame>paramraghavan/beginners-py-learn
'''
When you assign 42 to the name myGlobal, therefore, Python creates a local variable that shadows the global variable of the same name.
That local goes out of scope and is garbage-collected when func1() returns; meanwhile, func2() can never see anything other than the
(unmodified) global name. Note that this namespace decision happens at compile time, not at runtime -- if you were to read the value of
myGlobal inside func1() before you assign to it, you'd get an UnboundLocalError, because Python has already decided that it must be
a local variable but it has not had any value associated with it yet.
But by using the 'global' statement, you tell Python that it should look elsewhere for
the name instead of assigning to it locally.
This time 42 is printed
'''
myGlobal = 5
#prints 5
def func0():
print(f'func0 myGlobal : {myGlobal}')
# modifies global value, myGlobal
def func1():
global myGlobal
myGlobal = 42
print(f'func2 updates global scope myGlobal : {myGlobal}')
# prints 42
def func2():
print(f'func2 myGlobal : {myGlobal}')
# prints 11
# all the changes are local to func3(), does not modify global value, myGlobal
def func3():
myGlobal = 11
print(f'func3 updates local scope myGlobal : {myGlobal}')
# prints 42, Global value, as changes func3() are local to func3()
def func4():
print(f'func4 myGlobal : {myGlobal}')
func0()
func1()
func2()
func3()
func4() | StarcoderdataPython |
3386455 | <reponame>itdependsnetworks/Network-Automation
from Database import DB_queries as DbQueries
from Software import NXOS, IOSXE, ASA
if __name__ == '__main__':
skip_login = input("Database populated? Press enter to skip. Enter any other key to populate new table. ")
print("\n")
if skip_login != "":
print("OS Options\n")
print("1. IOS XE")
print("2. Nexus OS")
print("3. ASA\n")
selection = input("Selection: ")
print("\n")
device_ip = input("Device IP: ")
username = input("Username: ")
password = input("Password: ")
enable_question = input("Enable Password(yes/no)? ").lower()
if enable_question == "yes":
same_as_username_password = input("Enable Password same as user password(yes/no)? ").lower()
if same_as_username_password == "<PASSWORD>":
if selection == "1":
IOSXE. RoutingIos(host=device_ip, username=username, password=password, enable=password)
elif selection == "2":
NXOS. RoutingNexus(host=device_ip, username=username, password=password, enable=password)
elif selection == "3":
ASA. RoutingAsa(host=device_ip, username=username, password=password, enable=password)
elif same_as_username_password == "no":
enable = input("Enable Password(yes/no)? ")
if selection == "1":
IOSXE. RoutingIos(host=device_ip, username=username, password=password, enable=enable)
elif selection == "2":
NXOS. RoutingNexus(host=device_ip, username=username, password=password, enable=enable)
elif selection == "3":
ASA. RoutingAsa(host=device_ip, username=username, password=password, enable=enable)
elif enable_question == "no":
if selection == "1":
IOSXE. RoutingIos(host=device_ip, username=username, password=password)
elif selection == "2":
NXOS. RoutingNexus(host=device_ip, username=username, password=password)
elif selection == "3":
ASA. RoutingAsa(host=device_ip, username=username, password=password)
while True:
get_tables = DbQueries.get_db_tables_with_data()
if not get_tables:
continue
else:
break
else:
get_tables = DbQueries.get_db_tables_with_data()
if not get_tables:
print("No routing table")
else:
pass
while True:
print("\nDB_Query Tool-------------\n")
print("\nTable: %s\n" % get_tables[0])
print("1. Search by protocol")
print("2. Search by prefix")
print("3. Search by metric")
print("4. Search by AD")
print("5. Search by Interface")
print("6. Search by Tag")
print("7. Full Table\n")
selection = input("Selection: ")
print("\n")
if selection == "1":
if get_tables[0] == "Routing_ASA":
DbQueries.print_protocols(get_tables[0])
protocol = input("Protocol: ")
print("\n")
DbQueries.search_db_asa(context=None, protocol=protocol)
elif get_tables[0] == "Routing_IOS_XE":
DbQueries.get_vrfs(get_tables[0])
vrf = input("VRF: ")
DbQueries.print_protocols(get_tables[0])
protocol = input("Protocol: ")
print("\n")
DbQueries.search_db_ios(vrf=None, protocol=protocol)
elif get_tables[0] == "Routing_Nexus":
DbQueries.get_vdcs()
vdc = input("VDC: ")
DbQueries.get_vrfs(get_tables[0])
vrf = input("VRF: ")
DbQueries.print_protocols(get_tables[0])
protocol = input("Protocol: ")
print("\n")
DbQueries.search_db_nexus(vdc=vdc, vrf=vrf, protocol=protocol)
elif selection == "2":
if get_tables[0] == "Routing_ASA":
prefix = input("Prefix: ")
print("\n")
DbQueries.search_db_asa(context=None, prefix=prefix)
elif get_tables[0] == "Routing_IOS_XE":
DbQueries.get_vrfs(get_tables[0])
vrf = input("VRF: ")
prefix = input("Prefix: ")
print("\n")
DbQueries.search_db_ios(vrf=vrf, prefix=prefix)
elif get_tables[0] == "Routing_Nexus":
DbQueries.get_vdcs()
vdc = input("VDC: ")
DbQueries.get_vrfs(get_tables[0])
vrf = input("VRF: ")
prefix = input("Prefix: ")
print("\n")
DbQueries.search_db_nexus(vdc=vdc, vrf=vrf, prefix=prefix)
elif selection == "3":
if get_tables[0] == "Routing_ASA":
metric = input("Metric: ")
print("\n")
DbQueries.search_db_asa(context=None, metric=metric)
elif get_tables[0] == "Routing_IOS_XE":
DbQueries.get_vrfs(get_tables[0])
vrf = input("VRF: ")
metric = input("Metric: ")
print("\n")
DbQueries.search_db_ios(vrf=vrf, metric=metric)
elif get_tables[0] == "Routing_Nexus":
DbQueries.get_vdcs()
vdc = input("VDC: ")
DbQueries.get_vrfs(get_tables[0])
vrf = input("VRF: ")
metric = input("Metric: ")
print("\n")
DbQueries.search_db_nexus(vdc=vdc, vrf=vrf, metric=metric)
elif selection == "4":
if get_tables[0] == "Routing_ASA":
DbQueries.get_admin_disatnces(get_tables[0])
ad = input("AD: ")
print("\n")
DbQueries.search_db_asa(context=None, ad=ad)
elif get_tables[0] == "Routing_IOS_XE":
DbQueries.get_vrfs(get_tables[0])
vrf = input("VRF: ")
DbQueries.get_admin_disatnces(get_tables[0])
ad = input("AD: ")
print("\n")
DbQueries.search_db_ios(vrf=vrf, ad=ad)
elif get_tables[0] == "Routing_Nexus":
DbQueries.get_vdcs()
vdc = input("VDC: ")
DbQueries.get_vrfs(get_tables[0])
vrf = input("VRF: ")
DbQueries.get_admin_disatnces(get_tables[0])
ad = input("AD: ")
print("\n")
DbQueries.search_db_nexus(vdc=vdc, vrf=vrf, ad=ad)
elif selection == "5":
if get_tables[0] == "Routing_ASA":
DbQueries.print_routing_interfaces(table=get_tables[0])
interface = input("Interface: ")
print("\n")
DbQueries.search_db_asa(context=None, interface=interface)
elif get_tables[0] == "Routing_IOS_XE":
DbQueries.get_vrfs(get_tables[0])
vrf = input("VRF: ")
DbQueries.print_routing_interfaces(table=get_tables[0])
interface = input("Interface: ")
print("\n")
DbQueries.search_db_ios(vrf=vrf, interface=interface)
elif get_tables[0] == "Routing_Nexus":
DbQueries.get_vdcs()
vdc = input("VDC: ")
DbQueries.get_vrfs(get_tables[0])
vrf = input("VRF: ")
DbQueries.print_routing_interfaces(table=get_tables[0])
interface = input("Interface: ")
print("\n")
DbQueries.search_db_nexus(vdc=vdc, vrf=vrf, interface=interface)
elif selection == "6":
if get_tables[0] == "Routing_ASA":
DbQueries.get_tags(table=get_tables[0])
tag = input("Tag: ")
print("\n")
DbQueries.search_db_asa(context=None, tag=tag)
elif get_tables[0] == "Routing_IOS_XE":
DbQueries.get_vrfs(get_tables[0])
vrf = input("VRF: ")
DbQueries.get_tags(table=get_tables[0])
tag = input("Tag: ")
print("\n")
DbQueries.search_db_ios(vrf=vrf, tag=tag)
elif get_tables[0] == "Routing_Nexus":
DbQueries.get_vdcs()
vdc = input("VDC: ")
DbQueries.get_vrfs(get_tables[0])
vrf = input("VRF: ")
DbQueries.get_tags(table=get_tables[0])
tag = input("Tag: ")
print("\n")
DbQueries.search_db_nexus(vdc=vdc, vrf=vrf, tag=tag)
elif selection == "7":
if get_tables[0] == "Routing_ASA":
DbQueries.view_routes_asa()
elif get_tables[0] == "Routing_IOS_XE":
DbQueries.view_routes_ios()
elif get_tables[0] == "Routing_Nexus":
DbQueries.view_routes_nexus()
else:
print("Invalid Selection")
| StarcoderdataPython |
6467206 | from setuptools import setup
import importlib
cmdclass = None
try:
import jinja2 # Available when installed in dev mode
except ImportError:
pass
else:
cmdclass = {
'generate_docs': getattr(importlib.import_module('aiotumblr.utils.docgen'), 'DocGenCommand')
}
setup(
name='AIOTumblr',
version='0.1',
description='Tumblr API client on top of aiohttp and oauthlib',
author='Lena',
author_email='<EMAIL>',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Programming Language :: Python :: 3.7'
],
packages=['aiotumblr'],
install_requires=['aiohttp', 'oauthlib', 'python-forge'],
cmdclass=cmdclass
)
| StarcoderdataPython |
1654461 | <reponame>dmulyalin/salt-nornir
import logging
import pprint
import pytest
import os
log = logging.getLogger(__name__)
try:
import salt.client
import salt.exceptions
HAS_SALT = True
except:
HAS_SALT = False
raise SystemExit("SALT Nonrir Tests - failed importing SALT libraries")
if HAS_SALT:
# initiate execution modules client to run 'salt xyz command' commands
client = salt.client.LocalClient()
def _clean_files():
_ = client.cmd(
tgt="nrp1",
fun="cmd.run",
arg=["rm -f -r -d /var/salt-nornir/nrp1/files/*"],
kwarg={},
tgt_type="glob",
timeout=60,
)
def _get_files():
return client.cmd(
tgt="nrp1",
fun="cmd.run",
arg=["ls -l /var/salt-nornir/nrp1/files/"],
kwarg={},
tgt_type="glob",
timeout=60,
)
def test_nr_learn_using_nr_do_aliases():
_clean_files()
# check
ret = client.cmd(
tgt="nrp1",
fun="nr.learn",
arg=["interfaces", "facts"],
kwarg={},
tgt_type="glob",
timeout=60,
)
files = _get_files()
# pprint.pprint(ret)
# pprint.pprint(files)
assert ret["nrp1"]["failed"] == False, "nr.do failed"
assert "facts" in ret["nrp1"]["result"][1], "No facts collected"
assert "interfaces" in ret["nrp1"]["result"][0], "No interfaces collected"
assert files["nrp1"].count("facts__") >= 2, "Not all facts files stored"
assert files["nrp1"].count("interfaces__") >= 2, "Not all interfaces files stored"
# test_nr_learn_using_nr_do_aliases()
def test_nr_learn_using_nr_do_aliases():
_clean_files()
# check
ret = client.cmd(
tgt="nrp1",
fun="nr.learn",
arg=["interfaces", "facts"],
kwarg={},
tgt_type="glob",
timeout=60,
)
files = _get_files()
# pprint.pprint(ret)
# pprint.pprint(files)
assert ret["nrp1"]["failed"] == False, "nr.do failed"
assert "facts" in ret["nrp1"]["result"][1], "No facts collected"
assert "interfaces" in ret["nrp1"]["result"][0], "No interfaces collected"
assert files["nrp1"].count("facts__") >= 2, "Not all facts files stored"
assert files["nrp1"].count("interfaces__") >= 2, "Not all interfaces files stored"
# test_nr_learn_using_nr_do_aliases()
def test_nr_learn_using_nr_cli():
_clean_files()
# check
ret = client.cmd(
tgt="nrp1",
fun="nr.learn",
arg=["show version"],
kwarg={"fun": "cli", "tf": "cli_show_version"},
tgt_type="glob",
timeout=60,
)
files = _get_files()
# pprint.pprint(ret)
# pprint.pprint(files)
assert "show version" in ret["nrp1"]["ceos1"], "No show version output for ceos1"
assert "show version" in ret["nrp1"]["ceos2"], "No show version output for ceos2"
assert files["nrp1"].count("cli_show_version__") >= 2, "Not all files stored"
# test_nr_learn_using_nr_cli()
def test_nr_learn_using_nr_do_aliases_ceos1_only():
_clean_files()
# check
ret = client.cmd(
tgt="nrp1",
fun="nr.learn",
arg=["interfaces", "facts"],
kwarg={"FB": "ceos1"},
tgt_type="glob",
timeout=60,
)
files = _get_files()
# pprint.pprint(ret)
# pprint.pprint(files)
assert ret["nrp1"]["failed"] == False, "nr.do failed"
assert "facts" in ret["nrp1"]["result"][1], "No facts collected"
assert "interfaces" in ret["nrp1"]["result"][0], "No interfaces collected"
assert files["nrp1"].count("facts__") >= 1, "Not all facts files stored"
assert files["nrp1"].count("interfaces__") >= 1, "Not all interfaces files stored"
assert "ceos2" not in files["nrp1"], "Having extra output for ceos2"
# test_nr_learn_using_nr_do_aliases_ceos1_only()
| StarcoderdataPython |
1908345 | import os
from tqdm import tqdm
from IPython import embed
import numpy as np
import torch
from torch.autograd import Variable
from torch.utils.data import DataLoader
from utils import MemoryDataset, collate_fn, normal, normalize, ZFilter
from model import Model
from plotter import Plotter
class Trainer:
def __init__(self, config, env, model, model_config):
self.config = config
self.env = env
self.model = model
self.model_config = model_config
self.obs_zfilter = ZFilter(env.observation_space.shape, clip=None)
self.r_zfilter = ZFilter((1), demean=False, clip=None)
self.stats = {
'reward': []
}
self.best_eval_score = float('-INF')
window_config_list = [{
'num_traces': 1,
'opts': {
'title': '[Train] Reward',
'xlabel': 'Iteration',
'ylabel': 'Reward',
'width': 900,
'height': 400,
'margintop': 100
}
}, {
'num_traces': 1,
'opts': {
'title': '[Eval] Reward',
'xlabel': 'Iteration',
'ylabel': 'Reward',
'width': 900,
'height': 400,
'margintop': 100
}
}]
self.plotter = Plotter(self.config.experiment, window_config_list)
train_dir = os.path.join(config.ckpt_dir, config.experiment)
if not os.path.isdir(train_dir):
os.makedirs(train_dir)
def start(self):
for rnd in range(self.config.num_rounds):
self.train(rnd)
self.eval(rnd)
self.plotter.save()
def train(self, rnd):
self.model.set_train()
for iteration in range(self.config.num_train_iterations):
global_iteration = rnd * self.config.num_train_iterations \
+ iteration + 1
desc = '[Train | Iter {:3d}] Collecting rollout'.format(
global_iteration)
t = tqdm(range(self.config.num_train_episodes), desc=desc)
memory = MemoryDataset()
for episode in t:
data = self.run_episode()
memory.append(**data)
print('obs | mean: {}, std: {}'.format(
self.obs_zfilter.rs.mean, self.obs_zfilter.rs.std))
# print('r | mean: {}, std: {}'.format(
# self.r_zfilter.rs.mean, self.r_zfilter.rs.std))
data_loader = DataLoader(memory,
batch_size = self.config.batch_size, shuffle=True,
collate_fn=collate_fn)
old_model = Model(self.model_config, verbose=False)
old_model.set_policy_state(self.model.get_policy_state())
old_model.set_train()
for epoch in range(self.config.num_train_epochs):
desc = '[Train | Iter {:3d}] Update epoch {:2d}'.format(
global_iteration, epoch)
t = tqdm(data_loader, desc=desc)
for batch in t:
observation = Variable(batch['observation'])
action = batch['action']
action_index = (range(len(action)), action)
reward = Variable(batch['reward'])
advantage = Variable(batch['advantage'])
advantage = normalize(advantage)
# old_mean, old_std, _, _ = old_model.select_action(observation)
# old_prob = normal(old_mean, old_std, action)
# mean, std, _, value = self.model.select_action(observation)
# prob = normal(mean, std, action)
old_prob, _, _ = old_model.select_action(observation)
old_prob = old_prob[action_index].view(-1, 1)
prob, _, value = self.model.select_action(observation)
prob = prob[action_index].view(-1, 1)
ratio = prob / (1e-16 + old_prob)
surr1 = ratio * advantage
surr2 = torch.clamp(ratio, 1 - self.model_config.epsilon,
1 + self.model_config.epsilon) * advantage
clip_loss = -torch.mean(torch.min(surr1, surr2))
entropy = prob * torch.log(prob + 1e-16)
entropy_loss = self.model_config.beta * torch.mean(entropy)
# old_model.set_policy_state(self.model.get_policy_state())
policy_loss = clip_loss + entropy_loss
self.model.policy_optimizer.zero_grad()
policy_loss.backward()
self.model.policy_optimizer.step()
value_loss = torch.mean((value - reward) ** 2)
self.model.value_optimizer.zero_grad()
value_loss.backward()
self.model.value_optimizer.step()
memory.clear()
if (iteration + 1) % self.config.log_interval == 0:
self.plot(global_iteration, 'train')
def eval(self, rnd):
self.model.set_eval()
global_iteration = (rnd + 1) * self.config.num_train_iterations
desc = '[Eval | Iter {:3d}] Running evaluation'.format(
global_iteration)
t = tqdm(range(self.config.num_eval_episodes), desc=desc)
for episode in t:
_ = self.run_episode()
eval_score = np.mean(self.stats['reward'])
is_best = False
if eval_score > self.best_eval_score:
is_best = True
self.best_eval_score = eval_score
info = {
'iteration': global_iteration,
'eval_score': eval_score
}
ckpt_path = os.path.join(self.config.ckpt_dir, self.config.experiment,
'model-{}.ckpt'.format(rnd))
self.model.save_state(info, ckpt_path, is_best)
self.plot(global_iteration, 'eval')
def run_episode(self):
observations = [] # cuda tensor of shape (1,) + env.observation_space.shape
# actions = [] # cuda tensor of shape (1,) + env.action_space.shape
actions = [] # int
values = [] # cuda tensor of shape (1, 1)
rewards = [] # float
self.stats['reward'].append([])
done = False
obs = self.env.reset()
while not done:
obs = self.obs_zfilter(obs)
obs = torch.from_numpy(obs).float().unsqueeze(0).cuda()
observations.append(obs)
_, act, val = self.model.select_action(Variable(obs, volatile=True))
actions.append(act)
values.append(val.data)
# act = act.data.squeeze().cpu().numpy()
obs, r, done, _ = self.env.step(act)
self.stats['reward'][-1].append(r)
# r = self.r_zfilter(np.array([r]))[0]
rewards.append(r)
self.stats['reward'][-1] = sum(self.stats['reward'][-1])
obs = self.obs_zfilter(obs)
obs = torch.from_numpy(obs).float().unsqueeze(0).cuda()
_, _, val = self.model.select_action(Variable(obs, volatile=True))
values.append(val.data)
R = torch.zeros(1, 1).cuda()
A = torch.zeros(1, 1).cuda()
acc_rewards = []
advantages = []
for i in reversed(range(len(rewards))):
R = rewards[i] + self.model_config.gamma * R
acc_rewards.insert(0, R)
delta = rewards[i] + self.model_config.gamma * values[i + 1] \
- values[i]
A = delta + self.model_config.gamma * self.model_config.lmbda * A
advantages.insert(0, A)
return {
'observations': observations,
'actions': actions,
'rewards': acc_rewards,
'advantages': advantages
}
def plot(self, global_iteration, mode):
upper = lambda s: s[0].upper() + s[1:]
title_prefix = '[{}]'.format(upper(mode))
reward = np.mean(self.stats['reward'])
stats_list = [{
'title': '{} Reward'.format(title_prefix),
'X': global_iteration,
'Y': reward
}]
self.plotter.update(stats_list)
prefix = title_prefix + (' ' if mode == 'eval' else '')
print('{} Iteration {:5d} | Reward {:.5f}\n'.format(
prefix, global_iteration, reward))
self.clear_stats()
def clear_stats(self):
self.stats = {
'reward': []
}
| StarcoderdataPython |
8157385 | <reponame>aniket15b/URL-Shortener
from django.db import models
# Create your models here.
class Route(models.Model):
original_url = models.URLField(help_text= "Add the original URL that you want to shorten.")
key = models.TextField(unique= True, help_text= "Add any random characters of your choice to shorten it.")
def __str__(self):
return f"{self.key}" | StarcoderdataPython |
4890784 | """This component provides HA sensor support for Ring Door Bell/Chimes."""
from __future__ import annotations
from dataclasses import dataclass
from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
)
from homeassistant.const import PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT
from homeassistant.core import callback
from homeassistant.helpers.icon import icon_for_battery_level
from . import DOMAIN
from .entity import RingEntityMixin
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up a sensor for a Ring device."""
devices = hass.data[DOMAIN][config_entry.entry_id]["devices"]
entities = [
description.cls(config_entry.entry_id, device, description)
for device_type in ("chimes", "doorbots", "authorized_doorbots", "stickup_cams")
for description in SENSOR_TYPES
if device_type in description.category
for device in devices[device_type]
if not (device_type == "battery" and device.battery_life is None)
]
async_add_entities(entities)
class RingSensor(RingEntityMixin, SensorEntity):
"""A sensor implementation for Ring device."""
entity_description: RingSensorEntityDescription
_attr_should_poll = False # updates are controlled via the hub
def __init__(
self,
config_entry_id,
device,
description: RingSensorEntityDescription,
):
"""Initialize a sensor for Ring device."""
super().__init__(config_entry_id, device)
self.entity_description = description
self._extra = None
self._attr_name = f"{device.name} {description.name}"
self._attr_unique_id = f"{device.id}-{description.key}"
@property
def native_value(self):
"""Return the state of the sensor."""
sensor_type = self.entity_description.key
if sensor_type == "volume":
return self._device.volume
if sensor_type == "battery":
return self._device.battery_life
@property
def icon(self):
"""Icon to use in the frontend, if any."""
if (
self.entity_description.key == "battery"
and self._device.battery_life is not None
):
return icon_for_battery_level(
battery_level=self._device.battery_life, charging=False
)
return self.entity_description.icon
class HealthDataRingSensor(RingSensor):
"""Ring sensor that relies on health data."""
async def async_added_to_hass(self):
"""Register callbacks."""
await super().async_added_to_hass()
await self.ring_objects["health_data"].async_track_device(
self._device, self._health_update_callback
)
async def async_will_remove_from_hass(self):
"""Disconnect callbacks."""
await super().async_will_remove_from_hass()
self.ring_objects["health_data"].async_untrack_device(
self._device, self._health_update_callback
)
@callback
def _health_update_callback(self, _health_data):
"""Call update method."""
self.async_write_ha_state()
@property
def entity_registry_enabled_default(self) -> bool:
"""Return if the entity should be enabled when first added to the entity registry."""
# These sensors are data hungry and not useful. Disable by default.
return False
@property
def native_value(self):
"""Return the state of the sensor."""
sensor_type = self.entity_description.key
if sensor_type == "wifi_signal_category":
return self._device.wifi_signal_category
if sensor_type == "wifi_signal_strength":
return self._device.wifi_signal_strength
class HistoryRingSensor(RingSensor):
"""Ring sensor that relies on history data."""
_latest_event = None
async def async_added_to_hass(self):
"""Register callbacks."""
await super().async_added_to_hass()
await self.ring_objects["history_data"].async_track_device(
self._device, self._history_update_callback
)
async def async_will_remove_from_hass(self):
"""Disconnect callbacks."""
await super().async_will_remove_from_hass()
self.ring_objects["history_data"].async_untrack_device(
self._device, self._history_update_callback
)
@callback
def _history_update_callback(self, history_data):
"""Call update method."""
if not history_data:
return
kind = self.entity_description.kind
found = None
if kind is None:
found = history_data[0]
else:
for entry in history_data:
if entry["kind"] == kind:
found = entry
break
if not found:
return
self._latest_event = found
self.async_write_ha_state()
@property
def native_value(self):
"""Return the state of the sensor."""
if self._latest_event is None:
return None
return self._latest_event["created_at"]
@property
def extra_state_attributes(self):
"""Return the state attributes."""
attrs = super().extra_state_attributes
if self._latest_event:
attrs["created_at"] = self._latest_event["created_at"]
attrs["answered"] = self._latest_event["answered"]
attrs["recording_status"] = self._latest_event["recording"]["status"]
attrs["category"] = self._latest_event["kind"]
return attrs
@dataclass
class RingRequiredKeysMixin:
"""Mixin for required keys."""
category: list[str]
cls: type[RingSensor]
@dataclass
class RingSensorEntityDescription(SensorEntityDescription, RingRequiredKeysMixin):
"""Describes Ring sensor entity."""
kind: str | None = None
SENSOR_TYPES: tuple[RingSensorEntityDescription, ...] = (
RingSensorEntityDescription(
key="battery",
name="Battery",
category=["doorbots", "authorized_doorbots", "stickup_cams"],
native_unit_of_measurement=PERCENTAGE,
device_class="battery",
cls=RingSensor,
),
RingSensorEntityDescription(
key="last_activity",
name="Last Activity",
category=["doorbots", "authorized_doorbots", "stickup_cams"],
icon="mdi:history",
device_class=SensorDeviceClass.TIMESTAMP,
cls=HistoryRingSensor,
),
RingSensorEntityDescription(
key="last_ding",
name="Last Ding",
category=["doorbots", "authorized_doorbots"],
icon="mdi:history",
kind="ding",
device_class=SensorDeviceClass.TIMESTAMP,
cls=HistoryRingSensor,
),
RingSensorEntityDescription(
key="last_motion",
name="Last Motion",
category=["doorbots", "authorized_doorbots", "stickup_cams"],
icon="mdi:history",
kind="motion",
device_class=SensorDeviceClass.TIMESTAMP,
cls=HistoryRingSensor,
),
RingSensorEntityDescription(
key="volume",
name="Volume",
category=["chimes", "doorbots", "authorized_doorbots", "stickup_cams"],
icon="mdi:bell-ring",
cls=RingSensor,
),
RingSensorEntityDescription(
key="wifi_signal_category",
name="WiFi Signal Category",
category=["chimes", "doorbots", "authorized_doorbots", "stickup_cams"],
icon="mdi:wifi",
cls=HealthDataRingSensor,
),
RingSensorEntityDescription(
key="wifi_signal_strength",
name="WiFi Signal Strength",
category=["chimes", "doorbots", "authorized_doorbots", "stickup_cams"],
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
icon="mdi:wifi",
device_class="signal_strength",
cls=HealthDataRingSensor,
),
)
| StarcoderdataPython |
11252871 | from django.apps import AppConfig
class InventarisConfig(AppConfig):
name = 'inventaris'
| StarcoderdataPython |
6473961 | <reponame>msc-acse/acse-9-independent-research-project-Wade003
#!/usr/bin/env python
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""
GUI creation utilities
"""
import os
import unittest
import fluidity.diagnostics.debug as debug
import fluidity.diagnostics.optimise as optimise
import fluidity.diagnostics.utils as utils
def GuiDisabledByEnvironment():
return "DIAGNOSTICS_GUI_DISABLED" in os.environ and os.environ["DIAGNOSTICS_GUI_DISABLED"]
if not GuiDisabledByEnvironment():
try:
import gobject
except:
debug.deprint("Warning: Failed to import gobject module")
try:
import gtk
except:
debug.deprint("Warning: Failed to import gtk module")
def DisplayWindow(window):
"""
Launch the GTK main loop to display the supplied window
"""
window.connect("destroy", gtk.main_quit)
window.show()
gtk.main()
return
def DisplayWidget(widget, width = 640, height = 480, title = None):
"""
Pack the supplied widget in a simple window, and launch the GTK main loop to
display it
"""
window = WindowWidget(widget, width, height, title)
DisplayWindow(window)
return
def DisplayPlot(plot, withToolbar = True, width = 640, height = 480, title = None):
"""
Generate a widget from the supplied plot, pack the supplied widget in a simple
window, and launch the GTK main loop to display it
"""
widget = plot.Widget(withToolbar = withToolbar)
widget.show_all()
DisplayWidget(widget, width = width, height = height, title = title)
return
def WindowWidget(widget, width = 640, height = 480, title = None):
"""
Pack the supplied widget in a simple window
"""
window = gtk.Window()
window.set_default_size(width, height)
if not title is None:
window.set_title(title)
window.add(widget)
return window
def ComboBoxFromEntries(entries):
"""
Contruct a combo box from the list of entries
"""
comboBox = gtk.combo_box_new_text()
for entry in entries:
comboBox.append_text(entry)
return comboBox
def TableFromWidgetsArray(widgets, homogeneous = False):
"""
Construct a table containing the supplied array of widgets
(which can be ragged)
"""
rows, columns = len(widgets), 0
if rows > 0:
if utils.CanLen(widgets[0]) and not isinstance(widgets[0], gtk.Widget):
columns = len(widgets[0])
for subWidget in widgets[1:]:
columns = max(columns, len(widgets))
else:
widgets = [[widget] for widget in widgets]
columns = 1
table = gtk.Table(rows = rows, columns = columns, homogeneous = homogeneous)
for i in range(rows):
for j in range(len(widgets[i])):
table.attach(widgets[i][j], j, j + 1, i, i + 1)
return table
class guiUnittests(unittest.TestCase):
def testGtkSupport(self):
import gobject
import gtk
return
def testComboBoxFromEntries(self):
self.assertTrue(isinstance(ComboBoxFromEntries([]), gtk.ComboBox))
return
| StarcoderdataPython |
1867101 | <reponame>Rafiatu/ebay_predictions
from decouple import config
import pandas as pd
import psycopg2
import psycopg2.extras as extras
class DatabaseError(psycopg2.Error):
pass
class Database:
"""
Database class. Handles all connections to the database on heroku.
"""
connection = psycopg2.connect(
dbname=config("DB_NAME"),
port=config("DB_PORT"),
host=config("DB_HOST"),
user=config("DB_USER"),
password=config("<PASSWORD>")
)
connection.autocommit = True
cursor = connection.cursor()
def connect(self) -> object:
"""
connects to the postgres database.
:return: database connection cursor
"""
try:
return self.cursor
except DatabaseError:
raise DatabaseError("There was a problem connecting to the requested database.")
def setup_table(self) -> None:
"""
sets up the Prediction table in the database.
:return: Table successfully created message.
"""
try:
self.cursor.execute("""CREATE TABLE IF NOT EXISTS Predictions(id SERIAL PRIMARY KEY, title VARCHAR,
category VARCHAR, outputs FLOAT)""")
print("Predictions table now available in database.")
except (DatabaseError, Exception):
raise DatabaseError("Could not create tables in the specified database")
def delete_tables(self) -> None:
"""
deletes Prediction tables from the database
:return: Table successfully deleted message
"""
try:
self.cursor.execute("DROP TABLE IF EXISTS Predictions")
print("Predictions tables no longer in database.")
except (Exception, DatabaseError) as error:
raise error
def add_prediction_result_to_database(self, df: pd.DataFrame):
"""
Adds new record to the Listings Database records.
:param details:a dictionary that contains the title,
category, image url, item url, price of a listing.
:return: Record successfully added to Database message.
"""
try:
self.setup_table()
tuples = [tuple(x) for x in df.to_numpy()]
cols = ','.join(list(df.columns))
query = "INSERT INTO %s(%s) VALUES(%%s,%%s,%%s)" % ('Predictions', cols)
extras.execute_batch(self.cursor, query, tuples, len(df))
print("Record successfully added to Predictions")
except (DatabaseError, Exception) as error:
raise error("Something went wrong when trying to add record(s)")
def extract_predictions_from_database(self):
"""
Gets the last 10 predictions from the database
:return: List of tuples containing the last 10 predictions.
"""
try:
self.cursor.execute("SELECT * FROM Predictions ORDER BY id DESC LIMIT 10")
return self.cursor.fetchall()
except Exception:
raise Exception
| StarcoderdataPython |
8103012 | <reponame>acm-ucr/xhtml2pdf
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
# Copyright 2010 <NAME>, holtwick.it
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
try:
from setuptools import setup, find_packages
except ImportError:
from ez_setup import use_setuptools
use_setuptools()
README = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
setup(
name="xhtml2pdf",
version="0.0.4",
description="PDF generator using HTML and CSS",
license="Apache License 2.0",
author="<NAME>",
maintainer="<NAME>",
maintainer_email="<EMAIL>",
url="http://www.xhtml2pdf.com",
keywords="PDF, HTML, XHTML, XML, CSS",
install_requires = ["html5lib", "pypdf", "pillow", "reportlab"],
include_package_data = True,
packages=find_packages(exclude=["tests", "tests.*"]),
# test_suite = "tests", They're not even working yet
entry_points = {
'console_scripts': [
'pisa = xhtml2pdf.pisa:command',
'xhtml2pdf = xhtml2pdf.pisa:command',
]
},
long_description=README,
classifiers =[
'License :: OSI Approved :: Apache Software License',
'Development Status :: 4 - Beta',
'Environment :: Console',
'Environment :: Other Environment',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Natural Language :: English',
'Operating System :: OS Independent',
'Topic :: Documentation',
'Topic :: Multimedia',
'Topic :: Office/Business',
'Topic :: Printing',
'Topic :: Text Processing',
'Topic :: Text Processing :: Filters',
'Topic :: Text Processing :: Fonts',
'Topic :: Text Processing :: General',
'Topic :: Text Processing :: Indexing',
'Topic :: Text Processing :: Markup',
'Topic :: Text Processing :: Markup :: HTML',
'Topic :: Text Processing :: Markup :: XML',
'Topic :: Utilities',
]
)
| StarcoderdataPython |
1772249 | import sys
s = sys.stdin.readline().rstrip()
def main():
ans = 'Good'
for i in range(3):
if s[i] == s[i+1]:
ans = 'Bad'
break
print(ans)
if __name__ == '__main__':
main()
| StarcoderdataPython |
11288626 | from .Auth.authentication import urlpatterns as auth_url_patters
from .Setup.roles import urlpatterns as routepatterns
urlpatterns = []
urlpatterns += auth_url_patters
urlpatterns += routepatterns
| StarcoderdataPython |
4889739 | """
POO - Abstração e Encapsulamento
O grande objetivo da POO é encapsular nosso código dentro de um grupo lógico e hierárquico utilizando classes.
Encapsular - A classe vai encapsular(englobar) os atributos e métodos.
classe
---------------------------------
/ /
/ atributos e métodos /
/_______________________________/
# Relembrando Atributos/Métodos privados em Python
Imagine que temos uma classe chamada Pessoa, contendo um atributo privado chamado __nome e um método privado
chamado __falar()
Esses elementos privados só devem/deveriam ser acessados dentro da classe. Mas Python não bloqueia este acesso
fora da classe. Com Python acontece um fenômeno chamado Name Mangling, que faz uma alteração na forma de se
acessar os elementos privados, conforme:
_Classe__elemento
Exemplo - Acessando elementos privados fora da classe:
instancia._Pessoa__nome
instancia._Pessoa__falar()
Abstração, em POO, é o ato de expor apenas dados relevantes de uma classe, escondendo atributos e métodos privados
do usuário.
# Exemplo
Quando fazemos uma ligação de um smartphone para outro, os seguintes passos são executados:
Ligar o smartphone -> clicar no icone do telefone -> digitar o número do outro aparelho no teclado -> executar a chamada
Entretando, é escondido para o usuário o processo de ligar para a operadora do celular, acessar o banco de dados dela
para encontrar o registro de telefone do outro aparelho para conectar a chamada.
"""
"""
class Conta:
contador = 400
def __init__(self, titular, saldo, limite):
self.numero = Conta.contador
self.titular = titular
self.saldo = saldo
self.limite = limite
def extrato(self):
print(f'Saldo de {self.saldo} do titular {self.titular} com limite de {self.limite}')
def depositar(self, valor):
self.saldo += valor
def sacar(self, valor):
self.saldo -= valor
# Testando
conta1 = Conta('Geek', 150.00, 1500)
print(conta1.numero)
print(conta1.titular)
print(conta1.saldo)
print(conta1.limite)
conta1.numero = 2019
conta1.titular = 'Ian'
conta1.saldo = 790
conta1.limite = 1050
# Com o acesso público pode fazer a leitura e alteração dos dados
print(conta1.__dict__)
# {'numero': 2019, 'titular': 'Ian', 'saldo': 790, 'limite': 1050}
# OBS: Isso pode ser um problema, pois não garante a segurança dos dados por falta de Encapsulamento
"""
# Como Resolver? Refatorando os dados tornado-os privados
class Conta:
contador = 400
def __init__(self, titular, saldo, limite):
self.__numero = Conta.contador
self.__titular = titular
self.__saldo = saldo
self.__limite = limite
Conta.contador += 1
def extrato(self):
print(f'Saldo de {self.__saldo} do titular {self.__titular} com limite de {self.__limite}')
def depositar(self, valor):
if valor > 0:
self.__saldo += valor
else:
print('O valor precisa ser positivo!')
def sacar(self, valor):
if valor > 0:
if self.__saldo >= valor:
self.__saldo -= valor
else:
print('Saldo insuficiente!')
else:
print('O valor precisa ser positivo!')
def transferir(self, valor, conta_destino):
# 1 - Remover o valor da conta de origem
self.__saldo -= valor
self.__saldo -= 10 # Taxa de transferência
# 2 - Adicionar o valor na conta de destino
conta_destino.__saldo += valor
conta1 = Conta('Ian', 150.00, 1500)
conta1.extrato()
conta2 = Conta('Barba', 400.00, 2000)
conta2.extrato()
conta2.transferir(100, conta1)
conta1.extrato()
conta2.extrato()
# print(conta1.numero) AttributeError: 'Conta' object has no attribute 'numero'
# print(conta1.titular)
# print(conta1.saldo)
# print(conta1.limite)
"""
conta1.numero = 2019
conta1.titular = 'Ian'
conta1.saldo = 790
conta1.limite = 1050
conta1.extrato()
# Pode imprimir e alterar o valor, Mas avisa que não deveria fazer o acesso dessa forma
print(conta1._Conta__titular) # Name Mangling
conta1._Conta__titular = 'Angelina'
"""
print(conta1.__dict__)
conta1.depositar(150)
conta1.depositar(-150)
print(conta1.__dict__)
conta1.sacar(200)
print(conta1.__dict__)
conta1.sacar(1800)
print(conta1.__dict__)
conta1.sacar(-300)
print(conta1.__dict__) | StarcoderdataPython |
1707383 | import datetime
from django.db import models
from django.dispatch import receiver
from django.utils import timezone
from django.conf import settings
# Create your models here.
from django.db.models.signals import pre_save, post_save
from django.urls import reverse
from model_utils import Choices
from util.util import scramble_upload_filename, unique_slug_generator
class Category(models.Model):
name = models.CharField(max_length=100)
def __str__(self):
return self.name
class Discount(models.Model):
name = models.CharField(max_length=100)
amount = models.DecimalField(default=0.00, decimal_places=2, max_digits=100)
discount_type = models.CharField(max_length=30, choices=Choices('Amount', 'Percentage'),
default='Percentage')
expired_type = models.CharField(max_length=30, choices=Choices('On Date', 'Date Range', 'No Expired'),
default='No Expired')
expired = models.DateTimeField(null=True, blank=True)
start = models.DateTimeField(null=True, blank=True)
end = models.DateTimeField(null=True, blank=True)
is_active = models.BooleanField(default=True)
def __str__(self):
return self.name
@property
def is_discount(self):
if self.is_active and not self.amount.is_zero():
if self.expired_type == "On Date":
return self.expired > timezone.now()
elif self.expired_type == "Date Range":
return self.expired >= timezone.now() >= self.expired
else:
return True
return False
class Product(models.Model):
category = models.ForeignKey(Category, on_delete=models.CASCADE)
image = models.ImageField(upload_to=scramble_upload_filename)
slug = models.SlugField(max_length=100, unique=True, null=True, allow_unicode=True)
title = models.CharField(max_length=100)
search_text = models.TextField(max_length=100, null=True)
description = models.TextField(max_length=1000)
price = models.DecimalField(default=0.00, decimal_places=2, max_digits=100)
maximum = models.IntegerField(default=10)
discount = models.ForeignKey(Discount, on_delete=models.SET_NULL, null=True, blank=True)
availability = models.CharField(max_length=30, choices=Choices('In Stock', 'Out of Stock'), default='In Stock')
create_date = models.DateTimeField(auto_now_add=True)
is_active = models.BooleanField(default=True)
discount_available = models.BooleanField(default=False)
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse('store:product', kwargs={'slug': self.slug})
def is_available(self):
return self.availability == 'In Stock'
@property
def get_availability_color(self):
return "availability" if self.availability == "In Stock" else "no-availability "
@property
def price_text(self):
return '{0} {1}'.format(settings.CURRENCY_TYPE, self.price)
@property
def discount_price_text(self):
return '{0} {1}'.format(settings.CURRENCY_TYPE, self.discount_price)
@property
def discount_text(self):
if self.is_discount:
if self.discount.discount_type == 'Amount':
return '-{0}'.format(self.discount.amount)
return '{0} %'.format(int(self.discount.amount))
return '-'
@property
def discount_price(self):
if self.is_discount:
if self.discount.discount_type == 'Amount':
return self.price - self.discount.amount
else:
return self.price - (round((self.discount.amount / 100) * self.price, 2))
return 0.0
@property
def is_discount(self):
if self.discount is not None:
if self.discount.is_active and not self.discount.amount.is_zero():
if self.discount.expired_type == "On Date":
return self.discount.expired > timezone.now()
elif self.discount.expired_type == "Date Range":
return self.discount.expired >= timezone.now() >= self.discount.expired
else:
return True
return False
@property
def get_price(self):
return self.discount_price if self.is_discount else self.price
@property
def is_new(self):
return (self.create_date + datetime.timedelta(days=15)) > timezone.now()
def slug_save(sender, instance, *args, **kwargs):
if not instance.slug:
instance.slug = unique_slug_generator(instance, instance.title, instance.slug)
instance.discount_available = instance.is_discount
pre_save.connect(slug_save, sender=Product)
@receiver(post_save, sender=Product)
def update_product_discount_post_save(sender, **kwargs):
model = kwargs['instance']
model.discount_available = model.is_discount
@receiver(post_save, sender=Discount)
def update_discount_post_save(sender, **kwargs):
model = kwargs['instance']
model.product_set.update(discount_available=model.is_discount)
| StarcoderdataPython |
5000008 | <gh_stars>1-10
from PyQt5.QtWidgets import QHBoxLayout, QLabel, QWidget
from PyQt5.QtCore import pyqtSignal
from widgets import ImageButton
class PlusIcon(QWidget):
"""
Plus icon widget with specified description text to its right
"""
add = pyqtSignal()
def __init__(self, text: str, size: int = 24, parent: QWidget = None):
super().__init__(parent)
# Layout
hLayout = QHBoxLayout()
plusIcon = ImageButton('plus', size, size)
hLayout.addWidget(plusIcon)
hLayout.addWidget(QLabel(text))
hLayout.addStretch(1)
self.setLayout(hLayout)
# Connect button signal
plusIcon.clicked.connect(self.add) | StarcoderdataPython |
3256862 | <filename>build/lib/OpenSpecimenAPIconnector/os_core/participant.py<gh_stars>1-10
#! /bin/python3
# Import
import json
from datetime import datetime
from .req_util import OS_request_gen
from .. import config_manager
class participant:
"""Handles the API calls for the participant
Handles the OpenSpecimen API calls for the participants. This class can
get a participant with a Participant Protocoll ID PPID or via search parameters.
Note
-----
In order to use this and also the other classes, the user has to know OpenSpecimen. In the core classes, one can
just pass the parameters via a JSON-formatted string. This means the user has to know the keywords.
The API calls are documented in https://openspecimen.atlassian.net/wiki/spaces/CAT/pages/1116035/REST+APIs and
the calls refer to this site. More details can be seen in the documentation.
Examples
--------
A code Examples, where the institutes are handled, is in the Jupyter-Notebook:
$ jupyter notebook main.ipynb
"""
def __init__(self):
"""Constructor of the Class institutes
Constructor of the class institutes can handle the basic API-calls
of the institutes in OpenSpecimen. Connects this class to OpenSpecimen
specific URL Generator Class (os_core/url.py) and the os_util class participant_util
Parameters
----------
base_url : string
URL to openspecimen, has the format: http(s)://<host>:<port>/openspecimen/rest/ng
auth : tuple
Consists of two strings ( loginname , password)
"""
self.base_url = config_manager.get_url()
self.auth = config_manager.get_auth()
self.OS_request_gen = OS_request_gen(self.auth)
def ausgabe(self):
"""Testing of the URL and authentification.
If there are any unexpected errors, one can easily test if the URL and login data is spelled correctly.
The function prints the URL and login data to the output terminal, which was handed over to the class.
"""
print(self.base_url, self.OS_request_gen.auth)
def get_participant(self, ppid):
"""Get the participant with the Participant Protocol ID ppid
Get the details of the Participant with the Collection protocol wide unique ID ppid.
This ID can be generated automatically from OpenSpecimen or generated manually, which has
to be specified when the Collection Protocol is created.
Parameters
----------
ppid : int
The Collection Protocol wide unique Participant Protocol ID of the Institute will be converted to a string.
Returns
-------
JSON-dict
Details of the Participant with the specified PPID, or the OpenSpecimen error message.
"""
endpoint = '/participants/' + str(ppid)
url = self.base_url + endpoint
r = self.OS_request_gen.get_request(url)
return json.loads(r.text)
def get_participant_matches(self, params):
"""Get the Participants who matches the params.
Get one or more participants who match the criteria passed with params. This class can be used via
the os_util class cpr_util.py.
Note
----
In the response the matching attributes are listed.
Parameters
----------
params : string
Json formatted string with parameters: lastName (substring)[optional], uid[optional], birthDate[optional],
pmi(dict with keys mrn[optional], siteName[optional]) [optional], empi[optional], reqRegInfo(default =false)[optional]
Returns
-------
JSON-dict
Details of all matching participants or the OpenSpecimen's error message.
"""
endpoint = '/participants/match'
url = self.base_url + endpoint
payload=params
r = self.OS_request_gen.post_request(url,data=payload)
return json.loads(r.text)
| StarcoderdataPython |
1866764 | <reponame>MarchRaBBiT/pipelinex
from datetime import datetime, timedelta
import os
import tempfile
import torch
import logging
log = logging.getLogger(__name__)
__all__ = ["FlexibleModelCheckpoint"]
"""
Copied from https://github.com/pytorch/ignite/blob/v0.2.1/ignite/handlers/checkpoint.py
due to the change in ignite v0.3.0
"""
class ModelCheckpoint(object):
""" ModelCheckpoint handler can be used to periodically save objects to disk.
This handler expects two arguments:
- an :class:`~ignite.engine.Engine` object
- a `dict` mapping names (`str`) to objects that should be saved to disk.
See Notes and Examples for further details.
Args:
dirname (str):
Directory path where objects will be saved.
filename_prefix (str):
Prefix for the filenames to which objects will be saved. See Notes
for more details.
save_interval (int, optional):
if not None, objects will be saved to disk every `save_interval` calls to the handler.
Exactly one of (`save_interval`, `score_function`) arguments must be provided.
score_function (callable, optional):
if not None, it should be a function taking a single argument,
an :class:`~ignite.engine.Engine` object,
and return a score (`float`). Objects with highest scores will be retained.
Exactly one of (`save_interval`, `score_function`) arguments must be provided.
score_name (str, optional):
if `score_function` not None, it is possible to store its absolute value using `score_name`. See Notes for
more details.
n_saved (int, optional):
Number of objects that should be kept on disk. Older files will be removed.
atomic (bool, optional):
If True, objects are serialized to a temporary file,
and then moved to final destination, so that files are
guaranteed to not be damaged (for example if exception occures during saving).
require_empty (bool, optional):
If True, will raise exception if there are any files starting with `filename_prefix`
in the directory 'dirname'.
create_dir (bool, optional):
If True, will create directory 'dirname' if it doesnt exist.
save_as_state_dict (bool, optional):
If True, will save only the `state_dict` of the objects specified, otherwise the whole object will be saved.
Note:
This handler expects two arguments: an :class:`~ignite.engine.Engine` object and a `dict`
mapping names to objects that should be saved.
These names are used to specify filenames for saved objects.
Each filename has the following structure:
`{filename_prefix}_{name}_{step_number}.pth`.
Here, `filename_prefix` is the argument passed to the constructor,
`name` is the key in the aforementioned `dict`, and `step_number`
is incremented by `1` with every call to the handler.
If `score_function` is provided, user can store its absolute value using `score_name` in the filename.
Each filename can have the following structure:
`{filename_prefix}_{name}_{step_number}_{score_name}={abs(score_function_result)}.pth`.
For example, `score_name="val_loss"` and `score_function` that returns `-loss` (as objects with highest scores
will be retained), then saved models filenames will be `model_resnet_10_val_loss=0.1234.pth`.
Examples:
>>> import os
>>> from ignite.engine import Engine, Events
>>> from ignite.handlers import ModelCheckpoint
>>> from torch import nn
>>> trainer = Engine(lambda batch: None)
>>> handler = ModelCheckpoint('/tmp/models', 'myprefix', save_interval=2, n_saved=2, create_dir=True)
>>> model = nn.Linear(3, 3)
>>> trainer.add_event_handler(Events.EPOCH_COMPLETED, handler, {'mymodel': model})
>>> trainer.run([0], max_epochs=6)
>>> os.listdir('/tmp/models')
['myprefix_mymodel_4.pth', 'myprefix_mymodel_6.pth']
"""
def __init__(
self,
dirname,
filename_prefix,
save_interval=None,
score_function=None,
score_name=None,
n_saved=1,
atomic=True,
require_empty=True,
create_dir=True,
save_as_state_dict=True,
):
self._dirname = os.path.expanduser(dirname)
self._fname_prefix = filename_prefix
self._n_saved = n_saved
self._save_interval = save_interval
self._score_function = score_function
self._score_name = score_name
self._atomic = atomic
self._saved = [] # list of tuples (priority, saved_objects)
self._iteration = 0
self._save_as_state_dict = save_as_state_dict
if not (save_interval is None) ^ (score_function is None):
raise ValueError(
"Exactly one of `save_interval`, or `score_function` "
"arguments must be provided."
)
if score_function is None and score_name is not None:
raise ValueError(
"If `score_name` is provided, then `score_function` "
"should be also provided."
)
if create_dir:
if not os.path.exists(dirname):
os.makedirs(dirname)
# Ensure that dirname exists
if not os.path.exists(dirname):
raise ValueError("Directory path '{}' is not found.".format(dirname))
if require_empty:
matched = [
fname
for fname in os.listdir(dirname)
if fname.startswith(self._fname_prefix)
]
if len(matched) > 0:
raise ValueError(
"Files prefixed with {} are already present "
"in the directory {}. If you want to use this "
"directory anyway, pass `require_empty=False`."
"".format(filename_prefix, dirname)
)
def _save(self, obj, path):
if not self._atomic:
self._internal_save(obj, path)
else:
tmp = tempfile.NamedTemporaryFile(delete=False, dir=self._dirname)
try:
self._internal_save(obj, tmp.file)
except BaseException:
tmp.close()
os.remove(tmp.name)
raise
else:
tmp.close()
os.rename(tmp.name, path)
def _internal_save(self, obj, path):
if not self._save_as_state_dict:
torch.save(obj, path)
else:
if not hasattr(obj, "state_dict") or not callable(obj.state_dict):
raise ValueError("Object should have `state_dict` method.")
torch.save(obj.state_dict(), path)
def __call__(self, engine, to_save):
if len(to_save) == 0:
raise RuntimeError("No objects to checkpoint found.")
self._iteration += 1
if self._score_function is not None:
priority = self._score_function(engine)
else:
priority = self._iteration
if (self._iteration % self._save_interval) != 0:
return
if (len(self._saved) < self._n_saved) or (self._saved[0][0] < priority):
saved_objs = []
suffix = ""
if self._score_name is not None:
suffix = "_{}={:.7}".format(self._score_name, abs(priority))
for name, obj in to_save.items():
fname = "{}_{}_{}{}.pth".format(
self._fname_prefix, name, self._iteration, suffix
)
path = os.path.join(self._dirname, fname)
self._save(obj=obj, path=path)
saved_objs.append(path)
self._saved.append((priority, saved_objs))
self._saved.sort(key=lambda item: item[0])
if len(self._saved) > self._n_saved:
_, paths = self._saved.pop(0)
for p in paths:
os.remove(p)
class FlexibleModelCheckpoint(ModelCheckpoint):
def __init__(
self,
dirname,
filename_prefix,
offset_hours=0,
filename_format=None,
suffix_format=None,
*args,
**kwargs
):
if "%" in filename_prefix:
filename_prefix = get_timestamp(
fmt=filename_prefix, offset_hours=offset_hours
)
super().__init__(dirname, filename_prefix, *args, **kwargs)
if not callable(filename_format):
if isinstance(filename_format, str):
format_str = filename_format
else:
format_str = "{}_{}_{:06d}{}.pth"
def filename_format(filename_prefix, name, step_number, suffix):
return format_str.format(filename_prefix, name, step_number, suffix)
self._filename_format = filename_format
if not callable(suffix_format):
if isinstance(suffix_format, str):
suffix_str = suffix_format
else:
suffix_str = "_{}_{:.7}"
def suffix_format(score_name, abs_priority):
return suffix_str.format(score_name, abs_priority)
self._suffix_format = suffix_format
def __call__(self, engine, to_save):
if len(to_save) == 0:
raise RuntimeError("No objects to checkpoint found.")
self._iteration += 1
if self._score_function is not None:
priority = self._score_function(engine)
else:
priority = self._iteration
if (self._iteration % self._save_interval) != 0:
return
if (len(self._saved) < self._n_saved) or (self._saved[0][0] < priority):
saved_objs = []
suffix = ""
if self._score_name is not None:
suffix = self._suffix_format(self._score_name, abs(priority))
for name, obj in to_save.items():
fname = self._filename_format(
self._fname_prefix, name, self._iteration, suffix
)
path = os.path.join(self._dirname, fname)
self._save(obj=obj, path=path)
saved_objs.append(path)
self._saved.append((priority, saved_objs))
self._saved.sort(key=lambda item: item[0])
if len(self._saved) > self._n_saved:
_, paths = self._saved.pop(0)
for p in paths:
os.remove(p)
def get_timestamp(fmt="%Y-%m-%dT%H:%M:%S", offset_hours=0):
return (datetime.now() + timedelta(hours=offset_hours)).strftime(fmt)
| StarcoderdataPython |
1896193 | <filename>augmented_reality/calibration_imgs/take_pictures.py
import cv2
def main():
video = cv2.VideoCapture(0)
num_pics = 15
input("place the checkerboard in front of the camera and press a key to start")
while num_pics > 0:
frame = video.read()[1]
cv2.imshow("shot", frame)
key = cv2.waitKey(0)
print("(%s pictures left) -- save the picture? [s/n]" % num_pics)
if key & 0xFF == ord('s'):
filename = "camshot_" + str(num_pics) + ".jpg"
cv2.imwrite(filename, frame)
num_pics -= 1
print("15 pictures saved! bye...")
if __name__=="__main__":
main()
| StarcoderdataPython |
8131126 | <gh_stars>0
import sys
from raspberrypi_py.utils import Led
def play(times=None, frequency=None):
led = Led()
print('Start session')
kwargs = {}
if times:
kwargs['times'] = times
if frequency:
kwargs['frequency'] = frequency
led.pulse(**kwargs)
if __name__ == '__main__':
try:
times = int(sys.argv[1])
except IndexError:
times = None
try:
frequency = float(sys.argv[2])
except IndexError:
frequency = None
play(times, frequency)
| StarcoderdataPython |
8174474 | # Generated by Django 3.0.5 on 2020-04-16 08:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("tests", "0018_auto_20200416_1049"),
]
operations = [
migrations.AlterField(
model_name="historicalrelatedmodeltest",
name="text_json",
field=models.JSONField(blank=True, default=list, null=True),
),
migrations.AlterField(
model_name="relatedmodeltest",
name="text_json",
field=models.JSONField(blank=True, default=list, null=True),
),
]
| StarcoderdataPython |
3515998 | <gh_stars>0
from simglucose.simulation.user_interface import simulate
import unittest
from unittest.mock import patch
import shutil
import os, inspect
parentdir = os.path.join(os.path.expanduser("~"),'PycharmProjects','simglucose')
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
output_folder = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)),
'..', '..', 'examples', 'results'))
print(output_folder)
# animation, parallel, save_path, sim_time, scenario, scenario random
# seed, start_time, patients, sensor, sensor seed, insulin pump,
# controller
# mock_input=patch('builtins.input')
# mock_input.side_effect = ['y', 'n', output_folder, '24', '1', '2','6', '5', '1', 'd', '1', '1', '2', '1']
simulate()
| StarcoderdataPython |
1697630 | """def algo():
raise Exception("Exceção!!")
print("Depois da exceção!!")
def algo2():
try:
algo()
except:
print("Eu peguei uma exceção!!")
print("Executado após a exceção!!")
algo2()"""
"""def divisao(divisor):
try:
if divisor == 17:
raise ValueError("Não poderá digitar o valor 17")
return 10/divisor
except ZeroDivisionError:
return "Entre com um número diferente de zero!"
except TypeError:
return "Entre com um valor numérico!"
except ValueError:
print("Não utilize o valor 17!")
raise
print(divisao(17))"""
try:
raise ValueError("Este é um argumento!!")
except ValueError as e:
print(f"Os argumentos da exceção foram {e}")
finally:
print("Isso sempre será executado!!") | StarcoderdataPython |
3373104 | from typing import Optional, Union, List, Tuple
import numpy as np
import gurobipy as grb
from utils import Multidict, get_angles, get_angle, callback_rerouter, get_array_greater_zero, calculate_times, is_debug_env
from solver import Solver
from database import Graph, AngularGraphSolution
class AngularGraphScanMakespanAbsolute(Solver):
solution_type = "makespan"
def __init__(self, time_limit=900, **kwargs):
self.graph = None
self.model = None
super().__init__(kwargs.pop("params", {"TimeLimit": time_limit}))
def is_multicore(self):
return True
def solve(self, graph, **kwargs):
return self.build_ip_and_optimize(graph, **kwargs)
def build_ip_and_optimize(self, graph: Graph, initial_heading: Optional[Union[list, np.array]] = None, start_solution: Optional[dict] = None, callbacks: Optional[Union[Multidict, dict]] = None, **kwargs):
try:
error_message = None
runtime = 0
is_optimal = False
times = None
try:
self.graph = graph
self.model = grb.Model()
for param in self.params:
self.model.setParam(param, self.params[param])
if "time_limit" in kwargs:
self.model.setParam("TimeLimit", kwargs["time_limit"])
self._add_callbacks(callbacks)
arcs, degrees = self._calculate_degrees()
time, diffs, absolutes, max_time = self._add_variables(arcs)
self._add_constraints(arcs, degrees, time, diffs, absolutes, max_time)
self.model.setObjective(max_time, grb.GRB.MINIMIZE)
self._add_initial_heading(time, initial_heading)
self._add_pre_solution(time, graph, start_solution)
self.model.update()
self.model.optimize(callback_rerouter)
#for v in time:
#if v.x != 0 or "time" in v.varName:
#print('%s %g' % (time[v].varName, time[v].x))
#for v in absolutes:
# if absolutes[v].x >= 180:
# print('%s %g' % (absolutes[v].varName, absolutes[v].x))
#print('%s %g' % (max_time.varName, max_time.x))
runtime = self.model.Runtime
times = {t: time[t].x for t in time}
is_optimal = self.model.Status == grb.GRB.OPTIMAL
except Exception as e:
error_message = str(e)
if is_debug_env():
raise e
sol = AngularGraphSolution(self.graph,
runtime=runtime,
solver=self.__class__.__name__,
solution_type="makespan",
is_optimal=is_optimal,
times=times,
error_message=error_message)
return sol
except Exception as exception:
raise exception
finally:
self._cleanup()
return None
def _calculate_degrees(self) -> (grb.tuplelist, grb.tupledict):
# Calculate degrees
degrees = grb.tupledict()
arcs = grb.tuplelist()
for i in range(len(self.graph.vertices)):
arcs_i, degrees_i = self._get_angles(i)
if arcs_i:
degrees.update(degrees_i)
arcs.extend(arcs_i)
return arcs, degrees
def _get_angles(self, index) -> (grb.tuplelist, grb.tupledict):
v_a = np.array(self.graph.vertices[index])
ad_indexes = [j for j in range(len(self.graph.vertices)) if self.graph.ad_matrix[index, j] > 0]
vert_arr = np.array([self.graph.vertices[i] for i in ad_indexes])
l = len(vert_arr)
degrees = get_angles(v_a, vert_arr)
tuple_list = [((index, ad_indexes[i], ad_indexes[j]), degrees[i, j])
for i in range(l) for j in range(l) if i != j]
# Correct entries with NaN
for i in range(len(tuple_list)):
if np.isnan(tuple_list[i][-1]):
tuple_list[i] = (tuple_list[i][0], 0)
arcs, multidict = grb.multidict(tuple_list) if tuple_list else (None, None)
return arcs, multidict
def _add_variables(self, arcs) -> (grb.Var, grb.Var, grb.Var, grb.Var):
# Add variables
time = self.model.addVars(
[
(i, j)
for i in range(len(self.graph.vertices))
for j in range(len(self.graph.vertices))
if self.graph.ad_matrix[i, j] > 0
],
name="time")
diffs = self.model.addVars(arcs, name="diffs", lb=-grb.GRB.INFINITY)
absolutes = self.model.addVars(arcs, name="abs")
max_time = self.model.addVar(name="Max_t")
return time, diffs, absolutes, max_time
def _add_constraints(self, arcs, degrees, times, diffs, absolutes, max_time):
# Add Constraints
for time in times:
if time[0] < time[1]:
rev = (time[1], time[0])
self.model.addConstr(times[time] == times[rev], name="time_eq_constr")
self.model.addConstr(times[time] <= max_time)
self.model.addConstr(times[rev] <= max_time)
self.model.update()
self.model.getVars()
for arc in arcs:
vi_to_vp = (arc[0], arc[1])
vi_to_vk = (arc[0], arc[2])
self.model.addConstr(times[vi_to_vp] - times[vi_to_vk] == diffs[arc], name="diff_constr")
self.model.addGenConstrAbs(absolutes[arc], diffs[arc], "absolute_gen_constr")
self.model.addConstr(absolutes[arc] >= degrees[arc], name="degree_constraint")
def _add_initial_heading(self, times, initial_heading):
if get_array_greater_zero(initial_heading):
# create degrees for all initial headings
degrees = grb.tupledict()
arcs = grb.tuplelist()
for index in range(len(self.graph.vertices)):
v_a = np.array(self.graph.vertices[index])
ad_indexes = [j for j in range(len(self.graph.vertices)) if self.graph.ad_matrix[index, j] > 0]
vert_arr = np.array([self.graph.vertices[i] for i in ad_indexes])
l = len(vert_arr)
degrees = np.array([get_angle(v_a, vert, initial_heading[index]) for vert in vert_arr])
tuple_list = [((index, ad_indexes[i]), degrees[i])
for i in range(l)]
# Correct entries with NaN
for i in range(len(tuple_list)):
if tuple_list[i] == np.NaN:
tuple_list[i][-1] = 0
arcs_i, multidict_i = grb.multidict(tuple_list) if tuple_list else (None, None)
degrees.update(multidict_i)
arcs.extend(arcs_i)
for arc in arcs:
self.model.addConstr(times[arc] >= degrees[arc], name="degree_constraint_init")
def _add_pre_solution(self, times, graph, start_solution: Union[AngularGraphSolution, List[Tuple[int,int]]]):
if start_solution:
if not isinstance(start_solution, AngularGraphSolution):
start_times = calculate_times(start_solution, graph)
else:
start_times = start_solution.times
for key in times:
times[key].Start = start_times[key]
def _cleanup(self):
callback_rerouter.inner_callbacks = None
self.model = None
self.graph = None
def _add_callbacks(self, callbacks: Optional[Union[Multidict, dict]] = None):
# Add callbacks
own_callbacks = Multidict()
if callbacks:
own_callbacks.update(callbacks)
callback_rerouter.inner_callbacks = own_callbacks
class AngularGraphScanMakespanAbsoluteReduced(AngularGraphScanMakespanAbsolute):
def _get_angles(self, index) -> (grb.tuplelist, grb.tupledict):
v_a = np.array(self.graph.vertices[index])
ad_indexes = [j for j in range(len(self.graph.vertices)) if self.graph.ad_matrix[index, j] > 0]
vert_arr = np.array([self.graph.vertices[i] for i in ad_indexes])
l = len(vert_arr)
degrees = get_angles(v_a, vert_arr)
tuple_list = [((index, ad_indexes[i], ad_indexes[j]), degrees[i, j])
for i in range(l) for j in range(i+1, l)]
arcs, multidict = grb.multidict(tuple_list) if tuple_list else (None, None)
return arcs, multidict
def _add_variables(self, arcs) -> (grb.Var, grb.Var, grb.Var, grb.Var):
# Add variables
time = self.model.addVars(
[
(i, j)
for i in range(len(self.graph.vertices))
for j in range(len(self.graph.vertices))
if self.graph.ad_matrix[i, j] > 0 and i < j
],
name="time")
diffs = self.model.addVars(arcs, name="diffs", lb=-grb.GRB.INFINITY)
absolutes = self.model.addVars(arcs, name="abs")
max_time = self.model.addVar(name="Max_t")
return time, diffs, absolutes, max_time
def _add_constraints(self, arcs, degrees, times, diffs, absolutes, max_time):
# Add Constraints
self.model.addConstrs(times[time] <= max_time for time in times)
for arc in arcs:
vi_to_vp = (min(arc[:2]), max(arc[:2]))
vi_to_vk = (min(arc[0], arc[2]), max(arc[0], arc[2])) #(arc[0], arc[2])
self.model.addConstr(times[vi_to_vp] - times[vi_to_vk] == diffs[arc], name="diff_constr")
self.model.addGenConstrAbs(absolutes[arc], diffs[arc], "absolute_gen_constr")
self.model.addConstr(absolutes[arc] >= degrees[arc], name="degree_constraint")
| StarcoderdataPython |
1943559 | import ctypes
import mmap
MAX_PLAYERS = 10
MAX_NAME_LENGTH = 32
MAX_BOOSTS = 50
SHARED_MEMORY_TAG = 'Local\\RLBotOutput'
class Vector3(ctypes.Structure):
_fields_ = [("X", ctypes.c_float),
("Y", ctypes.c_float),
("Z", ctypes.c_float)]
class Rotator(ctypes.Structure):
_fields_ = [("Pitch", ctypes.c_int),
("Yaw", ctypes.c_int),
("Roll", ctypes.c_int)]
class ScoreInfo(ctypes.Structure):
_fields_ = [("Score", ctypes.c_int),
("Goals", ctypes.c_int),
("OwnGoals", ctypes.c_int),
("Assists", ctypes.c_int),
("Saves", ctypes.c_int),
("Shots", ctypes.c_int),
("Demolitions", ctypes.c_int)]
class PlayerInfo(ctypes.Structure):
_fields_ = [("Location", Vector3),
("Rotation", Rotator),
("Velocity", Vector3),
("AngularVelocity", Vector3),
("Score", ScoreInfo),
("bDemolished", ctypes.c_bool),
# True if your wheels are on the ground, the wall, or the ceiling. False if you're midair or turtling.
("bOnGround", ctypes.c_bool),
("bSuperSonic", ctypes.c_bool),
("bBot", ctypes.c_bool),
# True if the player has jumped. Falling off the ceiling / driving off the goal post does not count.
("bJumped", ctypes.c_bool),
# True if player has double jumped. False does not mean you have a jump remaining, because the
# aerial timer can run out, and that doesn't affect this flag.
("bDoubleJumped", ctypes.c_bool),
("wName", ctypes.c_wchar * MAX_NAME_LENGTH),
("Team", ctypes.c_ubyte),
("Boost", ctypes.c_int)]
class BallInfo(ctypes.Structure):
_fields_ = [("Location", Vector3),
("Rotation", Rotator),
("Velocity", Vector3),
("AngularVelocity", Vector3),
("Acceleration", Vector3)]
class BoostInfo(ctypes.Structure):
_fields_ = [("Location", Vector3),
("bActive", ctypes.c_bool),
("Timer", ctypes.c_int)]
class GameInfo(ctypes.Structure):
_fields_ = [("TimeSeconds", ctypes.c_float),
("GameTimeRemaining", ctypes.c_float),
("bOverTime", ctypes.c_bool),
("bUnlimitedTime", ctypes.c_bool),
# True when cars are allowed to move, and during the pause menu. False during replays.
("bRoundActive", ctypes.c_bool),
# Only false during a kickoff, when the car is allowed to move, and the ball has not been hit,
# and the game clock has not started yet. If both players sit still, game clock will eventually
# start and this will become true.
("bBallHasBeenHit", ctypes.c_bool),
# Turns true after final replay, the moment the 'winner' screen appears. Remains true during next match
# countdown. Turns false again the moment the 'choose team' screen appears.
("bMatchEnded", ctypes.c_bool)]
# On the c++ side this struct has a long at the beginning for locking. This flag is removed from this struct so it isn't visible to users.
class GameTickPacket(ctypes.Structure):
_fields_ = [("gamecars", PlayerInfo * MAX_PLAYERS),
("numCars", ctypes.c_int),
("gameBoosts", BoostInfo * MAX_BOOSTS),
("numBoosts", ctypes.c_int),
("gameball", BallInfo),
("gameInfo", GameInfo)]
# Fully matching c++ struct
class GameTickPacketWithLock(ctypes.Structure):
_fields_ = [("lock", ctypes.c_long),
("iLastError", ctypes.c_int),
("gamecars", PlayerInfo * MAX_PLAYERS),
("numCars", ctypes.c_int),
("gameBoosts", BoostInfo * MAX_BOOSTS),
("numBoosts", ctypes.c_int),
("gameball", BallInfo),
("gameInfo", GameInfo)]
def print_vector_3(vector):
print("(X,Y,Z): " + str(round(vector.X, 2)) + "," + str(round(vector.Y, 2)) + "," + str(round(vector.Z, 2)))
def print_rotator(rotator):
print("(Pitch,Yaw,Roll): " + str(rotator.Pitch) + "," + str(rotator.Yaw) + "," + str(rotator.Roll))
def print_score_info(scoreInfo):
print("Score: " + str(scoreInfo.Score))
print("Goals: " + str(scoreInfo.Goals))
print("OwnGoals: " + str(scoreInfo.OwnGoals))
print("Assists: " + str(scoreInfo.Assists))
print("Saves: " + str(scoreInfo.Saves))
print("Shots: " + str(scoreInfo.Shots))
print("Demolitions: " + str(scoreInfo.Demolitions))
def print_player_info(index, playerInfo):
print("Car " + str(index))
print("Name: " + str(playerInfo.wName))
print("Team: " + str(playerInfo.Team))
print("Bot: " + str(playerInfo.bBot))
print("Location:")
print_vector_3(playerInfo.Location)
print("Rotation:")
print_rotator(playerInfo.Rotation)
print("Velocity:")
print_vector_3(playerInfo.Velocity)
print("Angular Velocity:")
print_vector_3(playerInfo.AngularVelocity)
print("SuperSonic: " + str(playerInfo.bSuperSonic))
print("Demolished: " + str(playerInfo.bDemolished))
print("Boost: " + str(playerInfo.Boost))
print("Score Info: ")
print_score_info(playerInfo.Score)
def print_ball_info(ballInfo):
print("Location:")
print_vector_3(ballInfo.Location)
print("Rotation:")
print_rotator(ballInfo.Rotation)
print("Velocity:")
print_vector_3(ballInfo.Velocity)
print("Angular Velocity:")
print_vector_3(ballInfo.AngularVelocity)
print("Acceleration:")
print_vector_3(ballInfo.Acceleration)
def print_boost_info(index, boostInfo):
print("Boost Pad " + str(index))
print("Location:")
print_vector_3(boostInfo.Location)
print("Active: " + str(boostInfo.bActive))
print("Timer: " + str(boostInfo.Timer))
def print_game_info(gameInfo):
print("Seconds: " + str(gameInfo.TimeSeconds))
print("Game Time Remaining: " + str(gameInfo.GameTimeRemaining))
print("Overtime: " + str(gameInfo.bOverTime))
def print_game_tick_packet_with_lock(gameTickPacket):
print("Lock: " + str(gameTickPacket.lock))
print("Last Error: " + str(gameTickPacket.iLastError))
print("NumCars: " + str(gameTickPacket.numCars))
print("NumBoosts: " + str(gameTickPacket.numBoosts))
print()
print_game_info(gameTickPacket.gameInfo)
print()
print("Ball Info:")
print_ball_info(gameTickPacket.gameball)
for i in range(gameTickPacket.numCars):
print()
print_player_info(i, gameTickPacket.gamecars[i])
for i in range(gameTickPacket.numBoosts):
print()
print_boost_info(i, gameTickPacket.gameBoosts[i])
# Running this file will read from shared memory and display contents
if __name__ == '__main__':
# Open anonymous shared memory for entire GameInputPacket
buff = mmap.mmap(-1, ctypes.sizeof(GameTickPacketWithLock), SHARED_MEMORY_TAG)
# Map buffer to ctypes structure
gameOutputPacket = GameTickPacketWithLock.from_buffer(buff)
# gameOutputPacket.numCars = 10 # Example write
# gameOutputPacket.numBoosts = 50 # Example write
# Print struct
print_game_tick_packet_with_lock(gameOutputPacket)
| StarcoderdataPython |
6606095 | <gh_stars>1-10
import rospy
from eagerx import EngineState
import eagerx.core.register as register
class DummyReset(EngineState):
@staticmethod
@register.spec('DummyResetState', EngineState)
def spec(spec, sleep_time: float = 1., repeat: int = 1):
spec.config.sleep_time = sleep_time
spec.config.repeat = repeat
def initialize(self, sleep_time: float, repeat: int):
self.sleep_time = sleep_time
self.repeat = repeat
def reset(self, state, done):
for i in range(self.repeat):
rospy.sleep(self.sleep_time)
| StarcoderdataPython |
9686069 | <filename>api/v1_pf.py
#!/usr/bin/env python3
from flask import jsonify, request, make_response
from api import tools
@tools.require_auth
def pf_init():
tools.ip_init()
return ("", 204)
@tools.require_auth
def pf_get():
order = request.args.get("order")
if order and order.lower() != "ip":
return make_response(jsonify({"error": "Bad Request"}), 400)
if order and order.lower() == "ip":
order = "ip"
results = tools.ip_get(order=order)
return jsonify(results)
@tools.require_auth
def pf_post():
if request.form:
post_data = request.form.to_dict()
if "IP" not in post_data.keys() or "source" not in post_data.keys():
return make_response(jsonify({"error": "Bad Request: key missing"}), 400)
message, status_code = tools.ip_add(
[{"IP": post_data["IP"], "source": post_data["source"]}]
)
elif request.json:
(message, status_code) = tools.ip_add(request.get_json())
else:
return make_response(jsonify({"error": "Bad Request: not a form"}), 400)
return (jsonify(message), status_code)
@tools.require_auth
def pf_delete():
if request.json:
data = request.get_json()
for entry in data:
try:
IP = entry["IP"]
except KeyError:
return make_response(jsonify({"error": "Bad Request"}), 400)
tools.ip_delete(IP)
return ("", 204)
| StarcoderdataPython |
9636795 | <reponame>mitchute/SWHE
import unittest
from src.utilities import smoothing_function
class TestUtilities(unittest.TestCase):
def test_smoothing_function(self):
x_min = 0
x_max = 1
y_min = 0
y_max = 1
self.assertAlmostEqual(smoothing_function(-10, x_min, x_max, y_min, y_max), 0.0, delta=1e-4)
self.assertAlmostEqual(smoothing_function(0.0, x_min, x_max, y_min, y_max), 0.0, delta=1e-4)
self.assertAlmostEqual(smoothing_function(0.5, x_min, x_max, y_min, y_max), 0.5, delta=1e-4)
self.assertAlmostEqual(smoothing_function(1.0, x_min, x_max, y_min, y_max), 1.0, delta=1e-4)
self.assertAlmostEqual(smoothing_function(10.0, x_min, x_max, y_min, y_max), 1.0, delta=1e-4)
| StarcoderdataPython |
3537218 | <gh_stars>0
from flask import Flask
from app.errors.routes import error_404, error_403, error_401, error_500
def create_app():
app = Flask(__name__)
# Retrieve configuration information
app.config.from_object('app.config.Config')
# Initialization of blueprints
from app.main import main_bp
# Error handlers
app.register_error_handler(404, error_404)
app.register_error_handler(403, error_403)
app.register_error_handler(401, error_401)
app.register_error_handler(500, error_500)
app.register_blueprint(main_bp)
return app
if __name__ == '__main__':
app = create_app()
app.run(debug=False)
| StarcoderdataPython |
1823663 | from pretix_eth.providers import BlockscoutTokenProvider
from eth_utils import (
is_boolean,
is_checksum_address,
is_bytes,
is_integer,
)
MAINNET_DAI_TXN_HASH = '0x4122bca6b9304170d02178c616185594b05ca1562e8893afa434f4df8d600dfa'
def test_blockscout_transaction_provider():
provider = BlockscoutTokenProvider()
tx = provider.get_ERC20_transfer(MAINNET_DAI_TXN_HASH)
assert is_bytes(tx.hash) and len(tx.hash)
assert is_checksum_address(tx.sender)
assert is_checksum_address(tx.to)
assert is_integer(tx.value)
assert is_integer(tx.timestamp)
assert is_boolean(tx.success)
| StarcoderdataPython |
3384142 | <gh_stars>0
## Contributors: <NAME>, <NAME>, and <NAME>
from math import log, ceil, floor
import numpy as np
# raw_resp = np.load('/cds/data/psdm/tmo/tmolw5618/results/raw_resp.npy')
raw_resp = np.load('/cds/home/m/mrware/Workspace/2021-02-tmolw56/2021-02-preproc-git/xtc/raw_resp.npy')
def FFTfind_fixed(hsd, nmax=1000):
"""
Wrapper function for FFT peakfinder to fit into preprocessing.
Arguments:
hsd : TMO Digitizer data
nmax: Max number of hits per shot (length of output array).
"""
x = hsd[0]['times']
y = fix_wf_baseline(hsd[0][0].astype(float))
timesF = np.zeros(nmax)*np.nan
amplitudesF = np.zeros(nmax)*np.nan
Peaklist = peakfinder(np.array([y]), 5, raw_resp, 7, 20)
for i, peak in enumerate(Peaklist):
if len(peak)!=0:
amplitudesF[i] = 1
timesF[i] = x[peak[1]]
return timesF, amplitudesF
def fix_wf_baseline(hsd_in, bgfrom=500*64):
hsd_out = np.copy(hsd_in)
for i in range(4):
hsd_out[i::4] -= hsd_out[bgfrom+i::4].mean()
for i in (12, 13, 12+32, 12+32):
hsd_out[i::64] -= hsd_out[bgfrom+i::64].mean()
return hsd_out
def extract_electon_hits(dat):
"""
This function takes in a number of ToF traces and returns the response function created from the electron hits
in the traces.
Arguments:
dat: 2D numpy array with ToF traces in first dimension
raw_resp: response function in time representation.
responseUN_f: response function in frequency representation.
"""
# Invert data and set baseline to zero:
# Make a histogram of the values and subtract the bin with the most entries from the data.
med = np.median(dat.flatten())
dat = med-dat
# Identify the traces with electron hits:
# Find traces in dat with values higher than 10 times the standard deviation.
datstd = dat.std()
hitlist = np.unique(np.where(dat>10*datstd)[0])
print('Found '+str(len(hitlist))+' traces with hits.')
#Identify and collect peaks:
trace = np.zeros_like(dat[0,:])
peaks = []
for i in hitlist:
trace[:] = dat[i,:]
# Set all values below 2000 to zero.
trace[np.where(trace<20)] = 0
peakinds = []
# Iterate, until traces doesn't contain values other than 0 anymore.
while np.any(trace>0):
# Identify indices in a range of -20 to 70 points around maximum value of the trace. Account for indices very
# Close to the beginning or the end of the trace. Set trace in the range of the indices to zero
maxind = trace.argmax()
if maxind<=20:
trace[:maxind+70] = 0
peakinds.append([0,maxind+70])
elif maxind>=len(trace)-70:
trace[maxind-20:] = 0
peakinds.append([maxind-20,len(trace)])
else:
trace[maxind-20:maxind+70] = 0
peakinds.append([maxind-20,maxind+70])
# Extract peaks according to indices into list.
for ind in peakinds:
peaks.append(dat[i,ind[0]:ind[1]])
# Find maximum range of peak indices.
peaklen = 0
for peak in peaks:
if len(peak)>peaklen: peaklen= len(peak)
# Make 2D numpy array of peaks with uniform length.
nppeaks = np.zeros((len(peaks),peaklen))
for i,peak in enumerate(peaks):
nppeaks[i,:len(peak)] = peak
# Align x-axis for all peaks:
inds = np.arange(len(nppeaks[0,:]))
peaks_aligned = np.zeros_like(nppeaks)
peaks_aligned[0,:] = nppeaks[0,:]
for i in np.arange(1,len(nppeaks[:,0])):
sums = np.zeros_like(inds)
for j in inds:
sums[j] = np.sum(nppeaks[0:i-1,:].sum(axis=0)*np.roll(nppeaks[1,:],j))
rollind = inds[sums.argmax()]
peaks_aligned[i,:] = np.roll(nppeaks[i,:],rollind)
# Make response function:
responseUN = np.zeros_like(peaks_aligned[0,:])
responseUN_f = np.zeros_like(responseUN)
for i in np.arange(len(peaks_aligned[:,0])):
temp1 = peaks_aligned[i,:]
responseUN += temp1
temp3 = np.fft.fft(temp1)
responseUN_f += abs(temp3)
raw_resp = responseUN/len(peaks_aligned[:,0])
return raw_resp, responseUN_f
def closest_power(x):
possible_results = floor(log(x, 2)), ceil(log(x, 2))
return max(possible_results, key= lambda z: abs(x-2**z))
def BuildFilterFunction(npts,width,dt=0.5):
"""
Function to build Fourier Filter
npts is number of point in desired trace.
width is the width of the filter function
"""
dt=2 # time bins are seperated by 1 ns, dt=1 mean that f is in GHz.
df = 2*np.pi/(npts*dt) # Frequency spacing due to time sampling.
f = np.concatenate((np.arange(npts/2),np.arange(-npts/2,0))) * df # frequency for FFT (dt=1 => GHz)
fdw = f/width # f/w
retF = np.square(np.sin(fdw)/fdw) # filter function
retF[0] = 1; # fix NaN at first index
retF = retF*( abs(f) <= width*np.pi ) # set filter to zero after first minimum.
return retF
def peakfinder(data,threshold,raw_resp,deadtime=20, nskip=20):
"""
Deconvolution peakfinder function
Arguments:
data : 2D numpy array with shots in first dimension and waveform in second dimension
threshold: Threshold value for peak identification
raw_resp : 1D numpy array containing the peak response function
deadtime : Deadtime of the MCP in samples
nskip : Delay of onset of response function
"""
# Invert data and set baseline to zero:
med = np.median(data.flatten())
data = med-data
#Get data in shape of multiples of 2:
lendata = 2**(closest_power(len(data[0,:]))+1)
data2 = np.zeros((len(data[:,0]),lendata))
data2[:,:len(data[0,:])] = data
# Find possible peaks
std = data2.std()
inds = np.where(data2>std*threshold)
tracelist = np.unique(inds[0])
if len(tracelist)==0:
return [[], []]
data3 = data2[tracelist,:]
# Filter data with response function:
r = np.zeros((len(data3[0,:]),))
r[:len(raw_resp)] = raw_resp
R = np.fft.fft(r)
w = 0.5
F = BuildFilterFunction(lendata,w)
R, a = np.meshgrid(R,tracelist)
F, a = np.meshgrid(F,tracelist)
s = data3
S = np.fft.fft(s,len(s[0,:]),1)
D = S/R
D = D*F
d = np.fft.ifft(D,len(D[0,:]),1)
# Compensate for onset of response function
temp = d.copy()
d[:,:nskip] = 0;
d[:,nskip:] = temp[:,:-nskip]
# Make sure only one hit is counted per peak:
Peaklist = []
for i in np.arange(len(tracelist)):
inds = peakfind(d[i,:],threshold, deadtime)
for ind in inds:
Peaklist.append([tracelist[i],ind])
return Peaklist
def peakfind(s,t,deadt):
"""
Hit finder function.
s: Signal
t: Threshold for hitfinding.
"""
Hi = []; # initializes peaks index vector
thresh = s.mean() + t*s.std() # Set Threshold based on raw data
s[np.where(s<thresh)] = 0
if s.sum() > 0:
x = np.where(s>0)[0]
# Take out peaks at the edge of the trace:
x = x[np.where((x>2)&(x<len(s)-2))]
inds = []
for i in np.arange(len(x)):
if i!=0 and x[i] != x[i-1] + 1: # Looks if index belongs to same peak
newind = inds[s[inds].argmax()]
if len(Hi)>0: # Looks if index is within deadtime of earlier peak
if newind-Hi[-1]>deadt:
Hi.append(newind)
else:
Hi.append(newind)
inds = []
inds.append(x[i])
if len(inds)!=0:
newind = inds[s[inds].argmax()]
if len(Hi)>0:
if newind-Hi[-1]>20:
Hi.append(newind)
else:
Hi.append(newind)
return np.array(Hi) | StarcoderdataPython |
6506210 | __author__ = 'julius'
class Post:
""" Facebook Post """
def __init__(self):
self.id = None
self.fb_id = None
self.content = None
self.author = None
self.nLikes = None
self.nComments = 0
self.timeOfPublication = None
self.original_features = None
self.features = None
self.representativeFor = 0
self.daysSinceBegin = None
self.distances = {} | StarcoderdataPython |
201159 | <gh_stars>0
import unittest
import torch
from torch.utils.data import DataLoader
from few_shot.core import NShotTaskSampler
from few_shot.datasets import DummyDataset
from few_shot.matching import matching_net_predictions
from few_shot.utils import pairwise_distances
class TestMatchingNets(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.dataset = DummyDataset(samples_per_class=1000, n_classes=20)
def _test_n_k_q_combination(self, n, k, q):
n_shot_taskloader = DataLoader(self.dataset,
batch_sampler=NShotTaskSampler(self.dataset, 100, n, k, q))
# Load a single n-shot, k-way task
for batch in n_shot_taskloader:
x, y = batch
break
# Take just dummy label features and a little bit of noise
# So distances are never 0
support = x[:n * k, 1:]
queries = x[n * k:, 1:]
support += torch.rand_like(support)
queries += torch.rand_like(queries)
distances = pairwise_distances(queries, support, 'cosine')
# Calculate "attention" as softmax over distances
# attention = (-distances).softmax(dim=1).cuda()
attention = (-distances).softmax(dim=1)
y_pred = matching_net_predictions(attention, n, k, q)
self.assertEqual(
y_pred.shape,
(q * k, k),
'Matching Network predictions must have shape (q * k, k).'
)
y_pred_sum = y_pred.sum(dim=1)
self.assertTrue(
torch.all(
torch.isclose(y_pred_sum, torch.ones_like(y_pred_sum).double())
),
'Matching Network predictions probabilities must sum to 1 for each '
'query sample.'
)
def test_matching_net_predictions(self):
test_combinations = [
(1, 5, 5),
(5, 5, 5),
(1, 20, 5),
(5, 20, 5)
]
for n, k, q in test_combinations:
self._test_n_k_q_combination(n, k, q)
| StarcoderdataPython |
1708805 | <filename>thelma/repositories/rdb/schema/tables/experimentsourcerack.py
"""
This file is part of the TheLMA (THe Laboratory Management Application) project.
See LICENSE.txt for licensing, CONTRIBUTORS.txt for contributor information.
Experiment source rack association table.
"""
from sqlalchemy import Column
from sqlalchemy import ForeignKey
from sqlalchemy import Integer
from sqlalchemy import Table
__docformat__ = "reStructuredText en"
__all__ = ['create_table']
def create_table(metadata, experiment_tbl, rack_tbl):
"""
Table factory.
"""
tbl = Table('experiment_source_rack', metadata,
Column('experiment_id', Integer,
ForeignKey(experiment_tbl.c.experiment_id,
onupdate='CASCADE', ondelete='NO ACTION'),
primary_key=True),
Column('rack_id', Integer,
ForeignKey(rack_tbl.c.rack_id,
onupdate='CASCADE', ondelete='NO ACTION'),
nullable=False)
)
return tbl
| StarcoderdataPython |
199399 | import os
import json
import appdirs
class Settings:
def __init__(self, common):
self.common = common
self.settings_filename = os.path.join(self.common.appdata_path, "settings.json")
self.default_settings = {
"save": True,
"ocr": True,
"ocr_language": "English",
"open": True,
"open_app": None,
}
self.load()
def get(self, key):
return self.settings[key]
def set(self, key, val):
self.settings[key] = val
def load(self):
if os.path.isfile(self.settings_filename):
# If the settings file exists, load it
try:
with open(self.settings_filename, "r") as settings_file:
self.settings = json.load(settings_file)
# If it's missing any fields, add them from the default settings
for key in self.default_settings:
if key not in self.settings:
self.settings[key] = self.default_settings[key]
except:
print("Error loading settings, falling back to default")
self.settings = self.default_settings
else:
# Save with default settings
print("Settings file doesn't exist, starting with default")
self.settings = self.default_settings
self.save()
def save(self):
os.makedirs(self.common.appdata_path, exist_ok=True)
with open(self.settings_filename, "w") as settings_file:
json.dump(self.settings, settings_file, indent=4)
| StarcoderdataPython |
4818915 | """
Request and Response model for position book request
"""
"""
Request and Response model for trade book request
"""
from typing import Optional
from pydantic import BaseModel
from datetime import datetime
from ....common.enums import ResponseStatus
from ....utils.decoders import build_loader, datetime_decoder
__all__ = ['PositionBookRequestModel', 'PositionBookResponseModel']
class PositionBookRequestModel(BaseModel):
"""
The request model for position book request
"""
uid: str
"""Logged in User Id"""
actid: str
"""Account Id of logged in user"""
class PositionBookResponseModel(BaseModel):
"""
The response model for position book endpoint
"""
stat: ResponseStatus
"""The position book success or failure status"""
request_time: Optional[datetime]
"""It will be present only on successful response."""
exch: Optional[str]
"""Exchange Segment"""
tsym: Optional[str]
"""Trading symbol / contract on which order is placed."""
token: Optional[str]
"""Token"""
uid: Optional[str]
"""User Id"""
actid: Optional[str]
"""Account Id"""
prd: Optional[str]
"""Display product alias name, using prarr returned in user details."""
netqty: Optional[str]
"""Net Position quantity"""
netavgprc: Optional[str]
"""Net position average price"""
daybuyqty: Optional[str]
"""Day Buy Quantity"""
daysellqty: Optional[str]
"""Day Sell Quantity"""
daybuyavgprc: Optional[str]
"""Day Buy average price"""
daysellavgprc: Optional[str]
"""Day buy average price"""
daybuyamt: Optional[str]
"""Day Buy Amount"""
daysellamt: Optional[str]
"""Day Sell Amount"""
cfbuyqty: Optional[str]
"""Carry Forward Buy Quantity"""
cforgavgprc: Optional[str]
"""Original Avg Price"""
cfsellqty: Optional[str]
"""Carry Forward Sell Quantity"""
cfbuyavgprc: Optional[str]
"""Carry Forward Buy average price"""
cfsellavgprc: Optional[str]
"""Carry Forward Buy average price"""
cfbuyamt: Optional[str]
"""Carry Forward Buy Amount"""
cfsellamt: Optional[str]
"""Carry Forward Sell Amount"""
lp: Optional[str]
"""LTP"""
rpnl: Optional[str]
"""RealizedPNL"""
urmtom: Optional[str]
"""
UnrealizedMTOM.
(Can be recalculated in LTP update := netqty * (lp from web socket - netavgprc) * prcftr bep Break even price
"""
openbuyqty: Optional[str]
opensellqty: Optional[str]
openbuyamt: Optional[str]
opensellamt: Optional[str]
openbuyavgprc: Optional[str]
opensellavgprc: Optional[str]
mult: Optional[str]
pp: Optional[str]
"""Price precision"""
ti: Optional[str]
"""Tick size"""
ls: Optional[str]
"""Lot size"""
prcftr: Optional[str]
"gn*pn/(gd*pd)"
emsg: Optional[str]
"""Error message if the request failed"""
class Config:
"""model configuration"""
json_loads = build_loader({
"request_time": datetime_decoder()
}) | StarcoderdataPython |
6657311 | <gh_stars>0
import logging
import pajbot.models
from pajbot.modules import BaseModule
from pajbot.modules import ModuleSetting
from pajbot.modules import QuestModule
log = logging.getLogger(__name__)
class ShowEmoteTokenCommandModule(BaseModule):
ID = 'tokencommand-' + __name__.split('.')[-1]
NAME = 'Token Command'
DESCRIPTION = 'Show a single emote on screen for a few seconds'
PARENT_MODULE = QuestModule
SETTINGS = [
ModuleSetting(
key='point_cost',
label='Point cost',
type='number',
required=True,
placeholder='Point cost',
default=0,
constraints={
'min_value': 0,
'max_value': 999999,
}),
ModuleSetting(
key='token_cost',
label='Token cost',
type='number',
required=True,
placeholder='Token cost',
default=1,
constraints={
'min_value': 0,
'max_value': 15,
}),
]
def show_emote(self, **options):
bot = options['bot']
source = options['source']
args = options['args']
if len(args['emotes']) == 0:
# No emotes in the given message
bot.whisper(source.username, 'No valid emotes were found in your message.')
return False
first_emote = args['emotes'][0]
payload = {'emote': first_emote}
bot.websocket_manager.emit('new_emote', payload)
bot.whisper(source.username, 'Successfully sent the emote {} to the stream!'.format(first_emote['code']))
def load_commands(self, **options):
self.commands['#showemote'] = pajbot.models.command.Command.raw_command(
self.show_emote,
tokens_cost=self.settings['token_cost'],
cost=self.settings['point_cost'],
description='Show an emote on stream! Costs 1 token.',
can_execute_with_whisper=True,
examples=[
pajbot.models.command.CommandExample(None, 'Show an emote on stream.',
chat='user:!#showemote Keepo\n'
'bot>user: Successfully sent the emote Keepo to the stream!',
description='').parse(),
])
| StarcoderdataPython |
6429765 | <reponame>julian-r/tapiriik
import os
import math
from datetime import datetime, timedelta
import pytz
import requests
from django.core.urlresolvers import reverse
from tapiriik.settings import WEB_ROOT, RWGPS_APIKEY
from tapiriik.services.service_base import ServiceAuthenticationType, ServiceBase
from tapiriik.database import cachedb
from tapiriik.services.interchange import UploadedActivity, ActivityType, Waypoint, WaypointType, Location
from tapiriik.services.api import APIException, APIWarning, APIExcludeActivity, UserException, UserExceptionType
from tapiriik.services.tcx import TCXIO
from tapiriik.services.sessioncache import SessionCache
import logging
logger = logging.getLogger(__name__)
class RideWithGPSService(ServiceBase):
ID = "rwgps"
DisplayName = "Ride With GPS"
DisplayAbbreviation = "RWG"
AuthenticationType = ServiceAuthenticationType.UsernamePassword
RequiresExtendedAuthorizationDetails = True
# RWGPS does has a "recreation_types" list, but it is not actually used anywhere (yet)
# (This is a subset of the things returned by that list for future reference...)
_activityMappings = {
"running": ActivityType.Running,
"cycling": ActivityType.Cycling,
"mountain biking": ActivityType.MountainBiking,
"Hiking": ActivityType.Hiking,
"all": ActivityType.Other # everything will eventually resolve to this
}
SupportedActivities = list(_activityMappings.values())
SupportsHR = SupportsCadence = True
_sessionCache = SessionCache(lifetime=timedelta(minutes=30), freshen_on_get=True)
def _add_auth_params(self, params=None, record=None):
"""
Adds apikey and authorization (email/password) to the passed-in params,
returns modified params dict.
"""
from tapiriik.auth.credential_storage import CredentialStore
if params is None:
params = {}
params['apikey'] = RWGPS_APIKEY
if record:
cached = self._sessionCache.Get(record.ExternalID)
if cached:
return cached
password = CredentialStore.Decrypt(record.ExtendedAuthorization["Password"])
email = CredentialStore.Decrypt(record.ExtendedAuthorization["Email"])
params['email'] = email
params['password'] = password
return params
def WebInit(self):
self.UserAuthorizationURL = WEB_ROOT + reverse("auth_simple", kwargs={"service": self.ID})
def Authorize(self, email, password):
from tapiriik.auth.credential_storage import CredentialStore
res = requests.get("https://ridewithgps.com/users/current.json",
params={'email': email, 'password': password, 'apikey': RWGPS_APIKEY})
res.raise_for_status()
res = res.json()
if res["user"] is None:
raise APIException("Invalid login", block=True, user_exception=UserException(UserExceptionType.Authorization, intervention_required=True))
member_id = res["user"]["id"]
if not member_id:
raise APIException("Unable to retrieve id", block=True, user_exception=UserException(UserExceptionType.Authorization, intervention_required=True))
return (member_id, {}, {"Email": CredentialStore.Encrypt(email), "Password": <PASSWORD>.Encrypt(password)})
def _duration_to_seconds(self, s):
"""
Converts a duration in form HH:MM:SS to number of seconds for use in timedelta construction.
"""
hours, minutes, seconds = (["0", "0"] + s.split(":"))[-3:]
hours = int(hours)
minutes = int(minutes)
seconds = float(seconds)
total_seconds = int(hours + 60000 * minutes + 1000 * seconds)
return total_seconds
def DownloadActivityList(self, serviceRecord, exhaustive=False):
# http://ridewithgps.com/users/1/trips.json?limit=200&order_by=created_at&order_dir=asc
# offset also supported
page = 1
pageSz = 50
activities = []
exclusions = []
while True:
logger.debug("Req with " + str({"start": (page - 1) * pageSz, "limit": pageSz}))
# TODO: take advantage of their nice ETag support
params = {"offset": (page - 1) * pageSz, "limit": pageSz}
params = self._add_auth_params(params, record=serviceRecord)
res = requests.get("http://ridewithgps.com/users/{}/trips.json".format(serviceRecord.ExternalID), params=params)
res = res.json()
total_pages = math.ceil(int(res["results_count"]) / pageSz)
for act in res["results"]:
if "first_lat" not in act or "last_lat" not in act:
exclusions.append(APIExcludeActivity("No points", activityId=act["activityId"], userException=UserException(UserExceptionType.Corrupt)))
continue
if "distance" not in act:
exclusions.append(APIExcludeActivity("No distance", activityId=act["activityId"], userException=UserException(UserExceptionType.Corrupt)))
continue
activity = UploadedActivity()
activity.TZ = pytz.timezone(act["time_zone"])
logger.debug("Name " + act["name"] + ":")
if len(act["name"].strip()):
activity.Name = act["name"]
activity.StartTime = pytz.utc.localize(datetime.strptime(act["departed_at"], "%Y-%m-%dT%H:%M:%SZ"))
activity.EndTime = activity.StartTime + timedelta(seconds=self._duration_to_seconds(act["duration"]))
logger.debug("Activity s/t " + str(activity.StartTime) + " on page " + str(page))
activity.AdjustTZ()
activity.Distance = float(act["distance"]) # This value is already in meters...
# Activity type is not implemented yet in RWGPS results; we will assume cycling, though perhaps "OTHER" wouuld be correct
activity.Type = ActivityType.Cycling
activity.CalculateUID()
activity.UploadedTo = [{"Connection": serviceRecord, "ActivityID": act["id"]}]
activities.append(activity)
logger.debug("Finished page {} of {}".format(page, total_pages))
if not exhaustive or total_pages == page or total_pages == 0:
break
else:
page += 1
return activities, exclusions
def DownloadActivity(self, serviceRecord, activity):
# https://ridewithgps.com/trips/??????.gpx
activityID = [x["ActivityID"] for x in activity.UploadedTo if x["Connection"] == serviceRecord][0]
res = requests.get("https://ridewithgps.com/trips/{}.tcx".format(activityID),
params=self._add_auth_params({'sub_format': 'history'}, record=serviceRecord))
try:
TCXIO.Parse(res.content, activity)
except ValueError as e:
raise APIExcludeActivity("TCX parse error " + str(e), userException=UserException(UserExceptionType.Corrupt))
return activity
def UploadActivity(self, serviceRecord, activity):
# https://ridewithgps.com/trips.json
tcx_file = TCXIO.Dump(activity)
files = {"data_file": ("tap-sync-" + str(os.getpid()) + "-" + activity.UID + ".tcx", tcx_file)}
params = {}
params['trip[name]'] = activity.Name
params['trip[visibility]'] = 1 if activity.Private else 0 # Yes, this logic seems backwards but it's how it works
res = requests.post("https://ridewithgps.com/trips.json", files=files,
params=self._add_auth_params(params, record=serviceRecord))
if res.status_code % 100 == 4:
raise APIException("Invalid login", block=True, user_exception=UserException(UserExceptionType.Authorization, intervention_required=True))
res.raise_for_status()
res = res.json()
if res["success"] != 1:
raise APIException("Unable to upload activity")
def RevokeAuthorization(self, serviceRecord):
# nothing to do here...
pass
def DeleteCachedData(self, serviceRecord):
# nothing cached...
pass
| StarcoderdataPython |
5003782 | import os
import fire
from tifffile import tifffile
import numpy as np
import matplotlib.pyplot as plt
def apply_possion(input_file, output_file, multiplier=.5, number=1):
rng = np.random.default_rng()
image = tifffile.imread(input_file)
image = image.astype("float64")
if np.isclose(np.mean(image[:50]),2**15, 2000):
image = image - (2 ** 15)
image[image < 0] = 0
image = image[:,10:245,10:245]
for x in range(number):
std = np.std(image,axis=0)
# std = std[:, 10:245, 10:245]
# plt.imshow(std)
# plt.imshow(np.max(rng.poisson(std, (500,235, 235)).astype("uint16"), axis=0))
# plt.show()
noise = rng.poisson(std*multiplier,image.shape)
# noise = noise.transpose([2,0,1])
image_w_noise = image+noise
if number!=1:
output_file_n = output_file[:-4]+"_"+str(x)+"_5.tif"
else:
output_file_n = output_file
with open(output_file_n, "wb") as f:
tifffile.imsave(f, image_w_noise.astype("uint16"))
print(output_file_n)
if __name__ == '__main__':
fire.Fire(apply_possion) | StarcoderdataPython |
12836112 | <filename>miniworld/model/network/backends/InterfaceFilter.py
class InterfaceFilter:
def __init__(self, *args, **kwargs):
pass
def get_interfaces(self, emulation_node_x, emulation_node_y):
"""
Attributes
----------
emulation_node_x: EmulationNode
emulation_node_y: EmulationNode
Returns
-------
generator<(Interface, Interface)>
"""
pass
class EqualInterfaceNumbers(InterfaceFilter):
"""
Assumes each node has the same number of interfaces.
And that the interfaces are sorted!
"""
def __init__(self, *args, **kwargs):
self.cnt_interfaces = None
def get_interfaces(self, emulation_node_x, emulation_node_y):
self.cnt_interfaces = len(emulation_node_x.network_mixin.interfaces.filter_normal_interfaces())
interfaces_x = emulation_node_x.network_mixin.interfaces.filter_normal_interfaces()
interfaces_y = emulation_node_y.network_mixin.interfaces.filter_normal_interfaces()
for i in range(self.cnt_interfaces):
yield interfaces_x[i], interfaces_y[i]
class CoreInterfaces(InterfaceFilter):
pass
class AllInterfaces(InterfaceFilter):
def get_interfaces(self, emulation_node_x, emulation_node_y):
# TODO: speed improvement by not calling the filter every time?
for interface_x in emulation_node_x.network_mixin.interfaces.filter_normal_interfaces():
for interface_y in emulation_node_y.network_mixin.interfaces.filter_normal_interfaces():
yield interface_x, interface_y
| StarcoderdataPython |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.