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 | |
Thomas Vachuska | be1a196 | 2016-10-25 16:59:29 -0700 | [diff] [blame] | 17 | prefix = 'onos-(?:test-)?(\d+\.\d+\.\d+)' |
Brian O'Connor | 0fed575 | 2015-05-04 18:15:29 -0700 | [diff] [blame] | 18 | buildNum = '\.?([\w-]*)' |
Brian O'Connor | 71e147e | 2015-09-18 15:18:14 -0700 | [diff] [blame] | 19 | ext = '\.(?:tar\.gz|zip|deb|noarch\.rpm)' |
Brian O'Connor | 0fed575 | 2015-05-04 18:15:29 -0700 | [diff] [blame] | 20 | |
Thomas Vachuska | be1a196 | 2016-10-25 16:59:29 -0700 | [diff] [blame] | 21 | def findBits( path, target_version=None ): |
Brian O'Connor | 0fed575 | 2015-05-04 18:15:29 -0700 | [diff] [blame] | 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) |
Thomas Vachuska | be1a196 | 2016-10-25 16:59:29 -0700 | [diff] [blame] | 31 | if target_version is not None and version != target_version: |
| 32 | print 'Skipping %s...' % filePath |
| 33 | continue |
Brian O'Connor | 0fed575 | 2015-05-04 18:15:29 -0700 | [diff] [blame] | 34 | build = match.group(2) |
| 35 | if build: |
Brian O'Connor | 30a412d | 2015-05-21 18:04:26 -0700 | [diff] [blame] | 36 | if 'NIGHTLY' in build or 'rc' in build: |
Brian O'Connor | 0fed575 | 2015-05-04 18:15:29 -0700 | [diff] [blame] | 37 | uploadFile(filePath, dest='nightly/') |
| 38 | else: |
| 39 | #no build; this is a release |
| 40 | uploadFile(filePath, dest='release/') |
| 41 | |
| 42 | if __name__ == '__main__': |
Thomas Vachuska | be1a196 | 2016-10-25 16:59:29 -0700 | [diff] [blame] | 43 | import sys |
| 44 | |
| 45 | version = sys.argv[1] if len(sys.argv) >= 2 else None |
| 46 | findBits( '/tmp', version ) |