From: Ila Date: Sun, 19 May 2019 21:01:03 +0000 (+0200) Subject: migrating from py2 to py3 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=9d580b636a142f062a4dd2faa5c8214eaf5bc3a7;p=pgperffarm.git migrating from py2 to py3 --- 9d580b636a142f062a4dd2faa5c8214eaf5bc3a7 diff --cc README.rst index 4bb5911,05c7c57..0ad0d43 --- a/README.rst +++ b/README.rst @@@ -5,7 -5,6 +5,10 @@@ This repository contains the code for t IMPORTANT: migrating from Python2 to Python3 is in progress, hence why code might not work - for any issues feel free to contact @ila at ilaria.battiston@gmail.com ++<<<<<<< HEAD + ++======= ++>>>>>>> refs/remotes/origin/master web/ ---- diff --cc report.md index 553530b,553530b..d9ae1c3 --- a/report.md +++ b/report.md @@@ -1,8 -1,8 +1,14 @@@ # Google Summer of Code 2019 - report --Introduction - todo ++The 2019 Google Summer of Code project consists in working on the Develop Performance Farm Database and Website, work in progress from 2018. The current application has been built on Python and its module Django, but is missing some features: ++* Authentication/authorization tied into the community infrastructure; ++* Associating test systems with users to upload results to the REST API; ++* ++In the meanwhile, testing is being made with manually created accounts, ++ ++The system is being developed using Debian 9 and OSX Mojave. @@@ -10,26 -10,26 +16,26 @@@ #### Migrating from Python2.7 to Python3 --Since Python2.7 is no longer going to be maintained in 2020, the community agrees that migrating is necessary. The latest stable version of Python is Python3.6, and Python3.7 has had some issues with older versions of Django, hence I am going to use the first. ++Since Python2.7 is no longer going to be maintained in 2020, the community agrees that migrating is necessary. The latest stable version of Python is Python3.6, and Python3.7 has had some issues with older versions of Django, hence I am going to use the first if I find bugs. The major changes encountered are: * `import` syntax; ++* `print` syntax; * Manually compiled requirements with pip3; * Upgraded the Django version (see below); --* General syntax changes (WIP); * Error while installing psycopg2: * `env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2` on Mac, with Xcode developer tools and openssl; Changes have been added to `requirements.txt`. --TODO: continue making migrations using Python3.6, debugging and fixing the code. ++Everything works so far: migrations have no issues, yet there are a couple warnings when accessing the server from browser - I will look into that. #### Django version --Using Django1.11 is recommended because the authentication module is on a Django application, so there might be incompatibilies. The version has nonetheless being updated from 1.11.10 to 1.11.17, because the older one has bugs concerning Python3. ++Using Django1.11 is recommended because the authentication module is on a Django application, so there might be incompatibilies. The version has nonetheless being updated from 1.11.10 to 1.11.17, since the older one has bugs concerning Python3. diff --cc web/apps/test_records/serializer.py index 5decb02,5decb02..99759cd --- a/web/apps/test_records/serializer.py +++ b/web/apps/test_records/serializer.py @@@ -246,7 -246,7 +246,7 @@@ class TestStatusRecordListSerializer(se if (data_list_count == trend['none']): trend['is_first'] = True -- print str(data_list_count) ++ print(str(data_list_count)) return trend def get_machine_info(self, obj): @@@ -306,7 -306,7 +306,7 @@@ class TestRecordListSerializer(serializ if (data_list_count == trend['none']): trend['is_first'] = True -- print str(data_list_count) ++ print(str(data_list_count)) return trend def get_machine_info(self, obj): diff --cc web/apps/test_records/views.py index d09484b,d09484b..f681568 --- a/web/apps/test_records/views.py +++ b/web/apps/test_records/views.py @@@ -7,9 -7,9 +7,9 @@@ import shortuui from django.contrib.auth.hashers import make_password from rest_framework.pagination import PageNumberPagination --from exception import TestDataUploadError --from test_records.filters import TestRecordListFilter --from models import UserMachine, TestCategory, TestBranch ++from .exception import TestDataUploadError ++from .filters import TestRecordListFilter ++from .models import UserMachine, TestCategory, TestBranch from pgperffarm.settings import DB_ENUM from user_operation.views import UserMachinePermission from .serializer import MachineHistoryRecordSerializer, TestStatusRecordListSerializer, TestBranchSerializer, \ @@@ -115,7 -115,7 +115,7 @@@ def TestRecordCreate(request, format=No print(request.__str__()) data = request.data -- print type(data[0]) ++ print(type(data[0])) json_data = json.dumps(data[0], encoding="UTF-8", ensure_ascii=False) json_data = json.loads(json_data, encoding="UTF-8") # obj = data[0].pgbench @@@ -211,11 -211,11 +211,11 @@@ if not test_cate: continue else: -- print test_cate.cate_name ++ print(test_cate.cate_name) for scale, dataset_list in tag_list.iteritems(): -- print "ro[%s]=" % scale, dataset_list ++ print("ro[%s]=" % scale, dataset_list) for client_num, dataset in dataset_list.iteritems(): -- print 'std is:' + str(dataset['std']) ++ print('std is:' + str(dataset['std'])) test_dataset_data = { 'test_record': testRecordRet.id, @@@ -232,7 -232,7 +232,7 @@@ testDateSet = CreateTestDateSetSerializer(data=test_dataset_data) testDateSetRet = None if testDateSet.is_valid(): -- print 'dataset valid' ++ print('dataset valid') testDateSetRet = testDateSet.save() else: # print(testDateSet.errors) @@@ -248,7 -248,7 +248,7 @@@ testResultRet = None if testResult.is_valid(): -- print 'testResult valid' ++ print('testResult valid') testResultRet = testResult.save() else: # print(testResult.error_messages) diff --cc web/apps/user_operation/filters.py index d429d96,d429d96..a61ac8e --- a/web/apps/user_operation/filters.py +++ b/web/apps/user_operation/filters.py @@@ -3,7 -3,7 +3,7 @@@ import django_filters from django.db.models import Q --from models import UserMachine ++from .models import UserMachine from test_records.models import TestRecord diff --cc web/apps/user_operation/views.py index e7641cf,e7641cf..43696f6 --- a/web/apps/user_operation/views.py +++ b/web/apps/user_operation/views.py @@@ -8,11 -8,11 +8,11 @@@ from rest_framework import authenticati from rest_framework.pagination import PageNumberPagination from rest_framework_jwt.authentication import JSONWebTokenAuthentication --from filters import MachineRecordListFilter, UserMachineListFilter ++from .filters import MachineRecordListFilter, UserMachineListFilter from test_records.models import TestRecord from users.models import UserMachine, UserProfile from users.serializer import CreateUserProfileSerializer --from serializer import UserMachineManageSerializer, UserPortalInfoSerializer, TestRecordListSerializer, \ ++from .serializer import UserMachineManageSerializer, UserPortalInfoSerializer, TestRecordListSerializer, \ UserMachineSerializer, CreateUserMachineSerializer from rest_framework.response import Response from rest_framework import status