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/
----
# 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.
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):
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):
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, \
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)
import django_filters
from django.db.models import Q
--from models import UserMachine
++from .models import UserMachine
from test_records.models import TestRecord
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