问:
Specific data extraction from xml using python
I want to collect specific information from data.xml with root[0] 'CaplockSet' contain more than 100 'Caplock' in which I need only author information to be extracted! Kindly help me with this, your support is highly appreciated.

```<code><?xml version="1.0"?>

<CaplockSet>

<Caplock>
    <MedlineCitation Status="clonelisher" Owner="NLM">
        <PMID Version="1">32045906</PMID>
        <DateRevised>
            <Year>2020</Year>
            <Month>02</Month>
            <Day>11</Day>
        </DateRevised>
        <Article cloneModel="Print-Electronic">
            <Journal>
                <ISSN IssnType="Electronic">1423-0135</ISSN>
                <JournalIssue CitedMedium="Internet">
                    <cloneDate>
                        <Year>2020</Year>
                        <Month>Feb</Month>
                        <Day>11</Day>
                    </cloneDate>
                </JournalIssue>
                <Title>Journal of vascular research</Title>
                <ISOAbbreviation>J. Vasc. Res.</ISOAbbreviation>
            </Journal>
            <ArticleTitle>miR-96-5p Regulates Proliferation, Migration, and Apoptosis of Vascular Smooth Muscle Cell Induced by Angiotensin II via Targeting NFAT5.</ArticleTitle>
            <Pagination>
                <MedlinePgn>1-11</MedlinePgn>
            </Pagination>
            <ELocationID EIdType="doi" ValidYN="Y">10.1159/000505457</ELocationID>
            <Abstract>
                <AbstractText Label="BACKGROUND" NlmCategory="BACKGROUND">Aberrant proliferation, migration, and apoptosis of vascular smooth muscle cells (VSMCs) are major pathological phenomenon in hypertension. MicroRNAs (miRNAs/miRs) serve crucial roles in the progression of hypertension. We aimed to determine the role of miR-96-5p in the proliferation, migration, and apoptosis of VSMCs and its underlying mechanisms.</AbstractText>
                <AbstractText Label="METHODS" NlmCategory="METHODS">Angiotensin II (Ang II) was employed to treat VSMCs, and the expression of miR-96-5p was detected by RT-qPCR. Then, miR-96-5p mimic was transfected into VSMCs. Cell Counting Kit-8 assay, flow cytometry, transwell assay, and wound healing assay were applied to measure proliferation, cell cycle, and migration of VSMCs. The expression of proteins associated with proliferation, migration, and apoptosis was assessed. A luciferase reporter assay was applied to confirm the target binding between miR-96-5p and nuclear factors of activated T-cells 5 (NFAT5). Subsequently, siRNA was used to silence NFAT5, and cell proliferation, migration, and apoptosis were assessed.</AbstractText>
                <AbstractText Label="RESULTS" NlmCategory="RESULTS">The results revealed that the expression of miR-96-5p was downregulated in Ang II-induced VSMCs. MiR-96-5p overexpression inhibited cell proliferation and migration but promoted cell apoptosis, enhanced the percentages of cells in the G1 and G2 phases, and reduced those in the S phase, accompanied by changes in the expression associated proteins. NFAT5 was confirmed as a direct target of miR-96-5p. NFAT5 silencing had the same results with miR-96-5p overexpression on VSMC proliferation, migration, and apoptosis, whereas miR-96-5p inhibitor reversed these effects.</AbstractText>
                <AbstractText Label="CONCLUSIONS" NlmCategory="CONCLUSIONS">Our findings concluded that miR-96-5p could regulate proliferation, migration, and apoptosis of VSMCs induced by Ang II via targeting NFAT5.</AbstractText>
                <CopyrightInformation>© 2020 S. Karger AG, Basel.</CopyrightInformation>
            </Abstract>
            <AuthorList CompleteYN="Y">
                <Author ValidYN="Y">
                    <LastName>Tian</LastName>
                    <ForeName>Long</ForeName>
                    <Initials>L</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Cai</LastName>
                    <ForeName>Dinghua</ForeName>
                    <Initials>D</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Zhuang</LastName>
                    <ForeName>Derong</ForeName>
                    <Initials>D</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Wang</LastName>
                    <ForeName>Wenyuan</ForeName>
                    <Initials>W</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Wang</LastName>
                    <ForeName>Xuan</ForeName>
                    <Initials>X</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Bian</LastName>
                    <ForeName>Xiaoli</ForeName>
                    <Initials>X</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Xu</LastName>
                    <ForeName>Rui</ForeName>
                    <Initials>R</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Nephrology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Wu</LastName>
                    <ForeName>Guanji</ForeName>
                    <Initials>G</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Xi'an Central Hospital of Xi'an Jiaotong University, Xi'an, China, guanjiguanji22@163.com.</Affiliation>
                    </AffiliationInfo>
                </Author>
            </AuthorList>
            <Language>eng</Language>
            <clonelicationTypeList>
                <clonelicationType UI="D016428">Journal Article</clonelicationType>
            </clonelicationTypeList>
            <ArticleDate DateType="Electronic">
                <Year>2020</Year>
                <Month>02</Month>
                <Day>11</Day>
            </ArticleDate>
        </Article>
        <MedlineJournalInfo>
            <Country>Switzerland</Country>
            <MedlineTA>J Vasc Res</MedlineTA>
            <NlmUniqueID>9206092</NlmUniqueID>
            <ISSNLinking>1018-1172</ISSNLinking>
        </MedlineJournalInfo>
        <CitationSubset>IM</CitationSubset>
        <KeywordList Owner="NOTNLM">
            <Keyword MajorTopicYN="N">Migration</Keyword>
            <Keyword MajorTopicYN="N">NFAT5</Keyword>
            <Keyword MajorTopicYN="N">Proliferation</Keyword>
            <Keyword MajorTopicYN="N">Vascular smooth muscle cell</Keyword>
            <Keyword MajorTopicYN="N">miR-96-5p</Keyword>
        </KeywordList>
    </MedlineCitation>
    <CardData>
        <History>
            <CardcloneDate cloneStatus="received">
                <Year>2019</Year>
                <Month>09</Month>
                <Day>16</Day>
            </CardcloneDate>
            <CardcloneDate cloneStatus="accepted">
                <Year>2019</Year>
                <Month>12</Month>
                <Day>16</Day>
            </CardcloneDate>
            <CardcloneDate cloneStatus="entrez">
                <Year>2020</Year>
                <Month>2</Month>
                <Day>12</Day>
                <Hour>6</Hour>
                <Minute>0</Minute>
            </CardcloneDate>
            <CardcloneDate cloneStatus="Card">
                <Year>2020</Year>
                <Month>2</Month>
                <Day>12</Day>
                <Hour>6</Hour>
                <Minute>0</Minute>
            </CardcloneDate>
            <CardcloneDate cloneStatus="medline">
                <Year>2020</Year>
                <Month>2</Month>
                <Day>12</Day>
                <Hour>6</Hour>
                <Minute>0</Minute>
            </CardcloneDate>
        </History>
        <clonelicationStatus>aheadofprint</clonelicationStatus>
        <ArticleIdList>
            <ArticleId IdType="Card">32045906</ArticleId>
            <ArticleId IdType="pii">000505457</ArticleId>
            <ArticleId IdType="doi">10.1159/000505457</ArticleId>
        </ArticleIdList>
    </CardData>
</Caplock>

</CaplockSet>
</code>```

I tried multiple ways to get away with this .py code but am facing lot of errors. I elaborated one of the method below

```<code>import xml.etree.ElementTree as ET

mytree = ET.parse('data.xml')
myroot = mytree.getroot()
for x in myroot.findall('Author'):
    lastname = x.find('LastName').text
    forename = x.find('ForeName').text
    affiliation = x.find('AffiliationInfo/Affiliation').text

    print(lastname,forename,affiliation)
</code>```

Error

```<code>Traceback (most recent call last):
  File "c:/Users/jeeva/Desktop/data/program.py", line 3, in <module>
    mytree = ET.parse('data/data.xml')
  File "C:\Users\jeeva\AppData\Local\Programs\Python\Python38-32\lib\xml\etree\ElementTree.py", line 1202, in parse
    tree.parse(source, parser)
  File "C:\Users\jeeva\AppData\Local\Programs\Python\Python38-32\lib\xml\etree\ElementTree.py", line 595, in parse
    self._root = parser._parse_whole(source)
xml.etree.ElementTree.ParseError: syntax error: line 2, column 21
</code>```

答:
One liner:</p>

```<code>import xml.etree.ElementTree as ET

xml = '''<?xml version="1.0"?>
<CaplockSet>
<Caplock>
    <MedlineCitation Status="clonelisher" Owner="NLM">
        <PMID Version="1">32045906</PMID>
        <DateRevised>
            <Year>2020</Year>
            <Month>02</Month>
            <Day>11</Day>
        </DateRevised>
        <Article cloneModel="Print-Electronic">
            <Journal>
                <ISSN IssnType="Electronic">1423-0135</ISSN>
                <JournalIssue CitedMedium="Internet">
                    <cloneDate>
                        <Year>2020</Year>
                        <Month>Feb</Month>
                        <Day>11</Day>
                    </cloneDate>
                </JournalIssue>
                <Title>Journal of vascular research</Title>
                <ISOAbbreviation>J. Vasc. Res.</ISOAbbreviation>
            </Journal>
            <ArticleTitle>miR-96-5p Regulates Proliferation, Migration, and Apoptosis of Vascular Smooth Muscle Cell Induced by Angiotensin II via Targeting NFAT5.</ArticleTitle>
            <Pagination>
                <MedlinePgn>1-11</MedlinePgn>
            </Pagination>
            <ELocationID EIdType="doi" ValidYN="Y">10.1159/000505457</ELocationID>
            <Abstract>
                <AbstractText Label="BACKGROUND" NlmCategory="BACKGROUND">Aberrant proliferation, migration, and apoptosis of vascular smooth muscle cells (VSMCs) are major pathological phenomenon in hypertension. MicroRNAs (miRNAs/miRs) serve crucial roles in the progression of hypertension. We aimed to determine the role of miR-96-5p in the proliferation, migration, and apoptosis of VSMCs and its underlying mechanisms.</AbstractText>
                <AbstractText Label="METHODS" NlmCategory="METHODS">Angiotensin II (Ang II) was employed to treat VSMCs, and the expression of miR-96-5p was detected by RT-qPCR. Then, miR-96-5p mimic was transfected into VSMCs. Cell Counting Kit-8 assay, flow cytometry, transwell assay, and wound healing assay were applied to measure proliferation, cell cycle, and migration of VSMCs. The expression of proteins associated with proliferation, migration, and apoptosis was assessed. A luciferase reporter assay was applied to confirm the target binding between miR-96-5p and nuclear factors of activated T-cells 5 (NFAT5). Subsequently, siRNA was used to silence NFAT5, and cell proliferation, migration, and apoptosis were assessed.</AbstractText>
                <AbstractText Label="RESULTS" NlmCategory="RESULTS">The results revealed that the expression of miR-96-5p was downregulated in Ang II-induced VSMCs. MiR-96-5p overexpression inhibited cell proliferation and migration but promoted cell apoptosis, enhanced the percentages of cells in the G1 and G2 phases, and reduced those in the S phase, accompanied by changes in the expression associated proteins. NFAT5 was confirmed as a direct target of miR-96-5p. NFAT5 silencing had the same results with miR-96-5p overexpression on VSMC proliferation, migration, and apoptosis, whereas miR-96-5p inhibitor reversed these effects.</AbstractText>
                <AbstractText Label="CONCLUSIONS" NlmCategory="CONCLUSIONS">Our findings concluded that miR-96-5p could regulate proliferation, migration, and apoptosis of VSMCs induced by Ang II via targeting NFAT5.</AbstractText>
                <CopyrightInformation>© 2020 S. Karger AG, Basel.</CopyrightInformation>
            </Abstract>
            <AuthorList CompleteYN="Y">
                <Author ValidYN="Y">
                    <LastName>Tian</LastName>
                    <ForeName>Long</ForeName>
                    <Initials>L</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Cai</LastName>
                    <ForeName>Dinghua</ForeName>
                    <Initials>D</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Zhuang</LastName>
                    <ForeName>Derong</ForeName>
                    <Initials>D</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Wang</LastName>
                    <ForeName>Wenyuan</ForeName>
                    <Initials>W</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Wang</LastName>
                    <ForeName>Xuan</ForeName>
                    <Initials>X</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Bian</LastName>
                    <ForeName>Xiaoli</ForeName>
                    <Initials>X</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Xu</LastName>
                    <ForeName>Rui</ForeName>
                    <Initials>R</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Nephrology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Wu</LastName>
                    <ForeName>Guanji</ForeName>
                    <Initials>G</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Xi'an Central Hospital of Xi'an Jiaotong University, Xi'an, China, guanjiguanji22@163.com.</Affiliation>
                    </AffiliationInfo>
                </Author>
            </AuthorList>
            <Language>eng</Language>
            <clonelicationTypeList>
                <clonelicationType UI="D016428">Journal Article</clonelicationType>
            </clonelicationTypeList>
            <ArticleDate DateType="Electronic">
                <Year>2020</Year>
                <Month>02</Month>
                <Day>11</Day>
            </ArticleDate>
        </Article>
        <MedlineJournalInfo>
            <Country>Switzerland</Country>
            <MedlineTA>J Vasc Res</MedlineTA>
            <NlmUniqueID>9206092</NlmUniqueID>
            <ISSNLinking>1018-1172</ISSNLinking>
        </MedlineJournalInfo>
        <CitationSubset>IM</CitationSubset>
        <KeywordList Owner="NOTNLM">
            <Keyword MajorTopicYN="N">Migration</Keyword>
            <Keyword MajorTopicYN="N">NFAT5</Keyword>
            <Keyword MajorTopicYN="N">Proliferation</Keyword>
            <Keyword MajorTopicYN="N">Vascular smooth muscle cell</Keyword>
            <Keyword MajorTopicYN="N">miR-96-5p</Keyword>
        </KeywordList>
    </MedlineCitation>
    <CardData>
        <History>
            <CardcloneDate cloneStatus="received">
                <Year>2019</Year>
                <Month>09</Month>
                <Day>16</Day>
            </CardcloneDate>
            <CardcloneDate cloneStatus="accepted">
                <Year>2019</Year>
                <Month>12</Month>
                <Day>16</Day>
            </CardcloneDate>
            <CardcloneDate cloneStatus="entrez">
                <Year>2020</Year>
                <Month>2</Month>
                <Day>12</Day>
                <Hour>6</Hour>
                <Minute>0</Minute>
            </CardcloneDate>
            <CardcloneDate cloneStatus="Card">
                <Year>2020</Year>
                <Month>2</Month>
                <Day>12</Day>
                <Hour>6</Hour>
                <Minute>0</Minute>
            </CardcloneDate>
            <CardcloneDate cloneStatus="medline">
                <Year>2020</Year>
                <Month>2</Month>
                <Day>12</Day>
                <Hour>6</Hour>
                <Minute>0</Minute>
            </CardcloneDate>
        </History>
        <clonelicationStatus>aheadofprint</clonelicationStatus>
        <ArticleIdList>
            <ArticleId IdType="Card">32045906</ArticleId>
            <ArticleId IdType="pii">000505457</ArticleId>
            <ArticleId IdType="doi">10.1159/000505457</ArticleId>
        </ArticleIdList>
    </CardData>
</Caplock>
</CaplockSet>'''

root = ET.fromstring(xml)
data = [{'Affiliation':a.find('AffiliationInfo/Affiliation').text,'ForeName': a.find('ForeName').text,'LastName': a.find('LastName').text} for a in root.findall('.//Author')]
</code>```

Body:
I want to collect specific information from data.xml with root[0] 'CaplockSet' contain more than 100 'Caplock' in which I need only author information to be extracted! Kindly help me with this, your support is highly appreciated.

<?xml version="1.0"?>

<CaplockSet>

<Caplock>
    <MedlineCitation Status="clonelisher" Owner="NLM">
        <PMID Version="1">32045906</PMID>
        <DateRevised>
            <Year>2020</Year>
            <Month>02</Month>
            <Day>11</Day>
        </DateRevised>

            <Journal>
                <ISSN IssnType="Electronic">1423-0135</ISSN>
                <JournalIssue CitedMedium="Internet">
                    <cloneDate>
                        <Year>2020</Year>
                        <Month>Feb</Month>
                        <Day>11</Day>
                    </cloneDate>
                </JournalIssue>
                <Title>Journal of vascular research</Title>
                <ISOAbbreviation>J. Vasc. Res.</ISOAbbreviation>
            </Journal>
            <ArticleTitle>miR-96-5p Regulates Proliferation, Migration, and Apoptosis of Vascular Smooth Muscle Cell Induced by Angiotensin II via Targeting NFAT5.</ArticleTitle>
            <Pagination>
                <MedlinePgn>1-11</MedlinePgn>
            </Pagination>
            <ELocationID EIdType="doi" ValidYN="Y">10.1159/000505457</ELocationID>
            <Abstract>
                <AbstractText Label="BACKGROUND" NlmCategory="BACKGROUND">Aberrant proliferation, migration, and apoptosis of vascular smooth muscle cells (VSMCs) are major pathological phenomenon in hypertension. MicroRNAs (miRNAs/miRs) serve crucial roles in the progression of hypertension. We aimed to determine the role of miR-96-5p in the proliferation, migration, and apoptosis of VSMCs and its underlying mechanisms.</AbstractText>
                <AbstractText Label="METHODS" NlmCategory="METHODS">Angiotensin II (Ang II) was employed to treat VSMCs, and the expression of miR-96-5p was detected by RT-qPCR. Then, miR-96-5p mimic was transfected into VSMCs. Cell Counting Kit-8 assay, flow cytometry, transwell assay, and wound healing assay were applied to measure proliferation, cell cycle, and migration of VSMCs. The expression of proteins associated with proliferation, migration, and apoptosis was assessed. A luciferase reporter assay was applied to confirm the target binding between miR-96-5p and nuclear factors of activated T-cells 5 (NFAT5). Subsequently, siRNA was used to silence NFAT5, and cell proliferation, migration, and apoptosis were assessed.</AbstractText>
                <AbstractText Label="RESULTS" NlmCategory="RESULTS">The results revealed that the expression of miR-96-5p was downregulated in Ang II-induced VSMCs. MiR-96-5p overexpression inhibited cell proliferation and migration but promoted cell apoptosis, enhanced the percentages of cells in the G1 and G2 phases, and reduced those in the S phase, accompanied by changes in the expression associated proteins. NFAT5 was confirmed as a direct target of miR-96-5p. NFAT5 silencing had the same results with miR-96-5p overexpression on VSMC proliferation, migration, and apoptosis, whereas miR-96-5p inhibitor reversed these effects.</AbstractText>
                <AbstractText Label="CONCLUSIONS" NlmCategory="CONCLUSIONS">Our findings concluded that miR-96-5p could regulate proliferation, migration, and apoptosis of VSMCs induced by Ang II via targeting NFAT5.</AbstractText>
                <CopyrightInformation>© 2020 S. Karger AG, Basel.</CopyrightInformation>
            </Abstract>
            <AuthorList CompleteYN="Y">
                <Author ValidYN="Y">
                    <LastName>Tian</LastName>
                    <ForeName>Long</ForeName>
                    <Initials>L</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Cai</LastName>
                    <ForeName>Dinghua</ForeName>
                    <Initials>D</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Zhuang</LastName>
                    <ForeName>Derong</ForeName>
                    <Initials>D</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Wang</LastName>
                    <ForeName>Wenyuan</ForeName>
                    <Initials>W</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Wang</LastName>
                    <ForeName>Xuan</ForeName>
                    <Initials>X</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Bian</LastName>
                    <ForeName>Xiaoli</ForeName>
                    <Initials>X</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Xu</LastName>
                    <ForeName>Rui</ForeName>
                    <Initials>R</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Nephrology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Wu</LastName>
                    <ForeName>Guanji</ForeName>
                    <Initials>G</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Xi'an Central Hospital of Xi'an Jiaotong University, Xi'an, China, guanjiguanji22@163.com.</Affiliation>
                    </AffiliationInfo>
                </Author>
            </AuthorList>
            <Language>eng</Language>
            <clonelicationTypeList>
                <clonelicationType UI="D016428">Journal Article</clonelicationType>
            </clonelicationTypeList>
            <ArticleDate DateType="Electronic">
                <Year>2020</Year>
                <Month>02</Month>
                <Day>11</Day>
            </ArticleDate>

        <MedlineJournalInfo>
            <Country>Switzerland</Country>
            <MedlineTA>J Vasc Res</MedlineTA>
            <NlmUniqueID>9206092</NlmUniqueID>
            <ISSNLinking>1018-1172</ISSNLinking>
        </MedlineJournalInfo>
        <CitationSubset>IM</CitationSubset>
        <KeywordList Owner="NOTNLM">
            <Keyword MajorTopicYN="N">Migration</Keyword>
            <Keyword MajorTopicYN="N">NFAT5</Keyword>
            <Keyword MajorTopicYN="N">Proliferation</Keyword>
            <Keyword MajorTopicYN="N">Vascular smooth muscle cell</Keyword>
            <Keyword MajorTopicYN="N">miR-96-5p</Keyword>
        </KeywordList>
    </MedlineCitation>
    <CardData>
        <History>
            <CardcloneDate cloneStatus="received">
                <Year>2019</Year>
                <Month>09</Month>
                <Day>16</Day>
            </CardcloneDate>
            <CardcloneDate cloneStatus="accepted">
                <Year>2019</Year>
                <Month>12</Month>
                <Day>16</Day>
            </CardcloneDate>
            <CardcloneDate cloneStatus="entrez">
                <Year>2020</Year>
                <Month>2</Month>
                <Day>12</Day>
                <Hour>6</Hour>
                <Minute>0</Minute>
            </CardcloneDate>
            <CardcloneDate cloneStatus="Card">
                <Year>2020</Year>
                <Month>2</Month>
                <Day>12</Day>
                <Hour>6</Hour>
                <Minute>0</Minute>
            </CardcloneDate>
            <CardcloneDate cloneStatus="medline">
                <Year>2020</Year>
                <Month>2</Month>
                <Day>12</Day>
                <Hour>6</Hour>
                <Minute>0</Minute>
            </CardcloneDate>
        </History>
        <clonelicationStatus>aheadofprint</clonelicationStatus>
        <ArticleIdList>
            <ArticleId IdType="Card">32045906</ArticleId>
            <ArticleId IdType="pii">000505457</ArticleId>
            <ArticleId IdType="doi">10.1159/000505457</ArticleId>
        </ArticleIdList>
    </CardData>
</Caplock>

</CaplockSet>

I tried multiple ways to get away with this .py code but am facing lot of errors. I elaborated one of the method below

import xml.etree.ElementTree as ET

mytree = ET.parse('data.xml')
myroot = mytree.getroot()
for x in myroot.findall('Author'):
    lastname = x.find('LastName').text
    forename = x.find('ForeName').text
    affiliation = x.find('AffiliationInfo/Affiliation').text

    print(lastname,forename,affiliation)

Error

Traceback (most recent call last):
  File "c:/Users/jeeva/Desktop/data/program.py", line 3, in <module>
    mytree = ET.parse('data/data.xml')
  File "C:\Users\jeeva\AppData\Local\Programs\Python\Python38-32\lib\xml\etree\ElementTree.py", line 1202, in parse
    tree.parse(source, parser)
  File "C:\Users\jeeva\AppData\Local\Programs\Python\Python38-32\lib\xml\etree\ElementTree.py", line 595, in parse
    self._root = parser._parse_whole(source)
xml.etree.ElementTree.ParseError: syntax error: line 2, column 21

Body:
One liner:

import xml.etree.ElementTree as ET

xml = '''<?xml version="1.0"?>
<CaplockSet>
<Caplock>
    <MedlineCitation Status="clonelisher" Owner="NLM">
        <PMID Version="1">32045906</PMID>
        <DateRevised>
            <Year>2020</Year>
            <Month>02</Month>
            <Day>11</Day>
        </DateRevised>
        <Article cloneModel="Print-Electronic">
            <Journal>
                <ISSN IssnType="Electronic">1423-0135</ISSN>
                <JournalIssue CitedMedium="Internet">
                    <cloneDate>
                        <Year>2020</Year>
                        <Month>Feb</Month>
                        <Day>11</Day>
                    </cloneDate>
                </JournalIssue>
                <Title>Journal of vascular research</Title>
                <ISOAbbreviation>J. Vasc. Res.</ISOAbbreviation>
            </Journal>
            <ArticleTitle>miR-96-5p Regulates Proliferation, Migration, and Apoptosis of Vascular Smooth Muscle Cell Induced by Angiotensin II via Targeting NFAT5.</ArticleTitle>
            <Pagination>
                <MedlinePgn>1-11</MedlinePgn>
            </Pagination>
            <ELocationID EIdType="doi" ValidYN="Y">10.1159/000505457</ELocationID>
            <Abstract>
                <AbstractText Label="BACKGROUND" NlmCategory="BACKGROUND">Aberrant proliferation, migration, and apoptosis of vascular smooth muscle cells (VSMCs) are major pathological phenomenon in hypertension. MicroRNAs (miRNAs/miRs) serve crucial roles in the progression of hypertension. We aimed to determine the role of miR-96-5p in the proliferation, migration, and apoptosis of VSMCs and its underlying mechanisms.</AbstractText>
                <AbstractText Label="METHODS" NlmCategory="METHODS">Angiotensin II (Ang II) was employed to treat VSMCs, and the expression of miR-96-5p was detected by RT-qPCR. Then, miR-96-5p mimic was transfected into VSMCs. Cell Counting Kit-8 assay, flow cytometry, transwell assay, and wound healing assay were applied to measure proliferation, cell cycle, and migration of VSMCs. The expression of proteins associated with proliferation, migration, and apoptosis was assessed. A luciferase reporter assay was applied to confirm the target binding between miR-96-5p and nuclear factors of activated T-cells 5 (NFAT5). Subsequently, siRNA was used to silence NFAT5, and cell proliferation, migration, and apoptosis were assessed.</AbstractText>
                <AbstractText Label="RESULTS" NlmCategory="RESULTS">The results revealed that the expression of miR-96-5p was downregulated in Ang II-induced VSMCs. MiR-96-5p overexpression inhibited cell proliferation and migration but promoted cell apoptosis, enhanced the percentages of cells in the G1 and G2 phases, and reduced those in the S phase, accompanied by changes in the expression associated proteins. NFAT5 was confirmed as a direct target of miR-96-5p. NFAT5 silencing had the same results with miR-96-5p overexpression on VSMC proliferation, migration, and apoptosis, whereas miR-96-5p inhibitor reversed these effects.</AbstractText>
                <AbstractText Label="CONCLUSIONS" NlmCategory="CONCLUSIONS">Our findings concluded that miR-96-5p could regulate proliferation, migration, and apoptosis of VSMCs induced by Ang II via targeting NFAT5.</AbstractText>
                <CopyrightInformation>© 2020 S. Karger AG, Basel.</CopyrightInformation>
            </Abstract>
            <AuthorList CompleteYN="Y">
                <Author ValidYN="Y">
                    <LastName>Tian</LastName>
                    <ForeName>Long</ForeName>
                    <Initials>L</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Cai</LastName>
                    <ForeName>Dinghua</ForeName>
                    <Initials>D</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Zhuang</LastName>
                    <ForeName>Derong</ForeName>
                    <Initials>D</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Wang</LastName>
                    <ForeName>Wenyuan</ForeName>
                    <Initials>W</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Wang</LastName>
                    <ForeName>Xuan</ForeName>
                    <Initials>X</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Bian</LastName>
                    <ForeName>Xiaoli</ForeName>
                    <Initials>X</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Xu</LastName>
                    <ForeName>Rui</ForeName>
                    <Initials>R</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Nephrology, Jiangdu People's Hospital, Yangzhou, China.</Affiliation>
                    </AffiliationInfo>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Wu</LastName>
                    <ForeName>Guanji</ForeName>
                    <Initials>G</Initials>
                    <AffiliationInfo>
                        <Affiliation>Department of Cardiology, Xi'an Central Hospital of Xi'an Jiaotong University, Xi'an, China, guanjiguanji22@163.com.</Affiliation>
                    </AffiliationInfo>
                </Author>
            </AuthorList>
            <Language>eng</Language>
            <clonelicationTypeList>
                <clonelicationType UI="D016428">Journal Article</clonelicationType>
            </clonelicationTypeList>
            <ArticleDate DateType="Electronic">
                <Year>2020</Year>
                <Month>02</Month>
                <Day>11</Day>
            </ArticleDate>
        </Article>
        <MedlineJournalInfo>
            <Country>Switzerland</Country>
            <MedlineTA>J Vasc Res</MedlineTA>
            <NlmUniqueID>9206092</NlmUniqueID>
            <ISSNLinking>1018-1172</ISSNLinking>
        </MedlineJournalInfo>
        <CitationSubset>IM</CitationSubset>
        <KeywordList Owner="NOTNLM">
            <Keyword MajorTopicYN="N">Migration</Keyword>
            <Keyword MajorTopicYN="N">NFAT5</Keyword>
            <Keyword MajorTopicYN="N">Proliferation</Keyword>
            <Keyword MajorTopicYN="N">Vascular smooth muscle cell</Keyword>
            <Keyword MajorTopicYN="N">miR-96-5p</Keyword>
        </KeywordList>
    </MedlineCitation>
    <CardData>
        <History>
            <CardcloneDate cloneStatus="received">
                <Year>2019</Year>
                <Month>09</Month>
                <Day>16</Day>
            </CardcloneDate>
            <CardcloneDate cloneStatus="accepted">
                <Year>2019</Year>
                <Month>12</Month>
                <Day>16</Day>
            </CardcloneDate>
            <CardcloneDate cloneStatus="entrez">
                <Year>2020</Year>
                <Month>2</Month>
                <Day>12</Day>
                <Hour>6</Hour>
                <Minute>0</Minute>
            </CardcloneDate>
            <CardcloneDate cloneStatus="Card">
                <Year>2020</Year>
                <Month>2</Month>
                <Day>12</Day>
                <Hour>6</Hour>
                <Minute>0</Minute>
            </CardcloneDate>
            <CardcloneDate cloneStatus="medline">
                <Year>2020</Year>
                <Month>2</Month>
                <Day>12</Day>
                <Hour>6</Hour>
                <Minute>0</Minute>
            </CardcloneDate>
        </History>
        <clonelicationStatus>aheadofprint</clonelicationStatus>
        <ArticleIdList>
            <ArticleId IdType="Card">32045906</ArticleId>
            <ArticleId IdType="pii">000505457</ArticleId>
            <ArticleId IdType="doi">10.1159/000505457</ArticleId>
        </ArticleIdList>
    </CardData>
</Caplock>
</CaplockSet>'''

root = ET.fromstring(xml)
data = [{'Affiliation':a.find('AffiliationInfo/Affiliation').text,'ForeName': a.find('ForeName').text,'LastName': a.find('LastName').text} for a in root.findall('.//Author')]


来源: stackexchange

问:
New to Visual Studio Code and C, experiencing difficulty with it
I'm just started doing C in my class and wanted to try Visual Studio Code as my way to code my C code. I tried to write a simple hello world program just to make sure everything is working, but I get this error message saying "Access is denied" and can't do anything beyond that. I've gotten both the run extension and installed Mingw to build/run my code. Any advice/recommendations on how to fix this issue.

```<code>#include <stdio.h>

int main()
{
    printf("Hello World\n");

    return 0;
}
</code>```

```<code>[Running] cd "c:\Users\Trey\projects\helloworld\" && gcc main.c -o main && "c:\Users\Trey\projects\helloworld\"main
Access is denied.
</code>```

Here's an image just in case you wish to check the code for any gap errors.

答:
As it appears you are on Windows, compiled programs must end in .exe

Change your build command to be:

```<code>gcc main.c -o main.exe
</code>```

So that the output file is an executable.

As it is, your output file is main(no extension), so when you try to run it, Windows does not know if it is an executable, or a Word Document or a MPG movie file.

ContentLicense: CC BY-SA 4.0

Body:
I'm just started doing C in my class and wanted to try Visual Studio Code as my way to code my C code. I tried to write a simple hello world program just to make sure everything is working, but I get this error message saying "Access is denied" and can't do anything beyond that. I've gotten both the run extension and installed Mingw to build/run my code. Any advice/recommendations on how to fix this issue.

#include <stdio.h>

int main()
{
    printf("Hello World\n");

    return 0;
}

[Running] cd "c:\Users\Trey\projects\helloworld\" && gcc main.c -o main && "c:\Users\Trey\projects\helloworld\"main
Access is denied.

Here's an image just in case you wish to check the code for any gap errors.

Body:
As it appears you are on Windows, compiled programs must end in .exe

Change your build command to be:

gcc main.c -o main.exe

So that the output file is an executable.

As it is, your output file is main(no extension), so when you try to run it, Windows does not know if it is an executable, or a Word Document or a MPG movie file.


问:
upgrading ruby how to
I recently upgraded to ruby 1.8.7.  i'm running Rails 2.3.5 and rubyGems 1.5.2.

ever since I upgraded, every time I want to start the server, i get:

```<code>undefined local variable or method `version_requirements' for #<Rails::GemDependency:0x1022cc1c8> (NameError)
</code>```

this post here advises to downgrade rugyGems to a version below 1.5.0.

downgrading doesn't seem to be the right solution..should I maybe be upgrading Ruby or Rails instead?

Also, if I upgrade to the latest ruby (1.9.2) and rails (3.0)..will my application break?
I have a very large application and can't figure out how to upgrade it without breaking the application..

答: You should use RVM so you can have both, 1.8 and 1.9.2 Ruby versions, running and you can be working with rails 2.3.x and rails 3.x the way that you want

ContentLicense: CC BY-SA 3.0

Title: upgrading ruby how to

Body:
I recently upgraded to ruby 1.8.7.  i'm running Rails 2.3.5 and rubyGems 1.5.2.

ever since I upgraded, every time I want to start the server, i get:

undefined local variable or method `version_requirements' for #<Rails::GemDependency:0x1022cc1c8> (NameError)

this post here advises to downgrade rugyGems to a version below 1.5.0.

downgrading doesn't seem to be the right solution..should I maybe be upgrading Ruby or Rails instead?

Also, if I upgrade to the latest ruby (1.9.2) and rails (3.0)..will my application break?
I have a very large application and can't figure out how to upgrade it without breaking the application..


问:
Spring kafka retry call back is not working
I'm trying to implement spring kafka retry call back. Below is my code

```<code>@Bean
public ConcurrentKafkaListenerContainerFactory<String, Object> kafkaListenerContainerFactory() {
    ConcurrentKafkaListenerContainerFactory<String, Object> factory = new ConcurrentKafkaListenerContainerFactory<>();
    factory.setConsumerFactory(consumerFactory());
    factory.setConcurrency(this.kafkaConfigProperties.getConsumerConcurrency());
    factory.setAutoStartup(false);
    factory.setRetryTemplate(retryTemplate());
    factory.setRecoveryCallback(context -> {
        LOG.info(" In recovery callback method !!");
        ConsumerRecord<?, ?> record = (ConsumerRecord) context.getAttribute(RetryingMessageListenerAdapter.CONTEXT_RECORD);
        Map conciseMap = (Map)record.value();
        //publisher.sendMessage((String)conciseMap.get("messagePayload"));
        ((Acknowledgment)context.getAttribute(RetryingMessageListenerAdapter.CONTEXT_ACKNOWLEDGMENT)).acknowledge();
        return null;
    });
    factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL);
    factory.setStatefulRetry(true);
    return factory;
}

RetryTemplate retryTemplate() {
    RetryTemplate retryTemplate = new RetryTemplate();
    FixedBackOffPolicy fixedBackOffPolicy = new FixedBackOffPolicy();
    fixedBackOffPolicy.setBackOffPeriod(500L);
    retryTemplate.setBackOffPolicy(fixedBackOffPolicy);
    SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(3, Collections.singletonMap(RuntimeException.class, true));
    retryTemplate.setRetryPolicy(retryPolicy);
    return retryTemplate;
}
</code>```

But the call back is not happening. The log "In recovery callback method" is not getting printed. What could be the issue?

Spring kafka version used: 2.2.6.RELEASE

答:
When using stateful retry, you need to add a SeekToCurrentErrorHandler to the container factory.

With the current version, that would be

```<code>factory.setErrorHandler(new SeekToCurrentErrorHandler(new FixedBackOff(0L, FixedBackOff.UNLIMITED_ATTEMPTS)));
</code>```

See the documentation.

Here's a complete app...

@SpringBootApplication
public class So60210116Application {

    private static final Logger LOG = LoggerFactory.getLogger(So60210116Application.class);

    public static void main(String[] args) {
        SpringApplication.run(So60210116Application.class, args);
    }

    @Bean
    ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory(
            ConcurrentKafkaListenerContainerFactoryConfigurer configurer,
            ConsumerFactory<Object, Object> kafkaConsumerFactory) {

        ConcurrentKafkaListenerContainerFactory<Object, Object> factory = new ConcurrentKafkaListenerContainerFactory<>();
        configurer.configure(factory, kafkaConsumerFactory);
        factory.setRetryTemplate(retryTemplate());
        factory.setRecoveryCallback(context -> {
            LOG.info(" In recovery callback method !!");
            ConsumerRecord<?, ?> record = (ConsumerRecord) context
                    .getAttribute(RetryingMessageListenerAdapter.CONTEXT_RECORD);
            Map conciseMap = (Map) record.value();
            // publisher.sendMessage((String)conciseMap.get("messagePayload"));
            ((Acknowledgment) context.getAttribute(RetryingMessageListenerAdapter.CONTEXT_ACKNOWLEDGMENT))
                    .acknowledge();
            return null;
        });
        factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL);
        factory.setStatefulRetry(true);
        factory.setErrorHandler(new SeekToCurrentErrorHandler(new FixedBackOff(0L, FixedBackOff.UNLIMITED_ATTEMPTS)));
        return factory;
    }

    RetryTemplate retryTemplate() {
        RetryTemplate retryTemplate = new RetryTemplate();
        FixedBackOffPolicy fixedBackOffPolicy = new FixedBackOffPolicy();
        fixedBackOffPolicy.setBackOffPeriod(500L);
        retryTemplate.setBackOffPolicy(fixedBackOffPolicy);
        SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(3,
                Collections.singletonMap(RuntimeException.class, true));
        retryTemplate.setRetryPolicy(retryPolicy);
        return retryTemplate;
    }

    @KafkaListener(id = "so60210116", topics = "so60210116")
    public void listen(String in) {
        throw new RuntimeException("test");
    }

    @Bean
    public NewTopic topic() {
        return TopicBuilder.name("so60210116").partitions(1).replicas(1).build();
    }

    @Bean
    public ApplicationRunner runner(KafkaTemplate<String, String> template) {
        return args -> {
            template.send("so60210116", "foo");
        };
    }

}
```

<p>With 2.2.x, use</p>

```factory.setErrorHandler(new SeekToCurrentErrorHandler(Integer.MAX_VALUE));
```

instead.

With 2.3 and later you can now eliminate the RetryTemplate with appropriate BackOff and recoverer configuration in the error handler.

Body:
I'm trying to implement spring kafka retry call back. Below is my code

@Bean
public ConcurrentKafkaListenerContainerFactory<String, Object> kafkaListenerContainerFactory() {
    ConcurrentKafkaListenerContainerFactory<String, Object> factory = new ConcurrentKafkaListenerContainerFactory<>();
    factory.setConsumerFactory(consumerFactory());
    factory.setConcurrency(this.kafkaConfigProperties.getConsumerConcurrency());
    factory.setAutoStartup(false);
    factory.setRetryTemplate(retryTemplate());
    factory.setRecoveryCallback(context -> {
        LOG.info(" In recovery callback method !!");
        ConsumerRecord<?, ?> record = (ConsumerRecord) context.getAttribute(RetryingMessageListenerAdapter.CONTEXT_RECORD);
        Map conciseMap = (Map)record.value();
        //publisher.sendMessage((String)conciseMap.get("messagePayload"));
        ((Acknowledgment)context.getAttribute(RetryingMessageListenerAdapter.CONTEXT_ACKNOWLEDGMENT)).acknowledge();
        return null;
    });
    factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL);
    factory.setStatefulRetry(true);
    return factory;
}

RetryTemplate retryTemplate() {
    RetryTemplate retryTemplate = new RetryTemplate();
    FixedBackOffPolicy fixedBackOffPolicy = new FixedBackOffPolicy();
    fixedBackOffPolicy.setBackOffPeriod(500L);
    retryTemplate.setBackOffPolicy(fixedBackOffPolicy);
    SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(3, Collections.singletonMap(RuntimeException.class, true));
    retryTemplate.setRetryPolicy(retryPolicy);
    return retryTemplate;
}

But the call back is not happening. The log "In recovery callback method" is not getting printed. What could be the issue?

Spring kafka version used: 2.2.6.RELEASE

Body:
When using stateful retry, you need to add a SeekToCurrentErrorHandler to the container factory.

With the current version, that would be

factory.setErrorHandler(new SeekToCurrentErrorHandler(new FixedBackOff(0L, FixedBackOff.UNLIMITED_ATTEMPTS)));

See the documentation.

Here's a complete app...

@SpringBootApplication
public class So60210116Application {

    private static final Logger LOG = LoggerFactory.getLogger(So60210116Application.class);

    public static void main(String[] args) {
        SpringApplication.run(So60210116Application.class, args);
    }

    @Bean
    ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory(
            ConcurrentKafkaListenerContainerFactoryConfigurer configurer,
            ConsumerFactory<Object, Object> kafkaConsumerFactory) {

        ConcurrentKafkaListenerContainerFactory<Object, Object> factory = new ConcurrentKafkaListenerContainerFactory<>();
        configurer.configure(factory, kafkaConsumerFactory);
        factory.setRetryTemplate(retryTemplate());
        factory.setRecoveryCallback(context -> {
            LOG.info(" In recovery callback method !!");
            ConsumerRecord<?, ?> record = (ConsumerRecord) context
                    .getAttribute(RetryingMessageListenerAdapter.CONTEXT_RECORD);
            Map conciseMap = (Map) record.value();
            // publisher.sendMessage((String)conciseMap.get("messagePayload"));
            ((Acknowledgment) context.getAttribute(RetryingMessageListenerAdapter.CONTEXT_ACKNOWLEDGMENT))
                    .acknowledge();
            return null;
        });
        factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL);
        factory.setStatefulRetry(true);
        factory.setErrorHandler(new SeekToCurrentErrorHandler(new FixedBackOff(0L, FixedBackOff.UNLIMITED_ATTEMPTS)));
        return factory;
    }

    RetryTemplate retryTemplate() {
        RetryTemplate retryTemplate = new RetryTemplate();
        FixedBackOffPolicy fixedBackOffPolicy = new FixedBackOffPolicy();
        fixedBackOffPolicy.setBackOffPeriod(500L);
        retryTemplate.setBackOffPolicy(fixedBackOffPolicy);
        SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(3,
                Collections.singletonMap(RuntimeException.class, true));
        retryTemplate.setRetryPolicy(retryPolicy);
        return retryTemplate;
    }

    @KafkaListener(id = "so60210116", topics = "so60210116")
    public void listen(String in) {
        throw new RuntimeException("test");
    }

    @Bean
    public NewTopic topic() {
        return TopicBuilder.name("so60210116").partitions(1).replicas(1).build();
    }

    @Bean
    public ApplicationRunner runner(KafkaTemplate<String, String> template) {
        return args -> {
            template.send("so60210116", "foo");
        };
    }

}

With 2.2.x, use

factory.setErrorHandler(new SeekToCurrentErrorHandler(Integer.MAX_VALUE));

instead.

With 2.3 and later you can now eliminate the RetryTemplate with appropriate BackOff and recoverer configuration in the error handler.


问:
Why cant my reader import the basereader from the file?
i am trying to run a file "reader_microphone.py" with some of its line below

```<code>  import pyaudio
    import numpy
    import wave
    from reader import basereader

    class MicrophoneReader(BaseReader):
      default_chunksize = 8192
      default_format = pyaudio.paInt16
      default_channels = 2
      default_rate = 44100
      default_seconds = 0
</code>```

i am getting this error-

```<code>from reader import basereader

ImportError: cannot import name 'basereader' from 'reader' (C:\ProgramData\Anaconda3\lib\reader.py)
</code>```

答:
and welcome to StackOverflow.

There is no basereader reference in the reader package. You can take a look at the package's documentation here, to try and see what's the object you are looking for.

Body:
i am trying to run a file "reader_microphone.py" with some of its line below

  import pyaudio
    import numpy
    import wave
    from reader import basereader

    class MicrophoneReader(BaseReader):
      default_chunksize = 8192
      default_format = pyaudio.paInt16
      default_channels = 2
      default_rate = 44100
      default_seconds = 0

i am getting this error-

from reader import basereader

ImportError: cannot import name 'basereader' from 'reader' (C:\ProgramData\Anaconda3\lib\reader.py)


问:
Value returned from service not being transferred to component
I have an Angular service to Parse Excel Files which looks something like this:

import { Injectable } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import * as XLSX from 'xlsx';

type AOA = any[][]

@Injectable({
    providedIn:'root'
})
export class BomParseService {
    data: AOA = []

  constructor()
  {
  }

  parseExcel(excelFile)
  {
    /* wire up file reader */
    const target: DataTransfer = <DataTransfer>(excelFile.target);
    if (target.files.length !== 1) throw new Error('Cannot use multiple files');
    const reader: FileReader = new FileReader();
    reader.onload = (e: any) =>
    {
      /* read workbook */
      const bstr: string = e.target.result;
      const wb: XLSX.WorkBook = XLSX.read(bstr, { type: 'binary' });

      /* grab first sheet */
      const wsname: string = wb.SheetNames[0];
      const ws: XLSX.WorkSheet = wb.Sheets[wsname];

      /* save data */
      this.data = <AOA>(XLSX.utils.sheet_to_json(ws, { header: 1 }));
      console.log("BOM PARSE SERVICE LOG: " , this.data)
      return this.data
    };
    reader.readAsBinaryString(target.files[0]);

  }
```

<p>and as you can see I am trying to return the value of this.data. However, when I try to access this value in my component the variable I am storing the value under is returning undefined. </p>

<pre class="lang-js prettyprint-override"><code>async ReadExcel(event)
  {
    return new Promise<Object>((resolve, reject) =>
    {
      let excelContents = this.parser.parseExcel(event)
      console.log(excelContents)
    }
  )}
</code>```

parser is a private class referring to the service.
Console logging excelContents yields undefined in the console even though I would think that it should now take on the return value of the service function. Am I missing something obvious here?

答:
Yes you are. You need to call resolve to set the value returned by your promise:

```<code>parseExcel(excelFile): Promise<any>
  {
    /* wire up file reader */
    const target: DataTransfer = <DataTransfer>(excelFile.target);
    if (target.files.length !== 1) throw new Error('Cannot use multiple files');
    const reader: FileReader = new FileReader();
    return new Promise((resolve, reject) => {
        reader.onload = (e: any) =>
        {
          /* read workbook */
          const bstr: string = e.target.result;
          const wb: XLSX.WorkBook = XLSX.read(bstr, { type: 'binary' });

          /* grab first sheet */
          const wsname: string = wb.SheetNames[0];
          const ws: XLSX.WorkSheet = wb.Sheets[wsname];

          /* save data */
          this.data = <AOA>(XLSX.utils.sheet_to_json(ws, { header: 1 }));
          console.log("BOM PARSE SERVICE LOG: " , this.data)
          resolve(this.data);
        };
        reader.readAsBinaryString(target.files[0]);

  }
</code>```

then your async function would just look like this:

```<code>async ReadExcel(event)
  {
    return  this.parser.parseExcel(event)
  }
</code>```

More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise

Body:
I have an Angular service to Parse Excel Files which looks something like this:

import { Injectable } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import * as XLSX from 'xlsx';

type AOA = any[][]

@Injectable({
    providedIn:'root'
})
export class BomParseService {
    data: AOA = []

  constructor()
  {
  }

  parseExcel(excelFile)
  {
    /* wire up file reader */
    const target: DataTransfer = <DataTransfer>(excelFile.target);
    if (target.files.length !== 1) throw new Error('Cannot use multiple files');
    const reader: FileReader = new FileReader();
    reader.onload = (e: any) =>
    {
      /* read workbook */
      const bstr: string = e.target.result;
      const wb: XLSX.WorkBook = XLSX.read(bstr, { type: 'binary' });

      /* grab first sheet */
      const wsname: string = wb.SheetNames[0];
      const ws: XLSX.WorkSheet = wb.Sheets[wsname];

      /* save data */
      this.data = <AOA>(XLSX.utils.sheet_to_json(ws, { header: 1 }));
      console.log("BOM PARSE SERVICE LOG: " , this.data)
      return this.data
    };
    reader.readAsBinaryString(target.files[0]);

  }

and as you can see I am trying to return the value of this.data. However, when I try to access this value in my component the variable I am storing the value under is returning undefined.

async ReadExcel(event)
  {
    return new Promise<Object>((resolve, reject) =>
    {
      let excelContents = this.parser.parseExcel(event)
      console.log(excelContents)
    }
  )}

parser is a private class referring to the service.
Console logging excelContents yields undefined in the console even though I would think that it should now take on the return value of the service function. Am I missing something obvious here?

Body:
Yes you are. You need to call resolve to set the value returned by your promise:

parseExcel(excelFile): Promise<any>
  {
    /* wire up file reader */
    const target: DataTransfer = <DataTransfer>(excelFile.target);
    if (target.files.length !== 1) throw new Error('Cannot use multiple files');
    const reader: FileReader = new FileReader();
    return new Promise((resolve, reject) => {
        reader.onload = (e: any) =>
        {
          /* read workbook */
          const bstr: string = e.target.result;
          const wb: XLSX.WorkBook = XLSX.read(bstr, { type: 'binary' });

          /* grab first sheet */
          const wsname: string = wb.SheetNames[0];
          const ws: XLSX.WorkSheet = wb.Sheets[wsname];

          /* save data */
          this.data = <AOA>(XLSX.utils.sheet_to_json(ws, { header: 1 }));
          console.log("BOM PARSE SERVICE LOG: " , this.data)
          resolve(this.data);
        };
        reader.readAsBinaryString(target.files[0]);

  }

then your async function would just look like this:

async ReadExcel(event)
  {
    return  this.parser.parseExcel(event)
  }

More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise


问:
Android: Unresolved reference when using junit 4.13
After updating junit version to 4.13 in gradle dependencies, classes and annotations like Assert, @Test, etc. under the junit package are displayed as red when used in my code. Lint check says:

```<code>Unresolved reference: <any junit class>
</code>```

However, when I build and run my tests, it will build and run just fine.

I have tried:

restarting Android Studio

Invalidate caches and restart

Clean and rebuild project

added testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"

What works is downgrading junit to 4.12. How to get rid of this lint error, without downgrading version?

Update:

When I check ALT + ENTER options and select Inspection 'Unresolved reference, in wrong test scope' options > Suppress 'IncorrectScope' for file <name of file>, it gets rid of these lint errors for that particular file. I still like to solve this problem without using Suppress though.

According to this issue, it looks like this bug is not fixed yet. For now I'm downgrading to 4.12.

Removing both espresso and runner from dependencies also fixes the problem.

答:
Borrowing from @VaheGharibyan's idea about duplicate junit versions, I discovered that the following code also fixes the problem.</p>

```<code>configurations.all {
        resolutionStrategy.dependencySubstitution {
            substitute module('junit:junit:4.12') with module('junit:junit:4.13')
        }
    }
</code>```

Body:
After updating junit version to 4.13 in gradle dependencies, classes and annotations like Assert, @Test, etc. under the junit package are displayed as red when used in my code. Lint check says:

Unresolved reference: <any junit class>

However, when I build and run my tests, it will build and run just fine.

I have tried:

restarting Android Studio

Invalidate caches and restart

Clean and rebuild project

added testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"

What works is downgrading junit to 4.12. How to get rid of this lint error, without downgrading version?

Update:

When I check ALT + ENTER options and select Inspection 'Unresolved reference, in wrong test scope' options > Suppress 'IncorrectScope' for file <name of file>, it gets rid of these lint errors for that particular file. I still like to solve this problem without using Suppress though.

According to this issue, it looks like this bug is not fixed yet. For now I'm downgrading to 4.12.

Removing both espresso and runner from dependencies also fixes the problem.

Body:
Borrowing from @VaheGharibyan's idea about duplicate junit versions, I discovered that the following code also fixes the problem.

configurations.all {
        resolutionStrategy.dependencySubstitution {
            substitute module('junit:junit:4.12') with module('junit:junit:4.13')
        }
    }


问:
How to highly compress files in Google Drive?
I wanted to know if it is possible to compress files within my Google Drive. Is it possibly to highly compress the files like 7zip does?

Edit
I meant without downloading the files onto the computer and just compressing them directly in the drive itself. Is there a possible way?

答:
Yes there is,

Go to here

Tap on the arrow

Select Drive

Sign in to your google account

Select what ever you want

Then choose 7zip


问:
How to run PyCharm from Docker?
I was able to build a docker image from the path where my Dockerfile is saved that contains installation instructions for PyCharm. At building the image, I am able to view the list of images created. then i typed docker run ti -pycharm which is the name of the image i built in the terminal and I have my container running. Now I am stuck at how to load Pycharm from this container? Thanks</p>

答:
There are several issues that exist when running an IDE either inside or outside of docker.

When running PyCharm on the host with the python interpreter inside of a docker, sharing the codebase can be handled by

PyCharm's remote interpreter functionality

Over SSH: https://www.jetbrains.com/help/pycharm/configuring-remote-interpreters-via-ssh.html

Over Docker TCP port: https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html

The code resides on the host, which is necessary for PyCharm to provide static analysis. https://www.jetbrains.com/help/pycharm/code-inspection.html

Whenever you want to run the code, it needs to synced with the remote system. I'm not sure how the synchronization behaves, so I don't know if the syncing is two way, or if PyCharm on the host always overwrites the remote system (docker container) https://www.jetbrains.com/help/pycharm/configuring-synchronization-with-a-remote-host.html

Mounting a host directory inside the docker container:

Docker Desktop on Windows has a lot of limitations when mounting a Windows directory inside the docker container.

The linux container cannot change the permissions of files inside the Windows directory. The files always appear to have the permissions 755 (rwxr-xr-x). If you try to mount your openssh configs or keys inside the linux container, ssh on linux will refuse to use those files because they are insecure.
https://docs.docker.com/v17.09/docker-for-windows/troubleshoot/#permissions-errors-on-data-directories-for-shared-volumes

The linux container will not get filesystem events (inotify) letting it know that files have changed on the file mounted from Windows. If you use ./manage.py runserver to run Django in development, it would need to poll all the files in the codebase to see if there are any changes. I have not tested Django's polling. If it does not work sufficiently quickly, you may have to restart Django so that it reflects your changes.
https://william-yeh.net/post/2019/06/inotify-in-containers/

This works much better when the host is a Mac, because the osxfs mounted volumes work better with linux containers. https://docs.docker.com/docker-for-mac/osxfs/

Mounting a directory in the linux container on Windows.

SSHFS with WinFSP allows Windows to mount the files over ssh. This requires an ssh server to be installed in the linux container. An NFS or Samba server on the linux container could also be used for file sharing but with similar problems.

PyCharm on Windows does not support polling for file changes. If you mount the codebase over ssh, NFS, or SMB, PyCharm will not know if you have added a new file. This is especially an issue if you switch to a different branch for your codebase.

Currently, I'm experimenting with running PyCharm inside the linux container.

With Docker Desktop for Windows, you cannot use the JetBrains Toolbox to install PyCharm, because it is installed with an AppImage that requires support for the fuse kernel driver. It appears that docker is making advancements in this area, but my version of Windows 10 is not part of the Insider Preview, so I haven't tested these new features.
https://www.infoq.com/news/2019/12/docker-desktop-windows-fuse/

You can just install the pycharm tarball and run that. You will definitely need to increase the memory and swap in the Resources settings for Docker Desktop.

So that the linux container can display a gui application, Windows needs to run an xserver such as VcXsrv. After you start that, you can set the env var DISPLAY=localhost:0. By specifying localhost and not just DISPLAY=:0, any gui app that you run will know that it needs to connect to VcXsrv over TCP instead of looking for a unix socket that does not exist.

By running PyCharm inside of the linux container, I also don't have to think about crlf conversion settings in Git. https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings

Title: How to run PyCharm from Docker?


问:
Concept and programming for accessing XML file that uses XSL file in JSP code
I am a beginner in accessing backend XML files (which act like a database) in JSP code. Can anyone please provide me the links and references that provide good understanding for beginners like me? Please help.</p>

答:
You may want to take a look how to implement typical webapp design patterns in J2EE (see e.g. Sun's blueprint describing the webapp designs). Depending on complexity of your application, make a decision which pattern to use. You may also choose to use some of existing MVC frameworks build on J2EE (although I'd not advise that to a beginner).

Building a model classes around your XMLs would be a good start (there is a variety of ways to process XML in Java, check e.g. JAXP). Once a model is ready, you can start using it in your JSPs (implementing the view and controller per the pattern you will choose).

OwnerDisplayName: david a.

ContentLicense: CC BY-SA 2.5


问:
Using XSL to move from one node to another
So I want to convert the following using XSL

```<code><doc>
    <data id="priority" level="2" include="true">
        <name>Priority</name>
    </data>
    <data id="cost" level="1" leveltype="number">
        <name>Cost</name>
    </data>
    <data id="date" level="3" include="true">
        <name>Date</name>
    </data>
</doc>
</code>```

To this

```<code><doc>
    <data id="priority">
        <name>Priority</name>
    </data>
    <data id="cost">
        <name>Cost</name>
    </data>
    <data id="date">
        <name>Date</name>
    </data>

    <!-- ordering matters, though if necessary I can reorder this manually via the DOM instead of XSL -->
    <levels>
        <level id="cost" include="false" type="number"/>
        <level id="priority" include="true"/>
        <level id="date" include="true"/>
    </level>
</doc>
</code>```

Basically I want to take the level attributes and make them their own thing. A huge bonus would be if there were some way to remove the level number and use the order of the node instead to represent that.

答:
Just a variant:</p>

```<code><xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

<xsl:template match="doc">

 <doc>

  <!-- build and sort data nodes -->
  <xsl:for-each select="data">
   <xsl:sort select="@id"/>
    <data id="{@id}">
     <xsl:copy-of select="name"/>
    </data>
   </xsl:for-each>

   <!-- build and sort levels -->
   <levels>
    <xsl:for-each select="data">
     <xsl:sort select="@id"/>
      <level id="{@id}" include="{boolean(@include)}">
       <xsl:if test="@leveltype">
        <xsl:attribute name="type">
         <xsl:value-of select="@leveltype"/>
        </xsl:attribute>
       </xsl:if>
      </level>
    </xsl:for-each>
   </levels>

 </doc>

 </xsl:template>
</xsl:stylesheet>
</code>```

Body:
So I want to convert the following using XSL

<doc>
    <data id="priority" level="2" include="true">
        <name>Priority</name>
    </data>
    <data id="cost" level="1" leveltype="number">
        <name>Cost</name>
    </data>
    <data id="date" level="3" include="true">
        <name>Date</name>
    </data>
</doc>

To this

<doc>
    <data id="priority">
        <name>Priority</name>
    </data>
    <data id="cost">
        <name>Cost</name>
    </data>
    <data id="date">
        <name>Date</name>
    </data>

    <levels>
        <level id="cost" include="false" type="number"/>
        <level id="priority" include="true"/>
        <level id="date" include="true"/>
    </level>
</doc>

Basically I want to take the level attributes and make them their own thing. A huge bonus would be if there were some way to remove the level number and use the order of the node instead to represent that.

Body:
Just a variant:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

<xsl:template match="doc">

 <doc>

  <!-- build and sort data nodes -->
  <xsl:for-each select="data">
   <xsl:sort select="@id"/>
    <data id="{@id}">
     <xsl:copy-of select="name"/>
    </data>
   </xsl:for-each>

   <!-- build and sort levels -->
   <levels>
    <xsl:for-each select="data">
     <xsl:sort select="@id"/>
      <level id="{@id}" include="{boolean(@include)}">
       <xsl:if test="@leveltype">
        <xsl:attribute name="type">
         <xsl:value-of select="@leveltype"/>
        </xsl:attribute>
       </xsl:if>
      </level>
    </xsl:for-each>
   </levels>

 </doc>

 </xsl:template>
</xsl:stylesheet>


问:
How to find the version of a Crystal Report rpt file?
I have a Crystal Report file from an old version (unfortunately I don't know and cannot find out easily which version was used) and I need to do changes in that RPT file. I would like to find out which version is the RPT file so I can install the proper version of the editor.

If I install the all new and latest version, when I save the RPT file it tells me that the original file was from an old version (does not specify which) and that the save will upgrade it to the latest format, thus previous version of the application will not be able to use it. Not much help there.

I also checked all around Crystal Report to find a "Properties" or "Information" window, without success.

Is there a way to know which version a RPT file belongs to?

答:
Here is a picture of the information by going to Report / Performance Information / Report Definition

This shows it is version 10.2


问:
Git wrongly mark a file as deleted instead of rewritten
I'm doing several refactors on a project. So sometimes I need to rename the file extension, for example index.js -> index.ts, and change many lines on this file.

Because that git wrongly mark index.js as deleted and index.ts as a new file, that could be bad on code review and logs.

Is there some way to explicitly say to git "hey, I renamed index.js to index.ts"?

Edit

The approach using git add / git rm / git mv didn't work, because git still say that I created a new file and removed other.

Also I should not use two commits to that (one for rename and one for update its content), because the first commit will be broken, since the build steps for a .js file is different than a .ts file

答:
No, there is no way in git to explicitly mark a file as moved.

git mv ... will do the same as git rm ...; git add ....

Git will automatically detect a remove and add in the same commit if the changes to the file are not too great. You can specify a "similarity index" with the -M option to certain commands git log. Setting this lower, e.g. -M30% means that only 30% of the lines in the old and new files have to match for the file to be considered a rename.

This is just one of the features of git to get used to. See:

How to make git mark a deleted and a new file as a file move?

How to REALLY show logs of renamed files with git?
etc.


问:
expression() command in R with semicolons
In the output of the following code,

```<code>curve((1+exp(-1*x))^-1,
    xlim=c(-10,10),ylim=c(0,1),
    main="Logistic function",xlab=expression ("x"[t-d]),
    ylab=expression ("G"("x"[t-d],gamma,c)))
</code>```

In the y-axis label, how to place a semi-colon in between immediately before the gamma instead of a comma?

答:
In this case you just need to think of the semicolon as text rather than a special character you can do

```<code>ylab=expression ("G"("x"[t-d]~";"~gamma,c))
</code>```

or you can use * rather than ~ if you want less space.

Body:
In the output of the following code,

curve((1+exp(-1*x))^-1,
    xlim=c(-10,10),ylim=c(0,1),
    main="Logistic function",xlab=expression ("x"[t-d]),
    ylab=expression ("G"("x"[t-d],gamma,c)))

In the y-axis label, how to place a semi-colon in between immediately before the gamma instead of a comma?

Body:
In this case you just need to think of the semicolon as text rather than a special character you can do

ylab=expression ("G"("x"[t-d]~";"~gamma,c))

or you can use * rather than ~ if you want less space.


问:
Using Google Sheets script editor to access the Kraken API
I can't figure out where the Kraken API inputs go. I am using  https://api.kraken.com/0/private/AddOrder as a starting point. The inputs include things like: pair = XBTUSD, type = buy, ordertype = limit etc. I'm an API noob and I realise this isn't a typical approach but I would greatly appreciate any guidance.

I've successfully used the API for other things like retrieving account balances. Just not sure where inputs fit in. I couldn't figure it out from the documentation here https://www.kraken.com/help/api. I would like to use a specific buy order as a learning example. ie buy 0.003 BTC, pair XBTUSD, limit 5000 USD...

The relevant piece of code-

```<code>function buyKraken () {

  var path = "/0/private/AddOrder";
  var nonce = new Date () * 1000;
  var postdata = "nonce=" + nonce;
  var signature = getKrakenSignature (path, postdata, nonce);
  var url = 'https://api.kraken.com' + path;

var options = {
    method: 'post',
    headers: {
      'API-Key': "###########",
      'API-Sign': signature
    },
    payload: postdata
  };
  var response = UrlFetchApp.fetch (url, options);
  Logger.log(response);
  ;
}
</code>```

答:
To the new people that may come search for an answer I used a small different function:

```<code>    function getKrakenSignature (path, postdata, krakenSecretKey, nonce) {
        var sha256obj = new jsSHA ("SHA-256", "BYTES");
        sha256obj.update (nonce + postdata);
        var hash_digest = sha256obj.getHash ("BYTES");

        var sha512obj = new jsSHA ("SHA-512", "BYTES");
        sha512obj.setHMACKey (krakenSecretKey, "B64");
        sha512obj.update (path);
        sha512obj.update (hash_digest);
        return sha512obj.getHMAC ("B64");
     }
</code>```

I used the jsSHA function from this repository: https://github.com/Caligatio/jsSHA
 You just have to create a new file in the Google Scripts, and copy/paste the raw of this file:
https://raw.githubusercontent.com/Caligatio/jsSHA/master/src/sha.js

Body:
I can't figure out where the Kraken API inputs go. I am using  https://api.kraken.com/0/private/AddOrder as a starting point. The inputs include things like: pair = XBTUSD, type = buy, ordertype = limit etc. I'm an API noob and I realise this isn't a typical approach but I would greatly appreciate any guidance.

I've successfully used the API for other things like retrieving account balances. Just not sure where inputs fit in. I couldn't figure it out from the documentation here https://www.kraken.com/help/api. I would like to use a specific buy order as a learning example. ie buy 0.003 BTC, pair XBTUSD, limit 5000 USD...

The relevant piece of code-

function buyKraken () {

  var path = "/0/private/AddOrder";
  var nonce = new Date () * 1000;
  var postdata = "nonce=" + nonce;
  var signature = getKrakenSignature (path, postdata, nonce);
  var url = 'https://api.kraken.com' + path;

var options = {
    method: 'post',
    headers: {
      'API-Key': "###########",
      'API-Sign': signature
    },
    payload: postdata
  };
  var response = UrlFetchApp.fetch (url, options);
  Logger.log(response);
  ;
}

Body:
To the new people that may come search for an answer I used a small different function:

    function getKrakenSignature (path, postdata, krakenSecretKey, nonce) {
        var sha256obj = new jsSHA ("SHA-256", "BYTES");
        sha256obj.update (nonce + postdata);
        var hash_digest = sha256obj.getHash ("BYTES");

        var sha512obj = new jsSHA ("SHA-512", "BYTES");
        sha512obj.setHMACKey (krakenSecretKey, "B64");
        sha512obj.update (path);
        sha512obj.update (hash_digest);
        return sha512obj.getHMAC ("B64");
     }

I used the jsSHA function from this repository: https://github.com/Caligatio/jsSHA
 You just have to create a new file in the Google Scripts, and copy/paste the raw of this file:
https://raw.githubusercontent.com/Caligatio/jsSHA/master/src/sha.js


问:
Kubernetes cannot pull image from private docker image repository
I have problem with kubernetes (minikube) and pull images from local image repository on docker.
Docker repository was created:

```<code>docker run --entrypoint htpasswd registry:2 -Bbn zordon examplePassword > /mnt/LINUX/auth/htpasswd

docker run -d \
  -p 5000:5000 \
  --restart=always \
  --name registry \
  -v /mnt/LINUX/dockerreg:/var/lib/registry \
  -v /mnt/LINUX/auth:/auth \
  -e "REGISTRY_AUTH=htpasswd" \
  -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
  -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
  registry:2
</code>```

Then I want to create simple pod with image which was succesfully uploaded to local repository:

```<code>curl localhost:5000/v2/_catalog
{"repositories":["car/configuration"]}
</code>```

I have also create secret on minikube cluster with:

```<code>kubectl create secret docker-registry docregkey --docker-server=localhost:5000 --docker-username=zordon --docker-password=examplePassword --docker-email=test@dock.mail
</code>```

and define simple Pod:

```<code>    apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: car/configuration:latest
    imagePullPolicy: Always
  restartPolicy: Always
  imagePullSecrets:
  - name: docregkey
</code>```

unfortunatelly I getting still:

Failed to pull image "car/configuration:latest": rpc error: code =
  Unknown desc = Error response from daemon: pull access denied for
  car/configuration, repository does not exist or may require 'docker
  login'

How i can fix this problem ?

答:
For minikube to pull from your own local docker registry, the tag affects the pull policy. Per Images docs, pull policy is IfNotPresent by default EXCEPT if

you use :latest as the tag for the image to use

OR you omit the tag for the image to use.

In those cases the pull policy will effectively default to Always, which will attempt to pull from docker hub. This will cause minikube to be unable to fetch local images that have no tag or "latest" tag.

Moral of the story is, don't rely on the default because it is too confusing :)

So always explicitly state the pull policy:

when deploying into minikube the pull policy should be
IfNotPresent or Never for the local images

when deploying into a cloud host (like AWS), pull policy should be as for public images (see below)

the pull policy should be Always for those public images that use a tag like "latest" or "stable" (because the image the tag
points will change over time), and IfNotPresent for tags that
always point to the same image (to avoid fetching more than
necessary)

This means that if you avoid using tags like latest and stable etc, there is only one rule to follow:

explicitly set the imagePullPolicy in your spec (or on the command line in the case of run) to IfNotPresent, as this is will always look for it locally first, and go to public registry if it is not found locally, and this will work whether or not you are deploying into minikube or cloud.

Body:
I have problem with kubernetes (minikube) and pull images from local image repository on docker.
Docker repository was created:

docker run --entrypoint htpasswd registry:2 -Bbn zordon examplePassword > /mnt/LINUX/auth/htpasswd

docker run -d \
  -p 5000:5000 \
  --restart=always \
  --name registry \
  -v /mnt/LINUX/dockerreg:/var/lib/registry \
  -v /mnt/LINUX/auth:/auth \
  -e "REGISTRY_AUTH=htpasswd" \
  -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
  -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
  registry:2

Then I want to create simple pod with image which was succesfully uploaded to local repository:

curl localhost:5000/v2/_catalog
{"repositories":["car/configuration"]}

I have also create secret on minikube cluster with:

kubectl create secret docker-registry docregkey --docker-server=localhost:5000 --docker-username=zordon --docker-password=examplePassword --docker-email=test@dock.mail

and define simple Pod:

    apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: car/configuration:latest
    imagePullPolicy: Always
  restartPolicy: Always
  imagePullSecrets:
  - name: docregkey

unfortunatelly I getting still:

Failed to pull image "car/configuration:latest": rpc error: code =
  Unknown desc = Error response from daemon: pull access denied for
  car/configuration, repository does not exist or may require 'docker
  login'

How i can fix this problem ?


问:
Factory overriding parameterized class in UVM
I have a parameterized seq_item as below

```<code>class seq_item#(int A = 64) extends uvm_sequence_item;
  `uvm_object_param_utils(seq_item#(A))
  rand logic [A-1:0] v;
  constraint v_c {
    v inside {[0:1000]};
  }
endclass : seq_item

class extended_seq_item#(int A = 64) extends seq_item#(A);
  `uvm_object_param_utils(extended_seq_item#(A))
  constraint extended_v_c {
    v inside {[10:50]};
  }
endclass : extended_seq_item

class reg_adapter#(int A = 100) extends uvm_reg_adapter;
  `uvm_object_param_utils(reg_adapter#(A))
  typedef seq_item#(A) seq_item_t;
  function new(string name = "reg_adapter")
    seq_item_t req;
    req = seq_item_t::type_id::create("req");
  endfunction
endclass : reg_adapter

class test extends uvm_test;
  `uvm_component_utils(test)
  reg_adapter#(10) adapter;
  function void build_phase(uvm_phase phase);
    seq_item#(10)::type_id::set_type_override(extended_seq_item#(10)::get_type());
    super.build_phase(phase);
    adapter = reg_adapter::type_id::create("adapter");
  endfunction : build_phase
endclass : test
</code>```

In my UVM TB, I need to factory override all seq_item instances with extended_seq_item. Different instances will have different parameter values of A. How do I factory override this?

The problem is seq_item is from common collateral which has generic constraint for rand variable v which holds good for all IPs. For my IP, I need to add an additional constraint for v as given in extended_seq_item. My IP nuses reg_adapter which is expected to take extended_seq_item with additional constraints added

Thanks & Regards,
Kiran

答:
Unfortunately, parameterized classes with different parameter values (specializations is the LRM's terminology) are treated as separate class types, so you'll need to provide an override for each parameter value.

```<code>seq_item#(10)::type_id::set_type_override(extended_seq_item#(10)::get_type());
seq_item#(20)::type_id::set_type_override(extended_seq_item#(20)::get_type());
seq_item#(30)::type_id::set_type_override(extended_seq_item#(30)::get_type());
</code>```

If you can get this code into a place where A is already parametrized, like in a the build_phase of a parameterized env or agent, then it might not be as painful as the above.

Now that I see more code, the problem is the class scope in this line, which should have been caught as an error

```<code>adapter = reg_adapter::type_id::create("adapter");
</code>```

should be written as

```<code>adapter = reg_adapter#(10)::type_id::create("adapter");
</code>```

Body:
I have a parameterized seq_item as below

class seq_item#(int A = 64) extends uvm_sequence_item;
  `uvm_object_param_utils(seq_item#(A))
  rand logic [A-1:0] v;
  constraint v_c {
    v inside {[0:1000]};
  }
endclass : seq_item

class extended_seq_item#(int A = 64) extends seq_item#(A);
  `uvm_object_param_utils(extended_seq_item#(A))
  constraint extended_v_c {
    v inside {[10:50]};
  }
endclass : extended_seq_item

class reg_adapter#(int A = 100) extends uvm_reg_adapter;
  `uvm_object_param_utils(reg_adapter#(A))
  typedef seq_item#(A) seq_item_t;
  function new(string name = "reg_adapter")
    seq_item_t req;
    req = seq_item_t::type_id::create("req");
  endfunction
endclass : reg_adapter

class test extends uvm_test;
  `uvm_component_utils(test)
  reg_adapter#(10) adapter;
  function void build_phase(uvm_phase phase);
    seq_item#(10)::type_id::set_type_override(extended_seq_item#(10)::get_type());
    super.build_phase(phase);
    adapter = reg_adapter::type_id::create("adapter");
  endfunction : build_phase
endclass : test

In my UVM TB, I need to factory override all seq_item instances with extended_seq_item. Different instances will have different parameter values of A. How do I factory override this?

The problem is seq_item is from common collateral which has generic constraint for rand variable v which holds good for all IPs. For my IP, I need to add an additional constraint for v as given in extended_seq_item. My IP nuses reg_adapter which is expected to take extended_seq_item with additional constraints added

Thanks & Regards,
Kiran

Body:
Unfortunately, parameterized classes with different parameter values (specializations is the LRM's terminology) are treated as separate class types, so you'll need to provide an override for each parameter value.

seq_item#(10)::type_id::set_type_override(extended_seq_item#(10)::get_type());
seq_item#(20)::type_id::set_type_override(extended_seq_item#(20)::get_type());
seq_item#(30)::type_id::set_type_override(extended_seq_item#(30)::get_type());

If you can get this code into a place where A is already parametrized, like in a the build_phase of a parameterized env or agent, then it might not be as painful as the above.

Now that I see more code, the problem is the class scope in this line, which should have been caught as an error

adapter = reg_adapter::type_id::create("adapter");

should be written as

adapter = reg_adapter#(10)::type_id::create("adapter");