Gary Wu | d04e440 | 2017-07-28 12:26:54 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2016-2017 Huawei Technologies Co., Ltd. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | import sys, csv, subprocess |
| 18 | |
| 19 | root = subprocess.check_output(["git", "rev-parse", "--show-toplevel"]).rstrip() |
| 20 | path = "{}/autorelease/dist".format(root) |
| 21 | version = "1.1.0-SNAPSHOT" |
| 22 | url_template = "https://nexus.open-o.org/service/local/artifact/maven/redirect?r=snapshots&g={0}&a={1}&e={2}&c={3}&v=LATEST" |
| 23 | |
| 24 | subprocess.call(["rm", "-rf", path]) |
| 25 | subprocess.call(["mkdir", "-p", path]) |
| 26 | |
| 27 | |
| 28 | def parseRow(row): |
| 29 | service = row["service"] |
| 30 | filename = row["filename"] |
| 31 | groupId = row["groupId"] |
| 32 | artifactId = row["artifactId"] |
| 33 | extension = row["extension"] |
| 34 | classifier = row["classifier"] |
| 35 | url = url_template.format(groupId, artifactId, extension, classifier) |
| 36 | if classifier: |
| 37 | dest = "{}/{}-{}.{}.{}".format(path, filename, version, classifier, extension) |
| 38 | else: |
| 39 | dest = "{}/{}-{}.{}".format(path, filename, version, extension) |
| 40 | return {"url": url, "dest": dest} |
| 41 | |
| 42 | |
| 43 | with open( "{}/autorelease/binaries.csv".format(root), "r" ) as f: |
| 44 | reader = csv.DictReader(f) |
| 45 | errors = 0 |
| 46 | |
| 47 | items = [] |
| 48 | for row in reader: |
| 49 | item = parseRow(row) |
| 50 | items.append(item) |
| 51 | |
| 52 | result = subprocess.call(["wget", "-q", "--spider", "--content-disposition", item["url"]]) |
| 53 | if result == 0: |
| 54 | print "{} OK".format(row["service"]) |
| 55 | else: |
| 56 | errors += 1 |
| 57 | print "{} ERROR: {} not found".format(row["service"], item["url"]) |
| 58 | |
| 59 | print "{} errors found".format(errors) |
| 60 | |
| 61 | if errors > 0: |
| 62 | sys.exit(1) |