migrating from py2 to py3
authorIla <ilaria.battiston@gmail.com>
Sun, 19 May 2019 21:01:03 +0000 (23:01 +0200)
committerIla <ilaria.battiston@gmail.com>
Sun, 19 May 2019 21:01:03 +0000 (23:01 +0200)
1  2 
README.rst
report.md
web/apps/test_records/serializer.py
web/apps/test_records/views.py
web/apps/user_operation/filters.py
web/apps/user_operation/views.py

diff --cc README.rst
index 4bb591189c9fd651d5e519b87818e17ebdd3dbdf,05c7c5738aceb945ab4b4df922cadec61042c412..0ad0d43881761877029e3f6004c9572c0e6cf2db
@@@ -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 553530b3c5f4346080622791191e0b3ec2a44793,553530b3c5f4346080622791191e0b3ec2a44793..d9ae1c3a1a250cf7007713237ecaff533ca17006
+++ 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.
  
  
  
  
  #### 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.
  
  
  
index 5decb02e4476fd55551e7da9ece48dbc9b8a1284,5decb02e4476fd55551e7da9ece48dbc9b8a1284..99759cd8536c7791edea6a716bf3229b84962ba2
@@@ -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):
index d09484b7cb615e7fdb91bf73733af6e7eb6bf600,d09484b7cb615e7fdb91bf73733af6e7eb6bf600..f6815681ad278c44d4d816be67feedcf66c2d7a6
@@@ -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
                  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,
                          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)
  
                              testResultRet = None
                              if testResult.is_valid():
--                                print 'testResult valid'
++                                print('testResult valid')
                                  testResultRet = testResult.save()
                              else:
                                  # print(testResult.error_messages)
index d429d96f22f5c1806a644d6925035e82e85ebfb8,d429d96f22f5c1806a644d6925035e82e85ebfb8..a61ac8e346145a2006ec373f591bb42ef8ddb8fa
@@@ -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
  
  
index e7641cf8a4785903249bb8fd401d03fd44a2d726,e7641cf8a4785903249bb8fd401d03fd44a2d726..43696f6b727ef7eab32841063cce72f50bb5c619
@@@ -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