agent: adapt for python3 (#36273)
This commit is contained in:
parent
661a526109
commit
d49e9def72
|
@ -6,11 +6,11 @@ import requests
|
|||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import urlparse
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.core.management import call_command, get_commands
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
|
||||
from tenant_schemas.utils import tenant_context
|
||||
from hobo.multitenant.middleware import TenantMiddleware, TenantNotFound
|
||||
|
@ -65,7 +65,7 @@ class Command(BaseCommand):
|
|||
if json_filename == '-':
|
||||
hobo_environment = json.load(sys.stdin)
|
||||
else:
|
||||
hobo_environment = json.load(file(json_filename))
|
||||
hobo_environment = json.load(open(json_filename))
|
||||
self.deploy(base_url, hobo_environment, ignore_timestamp)
|
||||
|
||||
def deploy(self, base_url, hobo_environment, ignore_timestamp):
|
||||
|
@ -135,7 +135,7 @@ class Command(BaseCommand):
|
|||
continue
|
||||
tenant_idp_metadata = os.path.join(tenant.get_directory(),
|
||||
'idp-metadata-%s.xml' % service.get('id'))
|
||||
replace_file(tenant_idp_metadata, response.content)
|
||||
replace_file(tenant_idp_metadata, response.text)
|
||||
# break now, only a single IdP is supported
|
||||
break
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class Command(BaseCommand):
|
|||
# get environment definition from stdin
|
||||
return json.load(sys.stdin)
|
||||
else:
|
||||
return json.load(file(notification))
|
||||
return json.load(open(notification))
|
||||
|
||||
def handle(self, notification, **kwargs):
|
||||
notification = self.load_notification(notification)
|
||||
|
|
|
@ -86,7 +86,7 @@ def test_handle_from_scratch():
|
|||
|
||||
# handle from file
|
||||
command.deploy.reset_mock()
|
||||
with patch('hobo.agent.common.management.commands.hobo_deploy.file') as mocked_open:
|
||||
with patch('hobo.agent.common.management.commands.hobo_deploy.open') as mocked_open:
|
||||
mocked_open.side_effect = [StringIO.StringIO(CONTENT)]
|
||||
command.handle('https://combo.dev.publik.love/', 'envbof.json')
|
||||
assert command.deploy.mock_calls == EXPECTED
|
||||
|
@ -101,7 +101,7 @@ def test_handle_from_scratch():
|
|||
|
||||
# JSON having syntax error
|
||||
command.deploy.reset_mock()
|
||||
with patch('hobo.agent.common.management.commands.hobo_deploy.file') as mocked_open:
|
||||
with patch('hobo.agent.common.management.commands.hobo_deploy.open') as mocked_open:
|
||||
mocked_open.side_effect = [StringIO.StringIO('malformated JSON')]
|
||||
with pytest.raises(ValueError, match='No JSON object could be decoded'):
|
||||
command.handle('https://combo.dev.publik.love/', 'env.json')
|
||||
|
|
Loading…
Reference in New Issue