forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildbot-0.9.3-json-import.patch
1000 lines (848 loc) · 31.3 KB
/
buildbot-0.9.3-json-import.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
From 9e7a734c260b4f473eee11ff7a08b5064ff34e22 Mon Sep 17 00:00:00 2001
From: Tom Prince <[email protected]>
Date: Thu, 12 Jan 2017 11:54:19 -0700
Subject: [PATCH] Import `json` directly.
Emit deprecation warning.
Update documentation.
Fix tests.
Lint fix.
---
master/buildbot/changes/bitbucket.py | 3 +-
master/buildbot/changes/gerritchangesource.py | 2 +-
master/buildbot/clients/tryclient.py | 3 +-
master/buildbot/data/types.py | 2 +-
master/buildbot/db/builds.py | 4 ++-
master/buildbot/db/buildsets.py | 3 +-
master/buildbot/db/changes.py | 3 +-
master/buildbot/db/state.py | 4 ++-
master/buildbot/db/steps.py | 4 ++-
master/buildbot/db/types/json.py | 7 +++--
master/buildbot/newsfragments/json.removal | 1 +
master/buildbot/process/properties.py | 2 +-
master/buildbot/schedulers/trysched.py | 3 +-
master/buildbot/scripts/dataspec.py | 3 +-
master/buildbot/scripts/processwwwindex.py | 2 +-
master/buildbot/steps/transfer.py | 3 +-
master/buildbot/test/fake/fakedata.py | 3 +-
master/buildbot/test/fake/fakedb.py | 2 +-
master/buildbot/test/integration/test_www.py | 4 ++-
.../test/unit/test_changes_gerritchangesource.py | 2 +-
.../buildbot/test/unit/test_clients_tryclient.py | 4 ++-
master/buildbot/test/unit/test_db_buildsets.py | 3 +-
master/buildbot/test/unit/test_mq_wamp.py | 3 +-
.../test/unit/test_schedulers_forcesched.py | 3 +-
.../buildbot/test/unit/test_schedulers_trysched.py | 3 +-
.../test/unit/test_scripts_processwwwindex.py | 3 +-
master/buildbot/test/unit/test_steps_transfer.py | 3 +-
master/buildbot/test/unit/test_www_oauth.py | 4 +--
master/buildbot/test/unit/test_www_rest.py | 2 +-
master/buildbot/test/unit/test_www_sse.py | 2 +-
master/buildbot/test/unit/test_www_ws.py | 4 ++-
master/buildbot/test/util/validation.py | 2 +-
master/buildbot/test/util/www.py | 2 +-
master/buildbot/util/__init__.py | 32 ++++++++--------------
master/buildbot/worker/docker.py | 2 +-
master/buildbot/www/config.py | 3 +-
master/buildbot/www/hooks/base.py | 3 +-
master/buildbot/www/hooks/gitlab.py | 4 +--
master/buildbot/www/hooks/googlecode.py | 4 +--
master/buildbot/www/oauth2.py | 2 +-
master/buildbot/www/rest.py | 2 +-
master/buildbot/www/sse.py | 3 +-
master/buildbot/www/ws.py | 3 +-
master/docs/developer/utils.rst | 12 --------
44 files changed, 91 insertions(+), 77 deletions(-)
create mode 100644 master/buildbot/newsfragments/json.removal
diff --git a/master/buildbot/changes/bitbucket.py b/master/buildbot/changes/bitbucket.py
index 746d85398..3d5b57380 100644
--- a/master/buildbot/changes/bitbucket.py
+++ b/master/buildbot/changes/bitbucket.py
@@ -12,6 +12,8 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
import time
from datetime import datetime
@@ -25,7 +27,6 @@ from buildbot.util import ascii2unicode
from buildbot.util import datetime2epoch
from buildbot.util import deferredLocked
from buildbot.util import epoch2datetime
-from buildbot.util import json
class BitbucketPullrequestPoller(base.PollingChangeSource):
diff --git a/master/buildbot/changes/gerritchangesource.py b/master/buildbot/changes/gerritchangesource.py
index 036071bbf..5e1dd0e58 100644
--- a/master/buildbot/changes/gerritchangesource.py
+++ b/master/buildbot/changes/gerritchangesource.py
@@ -15,6 +15,7 @@
from future.utils import iteritems
import datetime
+import json
from twisted.internet import defer
from twisted.internet import reactor
@@ -26,7 +27,6 @@ from buildbot import util
from buildbot.changes import base
from buildbot.changes.filter import ChangeFilter
from buildbot.util import httpclientservice
-from buildbot.util import json
class GerritChangeFilter(ChangeFilter):
diff --git a/master/buildbot/clients/tryclient.py b/master/buildbot/clients/tryclient.py
index bee4f3462..3f59a3cd6 100644
--- a/master/buildbot/clients/tryclient.py
+++ b/master/buildbot/clients/tryclient.py
@@ -12,6 +12,8 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
import os
import random
import re
@@ -32,7 +34,6 @@ from twisted.python.procutils import which
from twisted.spread import pb
from buildbot.status import builder
-from buildbot.util import json
from buildbot.util import now
from buildbot.util.eventual import fireEventually
diff --git a/master/buildbot/data/types.py b/master/buildbot/data/types.py
index 6372303cd..c0dfc3587 100644
--- a/master/buildbot/data/types.py
+++ b/master/buildbot/data/types.py
@@ -19,10 +19,10 @@ from future.utils import iteritems
from future.utils import text_type
import datetime
+import json
import re
from buildbot import util
-from buildbot.util import json
class Type(object):
diff --git a/master/buildbot/db/builds.py b/master/buildbot/db/builds.py
index a716cb603..cd9dabc5d 100644
--- a/master/buildbot/db/builds.py
+++ b/master/buildbot/db/builds.py
@@ -12,6 +12,9 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
+
import sqlalchemy as sa
from twisted.internet import defer
@@ -20,7 +23,6 @@ from twisted.internet import reactor
from buildbot.db import NULL
from buildbot.db import base
from buildbot.util import epoch2datetime
-from buildbot.util import json
class BuildsConnectorComponent(base.DBConnectorComponent):
diff --git a/master/buildbot/db/buildsets.py b/master/buildbot/db/buildsets.py
index 4bac6da5c..1288b57f4 100644
--- a/master/buildbot/db/buildsets.py
+++ b/master/buildbot/db/buildsets.py
@@ -18,6 +18,8 @@ Support for buildsets in the database
from future.utils import integer_types
from future.utils import iteritems
+import json
+
import sqlalchemy as sa
from twisted.internet import defer
@@ -27,7 +29,6 @@ from buildbot.db import NULL
from buildbot.db import base
from buildbot.util import datetime2epoch
from buildbot.util import epoch2datetime
-from buildbot.util import json
class BsDict(dict):
diff --git a/master/buildbot/db/changes.py b/master/buildbot/db/changes.py
index caa643fa7..004995753 100644
--- a/master/buildbot/db/changes.py
+++ b/master/buildbot/db/changes.py
@@ -19,6 +19,8 @@ Support for changes in the database
from future.utils import iteritems
from future.utils import itervalues
+import json
+
import sqlalchemy as sa
from twisted.internet import defer
@@ -28,7 +30,6 @@ from twisted.python import log
from buildbot.db import base
from buildbot.util import datetime2epoch
from buildbot.util import epoch2datetime
-from buildbot.util import json
class ChDict(dict):
diff --git a/master/buildbot/db/state.py b/master/buildbot/db/state.py
index 6ba143cfa..e572eab62 100644
--- a/master/buildbot/db/state.py
+++ b/master/buildbot/db/state.py
@@ -12,11 +12,13 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
+
import sqlalchemy as sa
import sqlalchemy.exc
from buildbot.db import base
-from buildbot.util import json
class _IdNotFoundError(Exception):
diff --git a/master/buildbot/db/steps.py b/master/buildbot/db/steps.py
index f5e1c82bd..d0fbb52e3 100644
--- a/master/buildbot/db/steps.py
+++ b/master/buildbot/db/steps.py
@@ -12,6 +12,9 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
+
import sqlalchemy as sa
from twisted.internet import defer
@@ -19,7 +22,6 @@ from twisted.internet import reactor
from buildbot.db import base
from buildbot.util import epoch2datetime
-from buildbot.util import json
class StepsConnectorComponent(base.DBConnectorComponent):
diff --git a/master/buildbot/db/types/json.py b/master/buildbot/db/types/json.py
index ee105269d..932218135 100644
--- a/master/buildbot/db/types/json.py
+++ b/master/buildbot/db/types/json.py
@@ -12,11 +12,14 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+from __future__ import absolute_import
+
+import json
+
from sqlalchemy.types import Text
from sqlalchemy.types import TypeDecorator
-from buildbot.util import json
-
class JsonObject(TypeDecorator):
diff --git a/master/buildbot/newsfragments/json.removal b/master/buildbot/newsfragments/json.removal
new file mode 100644
index 000000000..9fc57b91e
--- /dev/null
+++ b/master/buildbot/newsfragments/json.removal
@@ -0,0 +1 @@
+:py:data:`buildbot.util.json` has been deprecated in favor of the standard library :py:mod:`json`.
diff --git a/master/buildbot/process/properties.py b/master/buildbot/process/properties.py
index 82954a1cb..9b336c2d9 100644
--- a/master/buildbot/process/properties.py
+++ b/master/buildbot/process/properties.py
@@ -16,6 +16,7 @@ from future.builtins import range
from future.utils import iteritems
import collections
+import json
import re
import weakref
@@ -28,7 +29,6 @@ from buildbot import util
from buildbot.interfaces import IProperties
from buildbot.interfaces import IRenderable
from buildbot.util import flatten
-from buildbot.util import json
from buildbot.worker_transition import reportDeprecatedWorkerNameUsage
diff --git a/master/buildbot/schedulers/trysched.py b/master/buildbot/schedulers/trysched.py
index 3b700d871..60d17c269 100644
--- a/master/buildbot/schedulers/trysched.py
+++ b/master/buildbot/schedulers/trysched.py
@@ -12,8 +12,10 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
from future.utils import iteritems
+import json
import os
from twisted.internet import defer
@@ -25,7 +27,6 @@ from buildbot import pbutil
from buildbot.process.properties import Properties
from buildbot.schedulers import base
from buildbot.util import ascii2unicode
-from buildbot.util import json
from buildbot.util import netstrings
from buildbot.util.maildir import MaildirService
diff --git a/master/buildbot/scripts/dataspec.py b/master/buildbot/scripts/dataspec.py
index 047aa297e..a3017db82 100644
--- a/master/buildbot/scripts/dataspec.py
+++ b/master/buildbot/scripts/dataspec.py
@@ -12,6 +12,8 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
import os
import sys
@@ -20,7 +22,6 @@ from twisted.internet import defer
from buildbot.data import connector
from buildbot.test.fake import fakemaster
from buildbot.util import in_reactor
-from buildbot.util import json
@in_reactor
diff --git a/master/buildbot/scripts/processwwwindex.py b/master/buildbot/scripts/processwwwindex.py
index 57db423c9..e7180f623 100644
--- a/master/buildbot/scripts/processwwwindex.py
+++ b/master/buildbot/scripts/processwwwindex.py
@@ -15,6 +15,7 @@
from __future__ import division
from __future__ import print_function
+import json
import os
import jinja2
@@ -23,7 +24,6 @@ from twisted.internet import defer
from buildbot.test.fake import fakemaster
from buildbot.util import in_reactor
-from buildbot.util import json
from buildbot.www import auth
from buildbot.www.config import IndexResource
from buildbot.www.service import WWWService
diff --git a/master/buildbot/steps/transfer.py b/master/buildbot/steps/transfer.py
index a3d423848..5dfb3b6a9 100644
--- a/master/buildbot/steps/transfer.py
+++ b/master/buildbot/steps/transfer.py
@@ -12,6 +12,8 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
import os
import stat
@@ -26,7 +28,6 @@ from buildbot.process.buildstep import FAILURE
from buildbot.process.buildstep import SKIPPED
from buildbot.process.buildstep import SUCCESS
from buildbot.process.buildstep import BuildStep
-from buildbot.util import json
from buildbot.util.eventual import eventually
from buildbot.worker_transition import WorkerAPICompatMixin
from buildbot.worker_transition import reportDeprecatedWorkerNameUsage
diff --git a/master/buildbot/test/fake/fakedata.py b/master/buildbot/test/fake/fakedata.py
index b5a2ef58c..92bfd5c7b 100644
--- a/master/buildbot/test/fake/fakedata.py
+++ b/master/buildbot/test/fake/fakedata.py
@@ -16,6 +16,8 @@ from future.utils import iteritems
from future.utils import itervalues
from future.utils import text_type
+import json
+
from twisted.internet import defer
from twisted.internet import reactor
from twisted.python import failure
@@ -23,7 +25,6 @@ from twisted.python import failure
from buildbot.data import connector
from buildbot.db.buildrequests import AlreadyClaimedError
from buildbot.test.util import validation
-from buildbot.util import json
from buildbot.util import service
diff --git a/master/buildbot/test/fake/fakedb.py b/master/buildbot/test/fake/fakedb.py
index 740e6b1e3..47340ef63 100644
--- a/master/buildbot/test/fake/fakedb.py
+++ b/master/buildbot/test/fake/fakedb.py
@@ -25,6 +25,7 @@ from future.utils import text_type
import base64
import copy
import hashlib
+import json
from twisted.internet import defer
from twisted.internet import reactor
@@ -35,7 +36,6 @@ from buildbot.db import changesources
from buildbot.db import schedulers
from buildbot.test.util import validation
from buildbot.util import datetime2epoch
-from buildbot.util import json
from buildbot.util import service
diff --git a/master/buildbot/test/integration/test_www.py b/master/buildbot/test/integration/test_www.py
index de8805f35..fcfc6b549 100644
--- a/master/buildbot/test/integration/test_www.py
+++ b/master/buildbot/test/integration/test_www.py
@@ -12,6 +12,9 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
+
import mock
from twisted.internet import defer
@@ -27,7 +30,6 @@ from buildbot.test.fake import fakedb
from buildbot.test.fake import fakemaster
from buildbot.test.util import db
from buildbot.test.util import www
-from buildbot.util import json
from buildbot.www import service as wwwservice
from buildbot.www import auth
from buildbot.www import authz
diff --git a/master/buildbot/test/unit/test_changes_gerritchangesource.py b/master/buildbot/test/unit/test_changes_gerritchangesource.py
index fe00fcf58..b5c939065 100644
--- a/master/buildbot/test/unit/test_changes_gerritchangesource.py
+++ b/master/buildbot/test/unit/test_changes_gerritchangesource.py
@@ -15,6 +15,7 @@
from future.utils import iteritems
import datetime
+import json
import types
from twisted.internet import defer
@@ -25,7 +26,6 @@ from buildbot.test.fake import httpclientservice as fakehttpclientservice
from buildbot.test.fake import fakedb
from buildbot.test.fake.change import Change
from buildbot.test.util import changesource
-from buildbot.util import json
class TestGerritHelpers(unittest.TestCase):
diff --git a/master/buildbot/test/unit/test_clients_tryclient.py b/master/buildbot/test/unit/test_clients_tryclient.py
index 765d6444f..13adbf8cd 100644
--- a/master/buildbot/test/unit/test_clients_tryclient.py
+++ b/master/buildbot/test/unit/test_clients_tryclient.py
@@ -12,10 +12,12 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
+
from twisted.trial import unittest
from buildbot.clients import tryclient
-from buildbot.util import json
class createJobfile(unittest.TestCase):
diff --git a/master/buildbot/test/unit/test_db_buildsets.py b/master/buildbot/test/unit/test_db_buildsets.py
index 5acea7a54..49c64790a 100644
--- a/master/buildbot/test/unit/test_db_buildsets.py
+++ b/master/buildbot/test/unit/test_db_buildsets.py
@@ -12,7 +12,9 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
import datetime
+import json
import mock
@@ -30,7 +32,6 @@ from buildbot.test.util import validation
from buildbot.util import UTC
from buildbot.util import datetime2epoch
from buildbot.util import epoch2datetime
-from buildbot.util import json
class Tests(interfaces.InterfaceTests):
diff --git a/master/buildbot/test/unit/test_mq_wamp.py b/master/buildbot/test/unit/test_mq_wamp.py
index 3ad41ae7d..55a9bf95f 100644
--- a/master/buildbot/test/unit/test_mq_wamp.py
+++ b/master/buildbot/test/unit/test_mq_wamp.py
@@ -12,8 +12,10 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
from future.builtins import range
+import json
import os
import textwrap
@@ -26,7 +28,6 @@ from twisted.trial import unittest
from buildbot.mq import wamp
from buildbot.test.fake import fakemaster
-from buildbot.util import json
from buildbot.wamp import connector
diff --git a/master/buildbot/test/unit/test_schedulers_forcesched.py b/master/buildbot/test/unit/test_schedulers_forcesched.py
index 72e19a830..22f3dea31 100644
--- a/master/buildbot/test/unit/test_schedulers_forcesched.py
+++ b/master/buildbot/test/unit/test_schedulers_forcesched.py
@@ -16,6 +16,8 @@ from __future__ import division
from __future__ import print_function
from future.utils import iteritems
+import json
+
from twisted.internet import defer
from twisted.trial import unittest
@@ -36,7 +38,6 @@ from buildbot.schedulers.forcesched import oneCodebase
from buildbot.test.util import scheduler
from buildbot.test.util.config import ConfigErrorsMixin
from buildbot.test.util.warnings import assertProducesWarning
-from buildbot.util import json
from buildbot.worker_transition import DeprecatedWorkerNameWarning
diff --git a/master/buildbot/test/unit/test_schedulers_trysched.py b/master/buildbot/test/unit/test_schedulers_trysched.py
index c5f9f347e..439ce5d2d 100644
--- a/master/buildbot/test/unit/test_schedulers_trysched.py
+++ b/master/buildbot/test/unit/test_schedulers_trysched.py
@@ -12,7 +12,9 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
import cStringIO as StringIO
+import json
import os
import shutil
import sys
@@ -27,7 +29,6 @@ from twisted.trial import unittest
from buildbot.schedulers import trysched
from buildbot.test.util import dirs
from buildbot.test.util import scheduler
-from buildbot.util import json
class TryBase(unittest.TestCase):
diff --git a/master/buildbot/test/unit/test_scripts_processwwwindex.py b/master/buildbot/test/unit/test_scripts_processwwwindex.py
index db01a5239..c265b8ab7 100644
--- a/master/buildbot/test/unit/test_scripts_processwwwindex.py
+++ b/master/buildbot/test/unit/test_scripts_processwwwindex.py
@@ -12,12 +12,13 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
import tempfile
from twisted.trial import unittest
from buildbot.scripts import processwwwindex
-from buildbot.util import json
class TestUsersClient(unittest.TestCase):
diff --git a/master/buildbot/test/unit/test_steps_transfer.py b/master/buildbot/test/unit/test_steps_transfer.py
index ee70af830..c91f0dfac 100644
--- a/master/buildbot/test/unit/test_steps_transfer.py
+++ b/master/buildbot/test/unit/test_steps_transfer.py
@@ -12,8 +12,10 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
from future.utils import iteritems
+import json
import os
import shutil
import stat
@@ -38,7 +40,6 @@ from buildbot.test.fake.remotecommand import ExpectRemoteRef
from buildbot.test.util import steps
from buildbot.test.util.warnings import assertNotProducesWarnings
from buildbot.test.util.warnings import assertProducesWarning
-from buildbot.util import json
from buildbot.worker_transition import DeprecatedWorkerAPIWarning
from buildbot.worker_transition import DeprecatedWorkerNameWarning
diff --git a/master/buildbot/test/unit/test_www_oauth.py b/master/buildbot/test/unit/test_www_oauth.py
index 177385cb0..ba7310bf8 100644
--- a/master/buildbot/test/unit/test_www_oauth.py
+++ b/master/buildbot/test/unit/test_www_oauth.py
@@ -12,6 +12,8 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
import os
import webbrowser
@@ -26,7 +28,6 @@ from twisted.web.resource import Resource
from twisted.web.server import Site
from buildbot.test.util import www
-from buildbot.util import json
try:
import requests
@@ -277,7 +278,6 @@ class OAuth2AuthGitHubE2E(www.WwwTestMixin, unittest.TestCase):
raise unittest.SkipTest(
"Need to pass OAUTHCONF path to json file via environ to run this e2e test")
- import json
config = json.load(open(os.environ['OAUTHCONF']))[self.authClass]
from buildbot.www import oauth2
self.auth = self._instantiateAuth(
diff --git a/master/buildbot/test/unit/test_www_rest.py b/master/buildbot/test/unit/test_www_rest.py
index c0e1a2680..2b87e4d0d 100644
--- a/master/buildbot/test/unit/test_www_rest.py
+++ b/master/buildbot/test/unit/test_www_rest.py
@@ -18,6 +18,7 @@ from future.utils import itervalues
from future.utils import string_types
from future.utils import text_type
+import json
import re
import mock
@@ -27,7 +28,6 @@ from twisted.trial import unittest
from buildbot.test.fake import endpoint
from buildbot.test.util import www
-from buildbot.util import json
from buildbot.www import authz
from buildbot.www import rest
from buildbot.www.rest import JSONRPC_CODES
diff --git a/master/buildbot/test/unit/test_www_sse.py b/master/buildbot/test/unit/test_www_sse.py
index ba2a1f0a9..3eac07047 100644
--- a/master/buildbot/test/unit/test_www_sse.py
+++ b/master/buildbot/test/unit/test_www_sse.py
@@ -13,13 +13,13 @@
#
# Copyright Buildbot Team Members
import datetime
+import json
from twisted.trial import unittest
from buildbot.test.unit import test_data_changes
from buildbot.test.util import www
from buildbot.util import datetime2epoch
-from buildbot.util import json
from buildbot.www import sse
diff --git a/master/buildbot/test/unit/test_www_ws.py b/master/buildbot/test/unit/test_www_ws.py
index a40393556..91051b21d 100644
--- a/master/buildbot/test/unit/test_www_ws.py
+++ b/master/buildbot/test/unit/test_www_ws.py
@@ -12,12 +12,14 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
+
from mock import Mock
from twisted.trial import unittest
from buildbot.test.util import www
-from buildbot.util import json
from buildbot.www import ws
diff --git a/master/buildbot/test/util/validation.py b/master/buildbot/test/util/validation.py
index 13647a63b..292e72bee 100644
--- a/master/buildbot/test/util/validation.py
+++ b/master/buildbot/test/util/validation.py
@@ -19,10 +19,10 @@ from future.utils import iteritems
from future.utils import text_type
import datetime
+import json
import re
from buildbot.util import UTC
-from buildbot.util import json
# Base class
diff --git a/master/buildbot/test/util/www.py b/master/buildbot/test/util/www.py
index 5fe38e268..d737327dd 100644
--- a/master/buildbot/test/util/www.py
+++ b/master/buildbot/test/util/www.py
@@ -17,6 +17,7 @@ from future.utils import integer_types
from future.utils import iteritems
import cgi
+import json
import os
import pkg_resources
from cStringIO import StringIO
@@ -28,7 +29,6 @@ from twisted.internet import defer
from twisted.web import server
from buildbot.test.fake import fakemaster
-from buildbot.util import json
from buildbot.www import auth
from buildbot.www import authz
diff --git a/master/buildbot/util/__init__.py b/master/buildbot/util/__init__.py
index ed78bf25f..3a9d55ca5 100644
--- a/master/buildbot/util/__init__.py
+++ b/master/buildbot/util/__init__.py
@@ -12,6 +12,7 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
from __future__ import division
from __future__ import print_function
@@ -28,9 +29,12 @@ import locale
import re
import textwrap
import time
+import json
from future.utils import text_type
from twisted.python import reflect
+from twisted.python.versions import Version
+from twisted.python.deprecate import deprecatedModuleAttribute
from zope.interface import implementer
@@ -181,26 +185,14 @@ def ascii2unicode(x):
return x
return text_type(x, 'ascii')
+_hush_pyflakes = [json]
-# place a working json module at 'buildbot.util.json'. Code is adapted from
-# Paul Wise <[email protected]>:
-# http://lists.debian.org/debian-python/2010/02/msg00016.html
-# json doesn't exist as a standard module until python2.6
-# However python2.6's json module is much slower than simplejson, so we prefer
-# to use simplejson if available.
-try:
- import simplejson as json
- assert json
-except ImportError:
- import json # python 2.6 or 2.7
-try:
- _tmp = json.loads
-except AttributeError:
- import warnings
- import sys
- warnings.warn("Use simplejson, not the old json module.")
- sys.modules.pop('json') # get rid of the bad json module
- import simplejson as json
+deprecatedModuleAttribute(
+ Version("buildbot", 0, 9, 4),
+ message="Use json from the standard library instead.",
+ moduleName="buildbot.util",
+ name="json",
+)
def toJson(obj):
@@ -432,7 +424,7 @@ def dictionary_merge(a, b):
__all__ = [
- 'naturalSort', 'now', 'formatInterval', 'ComparableMixin', 'json',
+ 'naturalSort', 'now', 'formatInterval', 'ComparableMixin',
'safeTranslate', 'none_or_str',
'NotABranch', 'deferredLocked', 'UTC',
'diffSets', 'makeList', 'in_reactor', 'string2boolean',
diff --git a/master/buildbot/worker/docker.py b/master/buildbot/worker/docker.py
index f39132737..a91424f1a 100644
--- a/master/buildbot/worker/docker.py
+++ b/master/buildbot/worker/docker.py
@@ -19,6 +19,7 @@ from __future__ import division
from __future__ import print_function
import hashlib
+import json
import socket
from io import BytesIO
@@ -28,7 +29,6 @@ from twisted.python import log
from buildbot import config
from buildbot.interfaces import LatentWorkerFailedToSubstantiate
-from buildbot.util import json
from buildbot.worker import AbstractLatentWorker
try:
diff --git a/master/buildbot/www/config.py b/master/buildbot/www/config.py
index e3f6f6214..4030e8e73 100644
--- a/master/buildbot/www/config.py
+++ b/master/buildbot/www/config.py
@@ -12,6 +12,8 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
import os
import posixpath
@@ -22,7 +24,6 @@ from twisted.python import log
from twisted.web.error import Error
from buildbot.interfaces import IConfigured
-from buildbot.util import json
from buildbot.www import resource
diff --git a/master/buildbot/www/hooks/base.py b/master/buildbot/www/hooks/base.py
index 149c3f925..9255be44a 100644
--- a/master/buildbot/www/hooks/base.py
+++ b/master/buildbot/www/hooks/base.py
@@ -17,7 +17,8 @@
# and inspired from code from the Chromium project
# otherwise, Andrew Melo <[email protected]> wrote the rest
# but "the rest" is pretty minimal
-from buildbot.util import json
+
+import json
def getChanges(request, options=None):
diff --git a/master/buildbot/www/hooks/gitlab.py b/master/buildbot/www/hooks/gitlab.py
index c7663a63a..ab1b65690 100644
--- a/master/buildbot/www/hooks/gitlab.py
+++ b/master/buildbot/www/hooks/gitlab.py
@@ -12,14 +12,14 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
+import json
import re
from dateutil.parser import parse as dateparse
from twisted.python import log
-from buildbot.util import json
-
def _process_change(payload, user, repo, repo_url, project, codebase=None):
"""
diff --git a/master/buildbot/www/hooks/googlecode.py b/master/buildbot/www/hooks/googlecode.py
index b8709bb4d..2a370e4f9 100644
--- a/master/buildbot/www/hooks/googlecode.py
+++ b/master/buildbot/www/hooks/googlecode.py
@@ -14,12 +14,12 @@
# Copyright 2011, Louis Opter <[email protected]>
#
# Quite inspired from the github hook.
+
import hmac
+import json
from twisted.python import log
-from buildbot.util import json
-
class GoogleCodeAuthFailed(Exception):
pass
diff --git a/master/buildbot/www/oauth2.py b/master/buildbot/www/oauth2.py
index 1d1ea4efd..baa9dab25 100644
--- a/master/buildbot/www/oauth2.py
+++ b/master/buildbot/www/oauth2.py
@@ -17,6 +17,7 @@ from future.moves.urllib.parse import urlencode
from future.utils import iteritems
from future.utils import string_types
+import json
from posixpath import join
import requests
@@ -24,7 +25,6 @@ import requests
from twisted.internet import defer
from twisted.internet import threads
-from buildbot.util import json
from buildbot.www import auth
from buildbot.www import resource
diff --git a/master/buildbot/www/rest.py b/master/buildbot/www/rest.py
index 3147a33b7..30f79d6ea 100644
--- a/master/buildbot/www/rest.py
+++ b/master/buildbot/www/rest.py
@@ -19,6 +19,7 @@ from future.utils import text_type
import cgi
import datetime
import fnmatch
+import json
import re
from contextlib import contextmanager
@@ -28,7 +29,6 @@ from twisted.web.error import Error
from buildbot.data import exceptions
from buildbot.data import resultspec
-from buildbot.util import json
from buildbot.util import toJson
from buildbot.www import resource
from buildbot.www.authz import Forbidden
diff --git a/master/buildbot/www/sse.py b/master/buildbot/www/sse.py
index df076195e..741328844 100644
--- a/master/buildbot/www/sse.py
+++ b/master/buildbot/www/sse.py
@@ -12,8 +12,10 @@
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
+
from future.utils import itervalues
+import json
import uuid
from twisted.python import log
@@ -21,7 +23,6 @@ from twisted.web import resource
from twisted.web import server
from buildbot.data.exceptions import InvalidPathError
-from buildbot.util import json
from buildbot.util import toJson
diff --git a/master/buildbot/www/ws.py b/master/buildbot/www/ws.py
index ed7bcad8f..1e48ec553 100644
--- a/master/buildbot/www/ws.py
+++ b/master/buildbot/www/ws.py
@@ -15,13 +15,14 @@
from future.utils import itervalues
from future.utils import string_types
+import json
+
from autobahn.twisted.resource import WebSocketResource
from autobahn.twisted.websocket import WebSocketServerFactory
from autobahn.twisted.websocket import WebSocketServerProtocol
from twisted.internet import defer
from twisted.python import log
-from buildbot.util import json
from buildbot.util import toJson
diff --git a/master/docs/developer/utils.rst b/master/docs/developer/utils.rst
index e1e64503a..2470330bd 100644
--- a/master/docs/developer/utils.rst
+++ b/master/docs/developer/utils.rst
@@ -506,18 +506,6 @@ The ``@poll.method`` decorator makes this behavior easy and reliable.
Force a call to the decorated method now.
If the decorated method is currently running, another call will begin as soon as it completes.
-:py:mod:`buildbot.util.json`
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-.. py:module:: buildbot.util.json
-
-This package is just an import of the best available JSON module.
-Use it instead of a more complex conditional import of :mod:`simplejson` or :mod:`json`:
-
-.. code-block:: python
-
- from buildbot.util import json
-
:py:mod:`buildbot.util.maildir`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
2.11.0