diff --git a/.gitignore b/.gitignore index 77ae454..539a427 100644 --- a/.gitignore +++ b/.gitignore @@ -1,48 +1,50 @@ .vscode debug nohup* *swp # Binaries for programs and plugins *.exe *.dll *.so *.dylib # Test binary, build with `go test -c` *.test # Output of the go coverage tool, specifically when used with LiteIDE *.out # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 .glide/ node_modules/ public/api *.idea/* +*.idea* +../.idea/ *.vscode *.log .travis.yml *.bak .tern-project public/build *.tmpl.js public/coverage *.swp frontend/public/assets/* #django *.egg-info *.pot *.py[co] .tox/ __pycache__ MANIFEST dist/ docs/_build/ docs/locale/ node_modules/ tests/coverage_html/ tests/.coverage build/ tests/report/ diff --git a/backend/goserver/goserver b/backend/goserver/goserver index 1be3c4d..c87ae09 100755 Binary files a/backend/goserver/goserver and b/backend/goserver/goserver differ diff --git a/backend/goserver/server/agregate/toolsInfo.go b/backend/goserver/server/agregate/toolsInfo.go index a80180e..fc19fa5 100644 --- a/backend/goserver/server/agregate/toolsInfo.go +++ b/backend/goserver/server/agregate/toolsInfo.go @@ -1,64 +1,65 @@ package agregate import ( "bufio" serv "kritaServers/backend/goserver/server" md "kritaServers/backend/goserver/server/models" "os" "gopkg.in/mgo.v2/bson" ) func countToolsUse(name string) (float64, float64) { resultsCount := []bson.M{} resultsAvg := []bson.M{} var countUse float64 var averageTimeUse float64 c := serv.Session.DB("telemetry").C("tools") pipe := c.Pipe([]bson.M{{"$unwind": "$tools"}, {"$match": bson.M{"tools.toolname": name}}, {"$group": bson.M{"_id": "$tools.toolname", "total_count": bson.M{"$sum": "$tools.countuse"}}}}) pipe2 := c.Pipe([]bson.M{{"$unwind": "$tools"}, {"$match": bson.M{"tools.toolname": name}}, {"$group": bson.M{"_id": "$tools.toolname", "total_count": bson.M{"$avg": "$tools.time"}}}}) resp := []bson.M{} resp2 := []bson.M{} err := pipe.All(&resp) err = pipe2.All(&resp2) serv.CheckErr(err) err = pipe.All(&resultsCount) err = pipe2.All(&resultsAvg) serv.CheckErr(err) if len(resultsCount) > 0 { countUse, _ = resultsCount[0]["total_count"].(float64) // fmt.Println(name, num) } if len(resultsAvg) > 0 { averageTimeUse, _ = resultsAvg[0]["total_count"].(float64) } return countUse, averageTimeUse } + func AgregateTools() { file, err := os.Open("list_tools.txt") serv.CheckErr(err) defer file.Close() var ToolUse md.ToolsCollected var ToolActivate md.ToolsCollected var ToolsUse []md.ToolsCollected var ToolsActivate []md.ToolsCollected scanner := bufio.NewScanner(file) for scanner.Scan() { ToolUse.Name = scanner.Text() - ToolUse.CountUse, _ = countToolsUse("/Use/" + ToolUse.Name) + ToolUse.CountUse, ToolUse.Time = countToolsUse("/Use/" + ToolUse.Name) ToolsUse = append(ToolsUse, ToolUse) ToolActivate.Name = ToolUse.Name - ToolActivate.CountUse, _ = countToolsUse("/Activate/" + ToolActivate.Name) - ToolsActivate = append(ToolsActivate, ToolUse) + ToolActivate.CountUse, ToolActivate.Time = countToolsUse("/Activate/" + ToolActivate.Name) + ToolsActivate = append(ToolsActivate, ToolActivate) } agregatedTools.ToolsActivate = ToolsActivate agregatedTools.ToolsUse = ToolsUse err = scanner.Err() serv.CheckErr(err) } diff --git a/backend/goserver/server/models/collectModel.go b/backend/goserver/server/models/collectModel.go index c37fa9b..1b47b97 100644 --- a/backend/goserver/server/models/collectModel.go +++ b/backend/goserver/server/models/collectModel.go @@ -1,156 +1,157 @@ package models type ActionCollected struct { CountUse float64 Name string } type ToolsCollected struct { CountUse float64 + Time float64 Name string } type ToolsCollectedData struct { ToolsUse []ToolsCollected ToolsActivate []ToolsCollected } type CountAndProportion struct { Count float64 Proportion string } type CollectedInstallData struct { Platform struct { Os struct { Windows CountAndProportion Linux CountAndProportion Mac CountAndProportion Other CountAndProportion Unknown CountAndProportion } Version struct { Windows struct { V7 CountAndProportion V8 CountAndProportion V81 CountAndProportion V10 CountAndProportion Other CountAndProportion } Linux struct { Ubuntu1404 CountAndProportion Ubuntu1410 CountAndProportion Ubuntu1504 CountAndProportion Ubuntu1510 CountAndProportion Ubuntu1604 CountAndProportion Ubuntu1610 CountAndProportion Ubuntu1704 CountAndProportion Other CountAndProportion } Mac struct { V1012 CountAndProportion Other CountAndProportion } } } CPU struct { Architecture struct { X86_64 CountAndProportion X86 CountAndProportion //на самом деле x86_64 c маленькой буквы Other CountAndProportion Unknown CountAndProportion } Cores struct { C1 CountAndProportion C2 CountAndProportion C3 CountAndProportion C4 CountAndProportion C6 CountAndProportion C8 CountAndProportion Other CountAndProportion Unknown CountAndProportion } } Compiler struct { Type struct { GCC CountAndProportion Clang CountAndProportion MSVC CountAndProportion Other CountAndProportion Unknown CountAndProportion } // Version struct { //подумать что можно сделать // V5dot4 float64 // Other float64 // } } Locale struct { Language struct { English CountAndProportion Russian CountAndProportion Other CountAndProportion Unknown CountAndProportion } } } //Less or equal then mb* type imageDistribution struct { Mb1 CountAndProportion Mb5 CountAndProportion Mb10 CountAndProportion Mb25 CountAndProportion Mb50 CountAndProportion Mb100 CountAndProportion Mb200 CountAndProportion Mb400 CountAndProportion Mb800 CountAndProportion More800 CountAndProportion Unknown CountAndProportion } type colorProfileDistribution struct { RGBA CountAndProportion CMYK CountAndProportion Grayscale CountAndProportion XYZ CountAndProportion YCbCr CountAndProportion Lab CountAndProportion Unknown CountAndProportion } //Less then L* type heightDistribution struct { L500 CountAndProportion L1000 CountAndProportion L2000 CountAndProportion L4000 CountAndProportion L8000 CountAndProportion M8000 CountAndProportion Unknown CountAndProportion } type widthDistribution struct { L500 CountAndProportion L1000 CountAndProportion L2000 CountAndProportion L4000 CountAndProportion L8000 CountAndProportion M8000 CountAndProportion Unknown CountAndProportion } type layersDistribution struct { L1 CountAndProportion L2 CountAndProportion L4 CountAndProportion L8 CountAndProportion L16 CountAndProportion L32 CountAndProportion L64 CountAndProportion M64 CountAndProportion Unknown CountAndProportion } type ImageCollected struct { ID imageDistribution CPD colorProfileDistribution HD heightDistribution WD widthDistribution LD layersDistribution //TODO COLORSPACE } diff --git a/frontend/treeview/db.sqlite3 b/frontend/treeview/db.sqlite3 index a9ef1b3..a115283 100644 Binary files a/frontend/treeview/db.sqlite3 and b/frontend/treeview/db.sqlite3 differ diff --git a/frontend/treeview/treeview/settings.py b/frontend/treeview/treeview/settings.py index 2c84edd..6c25ce4 100644 --- a/frontend/treeview/treeview/settings.py +++ b/frontend/treeview/treeview/settings.py @@ -1,125 +1,126 @@ """ Django settings for treeview project. Generated by 'django-admin startproject' using Django 1.11.3. For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'h!khjr!+%c_7v5-^w)*x2*sy5e#0g^3dmzyt1@y0wtr6^x)uiq' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [ '.akapustin.me', # Allow domain and subdomains 'localhost', '127.0.0.1' ] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'treeview_app', - 'graphos' + 'graphos', + 'django_tables2' ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'treeview.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'treeview.wsgi.application' # Database # https://docs.djangoproject.com/en/1.11/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Password validation # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/1.11/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'Europe/Moscow' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ STATIC_URL = '/static/' diff --git a/frontend/treeview/treeview_app/migrations/0001_initial.py b/frontend/treeview/treeview_app/migrations/0001_initial.py new file mode 100644 index 0000000..f49857a --- /dev/null +++ b/frontend/treeview/treeview_app/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.3 on 2017-08-16 14:28 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Tools', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('countUse', models.IntegerField()), + ], + ), + ] diff --git a/frontend/treeview/treeview_app/models.py b/frontend/treeview/treeview_app/migrations/__init__.py similarity index 100% copy from frontend/treeview/treeview_app/models.py copy to frontend/treeview/treeview_app/migrations/__init__.py diff --git a/frontend/treeview/treeview_app/models.py b/frontend/treeview/treeview_app/models.py index e69de29..9235651 100644 --- a/frontend/treeview/treeview_app/models.py +++ b/frontend/treeview/treeview_app/models.py @@ -0,0 +1,12 @@ +from django.db import models + + +class Tools(models.Model): + name = models.CharField(max_length=100) + time = models.FloatField() + countUse = models.IntegerField() + +class ToolsActivate(models.Model): + name = models.CharField(max_length=100) + time = models.FloatField() + countUse = models.IntegerField() diff --git a/frontend/treeview/treeview_app/static/django_tables2/bootstrap.css b/frontend/treeview/treeview_app/static/django_tables2/bootstrap.css new file mode 100644 index 0000000..80aaef2 --- /dev/null +++ b/frontend/treeview/treeview_app/static/django_tables2/bootstrap.css @@ -0,0 +1,8 @@ +.table-container th.asc:after { + content: '\0000a0\0025b2'; + float: right; +} +.table-container th.desc:after { + content: '\0000a0\0025bc'; + float: right; +} diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/css/screen.css b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/css/screen.css new file mode 100644 index 0000000..f0c6343 --- /dev/null +++ b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/css/screen.css @@ -0,0 +1,127 @@ +table.paleblue { + border-collapse: collapse; + border-color: #CCC; + border: 1px solid #DDD; +} + +table.paleblue, +table.paleblue + ul.pagination { + font: normal 11px/14px 'Lucida Grande', Verdana, Helvetica, Arial, sans-serif; +} + +table.paleblue a:link, +table.paleblue a:visited, +table.paleblue + ul.pagination > li > a { + color: #5B80B2; + text-decoration: none; + font-weight: bold; +} + +table.paleblue a:hover { + color: #036; +} + +table.paleblue td, +table.paleblue th { + padding: 5px; + line-height: 13px; + border-bottom: 1px solid #EEE; + border-left: 1px solid #DDD; + text-align: left; +} + +table.paleblue thead th:first-child, +table.paleblue thead td:first-child { + border-left: none !important; +} + +table.paleblue thead th, +table.paleblue thead td { + background: #FCFCFC url(../img/header-bg.png) left bottom repeat-x; + border-bottom: 1px solid #DDD; + padding: 2px 5px; + font-size: 11px; + vertical-align: middle; + color: #666; +} + +table.paleblue thead th > a:link, +table.paleblue thead th > a:visited { + color: #666; +} + +table.paleblue thead th.orderable > a { + padding-right: 20px; + background: url(../img/arrow-inactive-up.png) right center no-repeat; +} +table.paleblue thead th.orderable.asc > a { + background-image: url(../img/arrow-active-up.png); +} +table.paleblue thead th.orderable.desc > a { + background-image: url(../img/arrow-active-down.png); +} + +table.paleblue tr.odd { + background-color: #EDF3FE; +} + +table.paleblue tr.even { + background-color: white; +} + +table.paleblue + ul.pagination { + background: white url(../img/pagination-bg.gif) left 180% repeat-x; + overflow: auto; + margin: 0; + padding: 10px; + border: 1px solid #DDD; + list-style: none; +} + +table.paleblue + ul.pagination > li { + float: left; + line-height: 22px; + margin-left: 10px; +} + +table.paleblue + ul.pagination > li:first-child { + margin-left: 0; +} + +table.paleblue + ul.pagination > li.cardinality { + float: right; + color: #8d8d8d; +} + +table.paleblue > tbody > tr > td > span.true, +table.paleblue > tbody > tr > td > span.false { + background-position: top left; + background-repeat: no-repeat; + display: inline-block; + height: 10px; + overflow: hidden; + text-indent: -200px; + width: 10px; +} + +table.paleblue > tbody > tr > td > .missing { + background: transparent url(../img/missing.png) right center no-repeat; + color: #717171; + padding-right: 20px; +} + +table.paleblue > tbody > tr > td > .missing:hover { + color: #333; +} + +table.paleblue > tbody > tr > td > span.true { + background-image: url(../img/true.gif); +} + +table.paleblue > tbody > tr > td > span.false { + background-image: url(../img/false.gif); +} + +div.table-container { + display: inline-block; +} diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-active-down.png b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-active-down.png new file mode 100644 index 0000000..fbf6073 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-active-down.png differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-active-up.png b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-active-up.png new file mode 100644 index 0000000..e9b0e58 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-active-up.png differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-inactive-down.png b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-inactive-down.png new file mode 100644 index 0000000..0c16ab3 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-inactive-down.png differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-inactive-up.png b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-inactive-up.png new file mode 100644 index 0000000..d3f3245 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/arrow-inactive-up.png differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/false.gif b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/false.gif new file mode 100644 index 0000000..1b4ee58 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/false.gif differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/header-bg.png b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/header-bg.png new file mode 100644 index 0000000..c0d2027 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/header-bg.png differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/missing.png b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/missing.png new file mode 100644 index 0000000..aa3c8ab Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/missing.png differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/pagination-bg.gif b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/pagination-bg.gif new file mode 100644 index 0000000..f8402b8 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/pagination-bg.gif differ diff --git a/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/true.gif b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/true.gif new file mode 100644 index 0000000..7399282 Binary files /dev/null and b/frontend/treeview/treeview_app/static/django_tables2/themes/paleblue/img/true.gif differ diff --git a/frontend/treeview/treeview_app/tables.py b/frontend/treeview/treeview_app/tables.py new file mode 100644 index 0000000..2223669 --- /dev/null +++ b/frontend/treeview/treeview_app/tables.py @@ -0,0 +1,15 @@ +import django_tables2 as tables +from .models import Tools +from .models import ToolsActivate + +class ToolsTable(tables.Table): + class Meta: + model = Tools + # add class="paleblue" to tag + attrs = {'class': 'paleblue'} + +class ToolsActivateTable(tables.Table): + class Meta: + model = ToolsActivate + # add class="paleblue" to
tag + attrs = {'class': 'paleblue'} \ No newline at end of file diff --git a/frontend/treeview/treeview_app/templates/treeview_app/install_graphs.html b/frontend/treeview/treeview_app/templates/treeview_app/install_graphs.html new file mode 100644 index 0000000..32e47e2 --- /dev/null +++ b/frontend/treeview/treeview_app/templates/treeview_app/install_graphs.html @@ -0,0 +1,18 @@ + +{% load staticfiles %} + + + + + + + +{{ chart.as_html }} {{ chart1.as_html }} {{ chart2.as_html }} {{ chart3.as_html }} {{ chart4.as_html }} {{ chart5.as_html + }} {{ chart6.as_html }} {{ chart7.as_html }} + + + \ No newline at end of file diff --git a/frontend/treeview/treeview_app/templates/treeview_app/start_page.html b/frontend/treeview/treeview_app/templates/treeview_app/start_page.html index e1d7caf..935521d 100644 --- a/frontend/treeview/treeview_app/templates/treeview_app/start_page.html +++ b/frontend/treeview/treeview_app/templates/treeview_app/start_page.html @@ -1,50 +1,61 @@

Main page

+ + +
+
+ +
+
+
+ +
+
\ No newline at end of file diff --git a/frontend/treeview/treeview_app/templates/treeview_app/tools_table.html b/frontend/treeview/treeview_app/templates/treeview_app/tools_table.html new file mode 100644 index 0000000..1aadeb2 --- /dev/null +++ b/frontend/treeview/treeview_app/templates/treeview_app/tools_table.html @@ -0,0 +1,19 @@ + +{% load render_table from django_tables2 %} {% load staticfiles %} + + + + + + + + + Tools {% render_table tools %} + + + \ No newline at end of file diff --git a/frontend/treeview/treeview_app/urls.py b/frontend/treeview/treeview_app/urls.py index ba477f1..53184cd 100644 --- a/frontend/treeview/treeview_app/urls.py +++ b/frontend/treeview/treeview_app/urls.py @@ -1,14 +1,17 @@ from django.conf.urls import url from . import views from jsonview.decorators import json_view urlpatterns = [ url(r'^$', views.start_list, name='star_list'), url(r'^installInfo/$', views.show_install_info, name='show_install_info'), url(r'^actions/$', views.show_actions_info, name='show_actions_info'), url(r'^tools/$', views.show_tools_info, name='show_tools_info'), url(r'^images/$', views.show_images_info, name='show_images_info'), url(r'^imagesGraphs/$', views.image_graphs, name='image_graphs'), - url(r'^installGraphs/$', views.install_graphs , name='install_graphs'), + url(r'^installGraphs/$', views.install_graphs , name='install_graphs'), + url(r'^toolsTableUse/$', views.tools_table_use , name='tools_table_use'), + url(r'^toolsTableActivate/$', views.tools_table_activate , name='tools_table_activate'), + ] diff --git a/frontend/treeview/treeview_app/views.py b/frontend/treeview/treeview_app/views.py index 4bb0227..ebc7c37 100644 --- a/frontend/treeview/treeview_app/views.py +++ b/frontend/treeview/treeview_app/views.py @@ -1,252 +1,300 @@ from django.core.serializers import json import json from django.shortcuts import render import http.client from graphos.renderers import gchart from graphos.sources.simple import SimpleDataSource from graphos.renderers.gchart import BarChart +from .models import Tools, ToolsActivate +from django_tables2 import RequestConfig +from .tables import ToolsTable, ToolsActivateTable # Create your views here. def show_install_info(request): # response = json.dumps({"timestamp1": 22, "timestamp2": 14}) # temporary solution response = json.dumps({"there should be ": "error request"}) try: conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/install") r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() print(response) except Exception as e: print("error") return render(request, "treeview_app/error_page.html") return render(request, "treeview_app/install_info.html", {'json_string': response}) def show_images_info(request): # response = json.dumps({"timestamp1": 22, "timestamp2": 14}) # temporary solution response = json.dumps({"there should be ": "error request"}) try: conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/images") r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() print(response) except Exception as e: print("error") return render(request, "treeview_app/error_page.html") return render(request, "treeview_app/images_info.html", {'json_string': response}) def show_tools_info(request): # response = json.dumps({"timestamp1": 22, "timestamp2": 14}) # temporary solution response = json.dumps({"there should be ": "error request"}) try: conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/tools") r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() print(response) except Exception as e: print("error") return render(request, "treeview_app/error_page.html") return render(request, "treeview_app/tools_info.html", {'json_string': response}) def show_actions_info(request): # response = json.dumps({"timestamp1": 22, "timestamp2": 14}) # temporary solution response = json.dumps({"there should be ": "error request"}) try: conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/actions") r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() print(response) except Exception as e: print("error") return render(request, "treeview_app/error_page.html") return render(request, "treeview_app/actions_info.html", {'json_string': response}) def start_list(request): return render(request, 'treeview_app/start_page.html', {}) def getImageInfo(type, distribution, subsection, title): conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/images?type=" + type) r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() response = response.decode("utf-8") decoded = json.loads(response) resultList = [[title, subsection], ] for x in distribution: # print(decoded[x][subsection]) resultList.append([x, decoded[x][subsection]]) print(type + "TYPE") return resultList def image_graphs(request): WIDTH_COUNT = 0 HEIGHT_COUNT = 1 NUMLAYERS_COUNT = 2 FILESIZE_COUNT = 3 COLORPROFILE_COUNT = 4 response = [[], [], [], [], []] try: response[WIDTH_COUNT] = getImageInfo( "width", ["L500", "L1000", "L2000", "L4000", "L8000", "M8000", "Unknown"], "Count", "Width") response[HEIGHT_COUNT] = getImageInfo("height", [ "L500", "L1000", "L2000", "L4000", "L8000", "M8000", "Unknown"], "Count", "Height") response[NUMLAYERS_COUNT] = getImageInfo("numlayers", [ "L1", "L2", "L4", "L8", "L16", "L32", "L64", "M64", "Unknown"], "Count", "Num layers") response[FILESIZE_COUNT] = getImageInfo("filesize", [ "Mb1", "Mb5", "Mb10", "Mb25", "Mb50", "Mb100", "Mb200", "Mb400", "Mb800", "More800", "Unknown"], "Count", "File size") response[COLORPROFILE_COUNT] = getImageInfo("colorprofile", [ "RGBA", "CMYK", "Grayscale", "XYZ", "YCbCr", "Lab", "Unknown"], "Count", "Color Profile") except Exception as e: print(e) return render(request, "treeview_app/error_page.html") # DataSource object data_source = [0, 0, 0, 0, 0] data_source[WIDTH_COUNT] = SimpleDataSource(data=response[WIDTH_COUNT]) data_source[HEIGHT_COUNT] = SimpleDataSource(data=response[HEIGHT_COUNT]) data_source[NUMLAYERS_COUNT] = SimpleDataSource( data=response[NUMLAYERS_COUNT]) data_source[FILESIZE_COUNT] = SimpleDataSource( data=response[FILESIZE_COUNT]) data_source[COLORPROFILE_COUNT] = SimpleDataSource( data=response[COLORPROFILE_COUNT]) # Chart objects chart = [0, 0, 0, 0, 0] chart[WIDTH_COUNT] = BarChart(data_source[WIDTH_COUNT]) chart[HEIGHT_COUNT] = BarChart(data_source[HEIGHT_COUNT]) chart[NUMLAYERS_COUNT] = BarChart(data_source[NUMLAYERS_COUNT]) chart[FILESIZE_COUNT] = BarChart(data_source[FILESIZE_COUNT]) chart[COLORPROFILE_COUNT] = BarChart(data_source[COLORPROFILE_COUNT]) context = {'chart': chart[WIDTH_COUNT], 'chart2': chart[HEIGHT_COUNT], "chart4": chart[NUMLAYERS_COUNT], "chart6": chart[FILESIZE_COUNT], "chart8": chart[COLORPROFILE_COUNT] } return render(request, 'treeview_app/image_graphs.html', context) def getInstallInfo(type, distribution, subsection, title): print("get installInfo") conn = http.client.HTTPConnection("localhost:8080") conn.request("GET", "/get/install?type=" + type) r1 = conn.getresponse() response = r1.read() # what will happen if response code will be not 200 conn.close() response = response.decode("utf-8") decoded = json.loads(response) print(decoded) resultList = [[title, subsection], ] for x in distribution: # print(decoded[x][subsection]) resultList.append([x, decoded[x][subsection]]) print(type + "TYPE") return resultList def install_graphs(request): OS_COUNT = 0 WINDOWS_COUNT = 1 LINUX_COUNT = 2 MAC_COUNT = 3 CPU_ARCHITECTURE_COUNT = 4 CPU_CORES_COUNT = 5 COMPILER_COUNT = 6 LOCALE_COUNT = 7 response = [] for i in range(8): response.append([]) print("DD") try: response[OS_COUNT] = getInstallInfo( "os", ["Windows", "Linux", "Mac", "Unknown"], "Count", "Os") response[WINDOWS_COUNT] = getInstallInfo("windows", [ "V7", "V8", "V81", "V10", "Other"], "Count", "Versions of Windows") response[LINUX_COUNT] = getInstallInfo("linux", [ "Ubuntu1404", "Ubuntu1410", "Ubuntu1504", "Ubuntu1510", "Ubuntu1604", "Ubuntu1610", "Ubuntu1704", "Other"], "Count", "Version of Linux") response[MAC_COUNT] = getInstallInfo("mac", [ "V1012", "Other"], "Count", "Versions of Macs") response[CPU_ARCHITECTURE_COUNT] = getInstallInfo("architecture", [ "X86_64", "X86", "Other", "Unknown"], "Count", "Kinds of architecture") response[CPU_CORES_COUNT] = getInstallInfo("cores", [ - "C1", "C2", "C3", "C4", "C6", "C8","Other", "Unknown"], "Count", "Number of cores") + "C1", "C2", "C3", "C4", "C6", "C8", "Other", "Unknown"], "Count", "Number of cores") response[COMPILER_COUNT] = getInstallInfo("compiler", [ - "GCC", "Clang","MSVC", "Other", "Unknown"], "Count", "Compilers") + "GCC", "Clang", "MSVC", "Other", "Unknown"], "Count", "Compilers") response[LOCALE_COUNT] = getInstallInfo("locale", [ "English", "Russian", "Other", "Unknown"], "Count", "Locales") except Exception as e: print(e) return render(request, "treeview_app/error_page.html") # DataSource object data_source = [] for i in range(8): data_source.append([]) data_source[OS_COUNT] = SimpleDataSource(data=response[OS_COUNT]) data_source[WINDOWS_COUNT] = SimpleDataSource(data=response[WINDOWS_COUNT]) data_source[LINUX_COUNT] = SimpleDataSource( data=response[LINUX_COUNT]) data_source[MAC_COUNT] = SimpleDataSource( data=response[MAC_COUNT]) data_source[CPU_ARCHITECTURE_COUNT] = SimpleDataSource( data=response[CPU_ARCHITECTURE_COUNT]) data_source[CPU_CORES_COUNT] = SimpleDataSource( data=response[CPU_CORES_COUNT]) data_source[COMPILER_COUNT] = SimpleDataSource( data=response[COMPILER_COUNT]) data_source[LOCALE_COUNT] = SimpleDataSource( data=response[LOCALE_COUNT]) # Chart objects chart = [] for i in range(8): chart.append([]) chart[OS_COUNT] = BarChart(data_source[OS_COUNT]) chart[WINDOWS_COUNT] = BarChart(data_source[WINDOWS_COUNT]) chart[LINUX_COUNT] = BarChart(data_source[LINUX_COUNT]) chart[MAC_COUNT] = BarChart(data_source[MAC_COUNT]) chart[CPU_ARCHITECTURE_COUNT] = BarChart( data_source[CPU_ARCHITECTURE_COUNT]) chart[CPU_CORES_COUNT] = BarChart( data_source[CPU_CORES_COUNT]) chart[COMPILER_COUNT] = BarChart( data_source[COMPILER_COUNT]) chart[LOCALE_COUNT] = BarChart( data_source[LOCALE_COUNT]) context = {'chart': chart[OS_COUNT], 'chart1': chart[WINDOWS_COUNT], "chart2": chart[LINUX_COUNT], "chart3": chart[MAC_COUNT], "chart4": chart[CPU_ARCHITECTURE_COUNT], "chart5": chart[CPU_CORES_COUNT], "chart6": chart[COMPILER_COUNT], "chart7": chart[LOCALE_COUNT], } return render(request, 'treeview_app/install_graphs.html', context) + + +def tools_table_use(request): + Tools.objects.all().delete() + conn = http.client.HTTPConnection("localhost:8080") + conn.request("GET", "/get/tools") + r1 = conn.getresponse() + response = r1.read() # what will happen if response code will be not 200 + conn.close() + response = response.decode("utf-8") + decoded = json.loads(response) + resultList = [] + for x in decoded["ToolsUse"]: + # print(decoded[x][subsection]) + dd = Tools(name=x["Name"], countUse=x["CountUse"], time = x["Time"]) + dd.save() + + table = ToolsTable(Tools.objects.all()) + table2 = ToolsActivateTable(ToolsActivate.objects.all()) + RequestConfig(request).configure(table) + RequestConfig(request).configure(table2) + + context = {'tools': table, 'toolsactivate': table2} + return render(request, 'treeview_app/tools_table.html', context) + +def tools_table_activate(request): + ToolsActivate.objects.all().delete() + conn = http.client.HTTPConnection("localhost:8080") + conn.request("GET", "/get/tools") + r1 = conn.getresponse() + response = r1.read() # what will happen if response code will be not 200 + conn.close() + response = response.decode("utf-8") + decoded = json.loads(response) + resultList = [] + + for x in decoded["ToolsActivate"]: + # print(decoded[x][subsection]) + dd = ToolsActivate(name=x["Name"], countUse=x["CountUse"],time = x["Time"]) + dd.save() + table2 = ToolsActivateTable(ToolsActivate.objects.all()) + RequestConfig(request).configure(table2) + + context = {'tools': table2} + return render(request, 'treeview_app/tools_table.html', context)