Projet

Général

Profil

0001-python3-adapt-hobo_deploy-36273.patch

Christophe Siraut, 20 septembre 2019 09:39

Télécharger (3,98 ko)

Voir les différences:

Subject: [PATCH] python3: adapt hobo_deploy (#36273)

 hobo/agent/common/management/commands/hobo_deploy.py | 4 ++--
 hobo/environment/models.py                           | 3 ++-
 hobo/profile/models.py                               | 3 ++-
 tests/test_hobo_deploy.py                            | 8 ++++++--
 4 files changed, 12 insertions(+), 6 deletions(-)
hobo/agent/common/management/commands/hobo_deploy.py
6 6
import subprocess
7 7
import sys
8 8
import tempfile
9
import urlparse
10 9

  
11 10
from django.conf import settings
12 11
from django.core.management.base import BaseCommand, CommandError
13 12
from django.core.management import call_command, get_commands
13
from django.utils.six.moves.urllib import parse as urlparse
14 14

  
15 15
from tenant_schemas.utils import tenant_context
16 16
from hobo.multitenant.middleware import TenantMiddleware, TenantNotFound
......
65 65
            if json_filename == '-':
66 66
                hobo_environment = json.load(sys.stdin)
67 67
            else:
68
                hobo_environment = json.load(file(json_filename))
68
                hobo_environment = json.load(open(json_filename))
69 69
            self.deploy(base_url, hobo_environment, ignore_timestamp)
70 70

  
71 71
    def deploy(self, base_url, hobo_environment, ignore_timestamp):
hobo/environment/models.py
15 15
from django.utils.translation import ugettext_lazy as _
16 16
from django.core.exceptions import ValidationError
17 17
from django.core.validators import URLValidator
18
from django.utils.six import text_type
18 19

  
19 20
from django.contrib.contenttypes.models import ContentType
20 21
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
......
120 121

  
121 122
    def as_dict(self):
122 123
        as_dict = dict([(x, y) for (x, y) in self.__dict__.items()
123
                        if type(y) in (int, str, unicode)])
124
                        if type(y) in (int, str, text_type)])
124 125
        as_dict['base_url'] = self.get_base_url_path()
125 126
        as_dict['service-id'] = self.Extra.service_id
126 127
        as_dict['service-label'] = force_text(self.Extra.service_label)
hobo/profile/models.py
17 17
from django.core.validators import RegexValidator
18 18
from django.db import models
19 19
from django.utils.translation import ugettext_lazy as _
20
from django.utils.six import text_type
20 21

  
21 22

  
22 23
validate_attribute_name = RegexValidator(
......
68 69

  
69 70
    def as_dict(self):
70 71
        as_dict = dict([(x, y) for (x, y) in self.__dict__.items()
71
                        if type(y) in (str, unicode, bool)])
72
                        if type(y) in (str, text_type, bool)])
72 73
        return as_dict
73 74

  
74 75
    def get_real_kind_display(self):
tests/test_hobo_deploy.py
1 1
""" unit tests (mainly for code coverage)
2 2
"""
3
import StringIO
3
from django.utils.six.moves import StringIO
4
from django.utils import six
4 5
import os
5 6
import sys
6 7

  
7 8
import json
8 9
import pytest
9
from mock import call, patch, Mock
10
if six.PY3:
11
    from unittest.mock import call, patch, Mock
12
else:
13
    from mock import call, patch, Mock
10 14
from requests import Response, exceptions
11 15

  
12 16
from hobo.agent.common.management.commands.hobo_deploy import (
13
-