Brian O'Connor | 0fed575 | 2015-05-04 18:15:29 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Uploads ONOS distributable bits. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | #FIXME need to export s3Creds |
| 7 | |
| 8 | import re |
| 9 | from os import listdir |
| 10 | from os.path import isfile, join |
| 11 | |
| 12 | from uploadToS3 import uploadFile |
| 13 | |
| 14 | nightlyTag = 'NIGHTLY' |
| 15 | bitsPath = '/tmp' |
| 16 | |
| 17 | prefix = 'onos-(\d+\.\d+\.\d+)' |
| 18 | buildNum = '\.?([\w-]*)' |
| 19 | ext = '\.(?:tar\.gz|zip)' |
| 20 | |
| 21 | def findBits( path ): |
| 22 | for file in listdir( path ): |
| 23 | filePath = join( path, file ) |
| 24 | if not isfile( filePath ): |
| 25 | continue |
| 26 | |
| 27 | regex = prefix + buildNum + ext |
| 28 | match = re.match( regex, file ) |
| 29 | if match: |
| 30 | version = match.group(1) |
| 31 | build = match.group(2) |
| 32 | if build: |
| 33 | if 'NIGHTLY' in build: |
| 34 | uploadFile(filePath, dest='nightly/') |
| 35 | else: |
| 36 | #no build; this is a release |
| 37 | uploadFile(filePath, dest='release/') |
| 38 | |
| 39 | if __name__ == '__main__': |
| 40 | findBits( '/tmp' ) |