##// END OF EJS Templates
python3: fix urllib usage
super-admin -
r4914:49ad81de default
parent child Browse files
Show More
@@ -32,7 +32,7 b' from rhodecode.lib.utils2 import safe_un'
32
32
33
33
34 def route_path(name, params=None, **kwargs):
34 def route_path(name, params=None, **kwargs):
35 import urllib
35 import urllib.request, urllib.parse, urllib.error
36 from rhodecode.apps._base import ADMIN_PREFIX
36 from rhodecode.apps._base import ADMIN_PREFIX
37
37
38 base_url = {
38 base_url = {
@@ -42,7 +42,7 b' def route_path(name, params=None, **kwar'
42 }[name].format(**kwargs)
42 }[name].format(**kwargs)
43
43
44 if params:
44 if params:
45 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
45 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
46 return base_url
46 return base_url
47
47
48
48
@@ -25,7 +25,7 b' from rhodecode.model.settings import Set'
25
25
26
26
27 def route_path(name, params=None, **kwargs):
27 def route_path(name, params=None, **kwargs):
28 import urllib
28 import urllib.request, urllib.parse, urllib.error
29 from rhodecode.apps._base import ADMIN_PREFIX
29 from rhodecode.apps._base import ADMIN_PREFIX
30
30
31 base_url = {
31 base_url = {
@@ -36,7 +36,7 b' def route_path(name, params=None, **kwar'
36 }[name].format(**kwargs)
36 }[name].format(**kwargs)
37
37
38 if params:
38 if params:
39 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
39 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
40 return base_url
40 return base_url
41
41
42
42
@@ -27,7 +27,7 b' fixture = Fixture()'
27
27
28
28
29 def route_path(name, params=None, **kwargs):
29 def route_path(name, params=None, **kwargs):
30 import urllib
30 import urllib.request, urllib.parse, urllib.error
31 from rhodecode.apps._base import ADMIN_PREFIX
31 from rhodecode.apps._base import ADMIN_PREFIX
32
32
33 base_url = {
33 base_url = {
@@ -40,7 +40,7 b' def route_path(name, params=None, **kwar'
40 }[name].format(**kwargs)
40 }[name].format(**kwargs)
41
41
42 if params:
42 if params:
43 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
43 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
44 return base_url
44 return base_url
45
45
46
46
@@ -29,7 +29,7 b' from rhodecode.tests import ('
29
29
30
30
31 def route_path(name, params=None, **kwargs):
31 def route_path(name, params=None, **kwargs):
32 import urllib
32 import urllib.request, urllib.parse, urllib.error
33 from rhodecode.apps._base import ADMIN_PREFIX
33 from rhodecode.apps._base import ADMIN_PREFIX
34
34
35 base_url = {
35 base_url = {
@@ -70,7 +70,7 b' def route_path(name, params=None, **kwar'
70 }[name].format(**kwargs)
70 }[name].format(**kwargs)
71
71
72 if params:
72 if params:
73 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
73 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
74 return base_url
74 return base_url
75
75
76
76
@@ -18,7 +18,7 b''
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import urllib
21 import urllib.request, urllib.parse, urllib.error
22
22
23 import mock
23 import mock
24 import pytest
24 import pytest
@@ -43,7 +43,7 b' fixture = Fixture()'
43
43
44
44
45 def route_path(name, params=None, **kwargs):
45 def route_path(name, params=None, **kwargs):
46 import urllib
46 import urllib.request, urllib.parse, urllib.error
47
47
48 base_url = {
48 base_url = {
49 'repos': ADMIN_PREFIX + '/repos',
49 'repos': ADMIN_PREFIX + '/repos',
@@ -55,7 +55,7 b' def route_path(name, params=None, **kwar'
55 }[name].format(**kwargs)
55 }[name].format(**kwargs)
56
56
57 if params:
57 if params:
58 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
58 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
59 return base_url
59 return base_url
60
60
61
61
@@ -494,7 +494,7 b' class TestAdminRepos(object):'
494 assert response.json == {u'result': True}
494 assert response.json == {u'result': True}
495
495
496 flash_msg = u'Created repository <a href="/{}">{}</a>'.format(
496 flash_msg = u'Created repository <a href="/{}">{}</a>'.format(
497 urllib.quote(repo_name_utf8), repo_name)
497 urllib.parse.quote(repo_name_utf8), repo_name)
498 assert_session_flash(response, flash_msg)
498 assert_session_flash(response, flash_msg)
499
499
500 # test if the repo was created in the database
500 # test if the repo was created in the database
@@ -34,7 +34,7 b' fixture = Fixture()'
34
34
35
35
36 def route_path(name, params=None, **kwargs):
36 def route_path(name, params=None, **kwargs):
37 import urllib
37 import urllib.request, urllib.parse, urllib.error
38
38
39 base_url = {
39 base_url = {
40 'repo_groups': ADMIN_PREFIX + '/repo_groups',
40 'repo_groups': ADMIN_PREFIX + '/repo_groups',
@@ -45,7 +45,7 b' def route_path(name, params=None, **kwar'
45 }[name].format(**kwargs)
45 }[name].format(**kwargs)
46
46
47 if params:
47 if params:
48 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
48 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
49 return base_url
49 return base_url
50
50
51
51
@@ -35,7 +35,7 b" UPDATE_DATA_QUALNAME = 'rhodecode.model."
35
35
36
36
37 def route_path(name, params=None, **kwargs):
37 def route_path(name, params=None, **kwargs):
38 import urllib
38 import urllib.request, urllib.parse, urllib.error
39 from rhodecode.apps._base import ADMIN_PREFIX
39 from rhodecode.apps._base import ADMIN_PREFIX
40
40
41 base_url = {
41 base_url = {
@@ -102,7 +102,7 b' def route_path(name, params=None, **kwar'
102 }[name].format(**kwargs)
102 }[name].format(**kwargs)
103
103
104 if params:
104 if params:
105 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
105 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
106 return base_url
106 return base_url
107
107
108
108
@@ -31,7 +31,7 b' fixture = Fixture()'
31
31
32
32
33 def route_path(name, params=None, **kwargs):
33 def route_path(name, params=None, **kwargs):
34 import urllib
34 import urllib.request, urllib.parse, urllib.error
35 from rhodecode.apps._base import ADMIN_PREFIX
35 from rhodecode.apps._base import ADMIN_PREFIX
36
36
37 base_url = {
37 base_url = {
@@ -44,7 +44,7 b' def route_path(name, params=None, **kwar'
44 }[name].format(**kwargs)
44 }[name].format(**kwargs)
45
45
46 if params:
46 if params:
47 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
47 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
48 return base_url
48 return base_url
49
49
50
50
@@ -35,7 +35,7 b' fixture = Fixture()'
35
35
36
36
37 def route_path(name, params=None, **kwargs):
37 def route_path(name, params=None, **kwargs):
38 import urllib
38 import urllib.request, urllib.parse, urllib.error
39 from rhodecode.apps._base import ADMIN_PREFIX
39 from rhodecode.apps._base import ADMIN_PREFIX
40
40
41 base_url = {
41 base_url = {
@@ -97,7 +97,7 b' def route_path(name, params=None, **kwar'
97 }[name].format(**kwargs)
97 }[name].format(**kwargs)
98
98
99 if params:
99 if params:
100 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
100 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
101 return base_url
101 return base_url
102
102
103
103
@@ -29,7 +29,7 b' fixture = Fixture()'
29
29
30
30
31 def route_path(name, params=None, **kwargs):
31 def route_path(name, params=None, **kwargs):
32 import urllib
32 import urllib.request, urllib.parse, urllib.error
33 from rhodecode.apps._base import ADMIN_PREFIX
33 from rhodecode.apps._base import ADMIN_PREFIX
34
34
35 base_url = {
35 base_url = {
@@ -45,7 +45,7 b' def route_path(name, params=None, **kwar'
45 }[name].format(**kwargs)
45 }[name].format(**kwargs)
46
46
47 if params:
47 if params:
48 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
48 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
49 return base_url
49 return base_url
50
50
51
51
@@ -19,7 +19,7 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import logging
21 import logging
22 import urllib2
22 import urllib.request, urllib.error, urllib.parse
23 import os
23 import os
24
24
25 import rhodecode
25 import rhodecode
@@ -209,7 +209,7 b' class AdminSystemInfoSettingsView(BaseAp'
209 _err = lambda s: '<div style="color:#ff8888; padding:4px 0px">{}</div>'.format(s)
209 _err = lambda s: '<div style="color:#ff8888; padding:4px 0px">{}</div>'.format(s)
210 try:
210 try:
211 data = UpdateModel().get_update_data(update_url)
211 data = UpdateModel().get_update_data(update_url)
212 except urllib2.URLError as e:
212 except urllib.error.URLError as e:
213 log.exception("Exception contacting upgrade server")
213 log.exception("Exception contacting upgrade server")
214 self.request.override_renderer = 'string'
214 self.request.override_renderer = 'string'
215 return _err('Failed to contact upgrade server: %r' % e)
215 return _err('Failed to contact upgrade server: %r' % e)
@@ -28,7 +28,7 b' from rhodecode.apps.file_store import ut'
28
28
29
29
30 def route_path(name, params=None, **kwargs):
30 def route_path(name, params=None, **kwargs):
31 import urllib
31 import urllib.request, urllib.parse, urllib.error
32
32
33 base_url = {
33 base_url = {
34 'upload_file': '/_file_store/upload',
34 'upload_file': '/_file_store/upload',
@@ -38,7 +38,7 b' def route_path(name, params=None, **kwar'
38 }[name].format(**kwargs)
38 }[name].format(**kwargs)
39
39
40 if params:
40 if params:
41 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
41 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
42 return base_url
42 return base_url
43
43
44
44
@@ -31,7 +31,7 b' from rhodecode.tests import ('
31
31
32
32
33 def route_path(name, params=None, **kwargs):
33 def route_path(name, params=None, **kwargs):
34 import urllib
34 import urllib.request, urllib.parse, urllib.error
35 from rhodecode.apps._base import ADMIN_PREFIX
35 from rhodecode.apps._base import ADMIN_PREFIX
36
36
37 base_url = {
37 base_url = {
@@ -50,7 +50,7 b' def route_path(name, params=None, **kwar'
50 }[name].format(**kwargs)
50 }[name].format(**kwargs)
51
51
52 if params:
52 if params:
53 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
53 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
54 return base_url
54 return base_url
55
55
56
56
@@ -35,14 +35,14 b' fixture = Fixture()'
35
35
36
36
37 def route_path(name, params=None, **kwargs):
37 def route_path(name, params=None, **kwargs):
38 import urllib
38 import urllib.request, urllib.parse, urllib.error
39
39
40 base_url = {
40 base_url = {
41 'goto_switcher_data': '/_goto_data',
41 'goto_switcher_data': '/_goto_data',
42 }[name].format(**kwargs)
42 }[name].format(**kwargs)
43
43
44 if params:
44 if params:
45 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
45 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
46 return base_url
46 return base_url
47
47
48
48
@@ -29,14 +29,14 b' fixture = Fixture()'
29
29
30
30
31 def route_path(name, params=None, **kwargs):
31 def route_path(name, params=None, **kwargs):
32 import urllib
32 import urllib.request, urllib.parse, urllib.error
33
33
34 base_url = {
34 base_url = {
35 'repo_list_data': '/_repos',
35 'repo_list_data': '/_repos',
36 }[name].format(**kwargs)
36 }[name].format(**kwargs)
37
37
38 if params:
38 if params:
39 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
39 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
40 return base_url
40 return base_url
41
41
42
42
@@ -29,7 +29,7 b' fixture = Fixture()'
29
29
30
30
31 def route_path(name, params=None, **kwargs):
31 def route_path(name, params=None, **kwargs):
32 import urllib
32 import urllib.request, urllib.parse, urllib.error
33
33
34 base_url = {
34 base_url = {
35 'user_autocomplete_data': '/_users',
35 'user_autocomplete_data': '/_users',
@@ -37,7 +37,7 b' def route_path(name, params=None, **kwar'
37 }[name].format(**kwargs)
37 }[name].format(**kwargs)
38
38
39 if params:
39 if params:
40 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
40 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
41 return base_url
41 return base_url
42
42
43
43
@@ -49,7 +49,7 b' fixture = Fixture()'
49
49
50
50
51 def route_path(name, params=None, **kwargs):
51 def route_path(name, params=None, **kwargs):
52 import urllib
52 import urllib.request, urllib.parse, urllib.error
53
53
54 base_url = {
54 base_url = {
55 'user_autocomplete_data': '/_users',
55 'user_autocomplete_data': '/_users',
@@ -57,7 +57,7 b' def route_path(name, params=None, **kwar'
57 }[name].format(**kwargs)
57 }[name].format(**kwargs)
58
58
59 if params:
59 if params:
60 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
60 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
61 return base_url
61 return base_url
62
62
63
63
@@ -28,7 +28,7 b' from rhodecode.model.db import UserFollo'
28
28
29
29
30 def route_path(name, params=None, **kwargs):
30 def route_path(name, params=None, **kwargs):
31 import urllib
31 import urllib.request, urllib.parse, urllib.error
32
32
33 base_url = {
33 base_url = {
34 'journal': ADMIN_PREFIX + '/journal',
34 'journal': ADMIN_PREFIX + '/journal',
@@ -43,7 +43,7 b' def route_path(name, params=None, **kwar'
43 }[name].format(**kwargs)
43 }[name].format(**kwargs)
44
44
45 if params:
45 if params:
46 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
46 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
47 return base_url
47 return base_url
48
48
49
49
@@ -39,7 +39,7 b" whitelist_view = ['RepoCommitsView:repo_"
39
39
40
40
41 def route_path(name, params=None, **kwargs):
41 def route_path(name, params=None, **kwargs):
42 import urllib
42 import urllib.request, urllib.parse, urllib.error
43 from rhodecode.apps._base import ADMIN_PREFIX
43 from rhodecode.apps._base import ADMIN_PREFIX
44
44
45 base_url = {
45 base_url = {
@@ -61,7 +61,7 b' def route_path(name, params=None, **kwar'
61 }[name].format(**kwargs)
61 }[name].format(**kwargs)
62
62
63 if params:
63 if params:
64 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
64 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
65 return base_url
65 return base_url
66
66
67
67
@@ -31,7 +31,7 b' fixture = Fixture()'
31
31
32
32
33 def route_path(name, params=None, **kwargs):
33 def route_path(name, params=None, **kwargs):
34 import urllib
34 import urllib.request, urllib.parse, urllib.error
35 from rhodecode.apps._base import ADMIN_PREFIX
35 from rhodecode.apps._base import ADMIN_PREFIX
36
36
37 base_url = {
37 base_url = {
@@ -50,7 +50,7 b' def route_path(name, params=None, **kwar'
50 }[name].format(**kwargs)
50 }[name].format(**kwargs)
51
51
52 if params:
52 if params:
53 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
53 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
54 return base_url
54 return base_url
55
55
56
56
@@ -45,7 +45,7 b' from rhodecode.lib import helpers as h'
45
45
46
46
47 def route_path(name, params=None, **kwargs):
47 def route_path(name, params=None, **kwargs):
48 import urllib
48 import urllib.request, urllib.parse, urllib.error
49 from rhodecode.apps._base import ADMIN_PREFIX
49 from rhodecode.apps._base import ADMIN_PREFIX
50
50
51 base_url = {
51 base_url = {
@@ -56,7 +56,7 b' def route_path(name, params=None, **kwar'
56 }[name].format(**kwargs)
56 }[name].format(**kwargs)
57
57
58 if params:
58 if params:
59 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
59 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
60 return base_url
60 return base_url
61
61
62
62
@@ -35,7 +35,7 b' fixture = Fixture()'
35
35
36
36
37 def route_path(name, params=None, **kwargs):
37 def route_path(name, params=None, **kwargs):
38 import urllib
38 import urllib.request, urllib.parse, urllib.error
39 from rhodecode.apps._base import ADMIN_PREFIX
39 from rhodecode.apps._base import ADMIN_PREFIX
40
40
41 base_url = {
41 base_url = {
@@ -48,7 +48,7 b' def route_path(name, params=None, **kwar'
48 }[name].format(**kwargs)
48 }[name].format(**kwargs)
49
49
50 if params:
50 if params:
51 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
51 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
52 return base_url
52 return base_url
53
53
54
54
@@ -29,7 +29,7 b' fixture = Fixture()'
29
29
30
30
31 def route_path(name, params=None, **kwargs):
31 def route_path(name, params=None, **kwargs):
32 import urllib
32 import urllib.request, urllib.parse, urllib.error
33 from rhodecode.apps._base import ADMIN_PREFIX
33 from rhodecode.apps._base import ADMIN_PREFIX
34
34
35 base_url = {
35 base_url = {
@@ -44,7 +44,7 b' def route_path(name, params=None, **kwar'
44 }[name].format(**kwargs)
44 }[name].format(**kwargs)
45
45
46 if params:
46 if params:
47 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
47 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
48 return base_url
48 return base_url
49
49
50
50
@@ -24,7 +24,7 b' from rhodecode.tests import assert_sessi'
24
24
25
25
26 def route_path(name, params=None, **kwargs):
26 def route_path(name, params=None, **kwargs):
27 import urllib
27 import urllib.request, urllib.parse, urllib.error
28
28
29 base_url = {
29 base_url = {
30 'edit_repo_group_advanced':
30 'edit_repo_group_advanced':
@@ -34,7 +34,7 b' def route_path(name, params=None, **kwar'
34 }[name].format(**kwargs)
34 }[name].format(**kwargs)
35
35
36 if params:
36 if params:
37 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
37 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
38 return base_url
38 return base_url
39
39
40
40
@@ -24,7 +24,7 b' from rhodecode.tests.utils import permis'
24
24
25
25
26 def route_path(name, params=None, **kwargs):
26 def route_path(name, params=None, **kwargs):
27 import urllib
27 import urllib.request, urllib.parse, urllib.error
28
28
29 base_url = {
29 base_url = {
30 'edit_repo_group_perms':
30 'edit_repo_group_perms':
@@ -34,7 +34,7 b' def route_path(name, params=None, **kwar'
34 }[name].format(**kwargs)
34 }[name].format(**kwargs)
35
35
36 if params:
36 if params:
37 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
37 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
38 return base_url
38 return base_url
39
39
40
40
@@ -24,7 +24,7 b' from rhodecode.tests import assert_sessi'
24
24
25
25
26 def route_path(name, params=None, **kwargs):
26 def route_path(name, params=None, **kwargs):
27 import urllib
27 import urllib.request, urllib.parse, urllib.error
28
28
29 base_url = {
29 base_url = {
30 'edit_repo_group': '/{repo_group_name}/_edit',
30 'edit_repo_group': '/{repo_group_name}/_edit',
@@ -32,7 +32,7 b' def route_path(name, params=None, **kwar'
32 }[name].format(**kwargs)
32 }[name].format(**kwargs)
33
33
34 if params:
34 if params:
35 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
35 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
36 return base_url
36 return base_url
37
37
38
38
@@ -23,7 +23,7 b' from rhodecode.model.db import Repositor'
23
23
24
24
25 def route_path(name, params=None, **kwargs):
25 def route_path(name, params=None, **kwargs):
26 import urllib
26 import urllib.request, urllib.parse, urllib.error
27
27
28 base_url = {
28 base_url = {
29 'pullrequest_show_all': '/{repo_name}/pull-request',
29 'pullrequest_show_all': '/{repo_name}/pull-request',
@@ -31,7 +31,7 b' def route_path(name, params=None, **kwar'
31 }[name].format(**kwargs)
31 }[name].format(**kwargs)
32
32
33 if params:
33 if params:
34 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
34 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
35 return base_url
35 return base_url
36
36
37
37
@@ -23,14 +23,14 b' from rhodecode.model.db import Repositor'
23
23
24
24
25 def route_path(name, params=None, **kwargs):
25 def route_path(name, params=None, **kwargs):
26 import urllib
26 import urllib.request, urllib.parse, urllib.error
27
27
28 base_url = {
28 base_url = {
29 'bookmarks_home': '/{repo_name}/bookmarks',
29 'bookmarks_home': '/{repo_name}/bookmarks',
30 }[name].format(**kwargs)
30 }[name].format(**kwargs)
31
31
32 if params:
32 if params:
33 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
33 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
34 return base_url
34 return base_url
35
35
36
36
@@ -23,14 +23,14 b' from rhodecode.model.db import Repositor'
23
23
24
24
25 def route_path(name, params=None, **kwargs):
25 def route_path(name, params=None, **kwargs):
26 import urllib
26 import urllib.request, urllib.parse, urllib.error
27
27
28 base_url = {
28 base_url = {
29 'branches_home': '/{repo_name}/branches',
29 'branches_home': '/{repo_name}/branches',
30 }[name].format(**kwargs)
30 }[name].format(**kwargs)
31
31
32 if params:
32 if params:
33 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
33 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
34 return base_url
34 return base_url
35
35
36
36
@@ -29,7 +29,7 b' MATCH_HASH = re.compile(r\'<span class="c'
29
29
30
30
31 def route_path(name, params=None, **kwargs):
31 def route_path(name, params=None, **kwargs):
32 import urllib
32 import urllib.request, urllib.parse, urllib.error
33
33
34 base_url = {
34 base_url = {
35 'repo_changelog': '/{repo_name}/changelog',
35 'repo_changelog': '/{repo_name}/changelog',
@@ -39,7 +39,7 b' def route_path(name, params=None, **kwar'
39 }[name].format(**kwargs)
39 }[name].format(**kwargs)
40
40
41 if params:
41 if params:
42 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
42 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
43 return base_url
43 return base_url
44
44
45
45
@@ -28,7 +28,7 b' from rhodecode.lib import helpers as h'
28
28
29
29
30 def route_path(name, params=None, **kwargs):
30 def route_path(name, params=None, **kwargs):
31 import urllib
31 import urllib.request, urllib.parse, urllib.error
32
32
33 base_url = {
33 base_url = {
34 'repo_commit': '/{repo_name}/changeset/{commit_id}',
34 'repo_commit': '/{repo_name}/changeset/{commit_id}',
@@ -39,7 +39,7 b' def route_path(name, params=None, **kwar'
39 }[name].format(**kwargs)
39 }[name].format(**kwargs)
40
40
41 if params:
41 if params:
42 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
42 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
43 return base_url
43 return base_url
44
44
45
45
@@ -25,7 +25,7 b' from rhodecode.lib.helpers import _short'
25
25
26
26
27 def route_path(name, params=None, **kwargs):
27 def route_path(name, params=None, **kwargs):
28 import urllib
28 import urllib.request, urllib.parse, urllib.error
29
29
30 base_url = {
30 base_url = {
31 'repo_commit': '/{repo_name}/changeset/{commit_id}',
31 'repo_commit': '/{repo_name}/changeset/{commit_id}',
@@ -39,7 +39,7 b' def route_path(name, params=None, **kwar'
39 }[name].format(**kwargs)
39 }[name].format(**kwargs)
40
40
41 if params:
41 if params:
42 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
42 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
43 return base_url
43 return base_url
44
44
45
45
@@ -28,7 +28,7 b' from rhodecode.tests.utils import Assert'
28
28
29
29
30 def route_path(name, params=None, **kwargs):
30 def route_path(name, params=None, **kwargs):
31 import urllib
31 import urllib.request, urllib.parse, urllib.error
32
32
33 base_url = {
33 base_url = {
34 'repo_compare_select': '/{repo_name}/compare',
34 'repo_compare_select': '/{repo_name}/compare',
@@ -36,7 +36,7 b' def route_path(name, params=None, **kwar'
36 }[name].format(**kwargs)
36 }[name].format(**kwargs)
37
37
38 if params:
38 if params:
39 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
39 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
40 return base_url
40 return base_url
41
41
42
42
@@ -24,7 +24,7 b' from .test_repo_compare import ComparePa'
24
24
25
25
26 def route_path(name, params=None, **kwargs):
26 def route_path(name, params=None, **kwargs):
27 import urllib
27 import urllib.request, urllib.parse, urllib.error
28
28
29 base_url = {
29 base_url = {
30 'repo_compare_select': '/{repo_name}/compare',
30 'repo_compare_select': '/{repo_name}/compare',
@@ -32,7 +32,7 b' def route_path(name, params=None, **kwar'
32 }[name].format(**kwargs)
32 }[name].format(**kwargs)
33
33
34 if params:
34 if params:
35 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
35 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
36 return base_url
36 return base_url
37
37
38
38
@@ -30,7 +30,7 b' fixture = Fixture()'
30
30
31
31
32 def route_path(name, params=None, **kwargs):
32 def route_path(name, params=None, **kwargs):
33 import urllib
33 import urllib.request, urllib.parse, urllib.error
34
34
35 base_url = {
35 base_url = {
36 'repo_compare_select': '/{repo_name}/compare',
36 'repo_compare_select': '/{repo_name}/compare',
@@ -38,7 +38,7 b' def route_path(name, params=None, **kwar'
38 }[name].format(**kwargs)
38 }[name].format(**kwargs)
39
39
40 if params:
40 if params:
41 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
41 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
42 return base_url
42 return base_url
43
43
44
44
@@ -24,7 +24,7 b' from rhodecode.tests import TestControll'
24
24
25
25
26 def route_path(name, params=None, **kwargs):
26 def route_path(name, params=None, **kwargs):
27 import urllib
27 import urllib.request, urllib.parse, urllib.error
28
28
29 base_url = {
29 base_url = {
30 'rss_feed_home': '/{repo_name}/feed-rss',
30 'rss_feed_home': '/{repo_name}/feed-rss',
@@ -34,7 +34,7 b' def route_path(name, params=None, **kwar'
34 }[name].format(**kwargs)
34 }[name].format(**kwargs)
35
35
36 if params:
36 if params:
37 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
37 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
38 return base_url
38 return base_url
39
39
40
40
@@ -47,7 +47,7 b' def get_node_history(backend_type):'
47
47
48
48
49 def route_path(name, params=None, **kwargs):
49 def route_path(name, params=None, **kwargs):
50 import urllib
50 import urllib.request, urllib.parse, urllib.error
51
51
52 base_url = {
52 base_url = {
53 'repo_summary': '/{repo_name}',
53 'repo_summary': '/{repo_name}',
@@ -76,7 +76,7 b' def route_path(name, params=None, **kwar'
76 }[name].format(**kwargs)
76 }[name].format(**kwargs)
77
77
78 if params:
78 if params:
79 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
79 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
80 return base_url
80 return base_url
81
81
82
82
@@ -34,7 +34,7 b' fixture = Fixture()'
34
34
35
35
36 def route_path(name, params=None, **kwargs):
36 def route_path(name, params=None, **kwargs):
37 import urllib
37 import urllib.request, urllib.parse, urllib.error
38
38
39 base_url = {
39 base_url = {
40 'repo_summary': '/{repo_name}',
40 'repo_summary': '/{repo_name}',
@@ -46,7 +46,7 b' def route_path(name, params=None, **kwar'
46 }[name].format(**kwargs)
46 }[name].format(**kwargs)
47
47
48 if params:
48 if params:
49 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
49 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
50 return base_url
50 return base_url
51
51
52
52
@@ -27,7 +27,7 b' from rhodecode.model.settings import Set'
27
27
28
28
29 def route_path(name, params=None, **kwargs):
29 def route_path(name, params=None, **kwargs):
30 import urllib
30 import urllib.request, urllib.parse, urllib.error
31
31
32 base_url = {
32 base_url = {
33 'repo_summary': '/{repo_name}',
33 'repo_summary': '/{repo_name}',
@@ -38,7 +38,7 b' def route_path(name, params=None, **kwar'
38 }[name].format(**kwargs)
38 }[name].format(**kwargs)
39
39
40 if params:
40 if params:
41 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
41 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
42 return base_url
42 return base_url
43
43
44
44
@@ -33,7 +33,7 b' fixture = Fixture()'
33
33
34
34
35 def route_path(name, params=None, **kwargs):
35 def route_path(name, params=None, **kwargs):
36 import urllib
36 import urllib.request, urllib.parse, urllib.error
37
37
38 base_url = {
38 base_url = {
39 'edit_repo_maintenance': '/{repo_name}/settings/maintenance',
39 'edit_repo_maintenance': '/{repo_name}/settings/maintenance',
@@ -42,7 +42,7 b' def route_path(name, params=None, **kwar'
42 }[name].format(**kwargs)
42 }[name].format(**kwargs)
43
43
44 if params:
44 if params:
45 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
45 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
46 return base_url
46 return base_url
47
47
48
48
@@ -24,7 +24,7 b' from rhodecode.tests.utils import permis'
24
24
25
25
26 def route_path(name, params=None, **kwargs):
26 def route_path(name, params=None, **kwargs):
27 import urllib
27 import urllib.request, urllib.parse, urllib.error
28
28
29 base_url = {
29 base_url = {
30 'edit_repo_perms': '/{repo_name}/settings/permissions'
30 'edit_repo_perms': '/{repo_name}/settings/permissions'
@@ -32,7 +32,7 b' def route_path(name, params=None, **kwar'
32 }[name].format(**kwargs)
32 }[name].format(**kwargs)
33
33
34 if params:
34 if params:
35 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
35 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
36 return base_url
36 return base_url
37
37
38
38
@@ -37,7 +37,7 b' from rhodecode.tests import ('
37
37
38
38
39 def route_path(name, params=None, **kwargs):
39 def route_path(name, params=None, **kwargs):
40 import urllib
40 import urllib.request, urllib.parse, urllib.error
41
41
42 base_url = {
42 base_url = {
43 'repo_changelog': '/{repo_name}/changelog',
43 'repo_changelog': '/{repo_name}/changelog',
@@ -60,7 +60,7 b' def route_path(name, params=None, **kwar'
60 }[name].format(**kwargs)
60 }[name].format(**kwargs)
61
61
62 if params:
62 if params:
63 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
63 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
64 return base_url
64 return base_url
65
65
66
66
@@ -33,7 +33,7 b' fixture = Fixture()'
33
33
34
34
35 def route_path(name, params=None, **kwargs):
35 def route_path(name, params=None, **kwargs):
36 import urllib
36 import urllib.request, urllib.parse, urllib.error
37
37
38 base_url = {
38 base_url = {
39 'edit_repo': '/{repo_name}/settings',
39 'edit_repo': '/{repo_name}/settings',
@@ -48,7 +48,7 b' def route_path(name, params=None, **kwar'
48 }[name].format(**kwargs)
48 }[name].format(**kwargs)
49
49
50 if params:
50 if params:
51 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
51 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
52 return base_url
52 return base_url
53
53
54
54
@@ -32,7 +32,7 b' fixture = Fixture()'
32
32
33
33
34 def route_path(name, params=None, **kwargs):
34 def route_path(name, params=None, **kwargs):
35 import urllib
35 import urllib.request, urllib.parse, urllib.error
36
36
37 base_url = {
37 base_url = {
38 'repo_summary_explicit': '/{repo_name}/summary',
38 'repo_summary_explicit': '/{repo_name}/summary',
@@ -47,7 +47,7 b' def route_path(name, params=None, **kwar'
47 }[name].format(**kwargs)
47 }[name].format(**kwargs)
48
48
49 if params:
49 if params:
50 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
50 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
51 return base_url
51 return base_url
52
52
53
53
@@ -41,7 +41,7 b' fixture = Fixture()'
41
41
42
42
43 def route_path(name, params=None, **kwargs):
43 def route_path(name, params=None, **kwargs):
44 import urllib
44 import urllib.request, urllib.parse, urllib.error
45
45
46 base_url = {
46 base_url = {
47 'repo_summary': '/{repo_name}',
47 'repo_summary': '/{repo_name}',
@@ -52,7 +52,7 b' def route_path(name, params=None, **kwar'
52 }[name].format(**kwargs)
52 }[name].format(**kwargs)
53
53
54 if params:
54 if params:
55 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
55 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
56 return base_url
56 return base_url
57
57
58
58
@@ -23,14 +23,14 b' from rhodecode.model.db import Repositor'
23
23
24
24
25 def route_path(name, params=None, **kwargs):
25 def route_path(name, params=None, **kwargs):
26 import urllib
26 import urllib.request, urllib.parse, urllib.error
27
27
28 base_url = {
28 base_url = {
29 'tags_home': '/{repo_name}/tags',
29 'tags_home': '/{repo_name}/tags',
30 }[name].format(**kwargs)
30 }[name].format(**kwargs)
31
31
32 if params:
32 if params:
33 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
33 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
34 return base_url
34 return base_url
35
35
36
36
@@ -38,7 +38,7 b' fixture = Fixture()'
38
38
39
39
40 def route_path(name, params=None, **kwargs):
40 def route_path(name, params=None, **kwargs):
41 import urllib
41 import urllib.request, urllib.parse, urllib.error
42
42
43 base_url = {
43 base_url = {
44 'repo_summary': '/{repo_name}',
44 'repo_summary': '/{repo_name}',
@@ -50,7 +50,7 b' def route_path(name, params=None, **kwar'
50 }[name].format(**kwargs)
50 }[name].format(**kwargs)
51
51
52 if params:
52 if params:
53 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
53 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
54 return base_url
54 return base_url
55
55
56
56
@@ -28,7 +28,7 b' from rhodecode.tests.utils import Assert'
28
28
29
29
30 def route_path(name, params=None, **kwargs):
30 def route_path(name, params=None, **kwargs):
31 import urllib
31 import urllib.request, urllib.parse, urllib.error
32
32
33 base_url = {
33 base_url = {
34 'edit_repo': '/{repo_name}/settings',
34 'edit_repo': '/{repo_name}/settings',
@@ -37,7 +37,7 b' def route_path(name, params=None, **kwar'
37 }[name].format(**kwargs)
37 }[name].format(**kwargs)
38
38
39 if params:
39 if params:
40 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
40 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
41 return base_url
41 return base_url
42
42
43
43
@@ -24,7 +24,7 b' import os'
24 import shutil
24 import shutil
25 import tempfile
25 import tempfile
26 import collections
26 import collections
27 import urllib
27 import urllib.request, urllib.parse, urllib.error
28 import pathlib2
28 import pathlib2
29
29
30 from pyramid.httpexceptions import HTTPNotFound, HTTPBadRequest, HTTPFound
30 from pyramid.httpexceptions import HTTPNotFound, HTTPBadRequest, HTTPFound
@@ -804,7 +804,7 b' class RepoFilesView(RepoAppView):'
804 def _get_attachement_headers(self, f_path):
804 def _get_attachement_headers(self, f_path):
805 f_name = safe_str(f_path.split(Repository.NAME_SEP)[-1])
805 f_name = safe_str(f_path.split(Repository.NAME_SEP)[-1])
806 safe_path = f_name.replace('"', '\\"')
806 safe_path = f_name.replace('"', '\\"')
807 encoded_path = urllib.quote(f_name)
807 encoded_path = urllib.parse.quote(f_name)
808
808
809 return "attachment; " \
809 return "attachment; " \
810 "filename=\"{}\"; " \
810 "filename=\"{}\"; " \
@@ -19,7 +19,7 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import logging
21 import logging
22 import urllib
22 import urllib.request, urllib.parse, urllib.error
23
23
24 from webhelpers2.html.tools import update_params
24 from webhelpers2.html.tools import update_params
25
25
@@ -69,7 +69,7 b' def perform_search(request, tmpl_context'
69 'sort': search_sort
69 'sort': search_sort
70 }
70 }
71
71
72 return '?' + urllib.urlencode(query_params)
72 return '?' + urllib.parse.urlencode(query_params)
73
73
74 c = tmpl_context
74 c = tmpl_context
75 search_query = search_params.get('search_query')
75 search_query = search_params.get('search_query')
@@ -30,7 +30,7 b' fixture = Fixture()'
30
30
31
31
32 def route_path(name, params=None, **kwargs):
32 def route_path(name, params=None, **kwargs):
33 import urllib
33 import urllib.request, urllib.parse, urllib.error
34 from rhodecode.apps._base import ADMIN_PREFIX
34 from rhodecode.apps._base import ADMIN_PREFIX
35
35
36 base_url = {
36 base_url = {
@@ -48,7 +48,7 b' def route_path(name, params=None, **kwar'
48 }[name].format(**kwargs)
48 }[name].format(**kwargs)
49
49
50 if params:
50 if params:
51 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
51 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
52 return base_url
52 return base_url
53
53
54
54
@@ -24,7 +24,7 b' from rhodecode.tests.utils import permis'
24
24
25
25
26 def route_path(name, params=None, **kwargs):
26 def route_path(name, params=None, **kwargs):
27 import urllib
27 import urllib.request, urllib.parse, urllib.error
28 from rhodecode.apps._base import ADMIN_PREFIX
28 from rhodecode.apps._base import ADMIN_PREFIX
29
29
30 base_url = {
30 base_url = {
@@ -35,7 +35,7 b' def route_path(name, params=None, **kwar'
35 }[name].format(**kwargs)
35 }[name].format(**kwargs)
36
36
37 if params:
37 if params:
38 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
38 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
39 return base_url
39 return base_url
40
40
41
41
@@ -26,7 +26,7 b' RhodeCode authentication plugin for Atla'
26 import colander
26 import colander
27 import base64
27 import base64
28 import logging
28 import logging
29 import urllib2
29 import urllib.request, urllib.error, urllib.parse
30
30
31 from rhodecode.translation import _
31 from rhodecode.translation import _
32 from rhodecode.authentication.base import (
32 from rhodecode.authentication.base import (
@@ -128,10 +128,10 b' class CrowdServer(object):'
128 self._make_opener()
128 self._make_opener()
129
129
130 def _make_opener(self):
130 def _make_opener(self):
131 mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
131 mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
132 mgr.add_password(None, self._uri, self.user, self.passwd)
132 mgr.add_password(None, self._uri, self.user, self.passwd)
133 handler = urllib2.HTTPBasicAuthHandler(mgr)
133 handler = urllib.request.HTTPBasicAuthHandler(mgr)
134 self.opener = urllib2.build_opener(handler)
134 self.opener = urllib.request.build_opener(handler)
135
135
136 def _request(self, url, body=None, headers=None,
136 def _request(self, url, body=None, headers=None,
137 method=None, noformat=False,
137 method=None, noformat=False,
@@ -146,7 +146,7 b' class CrowdServer(object):'
146 log.debug("Sent crowd: \n%s"
146 log.debug("Sent crowd: \n%s"
147 % (formatted_json({"url": url, "body": body,
147 % (formatted_json({"url": url, "body": body,
148 "headers": _headers})))
148 "headers": _headers})))
149 request = urllib2.Request(url, body, _headers)
149 request = urllib.request.Request(url, body, _headers)
150 if method:
150 if method:
151 request.get_method = lambda: method
151 request.get_method = lambda: method
152
152
@@ -27,8 +27,8 b' http://www.jasig.org/cas'
27 import colander
27 import colander
28 import logging
28 import logging
29 import rhodecode
29 import rhodecode
30 import urllib
30 import urllib.request, urllib.parse, urllib.error
31 import urllib2
31 import urllib.request, urllib.error, urllib.parse
32
32
33 from rhodecode.translation import _
33 from rhodecode.translation import _
34 from rhodecode.authentication.base import (
34 from rhodecode.authentication.base import (
@@ -123,7 +123,7 b' class RhodeCodeAuthPlugin(RhodeCodeExter'
123 return None
123 return None
124
124
125 log.debug("Jasig CAS settings: %s", settings)
125 log.debug("Jasig CAS settings: %s", settings)
126 params = urllib.urlencode({'username': username, 'password': password})
126 params = urllib.parse.urlencode({'username': username, 'password': password})
127 headers = {"Content-type": "application/x-www-form-urlencoded",
127 headers = {"Content-type": "application/x-www-form-urlencoded",
128 "Accept": "text/plain",
128 "Accept": "text/plain",
129 "User-Agent": "RhodeCode-auth-%s" % rhodecode.__version__}
129 "User-Agent": "RhodeCode-auth-%s" % rhodecode.__version__}
@@ -131,13 +131,13 b' class RhodeCodeAuthPlugin(RhodeCodeExter'
131
131
132 log.debug("Sent Jasig CAS: \n%s",
132 log.debug("Sent Jasig CAS: \n%s",
133 {"url": url, "body": params, "headers": headers})
133 {"url": url, "body": params, "headers": headers})
134 request = urllib2.Request(url, params, headers)
134 request = urllib.request.Request(url, params, headers)
135 try:
135 try:
136 response = urllib2.urlopen(request)
136 response = urllib.request.urlopen(request)
137 except urllib2.HTTPError as e:
137 except urllib.error.HTTPError as e:
138 log.debug("HTTPError when requesting Jasig CAS (status code: %d)", e.code)
138 log.debug("HTTPError when requesting Jasig CAS (status code: %d)", e.code)
139 return None
139 return None
140 except urllib2.URLError as e:
140 except urllib.error.URLError as e:
141 log.debug("URLError when requesting Jasig CAS url: %s ", url)
141 log.debug("URLError when requesting Jasig CAS url: %s ", url)
142 return None
142 return None
143
143
@@ -21,7 +21,7 b' import os'
21 import string
21 import string
22 import functools
22 import functools
23 import collections
23 import collections
24 import urllib
24 import urllib.request, urllib.parse, urllib.error
25
25
26 log = logging.getLogger('rhodecode.' + __name__)
26 log = logging.getLogger('rhodecode.' + __name__)
27
27
@@ -195,5 +195,5 b' class UrlTemplate(string.Template):'
195
195
196 def safe_substitute(self, **kws):
196 def safe_substitute(self, **kws):
197 # url encode the kw for usage in url
197 # url encode the kw for usage in url
198 kws = {k: urllib.quote(str(v)) for k, v in kws.items()}
198 kws = {k: urllib.parse.quote(str(v)) for k, v in kws.items()}
199 return super(UrlTemplate, self).safe_substitute(**kws)
199 return super(UrlTemplate, self).safe_substitute(**kws)
@@ -23,7 +23,7 b' import string'
23 import collections
23 import collections
24 import logging
24 import logging
25 import requests
25 import requests
26 import urllib
26 import urllib.request, urllib.parse, urllib.error
27 from requests.adapters import HTTPAdapter
27 from requests.adapters import HTTPAdapter
28 from requests.packages.urllib3.util.retry import Retry
28 from requests.packages.urllib3.util.retry import Retry
29
29
@@ -40,7 +40,7 b' class UrlTmpl(string.Template):'
40
40
41 def safe_substitute(self, **kws):
41 def safe_substitute(self, **kws):
42 # url encode the kw for usage in url
42 # url encode the kw for usage in url
43 kws = {k: urllib.quote(safe_str(v)) for k, v in kws.items()}
43 kws = {k: urllib.parse.quote(safe_str(v)) for k, v in kws.items()}
44 return super(UrlTmpl, self).safe_substitute(**kws)
44 return super(UrlTmpl, self).safe_substitute(**kws)
45
45
46
46
@@ -31,7 +31,7 b' import math'
31 import re
31 import re
32 import sys
32 import sys
33 import time
33 import time
34 import urllib
34 import urllib.request, urllib.parse, urllib.error
35
35
36
36
37 class diff_match_patch:
37 class diff_match_patch:
@@ -1152,7 +1152,7 b' class diff_match_patch:'
1152 if op == self.DIFF_INSERT:
1152 if op == self.DIFF_INSERT:
1153 # High ascii will raise UnicodeDecodeError. Use Unicode instead.
1153 # High ascii will raise UnicodeDecodeError. Use Unicode instead.
1154 data = data.encode("utf-8")
1154 data = data.encode("utf-8")
1155 text.append("+" + urllib.quote(data, "!~*'();/?:@&=+$,# "))
1155 text.append("+" + urllib.parse.quote(data, "!~*'();/?:@&=+$,# "))
1156 elif op == self.DIFF_DELETE:
1156 elif op == self.DIFF_DELETE:
1157 text.append("-%d" % len(data))
1157 text.append("-%d" % len(data))
1158 elif op == self.DIFF_EQUAL:
1158 elif op == self.DIFF_EQUAL:
@@ -1188,7 +1188,7 b' class diff_match_patch:'
1188 # operation of this token (delete, insert, equality).
1188 # operation of this token (delete, insert, equality).
1189 param = token[1:]
1189 param = token[1:]
1190 if token[0] == "+":
1190 if token[0] == "+":
1191 param = urllib.unquote(param).decode("utf-8")
1191 param = urllib.parse.unquote(param).decode("utf-8")
1192 diffs.append((self.DIFF_INSERT, param))
1192 diffs.append((self.DIFF_INSERT, param))
1193 elif token[0] == "-" or token[0] == "=":
1193 elif token[0] == "-" or token[0] == "=":
1194 try:
1194 try:
@@ -1847,7 +1847,7 b' class diff_match_patch:'
1847 sign = text[0][0]
1847 sign = text[0][0]
1848 else:
1848 else:
1849 sign = ''
1849 sign = ''
1850 line = urllib.unquote(text[0][1:])
1850 line = urllib.parse.unquote(text[0][1:])
1851 line = line.decode("utf-8")
1851 line = line.decode("utf-8")
1852 if sign == '+':
1852 if sign == '+':
1853 # Insertion.
1853 # Insertion.
@@ -1915,5 +1915,5 b' class patch_obj:'
1915 text.append(" ")
1915 text.append(" ")
1916 # High ascii will raise UnicodeDecodeError. Use Unicode instead.
1916 # High ascii will raise UnicodeDecodeError. Use Unicode instead.
1917 data = data.encode("utf-8")
1917 data = data.encode("utf-8")
1918 text.append(urllib.quote(data, "!~*'();/?:@&=+$,# ") + "\n")
1918 text.append(urllib.parse.quote(data, "!~*'();/?:@&=+$,# ") + "\n")
1919 return "".join(text) No newline at end of file
1919 return "".join(text)
@@ -5,7 +5,7 b' Utilities for XML generation/parsing.'
5 import six
5 import six
6
6
7 from xml.sax.saxutils import XMLGenerator, quoteattr
7 from xml.sax.saxutils import XMLGenerator, quoteattr
8 from urllib import quote
8 from urllib.parse import quote
9 from rhodecode.lib.utils import safe_str, safe_unicode
9 from rhodecode.lib.utils import safe_str, safe_unicode
10
10
11
11
@@ -32,7 +32,7 b' import random'
32 import hashlib
32 import hashlib
33 import StringIO
33 import StringIO
34 import textwrap
34 import textwrap
35 import urllib
35 import urllib.request, urllib.parse, urllib.error
36 import math
36 import math
37 import logging
37 import logging
38 import re
38 import re
@@ -336,13 +336,13 b' def files_breadcrumbs(repo_name, repo_ty'
336
336
337
337
338 def files_url_data(request):
338 def files_url_data(request):
339 import urllib
339 import urllib.request, urllib.parse, urllib.error
340 matchdict = request.matchdict
340 matchdict = request.matchdict
341
341
342 if 'f_path' not in matchdict:
342 if 'f_path' not in matchdict:
343 matchdict['f_path'] = ''
343 matchdict['f_path'] = ''
344 else:
344 else:
345 matchdict['f_path'] = urllib.quote(safe_str(matchdict['f_path']))
345 matchdict['f_path'] = urllib.parse.quote(safe_str(matchdict['f_path']))
346 if 'commit_id' not in matchdict:
346 if 'commit_id' not in matchdict:
347 matchdict['commit_id'] = 'tip'
347 matchdict['commit_id'] = 'tip'
348
348
@@ -25,7 +25,7 b' SimpleHG middleware for handling mercuri'
25
25
26 import logging
26 import logging
27 import urlparse
27 import urlparse
28 import urllib
28 import urllib.request, urllib.parse, urllib.error
29
29
30 from rhodecode.lib import utils
30 from rhodecode.lib import utils
31 from rhodecode.lib.ext_json import json
31 from rhodecode.lib.ext_json import json
@@ -91,7 +91,7 b' class SimpleHg(simplevcs.SimpleVCS):'
91 if not head:
91 if not head:
92 break
92 break
93 i += 1
93 i += 1
94 chunks.append(urllib.unquote_plus(head))
94 chunks.append(urllib.parse.unquote_plus(head))
95 full_arg = ''.join(chunks)
95 full_arg = ''.join(chunks)
96 pref = 'cmds='
96 pref = 'cmds='
97 if full_arg.startswith(pref):
97 if full_arg.startswith(pref):
@@ -20,7 +20,7 b''
20
20
21 import base64
21 import base64
22 import logging
22 import logging
23 import urllib
23 import urllib.request, urllib.parse, urllib.error
24 import urlparse
24 import urlparse
25
25
26 import requests
26 import requests
@@ -124,7 +124,7 b' class SimpleSvnApp(object):'
124 def _get_url(self, svn_http_server, path):
124 def _get_url(self, svn_http_server, path):
125 svn_http_server_url = (svn_http_server or '').rstrip('/')
125 svn_http_server_url = (svn_http_server or '').rstrip('/')
126 url_path = urlparse.urljoin(svn_http_server_url + '/', (path or '').lstrip('/'))
126 url_path = urlparse.urljoin(svn_http_server_url + '/', (path or '').lstrip('/'))
127 url_path = urllib.quote(url_path, safe="/:=~+!$,;'")
127 url_path = urllib.parse.quote(url_path, safe="/:=~+!$,;'")
128 return url_path
128 return url_path
129
129
130 def _get_request_headers(self, environ):
130 def _get_request_headers(self, environ):
@@ -31,7 +31,7 b' import logging'
31 import re
31 import re
32 import sys
32 import sys
33 import time
33 import time
34 import urllib
34 import urllib.request, urllib.parse, urllib.error
35 import urlobject
35 import urlobject
36 import uuid
36 import uuid
37 import getpass
37 import getpass
@@ -433,8 +433,7 b' def get_encryption_key(config):'
433 return secret or default
433 return secret or default
434
434
435
435
436 def age(prevdate, now=None, show_short_version=False, show_suffix=True,
436 def age(prevdate, now=None, show_short_version=False, show_suffix=True, short_format=False):
437 short_format=False):
438 """
437 """
439 Turns a datetime into an age string.
438 Turns a datetime into an age string.
440 If show_short_version is True, this generates a shorter string with
439 If show_short_version is True, this generates a shorter string with
@@ -602,7 +601,7 b' def cleaned_uri(uri):'
602 :param uri:
601 :param uri:
603 :return: uri without this chars
602 :return: uri without this chars
604 """
603 """
605 return urllib.quote(uri, safe='@$:/')
604 return urllib.parse.quote(uri, safe='@$:/')
606
605
607
606
608 def credentials_filter(uri):
607 def credentials_filter(uri):
@@ -632,7 +631,7 b' def get_host_info(request):'
632
631
633 qualified_home_url = request.route_url('home')
632 qualified_home_url = request.route_url('home')
634 parsed_url = urlobject.URLObject(qualified_home_url)
633 parsed_url = urlobject.URLObject(qualified_home_url)
635 decoded_path = safe_unicode(urllib.unquote(parsed_url.path.rstrip('/')))
634 decoded_path = safe_unicode(urllib.parse.unquote(parsed_url.path.rstrip('/')))
636
635
637 return {
636 return {
638 'scheme': parsed_url.scheme,
637 'scheme': parsed_url.scheme,
@@ -644,7 +643,7 b' def get_host_info(request):'
644 def get_clone_url(request, uri_tmpl, repo_name, repo_id, repo_type, **override):
643 def get_clone_url(request, uri_tmpl, repo_name, repo_id, repo_type, **override):
645 qualified_home_url = request.route_url('home')
644 qualified_home_url = request.route_url('home')
646 parsed_url = urlobject.URLObject(qualified_home_url)
645 parsed_url = urlobject.URLObject(qualified_home_url)
647 decoded_path = safe_unicode(urllib.unquote(parsed_url.path.rstrip('/')))
646 decoded_path = safe_unicode(urllib.parse.unquote(parsed_url.path.rstrip('/')))
648
647
649 args = {
648 args = {
650 'scheme': parsed_url.scheme,
649 'scheme': parsed_url.scheme,
@@ -659,7 +658,7 b' def get_clone_url(request, uri_tmpl, rep'
659 'repo_type': repo_type
658 'repo_type': repo_type
660 }
659 }
661 args.update(override)
660 args.update(override)
662 args['user'] = urllib.quote(safe_str(args['user']))
661 args['user'] = urllib.parse.quote(safe_str(args['user']))
663
662
664 for k, v in args.items():
663 for k, v in args.items():
665 uri_tmpl = uri_tmpl.replace('{%s}' % k, v)
664 uri_tmpl = uri_tmpl.replace('{%s}' % k, v)
@@ -24,7 +24,7 b' HG repository module'
24 import os
24 import os
25 import logging
25 import logging
26 import binascii
26 import binascii
27 import urllib
27 import urllib.request, urllib.parse, urllib.error
28
28
29 from zope.cachedescriptors.property import Lazy as LazyProperty
29 from zope.cachedescriptors.property import Lazy as LazyProperty
30
30
@@ -427,7 +427,7 b' class MercurialRepository(BaseRepository'
427 """
427 """
428 url = url.encode('utf8')
428 url = url.encode('utf8')
429 if url != 'default' and '://' not in url:
429 if url != 'default' and '://' not in url:
430 url = "file:" + urllib.pathname2url(url)
430 url = "file:" + urllib.request.pathname2url(url)
431 return url
431 return url
432
432
433 def get_hook_location(self):
433 def get_hook_location(self):
@@ -24,7 +24,7 b' SVN repository module'
24
24
25 import logging
25 import logging
26 import os
26 import os
27 import urllib
27 import urllib.request, urllib.parse, urllib.error
28
28
29 from zope.cachedescriptors.property import Lazy as LazyProperty
29 from zope.cachedescriptors.property import Lazy as LazyProperty
30
30
@@ -234,7 +234,7 b' class SubversionRepository(base.BaseRepo'
234 """
234 """
235 # convert to URL if it's a local directory
235 # convert to URL if it's a local directory
236 if os.path.isdir(url):
236 if os.path.isdir(url):
237 url = 'file://' + urllib.pathname2url(url)
237 url = 'file://' + urllib.request.pathname2url(url)
238 return connection.Svn.check_url(url, config.serialize())
238 return connection.Svn.check_url(url, config.serialize())
239
239
240 @staticmethod
240 @staticmethod
@@ -366,5 +366,5 b' class SubversionRepository(base.BaseRepo'
366
366
367 def _sanitize_url(url):
367 def _sanitize_url(url):
368 if '://' not in url:
368 if '://' not in url:
369 url = 'file://' + urllib.pathname2url(url)
369 url = 'file://' + urllib.request.pathname2url(url)
370 return url
370 return url
@@ -26,7 +26,7 b' import copy'
26 import logging
26 import logging
27 import threading
27 import threading
28 import time
28 import time
29 import urllib2
29 import urllib.request, urllib.error, urllib.parse
30 import urlparse
30 import urlparse
31 import uuid
31 import uuid
32 import traceback
32 import traceback
@@ -50,7 +50,7 b' log = logging.getLogger(__name__)'
50 # HTTPApplication.ALLOWED_EXCEPTIONS
50 # HTTPApplication.ALLOWED_EXCEPTIONS
51 EXCEPTIONS_MAP = {
51 EXCEPTIONS_MAP = {
52 'KeyError': KeyError,
52 'KeyError': KeyError,
53 'URLError': urllib2.URLError,
53 'URLError': urllib.error.URLError,
54 }
54 }
55
55
56
56
@@ -23,7 +23,7 b' Custom vcs exceptions module.'
23 """
23 """
24 import logging
24 import logging
25 import functools
25 import functools
26 import urllib2
26 import urllib.request, urllib.error, urllib.parse
27 import rhodecode
27 import rhodecode
28
28
29 log = logging.getLogger(__name__)
29 log = logging.getLogger(__name__)
@@ -166,7 +166,7 b' class UnhandledException(VCSError):'
166 'unhandled': UnhandledException,
166 'unhandled': UnhandledException,
167 # TODO: johbo: Define our own exception for this and stop abusing
167 # TODO: johbo: Define our own exception for this and stop abusing
168 # urllib's exception class.
168 # urllib's exception class.
169 'url_error': urllib2.URLError,
169 'url_error': urllib.error.URLError,
170 'subrepo_merge_error': SubrepoMergeError,
170 'subrepo_merge_error': SubrepoMergeError,
171 }
171 }
172
172
@@ -29,7 +29,7 b' import logging'
29 import os
29 import os
30
30
31 import datetime
31 import datetime
32 import urllib
32 import urllib.request, urllib.parse, urllib.error
33 import collections
33 import collections
34
34
35 from pyramid.threadlocal import get_current_request
35 from pyramid.threadlocal import get_current_request
@@ -1597,7 +1597,7 b' class PullRequestModel(BaseModel):'
1597 if pull_request.is_closed():
1597 if pull_request.is_closed():
1598 return None
1598 return None
1599 else:
1599 else:
1600 pr_url = urllib.unquote(self.get_url(pull_request, request=request))
1600 pr_url = urllib.parse.unquote(self.get_url(pull_request, request=request))
1601 return safe_unicode('{pr_url}/repository'.format(pr_url=pr_url))
1601 return safe_unicode('{pr_url}/repository'.format(pr_url=pr_url))
1602
1602
1603 def _notify_reviewers(self, pull_request, user_ids, role, user):
1603 def _notify_reviewers(self, pull_request, user_ids, role, user):
@@ -19,7 +19,7 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import logging
21 import logging
22 import urllib2
22 import urllib.request, urllib.error, urllib.parse
23 from packaging.version import Version
23 from packaging.version import Version
24
24
25 import rhodecode
25 import rhodecode
@@ -41,7 +41,7 b' class UpdateModel(BaseModel):'
41 """Return the JSON update data."""
41 """Return the JSON update data."""
42 ver = rhodecode.__version__
42 ver = rhodecode.__version__
43 log.debug('Checking for upgrade on `%s` server', update_url)
43 log.debug('Checking for upgrade on `%s` server', update_url)
44 opener = urllib2.build_opener()
44 opener = urllib.request.build_opener()
45 opener.addheaders = [('User-agent', 'RhodeCode-SCM/%s' % ver)]
45 opener.addheaders = [('User-agent', 'RhodeCode-SCM/%s' % ver)]
46 response = opener.open(update_url)
46 response = opener.open(update_url)
47 response_data = response.read()
47 response_data = response.read()
@@ -246,10 +246,10 b' def no_newline_id_generator(test_name):'
246
246
247
247
248 def route_path_generator(url_defs, name, params=None, **kwargs):
248 def route_path_generator(url_defs, name, params=None, **kwargs):
249 import urllib
249 import urllib.request, urllib.parse, urllib.error
250
250
251 base_url = url_defs[name].format(**kwargs)
251 base_url = url_defs[name].format(**kwargs)
252
252
253 if params:
253 if params:
254 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
254 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
255 return base_url
255 return base_url
@@ -25,7 +25,7 b' from rhodecode.tests.fixture import Fixt'
25
25
26
26
27 def route_path(name, params=None, **kwargs):
27 def route_path(name, params=None, **kwargs):
28 import urllib
28 import urllib.request, urllib.parse, urllib.error
29 from rhodecode.apps._base import ADMIN_PREFIX
29 from rhodecode.apps._base import ADMIN_PREFIX
30
30
31 base_url = {
31 base_url = {
@@ -46,7 +46,7 b' def route_path(name, params=None, **kwar'
46 }[name].format(**kwargs)
46 }[name].format(**kwargs)
47
47
48 if params:
48 if params:
49 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
49 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
50 return base_url
50 return base_url
51
51
52
52
@@ -35,7 +35,7 b' import subprocess32'
35 import sys
35 import sys
36 import time
36 import time
37 import traceback
37 import traceback
38 import urllib
38 import urllib.request, urllib.parse, urllib.error
39
39
40 PROFILING_INTERVAL = 5
40 PROFILING_INTERVAL = 5
41 RC_WEBSITE = "http://localhost:5001/"
41 RC_WEBSITE = "http://localhost:5001/"
@@ -130,7 +130,7 b' rc.stdin.write("y\\n")'
130 # Verify that the website is up
130 # Verify that the website is up
131 time.sleep(4)
131 time.sleep(4)
132 try:
132 try:
133 urllib.urlopen(RC_WEBSITE)
133 urllib.request.urlopen(RC_WEBSITE)
134 except IOError:
134 except IOError:
135 print("RC - Website not started")
135 print("RC - Website not started")
136 vcs.terminate()
136 vcs.terminate()
@@ -28,8 +28,8 b' watch -n1 ./rhodecode/tests/mem_watch'
28
28
29
29
30 import cookielib
30 import cookielib
31 import urllib
31 import urllib.request, urllib.parse, urllib.error
32 import urllib2
32 import urllib.request, urllib.error, urllib.parse
33 import time
33 import time
34 import os
34 import os
35 import sys
35 import sys
@@ -66,13 +66,13 b' PROJECTS = ['
66
66
67
67
68 cj = cookielib.FileCookieJar('/tmp/rc_test_cookie.txt')
68 cj = cookielib.FileCookieJar('/tmp/rc_test_cookie.txt')
69 o = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
69 o = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
70 o.addheaders = [
70 o.addheaders = [
71 ('User-agent', 'rhodecode-crawler'),
71 ('User-agent', 'rhodecode-crawler'),
72 ('Accept-Language', 'en - us, en;q = 0.5')
72 ('Accept-Language', 'en - us, en;q = 0.5')
73 ]
73 ]
74
74
75 urllib2.install_opener(o)
75 urllib.request.install_opener(o)
76
76
77
77
78 def _get_repo(proj):
78 def _get_repo(proj):
@@ -94,7 +94,7 b' def test_changelog_walk(proj, pages=100)'
94
94
95 page = '/'.join((proj, 'changelog',))
95 page = '/'.join((proj, 'changelog',))
96
96
97 full_uri = (BASE_URI % page) + '?' + urllib.urlencode({'page': i})
97 full_uri = (BASE_URI % page) + '?' + urllib.parse.urlencode({'page': i})
98 s = time.time()
98 s = time.time()
99 f = o.open(full_uri)
99 f = o.open(full_uri)
100
100
@@ -26,8 +26,8 b' import pytest'
26 import subprocess32
26 import subprocess32
27 import configobj
27 import configobj
28 import logging
28 import logging
29
29 from urllib.request import urlopen
30 from urllib2 import urlopen, URLError
30 from urllib.error import URLError
31 from pyramid.compat import configparser
31 from pyramid.compat import configparser
32
32
33
33
@@ -24,11 +24,11 b' import logging'
24 import os.path
24 import os.path
25 import subprocess32
25 import subprocess32
26 import tempfile
26 import tempfile
27 import urllib2
27 import urllib.request, urllib.error, urllib.parse
28 from lxml.html import fromstring, tostring
28 from lxml.html import fromstring, tostring
29 from lxml.cssselect import CSSSelector
29 from lxml.cssselect import CSSSelector
30 from urlparse import urlparse, parse_qsl
30 from urlparse import urlparse, parse_qsl
31 from urllib import unquote_plus
31 from urllib.parse import unquote_plus
32 import webob
32 import webob
33
33
34 from webtest.app import TestResponse, TestApp, string_types
34 from webtest.app import TestResponse, TestApp, string_types
@@ -390,8 +390,8 b' def wait_for_url(url, timeout=10):'
390
390
391 def is_url_reachable(url):
391 def is_url_reachable(url):
392 try:
392 try:
393 urllib2.urlopen(url)
393 urllib.request.urlopen(url)
394 except urllib2.URLError:
394 except urllib.error.URLError:
395 log.exception('URL `{}` reach error'.format(url))
395 log.exception('URL `{}` reach error'.format(url))
396 return False
396 return False
397 return True
397 return True
@@ -19,7 +19,7 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import datetime
21 import datetime
22 from urllib2 import URLError
22 from urllib.error import URLError
23
23
24 import mock
24 import mock
25 import pytest
25 import pytest
General Comments 0
You need to be logged in to leave comments. Login now