Commit 87af6a56 authored by Stevan Radakovic's avatar Stevan Radakovic Committed by Neil Williams
Browse files

LAVA-1169 - Support xmlrpc.client imports in python3

Support xmlrpclib client api in python3

Change-Id: Ib714af997d6d81fa4f66f49a4d0b9cae4af77746
parent e24865f3
......@@ -23,11 +23,11 @@ XMP-RPC API
import datetime
import logging
import re
import xmlrpclib
import hashlib
import json
import os
import subprocess
import sys
from django.contrib.auth.models import User, Group
from django.core.urlresolvers import reverse
from django.db import IntegrityError
......@@ -41,6 +41,13 @@ from lava_scheduler_app.models import (
TestJob,
)
if sys.version_info[0] == 2:
# Python 2.x
import xmlrpclib
elif sys.version_info[0] == 3:
# For Python 3.0 and later
import xmlrpc.client as xmlrpclib
class errors:
"""
......
......@@ -18,8 +18,8 @@
import csv
import io
import xmlrpclib
import yaml
import sys
from linaro_django_xmlrpc.models import ExposedAPI
......@@ -38,6 +38,13 @@ from lava_results_app.models import (
)
from lava_scheduler_app.models import TestJob
if sys.version_info[0] == 2:
# Python 2.x
import xmlrpclib
elif sys.version_info[0] == 3:
# For Python 3.0 and later
import xmlrpc.client as xmlrpclib
class ResultsAPI(ExposedAPI):
......
from functools import wraps
from simplejson import JSONDecodeError
import xmlrpclib
import yaml
import sys
from django.conf import settings
from django.core.exceptions import PermissionDenied
......@@ -28,6 +28,13 @@ from lava_scheduler_app.schema import (
SubmissionException,
)
if sys.version_info[0] == 2:
# Python 2.x
import xmlrpclib
elif sys.version_info[0] == 3:
# For Python 3.0 and later
import xmlrpc.client as xmlrpclib
# functions need to be members to be exposed in the API
# pylint: disable=no-self-use
......
......@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with Lava Server. If not, see <http://www.gnu.org/licenses/>.
import xmlrpclib
import sys
from django.db import IntegrityError
......@@ -24,6 +24,13 @@ from linaro_django_xmlrpc.models import ExposedV2API
from lava_scheduler_app.api import check_superuser
from lava_scheduler_app.models import Alias
if sys.version_info[0] == 2:
# Python 2.x
import xmlrpclib
elif sys.version_info[0] == 3:
# For Python 3.0 and later
import xmlrpc.client as xmlrpclib
class SchedulerAliasesAPI(ExposedV2API):
......
......@@ -18,7 +18,7 @@
import glob
import os
import xmlrpclib
import sys
from django.db import IntegrityError
......@@ -26,6 +26,13 @@ from linaro_django_xmlrpc.models import ExposedV2API
from lava_scheduler_app.api import check_superuser
from lava_scheduler_app.models import Alias, DeviceType
if sys.version_info[0] == 2:
# Python 2.x
import xmlrpclib
elif sys.version_info[0] == 3:
# For Python 3.0 and later
import xmlrpc.client as xmlrpclib
class SchedulerDeviceTypesAPI(ExposedV2API):
......
......@@ -16,8 +16,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with Lava Server. If not, see <http://www.gnu.org/licenses/>.
import xmlrpclib
import yaml
import sys
from django.contrib.auth.models import User, Group
from django.core.exceptions import ValidationError
......@@ -34,6 +34,13 @@ from lava_scheduler_app.models import (
Worker
)
if sys.version_info[0] == 2:
# Python 2.x
import xmlrpclib
elif sys.version_info[0] == 3:
# For Python 3.0 and later
import xmlrpc.client as xmlrpclib
class SchedulerDevicesAPI(ExposedV2API):
......
......@@ -17,12 +17,19 @@
# along with Lava Server. If not, see <http://www.gnu.org/licenses/>.
import os
import xmlrpclib
import sys
from linaro_django_xmlrpc.models import ExposedV2API
from lava_scheduler_app.api import SchedulerAPI
from lava_scheduler_app.models import TestJob
if sys.version_info[0] == 2:
# Python 2.x
import xmlrpclib
elif sys.version_info[0] == 3:
# For Python 3.0 and later
import xmlrpc.client as xmlrpclib
class SchedulerJobsAPI(ExposedV2API):
......
......@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with Lava Server. If not, see <http://www.gnu.org/licenses/>.
import xmlrpclib
import sys
from django.db import IntegrityError
......@@ -24,6 +24,13 @@ from linaro_django_xmlrpc.models import ExposedV2API
from lava_scheduler_app.api import check_superuser
from lava_scheduler_app.models import Tag
if sys.version_info[0] == 2:
# Python 2.x
import xmlrpclib
elif sys.version_info[0] == 3:
# For Python 3.0 and later
import xmlrpc.client as xmlrpclib
class SchedulerTagsAPI(ExposedV2API):
......
......@@ -17,7 +17,7 @@
# along with Lava Server. If not, see <http://www.gnu.org/licenses/>.
import os
import xmlrpclib
import sys
from django.db import IntegrityError
......@@ -25,6 +25,13 @@ from linaro_django_xmlrpc.models import ExposedV2API
from lava_scheduler_app.api import check_superuser
from lava_scheduler_app.models import Worker
if sys.version_info[0] == 2:
# Python 2.x
import xmlrpclib
elif sys.version_info[0] == 3:
# For Python 3.0 and later
import xmlrpc.client as xmlrpclib
class SchedulerWorkersAPI(ExposedV2API):
......
......@@ -4,7 +4,6 @@ import yaml
import json
import logging
import cStringIO
import xmlrpclib
import unittest
from django.test import TransactionTestCase
from django.test.client import Client
......@@ -27,6 +26,13 @@ from lava_scheduler_app.dbutils import (
from lava_scheduler_app.tests.test_submission import ModelFactory, TestCaseWithFactory
# pylint: disable=invalid-name
if sys.version_info[0] == 2:
# Python 2.x
import xmlrpclib
elif sys.version_info[0] == 3:
# For Python 3.0 and later
import xmlrpc.client as xmlrpclib
# Based on http://www.technobabble.dk/2008/apr/02/xml-rpc-dispatching-through-django-test-client/
class TestTransport(xmlrpclib.Transport, object):
......
......@@ -19,8 +19,8 @@
import os
import subprocess
import sys
import yaml
import xmlrpclib
from django.http import Http404
......@@ -29,6 +29,13 @@ from lava_scheduler_app.views import get_restricted_job
from lava_scheduler_app.models import Device, DeviceType
from linaro_django_xmlrpc.models import errors, Mapper, SystemAPI
if sys.version_info[0] == 2:
# Python 2.x
import xmlrpclib
elif sys.version_info[0] == 3:
# For Python 3.0 and later
import xmlrpc.client as xmlrpclib
class LavaSystemAPI(SystemAPI):
"""
......
......@@ -24,12 +24,19 @@ import inspect
import logging
import pydoc
import random
import xmlrpclib
import sys
from django.contrib.auth.models import AnonymousUser, User
from django.db import models
from django.utils import timezone
if sys.version_info[0] == 2:
# Python 2.x
import xmlrpclib
elif sys.version_info[0] == 3:
# For Python 3.0 and later
import xmlrpc.client as xmlrpclib
class errors:
"""
......
......@@ -21,7 +21,7 @@ Unit tests for Linaro Django XML-RPC Application
"""
import re
import logging
import xmlrpclib
import sys
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
......@@ -38,6 +38,13 @@ from linaro_django_xmlrpc.models import (
xml_rpc_signature,
)
if sys.version_info[0] == 2:
# Python 2.x
import xmlrpclib
elif sys.version_info[0] == 3:
# For Python 3.0 and later
import xmlrpc.client as xmlrpclib
class MockUser(object):
"""
......
......@@ -37,6 +37,7 @@ import sys
if sys.version > '3':
import xmlrpc.client as xmlrpclib
else:
# Python 2.x
import xmlrpclib
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment