6
6
import requests
7
7
import argparse
8
8
from time import sleep
9
- from json import loads , dumps
10
- import xml .etree .cElementTree as etree
9
+ from json import loads
11
10
12
11
try :
13
12
from urllib .parse import urlencode
34
33
35
34
COLOR = True
36
35
37
- remove_ascii = re .compile (r'[^\x00-\x7F]' ).sub
38
-
39
36
remove_token = re .compile (r'token=[^\&]+' ).sub
40
37
41
38
ignored_path = re .compile (r'(/vendor)|'
@@ -167,6 +164,13 @@ def try_to_run(cmd):
167
164
write (' Error running `%s`: %s' % (cmd , str (getattr (e , 'output' , str (e )))))
168
165
169
166
167
+ def remove_non_ascii (data ):
168
+ try :
169
+ return data .decode ('utf8' )
170
+ except :
171
+ return '' .join ([i if ord (i ) < 128 else '' for i in data ])
172
+
173
+
170
174
def main (* argv , ** kwargs ):
171
175
root = os .getcwd ()
172
176
@@ -250,7 +254,7 @@ def main(*argv, **kwargs):
250
254
# ---------
251
255
# Travis CI
252
256
# ---------
253
- elif os .getenv ('CI' ) == " true" and os .getenv ('TRAVIS' ) == "true" :
257
+ elif os .getenv ('CI' ) == ' true' and os .getenv ('TRAVIS' ) == "true" :
254
258
# http://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
255
259
query .update (dict (branch = os .getenv ('TRAVIS_BRANCH' ),
256
260
service = 'travis' ,
@@ -275,7 +279,7 @@ def main(*argv, **kwargs):
275
279
# --------
276
280
# Codeship
277
281
# --------
278
- elif os .getenv ('CI' ) == " true" and os .getenv ('CI_NAME' ) == 'codeship' :
282
+ elif os .getenv ('CI' ) == ' true' and os .getenv ('CI_NAME' ) == 'codeship' :
279
283
# https://www.codeship.io/documentation/continuous-integration/set-environment-variables/
280
284
query .update (dict (branch = os .getenv ('CI_BRANCH' ),
281
285
service = 'codeship' ,
@@ -287,8 +291,8 @@ def main(*argv, **kwargs):
287
291
# ---------
288
292
# Buildkite
289
293
# ---------
290
- elif os .getenv ('CI' ) == " true" and os .getenv ('BUILDKITE' ) == 'true' :
291
- # https://buildkite.com/docs/guides/environment-variables
294
+ elif os .getenv ('CI' ) == ' true' and os .getenv ('BUILDKITE' ) == 'true' :
295
+ # https://buildkite.com/docs/guides/environment-variables
292
296
query .update (dict (branch = os .getenv ('BUILDKITE_BRANCH' ),
293
297
service = 'buildkite' ,
294
298
build = os .getenv ('BUILDKITE_BUILD_NUMBER' ) + '.' + os .getenv ('BUILDKITE_JOB_ID' ),
@@ -300,7 +304,7 @@ def main(*argv, **kwargs):
300
304
# ---------
301
305
# Circle CI
302
306
# ---------
303
- elif os .getenv ('CI' ) == " true" and os .getenv ('CIRCLECI' ) == 'true' :
307
+ elif os .getenv ('CI' ) == ' true' and os .getenv ('CIRCLECI' ) == 'true' :
304
308
# https://circleci.com/docs/environment-variables
305
309
query .update (dict (branch = os .getenv ('CIRCLE_BRANCH' ),
306
310
service = 'circleci' ,
@@ -314,7 +318,7 @@ def main(*argv, **kwargs):
314
318
# ---------
315
319
# Semaphore
316
320
# ---------
317
- elif os .getenv ('CI' ) == " true" and os .getenv ('SEMAPHORE' ) == " true" :
321
+ elif os .getenv ('CI' ) == ' true' and os .getenv ('SEMAPHORE' ) == ' true' :
318
322
# https://semaphoreapp.com/docs/available-environment-variables.html
319
323
query .update (dict (branch = os .getenv ('BRANCH_NAME' ),
320
324
service = 'semaphore' ,
@@ -581,10 +585,9 @@ def main(*argv, **kwargs):
581
585
'''$(find . -type f -name '*.php' -exec grep -nIH '^[[:space:]]*{' {} \;)\n '''
582
586
'''"''' )
583
587
write (" --> Found %s adjustments" % (adjustments .count ('\n ' ) - adjustments .count ('\n \n ' ) - 1 ))
588
+ reports = remove_non_ascii (reports )
584
589
reports = str (reports ) + '\n # path=fixes\n ' + str (adjustments ) + '<<<<<< EOF'
585
590
586
- reports = remove_ascii ('' , reports )
587
-
588
591
result = ''
589
592
if codecov .dump :
590
593
write ('-------------------- Debug --------------------' )
0 commit comments