20
20
# p-confluent-kafka-python__bld-travis__plat-linux__tag-__sha-112130ce297656ea1c39e7c94c99286f95133a24__bid-271588764__/confluent_kafka-0.11.0-cp35-cp35m-manylinux1_x86_64.whl
21
21
22
22
23
- import sys
24
23
import re
25
24
import os
26
25
import argparse
31
30
dry_run = False
32
31
33
32
34
-
35
33
class Artifact (object ):
36
- def __init__ (self , arts , path , info = None ):
34
+ def __init__ (self , arts , path , info = None ):
37
35
self .path = path
38
36
# Remove unexpanded AppVeyor $(..) tokens from filename
39
37
self .fname = re .sub (r'\$\([^\)]+\)' , '' , os .path .basename (path ))
@@ -42,13 +40,12 @@ def __init__ (self, arts, path, info=None):
42
40
self .arts = arts
43
41
arts .artifacts .append (self )
44
42
45
- def __repr__ (self ):
43
+ def __repr__ (self ):
46
44
return self .path
47
45
48
- def download (self , dirpath ):
46
+ def download (self , dirpath ):
49
47
""" Download artifact from S3 and store in dirpath directory.
50
48
If the artifact is already downloaded nothing is done. """
51
- dest = self .lpath
52
49
if os .path .isfile (self .lpath ) and os .path .getsize (self .lpath ) > 0 :
53
50
return
54
51
print ('Downloading %s -> %s' % (self .path , self .lpath ))
@@ -58,49 +55,17 @@ def download (self, dirpath):
58
55
59
56
60
57
class Artifacts (object ):
61
- def __init__ (self , gitref , dlpath ):
58
+ def __init__ (self , gitref , dlpath ):
62
59
super (Artifacts , self ).__init__ ()
63
60
self .gitref = gitref
64
61
self .artifacts = list ()
65
62
# Download directory
66
63
self .dlpath = dlpath
67
64
if not os .path .isdir (self .dlpath ):
68
65
if not dry_run :
69
- os .makedirs (self .dlpath , 0755 )
70
-
71
- def collect_single (self , path , folder ):
72
- """ Collect single entry
73
- :param: path string: S3 or local path to file
74
- :param: folder string: S3 folder name
75
- """
76
- folder = os .path .dirname (key .key )
77
-
78
- rinfo = re .findall (r'(?P<tag>[^-]+)-(?P<val>.*?)__' , folder )
79
- if rinfo is None or len (rinfo ) == 0 :
80
- # print('Incorrect folder/file name format for %s' % folder)
81
- return None
82
-
83
- info = dict (rinfo )
84
-
85
- # Ignore AppVeyor Debug builds
86
- if info .get ('bldtype' , '' ).lower () == 'debug' :
87
- print ('Ignoring debug artifact %s' % folder )
88
- return None
66
+ os .makedirs (self .dlpath , 0o755 )
89
67
90
- tag = info .get ('tag' , None )
91
- if tag is not None and (len (tag ) == 0 or tag .startswith ('$(' )):
92
- # AppVeyor doesn't substite $(APPVEYOR_REPO_TAG_NAME)
93
- # with an empty value when not set, it leaves that token
94
- # in the string - so translate that to no tag.
95
- tag = None
96
-
97
- sha = info .get ('sha' , None )
98
- if (tag is not None and tag == self .gitref ) or (sha is not None and sha .startswith (self .gitref )):
99
- return Artifact (self , path , info , lpath = lpath )
100
-
101
- return None
102
-
103
- def collect_single_s3 (self , path ):
68
+ def collect_single_s3 (self , path ):
104
69
""" Collect single S3 artifact
105
70
:param: path string: S3 path
106
71
"""
@@ -136,8 +101,7 @@ def collect_single_s3 (self, path):
136
101
137
102
return None
138
103
139
-
140
- def collect_s3 (self ):
104
+ def collect_s3 (self ):
141
105
""" Collect and download build-artifacts from S3 based on git reference """
142
106
print ('Collecting artifacts matching tag/sha %s from S3 bucket %s' % (self .gitref , s3_bucket ))
143
107
self .s3 = boto3 .resource ('s3' )
@@ -149,7 +113,7 @@ def collect_s3 (self):
149
113
for a in self .artifacts :
150
114
a .download (self .dlpath )
151
115
152
- def collect_local (self , path ):
116
+ def collect_local (self , path ):
153
117
""" Collect artifacts from a local directory possibly previously
154
118
collected from s3 """
155
119
for f in os .listdir (path ):
@@ -159,12 +123,13 @@ def collect_local (self, path):
159
123
Artifact (self , lpath )
160
124
161
125
162
-
163
126
if __name__ == '__main__' :
164
127
165
128
parser = argparse .ArgumentParser ()
166
129
parser .add_argument ("--no-s3" , help = "Don't collect from S3" , action = "store_true" )
167
- parser .add_argument ("--dry-run" , help = "Locate artifacts but don't actually download or do anything" , action = "store_true" )
130
+ parser .add_argument ("--dry-run" ,
131
+ help = "Locate artifacts but don't actually download or do anything" ,
132
+ action = "store_true" )
168
133
parser .add_argument ("--directory" , help = "Download directory (default: dl-<gitref>)" , default = None )
169
134
parser .add_argument ("tag" , help = "Tag or git SHA to collect" )
170
135
0 commit comments