Python3--Read Nexus Warehouse Jar tool __python

Source: Internet
Author: User

Avoid the convenience of downloading jar files every time, through Python, request crawl target URL, mosaic download address. Implement a shortcut positioning operation.

Import requests Import json _dx_name = ' _download_top_url = ' http://nexus.td.internal/nexus/repository/' _download_gro up = ' maven-snapshots/' _suffix = '. jar ' _projectlist = [' Dx-web ', ' dx-aps ', ' dx-autotask ', ' dx-dm ', ' dx-mt ', ' dx-agent '  ] def requestnexus (): global R param1 = {"Action": "Coreui_search", "method": "read", "data": [{Page]: 1, "Start": 0, "limit": +, "sort": [{"Property": "Name", "direction": "ASC"}], "filter": [{' Property ': ' Format "," value ":" Maven2 "}, {" Property ":" Attributes.maven2.artifactId "," Value ": _dx_name}]}," type ":" RP C "," Tid ": 13} # company internal address URL = ' Http://192.168.15.188:28081/nexus/service/extdirect ' r = Requests.post (URL, jso

    N=PARAM1) return R def Tranresult (r): print (r) result = Json.loads (r) data = result[' result ' [' data '] If Len (data) = = 0:print (' not match to content ... ') return rs_list = [] for d in data:path1 = d[' group '].replace ('. ', '/') + '/' path2 = _dx_name + '/' Path3 = (d[' version '].split ('-')) [0] + '-snapshot/' Path4 = _dx_name + '-' + d[' version '] global _download_group if d[' repositoryname '] = = ' Maven-snapshots ': _down Load_group = ' maven-snapshots/' elif d[' repositoryname '] = = ' maven-releases ': _download_group = ' maven -releases/' path3 = d[' version ' + '/' setsuffix () Download_url = _download_top_url + _downl
        Oad_group + path1 + path2 + path3 + path4 + _suffix rs = d[' name '] + '-' + d[' version ' + ': ' + download_url # print (rs) map = {' name ': d[' name '] + '-' + d[' version ', ' Value ': Download_url} rs_list.append (ma P) return rs_list def setsuffix (): If _projectlist.__contains__ (_dx_name): Global _suffix _suff IX = '. War ' def GETURL (value): Global _dx_name _dx_name = value r = Requestnexus () rs = R.text retur N Tranresult (RS) if __name__ = = "__main__": _dx_name = input (' Please enter jar name: ') R = Requestnexus () rs = R.text _list = Tranresult (rs
 For _map in _list:print (_map[' name '] + ': ' + _map[' value ')

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.