* Fixed sample setting file

* Working on removal of pycha of reports
This commit is contained in:
Adolfo Gómez García 2018-04-24 11:27:51 +02:00
parent 2ad3517bcd
commit 51cc23b223
5 changed files with 27 additions and 41 deletions

View File

@ -5,9 +5,7 @@ Settings file for uds server (Django)
from __future__ import unicode_literals
import os
import sys
import django
import django.conf.global_settings as DEFAULT_SETTINGS
# calculated paths for django and the site
# used as starting points for various other paths
@ -15,10 +13,9 @@ DJANGO_ROOT = os.path.dirname(os.path.realpath(django.__file__))
BASE_DIR = '/'.join(os.path.dirname(os.path.abspath(__file__)).split('/')[:-1]) # If used 'relpath' instead of abspath, returns path of "enterprise" instead of "openuds"
DEBUG = True
TEMPLATE_DEBUG = DEBUG
# USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # For testing begind a reverse proxy
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # For testing behind a reverse proxy
DATABASES = {
'default': {
@ -28,11 +25,11 @@ DATABASES = {
# 'init_command': 'SET storage_engine=INNODB, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED',
# 'init_command': 'SET storage_engine=MYISAM, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED',
},
'NAME': 'dbuds', # Or path to database file if using sqlite3.
'USER': 'dbuds', # Not used with sqlite3.
'PASSWORD': 'PASSWOR', # Not used with sqlite3.
'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
'NAME': 'dbuds', # Or path to database file if using sqlite3.
'USER': 'dbuds', # Not used with sqlite3.
'PASSWORD': 'PASSWOR', # Not used with sqlite3.
'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
# 'CONN_MAX_AGE': 600, # Enable DB Pooling, 10 minutes max connection duration
}
}
@ -64,6 +61,7 @@ LANGUAGES = (
('pt', ugettext('Portuguese')),
('it', ugettext('Italian')),
('eu', ugettext('Basque')),
('ar', ugettext('Arabian')),
('ca', ugettext('Catalan')),
)
@ -145,13 +143,6 @@ SECRET_KEY = 's5ky!7b5f#s35!e38xv%e-+iey6yi-#630x)kk3kk5_j8rie2*'
# This is a very long string, an RSA KEY (this can be changed, but if u loose it, all encription will be lost)
RSA_KEY = '-----BEGIN RSA PRIVATE KEY-----\nMIICXgIBAAKBgQC0qe1GlriQbHFYdKYRPBFDSS8Ne/TEKI2mtPKJf36XZTy6rIyH\nvUpT1gMScVjHjOISLNJQqktyv0G+ZGzLDmfkCUBev6JBlFwNeX3Dv/97Q0BsEzJX\noYHiDANUkuB30ukmGvG0sg1v4ccl+xs2Su6pFSc5bGINBcQ5tO0ZI6Q1nQIDAQAB\nAoGBAKA7Octqb+T/mQOX6ZXNjY38wXOXJb44LXHWeGnEnvUNf/Aci0L0epCidfUM\nfG33oKX4BMwwTVxHDrsa/HaXn0FZtbQeBVywZqMqWpkfL/Ho8XJ8Rsq8OfElrwek\nOCPXgxMzQYxoNHw8V97k5qhfupQ+h878BseN367xSyQ8plahAkEAuPgAi6aobwZ5\nFZhx/+6rmQ8sM8FOuzzm6bclrvfuRAUFa9+kMM2K48NAneAtLPphofqI8wDPCYgQ\nTl7O96GXVQJBAPoKtWIMuBHJXKCdUNOISmeEvEzJMPKduvyqnUYv17tM0JTV0uzO\nuDpJoNIwVPq5c3LJaORKeCZnt3dBrdH1FSkCQQC3DK+1hIvhvB0uUvxWlIL7aTmM\nSny47Y9zsc04N6JzbCiuVdeueGs/9eXHl6f9gBgI7eCD48QAocfJVygphqA1AkEA\nrvzZjcIK+9+pJHqUO0XxlFrPkQloaRK77uHUaW9IEjui6dZu4+2T/q7SjubmQgWR\nZy7Pap03UuFZA2wCoqJbaQJAUG0FVrnyUORUnMQvdDjAWps2sXoPvA8sbQY1W8dh\nR2k4TCFl2wD7LutvsdgdkiH0gWdh5tc1c4dRmSX1eQ27nA==\n-----END RSA PRIVATE KEY-----'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
@ -187,14 +178,15 @@ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'uds.core.util.request.GlobalRequestMiddleware',
'uds.core.util.middleware.XUACompatibleMiddleware',
)
'uds.core.util.middleware.RedirectMiddleware',
'uds.plugins.enterprise.middleware.Middleware',
]
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_COOKIE_HTTPONLY = False
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
ROOT_URLCONF = 'server.urls'
# Python dotted path to the WSGI application used by Django's runserver.
@ -222,11 +214,11 @@ COMPRESS_PRECOMPILERS = (
)
if DEBUG:
COMPRESS_DEBUG_TOGGLE = 'debug'
#
#
# Enable this if you need to allow round robin load balancing of web server
# This is so because we need to share the files between servers
# Another options is put /var/server/static on a shared nfs forder for all servers
#
#
# COMPRESS_STORAGE = 'uds.core.util.FileStorage.CompressorFileStorage'
# See http://docs.djangoproject.com/en/dev/topics/logging for

View File

@ -33,12 +33,12 @@
# We just need to import. Report loader will look for Report subclasses
# from . import usage
from . import login
from uds.reports.stats import user_access
from . import pools_performance
from . import pools_usage_day
from . import usage_by_pool
from . import pool_usage_summary
# from .login import StatsReportLogin, StatsReportLoginCSV
# from .user_access import StatsReportLogin, StatsReportLoginCSV
# from .pools_performance import PoolPerformanceReport
# from .pools_usage_day import CountersPoolAssigned
# from .usage_by_pool import UsageByPool

View File

@ -37,9 +37,8 @@ from django.utils.translation import ugettext, ugettext_lazy as _
from uds.core.ui.UserInterface import gui
from uds.core.util.stats import events
import six
import io
import csv
import six
from .base import StatsReport
@ -50,7 +49,7 @@ import logging
logger = logging.getLogger(__name__)
__updated__ = '2018-02-08'
__updated__ = '2018-04-24'
# several constants as Width height, margins, ..
WIDTH, HEIGHT = 1920, 1080
@ -128,8 +127,7 @@ class UsageSummaryByPool(StatsReport):
# Extract different number of users
data = []
for k, v in six.iteritems(users):
for k, v in users.items():
data.append({
'user': k,
'sessions': v['sessions'],
@ -170,7 +168,7 @@ class UsageSummaryByPoolCSV(UsageSummaryByPool):
endDate = UsageSummaryByPool.endDate
def generate(self):
output = six.StringIO()
output = io.StringIO()
writer = csv.writer(output)
reportData, poolName = self.getData()

View File

@ -32,8 +32,10 @@
"""
from __future__ import unicode_literals
import io
import csv
import six
import datetime
import logging
from django.utils.translation import ugettext, ugettext_lazy as _
from django.db.models import Count
@ -49,12 +51,9 @@ from .base import StatsReport
from uds.core.util import tools
from uds.models import ServicePool
import datetime
import logging
logger = logging.getLogger(__name__)
__updated__ = '2018-04-23'
__updated__ = '2018-04-24'
# several constants as Width height, margins, ..
WIDTH, HEIGHT, DPI = 19.2, 10.8, 100
@ -186,14 +185,11 @@ class PoolPerformanceReport(StatsReport):
def generate(self):
# Generate the sampling intervals and get dataUsers from db
start = self.startDate.stamp()
end = self.endDate.stamp()
xLabelFormat, poolsData, reportData = self.getRangeData()
size = (WIDTH, HEIGHT, DPI)
graph1 = six.BytesIO()
graph2 = six.BytesIO()
graph1 = io.BytesIO()
graph2 = io.BytesIO()
# surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT) # @UndefinedVariable
@ -208,7 +204,7 @@ class PoolPerformanceReport(StatsReport):
'y': [
{
'label': p['name'],
'data': [v[1] + 2 for v in p['dataUsers']]
'data': [v[1] for v in p['dataUsers']]
}
for p in poolsData],
'ylabel': 'Users'
@ -225,7 +221,7 @@ class PoolPerformanceReport(StatsReport):
'y': [
{
'label': p['name'],
'data': [v[1] + 2 for v in p['dataAccesses']]
'data': [v[1] for v in p['dataAccesses']]
}
for p in poolsData],
'ylabel': 'Accesses'
@ -263,7 +259,7 @@ class PoolPerformanceReportCSV(PoolPerformanceReport):
samplingPoints = PoolPerformanceReport.samplingPoints
def generate(self):
output = six.StringIO()
output = io.StringIO()
writer = csv.writer(output)
reportData = self.getRangeData()[2]