mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-11 05:17:55 +03:00
Merge remote-tracking branch 'origin/v1.7'
This commit is contained in:
commit
be5ed5a70b
actors/src
server/src/uds
core
osmanagers/WindowsOsManager
static/adm
@ -197,13 +197,18 @@ class UDSSystemTray(QtGui.QSystemTrayIcon):
|
||||
self.counter = 0
|
||||
|
||||
self.timer.start(5000) # Launch idle checking every 5 seconds
|
||||
self.graceTimerShots = 6 # Start counting for idle after 30 seconds after login, got on windows some "instant" logout because of idle timer not being reset??
|
||||
|
||||
self.ipc.start()
|
||||
# If this is running, it's because he have logged in
|
||||
self.ipc.sendLogin(operations.getCurrentUser())
|
||||
|
||||
def checkIdle(self):
|
||||
if self.maxIdleTime is None: # No idle checl
|
||||
if self.maxIdleTime is None: # No idle check
|
||||
return
|
||||
|
||||
if self.graceTimerShots > 0:
|
||||
self.graceTimerShots -= 1
|
||||
return
|
||||
|
||||
idleTime = operations.getIdleDuration()
|
||||
@ -221,12 +226,10 @@ class UDSSystemTray(QtGui.QSystemTrayIcon):
|
||||
if self.showIdleWarn is True and remainingTime < 120: # With two minutes, show a warning message
|
||||
self.showIdleWarn = False
|
||||
self.msgDlg.displayMessage("You have been idle for too long. The session will end if you don't resume operations")
|
||||
logger.debug('Here')
|
||||
|
||||
def displayMessage(self, message):
|
||||
logger.debug('Displaying message')
|
||||
self.msgDlg.displayMessage("You have been idle for too long. The session will end if you don't resume operations")
|
||||
QtGui.QMessageBox.information(None, "UDS Actor", message)
|
||||
self.msgDlg.displayMessage(message)
|
||||
|
||||
def executeScript(self, script):
|
||||
logger.debug('Executing script')
|
||||
@ -255,18 +258,22 @@ class UDSSystemTray(QtGui.QSystemTrayIcon):
|
||||
|
||||
def quit(self):
|
||||
logger.debug('Quit invoked')
|
||||
if self.stopped is True:
|
||||
return
|
||||
self.stopped = True
|
||||
if self.stopped is False:
|
||||
self.stopped = True
|
||||
try:
|
||||
# If we close Client, send Logoff to Broker
|
||||
self.ipc.sendLogout(operations.getCurrentUser())
|
||||
self.timer.stop()
|
||||
self.ipc.stop()
|
||||
except Exception:
|
||||
# May we have lost connection with server, simply exit in that case
|
||||
pass
|
||||
|
||||
try:
|
||||
# If we close Client, send Logoff to Broker
|
||||
self.ipc.sendLogout(operations.getCurrentUser())
|
||||
self.timer.stop()
|
||||
self.ipc.stop()
|
||||
operations.loggoff()
|
||||
operations.loggoff() # Invoke log off
|
||||
except Exception:
|
||||
# May we have lost connection with server, simply exit in that case
|
||||
pass
|
||||
|
||||
self.app.quit()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -108,7 +108,7 @@ class CommonService(object):
|
||||
ids = ','.join([i.mac for i in netInfo])
|
||||
if ids == '':
|
||||
# Wait for any network interface to be ready
|
||||
logger.debug('No network interfaces found, retrying in a while...')
|
||||
logger.debug('No valid network interfaces found, retrying in a while...')
|
||||
raise Exception()
|
||||
logger.debug('Ids: {}'.format(ids))
|
||||
self.api.init(ids)
|
||||
|
@ -62,7 +62,7 @@ def getNetworkInfo():
|
||||
for ip in obj.IPAddress:
|
||||
if ':' in ip: # Is IPV6, skip this
|
||||
continue
|
||||
if ip == '' or ip is None:
|
||||
if ip is None or ip == '' or ip.startswith('169.254') or ip.startswith('0.'): # If single link ip, or no ip
|
||||
continue
|
||||
# logger.debug('Net config found: {}=({}, {})'.format(obj.Caption, obj.MACAddress, ip))
|
||||
yield utils.Bunch(name=obj.Caption, mac=obj.MACAddress, ip=ip)
|
||||
|
@ -39,6 +39,7 @@ from uds.models import optimizeTable
|
||||
from django.db import connection
|
||||
import datetime
|
||||
import time
|
||||
import six
|
||||
|
||||
import logging
|
||||
|
||||
@ -162,7 +163,7 @@ class StatsManager(object):
|
||||
try:
|
||||
# Replaces nulls for ''
|
||||
def noneToEmpty(str):
|
||||
return str if str is not None else ''
|
||||
return six.text_type(str) if str is not None else ''
|
||||
|
||||
fld1 = noneToEmpty(kwargs.get('fld1', kwargs.get('username', '')))
|
||||
fld2 = noneToEmpty(kwargs.get('fld2', kwargs.get('srcip', '')))
|
||||
|
@ -45,6 +45,8 @@ from uds.core.services.Exceptions import MaxServicesReachedException
|
||||
from uds.models import UserService, getSqlDatetime
|
||||
from uds.core import services
|
||||
from uds.core.services import Service
|
||||
from uds.core.util.stats.events import addEvent, ET_CACHE_HIT, ET_CACHE_MISS
|
||||
|
||||
import requests
|
||||
import json
|
||||
import logging
|
||||
@ -358,7 +360,7 @@ class UserServiceManager(object):
|
||||
|
||||
def getAssignationForUser(self, ds, user):
|
||||
assignedUserService = self.getExistingAssignationForUser(ds, user)
|
||||
# If has an assigend user service, returns this without any more work
|
||||
# If has an assigned user service, returns this without any more work
|
||||
if assignedUserService is not None:
|
||||
return assignedUserService
|
||||
|
||||
@ -372,17 +374,21 @@ class UserServiceManager(object):
|
||||
else:
|
||||
cache = None
|
||||
|
||||
# Out of atomic transaction
|
||||
if cache is not None:
|
||||
logger.debug('Found a cached-ready service from {0} for user {1}, item {2}'.format(ds, user, cache))
|
||||
addEvent(ds, ET_CACHE_HIT, fld1=ds.cachedUserServices().filter(cache_level=services.UserDeployment.L1_CACHE, state=State.USABLE).count())
|
||||
ci = cache.getInstance() # User Deployment instance
|
||||
ci.assignToUser(user)
|
||||
cache.updateData(ci)
|
||||
cache.save()
|
||||
return cache
|
||||
|
||||
# Cache missed
|
||||
|
||||
# Now find if there is a preparing one
|
||||
with transaction.atomic():
|
||||
cache = ds.cachedUserServices().filter(cache_level=services.UserDeployment.L1_CACHE, state=State.PREPARING)[:1]
|
||||
cache = ds.cachedUserServices().select_for_update().filter(cache_level=services.UserDeployment.L1_CACHE, state=State.PREPARING)[:1]
|
||||
if len(cache) > 0:
|
||||
cache = cache[0]
|
||||
cache.assignToUser(user)
|
||||
@ -390,8 +396,10 @@ class UserServiceManager(object):
|
||||
else:
|
||||
cache = None
|
||||
|
||||
# Out of atomic transaction
|
||||
if cache is not None:
|
||||
logger.debug('Found a cached-preparing service from {0} for user {1}, item {2}'.format(ds, user, cache))
|
||||
addEvent(ds, ET_CACHE_MISS, fld1=ds.cachedUserServices().filter(cache_level=services.UserDeployment.L1_CACHE, state=State.PREPARING).count())
|
||||
ci = cache.getInstance() # User Deployment instance
|
||||
ci.assignToUser(user)
|
||||
cache.updateData(ci)
|
||||
@ -407,6 +415,7 @@ class UserServiceManager(object):
|
||||
if inAssigned >= ds.max_srvs: # cacheUpdater will drop necesary L1 machines, so it's not neccesary to check against inCacheL1
|
||||
raise MaxServicesReachedException()
|
||||
# Can create new service, create it
|
||||
addEvent(ds, ET_CACHE_MISS, fld1=0)
|
||||
return self.createAssignedFor(ds, user)
|
||||
|
||||
def getServicesInStateForProvider(self, provider_id, state):
|
||||
|
@ -43,8 +43,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
# Posible events, note that not all are used by every possible owner type
|
||||
(
|
||||
ET_LOGIN, ET_LOGOUT, ET_ACCESS,
|
||||
) = range(3)
|
||||
ET_LOGIN, ET_LOGOUT, ET_ACCESS, ET_CACHE_HIT, ET_CACHE_MISS
|
||||
) = range(5)
|
||||
|
||||
(
|
||||
OT_PROVIDER, OT_SERVICE, OT_DEPLOYED, OT_AUTHENTICATOR,
|
||||
|
@ -64,7 +64,7 @@ class WindowsOsManager(osmanagers.OSManager):
|
||||
order=11,
|
||||
tooltip=_('Maximum idle time (in seconds) before session is automaticatlly closed to the user (<= 0 means no max. idle time)'),
|
||||
required=True
|
||||
)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def validateLen(length):
|
||||
|
@ -172,9 +172,9 @@ tr.log-ERROR, tr.log-FATAL {
|
||||
/* Side Nav */
|
||||
|
||||
.side-nav {
|
||||
margin-left: -225px;
|
||||
left: 225px;
|
||||
width: 225px;
|
||||
margin-left: -180px;
|
||||
left: 180px;
|
||||
width: 180px;
|
||||
position: fixed;
|
||||
top: 50px;
|
||||
height: 100%;
|
||||
|
@ -148,9 +148,9 @@ _strftime = (fmt, d, locale, options) ->
|
||||
when "o"
|
||||
String(d.getDate()) + ordinal(d.getDate())
|
||||
when "P"
|
||||
(if d.getHours() < 12 then locale.am else locale.pm)
|
||||
'' # (if d.getHours() < 12 then locale.am else locale.pm)
|
||||
when "p"
|
||||
(if d.getHours() < 12 then locale.AM else locale.PM)
|
||||
'' # (if d.getHours() < 12 then locale.AM else locale.PM)
|
||||
when "R"
|
||||
_strftime locale.formats.R or "%H:%M", d, locale
|
||||
when "r"
|
||||
|
Loading…
Reference in New Issue
Block a user