new version on December 2020 failed to check users

Asked by Xudong Sun

Happy new year! Thanks for your hard work!
A bug caused the timekpr-next failing

2020-12-31 00:08:06.761067: --- start working on users ---
2020-12-31 00:08:06.761765: start checkUsers
2020-12-31 00:08:06.762151: start getUserList
2020-12-31 00:08:06.764337: USER: gdm, UID: 121, UNAME: gdm, UPATH: /org/freedesktop/login1/user/_121
2020-12-31 00:08:06.764845: USER: user, UID: 1000, UNAME: user, UPATH: /org/freedesktop/login1/user/_1000
2020-12-31 00:08:06.765138: finish getUserList
2020-12-31 00:08:06.765431: NOTE: system user "gdm" explicitly excluded
2020-12-31 00:08:06.765860: start adjustTimeSpentActual
2020-12-31 00:08:06.766155: INFO: sleeping for 44977.0
2020-12-31 00:08:06.766420: ---=== start isUserActive for "user" ===---
2020-12-31 00:08:06.781763: user stats, state: active, idleState: True
2020-12-31 00:08:06.782117: ---=== start cacheUserSessionList for "user" ===---
2020-12-31 00:08:06.788612: session already cached: 6
2020-12-31 00:08:06.788892: ---=== finish cacheUserSessionList for "user" ===---
2020-12-31 00:08:06.800860: got session - type: x11, VTNr: 2, state: active, idle: True, locked: True
2020-12-31 00:08:06.801028: session 6 included as active (track inactive sessions enabled)
2020-12-31 00:08:06.801120: ---=== finish isUserActive: True ===---
2020-12-31 00:08:06.801215: ---=== ERROR working on users ===---
2020-12-31 00:08:06.801425: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/timekpr/server/interface/dbus/daemon.py", line 135, in executeTimekprWorker
    self.checkUsers()
  File "/usr/lib/python3/dist-packages/timekpr/server/interface/dbus/daemon.py", line 247, in checkUsers
    userActiveEffective, userActiveActual, userScreenLocked = self._timekprUserList[rUserName].adjustTimeSpentActual(self._timekprConfig)
  File "/usr/lib/python3/dist-packages/timekpr/server/user/userdata.py", line 445, in adjustTimeSpentActual
    self._timekprUserData[self._currentDOW][cons.TK_CTRL_TSPBALD] += timeSpent
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'int'

2020-12-31 00:08:06.801519: ---=== ERROR working on users ===---
2020-12-31 00:08:06.801611: --- end working on users ---
2020-12-31 00:08:06.801699: --- performance: 0:00:00.046684 ---
2020-12-31 00:08:09.765134: --- start working on users ---
2020-12-31 00:08:09.765790: start checkUsers
2020-12-31 00:08:09.766194: start getUserList
2020-12-31 00:08:09.768394: USER: gdm, UID: 121, UNAME: gdm, UPATH: /org/freedesktop/login1/user/_121
2020-12-31 00:08:09.768918: USER: user, UID: 1000, UNAME: user, UPATH: /org/freedesktop/login1/user/_1000
2020-12-31 00:08:09.769223: finish getUserList
2020-12-31 00:08:09.769570: NOTE: system user "gdm" explicitly excluded
2020-12-31 00:08:09.770029: start adjustTimeSpentActual
2020-12-31 00:08:09.770350: INFO: sleeping for 44980.0
2020-12-31 00:08:09.770634: ---=== start isUserActive for "user" ===---
2020-12-31 00:08:09.791988: user stats, state: active, idleState: True
2020-12-31 00:08:09.792489: ---=== start cacheUserSessionList for "user" ===---
2020-12-31 00:08:09.800704: session already cached: 6
2020-12-31 00:08:09.800967: ---=== finish cacheUserSessionList for "user" ===---
2020-12-31 00:08:09.811949: got session - type: x11, VTNr: 2, state: active, idle: True, locked: True
2020-12-31 00:08:09.812167: session 6 included as active (track inactive sessions enabled)
2020-12-31 00:08:09.812316: ---=== finish isUserActive: True ===---
2020-12-31 00:08:09.812478: ---=== ERROR working on users ===---
2020-12-31 00:08:09.812823: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/timekpr/server/interface/dbus/daemon.py", line 135, in executeTimekprWorker
    self.checkUsers()
  File "/usr/lib/python3/dist-packages/timekpr/server/interface/dbus/daemon.py", line 247, in checkUsers
    userActiveEffective, userActiveActual, userScreenLocked = self._timekprUserList[rUserName].adjustTimeSpentActual(self._timekprConfig)
  File "/usr/lib/python3/dist-packages/timekpr/server/user/userdata.py", line 445, in adjustTimeSpentActual
    self._timekprUserData[self._currentDOW][cons.TK_CTRL_TSPBALD] += timeSpent
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'int'

2020-12-31 00:08:09.812987: ---=== ERROR working on users ===---
2020-12-31 00:08:09.813125: --- end working on users ---
2020-12-31 00:08:09.813269: --- performance: 0:00:00.046684 ---

Question information

Language:
English Edit question
Status:
Solved
For:
Timekpr-nExT Edit question
Assignee:
Eduards Bezverhijs Edit question
Solved by:
Eduards Bezverhijs
Solved:
Last query:
Last reply:
Revision history for this message
Eduards Bezverhijs (mjasnik) said :
#1

Thanks!

This error seems odd...
Please send me config files from /var/lib/timekpr/config and /var/lib/timekpr/work, you can paste them here too.

Revision history for this message
Xudong Sun (sunxd) said :
#2

the "user" should be replaced with sunxd in the previous error trace.

below are the configuration files
-------------------------------------------------------------------------WORK-------------------------------------------------------------------------------
----------------------------------sunxd.time-------------------------------
[sunxd]
# total spent time balance for today
TIME_SPENT_BALANCE = 90
# total actual spent for today
TIME_SPENT_DAY = 90
# total spent for this week
TIME_SPENT_WEEK = 68806
# total spent for this month
TIME_SPENT_MONTH = 1086910
# last update time of the file
LAST_CHECKED = 2020-12-30 11:38:21
-----------------------------------------user.time---------------------------------
[USER]
# total spent time balance for today
TIME_SPENT_BALANCE = 0
# total actual spent for today
TIME_SPENT_DAY = 0
# total spent for this week
TIME_SPENT_WEEK = 0
# total spent for this month
TIME_SPENT_MONTH = 0
# last update time of the file
LAST_CHECKED = 2020-06-15 19:51:49

[USER.PLAYTIME]
# total PlayTime balance spent for this day
PLAYTIME_SPENT_BALANCE = 0
# total PlayTime spent for this day
PLAYTIME_SPENT_DAY = 0

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------Config---------------------------------------------------------------------------------
----timekpr.sunxd.conf---------
[DOCUMENTATION]
#### this is the user configuration file for timekpr-next
#### if this file cannot be read properly, it will be overwritten with defaults
#### all numeric time values are specified in seconds
#### days and hours should be configured as per ISO 8601 (i.e. Monday is the first day of week (1-7) and hours are in 24h format (0-23))

[sunxd]
# this defines which hours are allowed (remove or add hours to limit access), configure limits for start/end minutes for hour in brackets, example: 22[00-15]
ALLOWED_HOURS_1 = 5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;
ALLOWED_HOURS_2 = 5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;
ALLOWED_HOURS_3 = 5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20[0:30];
ALLOWED_HOURS_4 = 5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20[0:30];
ALLOWED_HOURS_5 = 5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;
ALLOWED_HOURS_6 = 5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20[0:30];
ALLOWED_HOURS_7 = 5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20[0:30];
# this defines which days of the week a user can use computer (remove or add days to limit access)
ALLOWED_WEEKDAYS = 1;2;3;4;5;6;7
# this defines allowed time in seconds per week day a user can use the computer (number of values must match number if values for ALLOWED_WEEKDAYS)
LIMITS_PER_WEEKDAYS = 47600;47600;48600;47600;47600;47600;47600
# this defines allowed time per week in seconds (in addition to other limits)
LIMIT_PER_WEEK = 704800
# this defines allowed time per month in seconds (in addition to other limits)
LIMIT_PER_MONTH = 2678400
# this defines whether to account sessions which are inactive (locked screen, user switched away from desktop, etc.)
TRACK_INACTIVE = True
# this defines whether to show icon and notifications for user
HIDE_TRAY_ICON = False
# this defines user restriction / lockout mode: lock - lock screen, suspend - put computer to sleep, suspendwake - put computer to sleep and wake it up,
# terminate - terminate sessions, shutdown - shutdown the computer
LOCKOUT_TYPE = terminate
# this defines wakeup hour interval in format xn;yn where xn / yn are hours from 0 to 23, wakeup itself must be supported by BIOS / UEFI and enabled,
# this is effective only when lockout type is suspendwake
WAKEUP_HOUR_INTERVAL = 0;23

[sunxd.PLAYTIME]
# whether PlayTime is enabled for this user
PLAYTIME_ENABLED = False
# whether PlayTime is enabled to override existing time accounting, i.e. time ticks only when PlayTime processes / activities are running,
# in this case explicit PlayTime limits are ignored
PLAYTIME_LIMIT_OVERRIDE_ENABLED = False
# specify on which days PlayTime is enabled
PLAYTIME_ALLOWED_WEEKDAYS = 1;2;3;4;5;6;7
# how much PlayTime is allowed per allowed days (number of values must match number if values for PLAYTIME_ALLOWED_WEEKDAYS)
PLAYTIME_LIMITS_PER_WEEKDAYS = 0;0;0;0;0;0;0
# this defines which activities / processes are monitored, pattern: PLAYTIME_ACTIVITY_NNN = PROCESS_MASK[DESCRIPTION],
# where NNN is number left padded with 0 (keys must be unique and ordered), optionally it's possible to add user
# friendly description in [] brackets. Process mask supports regexp, except symbols [], please be careful entering it!
##PLAYTIME_ACTIVITIES## Do NOT remove or alter this line!

------------------timekpr.USER.conf------
[DOCUMENTATION]
#### this is the user configuration file for timekpr-next
#### if this file cannot be read properly, it will be overwritten with defaults
#### all numeric time values are specified in seconds
#### days and hours should be configured as per ISO 8601 (i.e. Monday is the first day of week (1-7) and hours are in 24h format (0-23))

[USER]
# this defines which hours are allowed (remove or add hours to limit access), configure limits for start/end minutes for hour in brackets, example: 22[00-15]
ALLOWED_HOURS_1 = 0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23
ALLOWED_HOURS_2 = 0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23
ALLOWED_HOURS_3 = 0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23
ALLOWED_HOURS_4 = 0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23
ALLOWED_HOURS_5 = 0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23
ALLOWED_HOURS_6 = 0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23
ALLOWED_HOURS_7 = 0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23
# this defines which days of the week a user can use computer (remove or add days to limit access)
ALLOWED_WEEKDAYS = 1;2;3;4;5;6;7
# this defines allowed time in seconds per week day a user can use the computer (number of values must match number if values for ALLOWED_WEEKDAYS)
LIMITS_PER_WEEKDAYS = 86400;86400;86400;86400;86400;86400;86400
# this defines allowed time per week in seconds (in addition to other limits)
LIMIT_PER_WEEK = 604800
# this defines allowed time per month in seconds (in addition to other limits)
LIMIT_PER_MONTH = 2678400
# this defines whether to account sessions which are inactive (locked screen, user switched away from desktop, etc.)
TRACK_INACTIVE = False
# this defines whether to show icon and notifications for user
HIDE_TRAY_ICON = False
# this defines user restriction / lockout mode: lock - lock screen, suspend - put computer to sleep, suspendwake - put computer to sleep and wake it up,
# terminate - terminate sessions, shutdown - shutdown the computer
LOCKOUT_TYPE = terminate
# this defines wakeup hour interval in format xn;yn where xn / yn are hours from 0 to 23, wakeup itself must be supported by BIOS / UEFI and enabled,
# this is effective only when lockout type is suspendwake
WAKEUP_HOUR_INTERVAL = 0;23

[USER.PLAYTIME]
# whether PlayTime is enabled for this user
PLAYTIME_ENABLED = False
# whether PlayTime is enabled to override existing time accounting, i.e. time ticks only when PlayTime processes / activities are running,
# in this case explicit PlayTime limits are ignored
PLAYTIME_LIMIT_OVERRIDE_ENABLED = False
# specify on which days PlayTime is enabled
PLAYTIME_ALLOWED_WEEKDAYS = 1;2;3;4;5;6;7
# how much PlayTime is allowed per allowed days (number of values must match number if values for PLAYTIME_ALLOWED_WEEKDAYS)
PLAYTIME_LIMITS_PER_WEEKDAYS = 14400;14400;14400;14400;14400;14400;14400
# this defines which activities / processes are monitored, pattern: PLAYTIME_ACTIVITY_NNN = PROCESS_MASK[DESCRIPTION],
# where NNN is number left padded with 0 (keys must be unique and ordered), optionally it's possible to add user
# friendly description in [] brackets. Process mask supports regexp, except symbols [], please be careful entering it!
##PLAYTIME_ACTIVITIES## Do NOT remove or alter this line!
PLAYTIME_ACTIVITY_001 = DOOMEternalx64vk.exe[Doom Eternal]
PLAYTIME_ACTIVITY_002 = Talos[The Talos Principle]
PLAYTIME_ACTIVITY_003 = GTA5.exe[Grand Theft Auto V]

Revision history for this message
Eduards Bezverhijs (mjasnik) said :
#3

Ok, config looks ok.
But I don't understand why the error is there.

Can you please do this (this will create a new fresh log file and restart timekpr):
sudo systemctl stop timekpr
echo "" | sudo tee /var/log/timekpr.log
sudo systemctl start timekpr

Wait couple of mins and send the clear new log file to me via email or put it in pastebin or some site.

Revision history for this message
Eduards Bezverhijs (mjasnik) said :
#5

Btw work file seema to be older version. Did you alter / copy?
I'll recheck upgrade routine.

Which distro are you using, btw?

Revision history for this message
Xudong Sun (sunxd) said :
#6

I did not change the configurations files for USER. The sole configuration file I changed manually is the timekpr.sunxd.conf in the conf folder.

The distribution I used is Ubuntu 18.04, the new version is updated through "sudo apt upgrade"

Revision history for this message
Xudong Sun (sunxd) said :
#7

new log file

2021-01-01 13:22:37.750085: --- initiating timekpr v. 0.5.0 ---
2021-01-01 13:22:37.750297: start init dbus daemon
2021-01-01 13:22:37.751716: finish init dbus daemon
2021-01-01 13:22:37.752938: initializing configuration manager
2021-01-01 13:22:37.753331: finish configuration manager
2021-01-01 13:22:37.754494: de-initializing configuration manager
2021-01-01 13:22:37.755146: initializing configuration manager
2021-01-01 13:22:37.755395: finish configuration manager
2021-01-01 13:22:37.756166: start timekpr login1 manager
2021-01-01 13:22:37.756249: getting login1 object on DBUS
2021-01-01 13:22:37.756622: getting login1 interface on DBUS
2021-01-01 13:22:37.756731: got interface, login1 successfully set up
2021-01-01 13:22:37.756812: finish login1 manager
2021-01-01 13:22:37.756935: start init timekprUserPlayTime
2021-01-01 13:22:37.757015: finish init timekprUserPlayTime
2021-01-01 13:22:37.757083: finish init daemon data
2021-01-01 13:22:37.757136: start daemons
2021-01-01 13:22:37.757436: start up worker thread
2021-01-01 13:22:37.757498: finish daemons, timekpr started
2021-01-01 13:22:37.757327: start up main loop thread
2021-01-01 13:22:37.757663: --- start working on users ---
2021-01-01 13:22:37.757910: start checkUsers
2021-01-01 13:22:37.758025: start getUserList
2021-01-01 13:22:37.758995: USER: sunxd, UID: 1000, UNAME: sunxd, UPATH: /org/freedesktop/login1/user/_1000
2021-01-01 13:22:37.759070: USER: gdm, UID: 121, UNAME: gdm, UPATH: /org/freedesktop/login1/user/_121
2021-01-01 13:22:37.759117: finish getUserList
2021-01-01 13:22:37.759180: NOTE: we have a new user "sunxd"
2021-01-01 13:22:37.759251: start init timekprUser
2021-01-01 13:22:37.760568: init user (sunxd) configuration manager
2021-01-01 13:22:37.760758: finish user configuration manager
2021-01-01 13:22:37.760837: init user (sunxd) control
2021-01-01 13:22:37.760984: finish init user control
2021-01-01 13:22:37.761111: start init notifications
2021-01-01 13:22:37.761194: finish init notifications
2021-01-01 13:22:37.761242: finish init timekprUser
2021-01-01 13:22:37.761310: start adjustLimitsFromConfig
2021-01-01 13:22:37.761353: start load user configuration
2021-01-01 13:22:37.761848: PT: found total 0 activities, valid 0
2021-01-01 13:22:37.762279: finish load user configuration
2021-01-01 13:22:37.762409: ---=== ERROR working on users ===---
2021-01-01 13:22:37.763574: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/timekpr/server/interface/dbus/daemon.py", line 135, in executeTimekprWorker
    self.checkUsers()
  File "/usr/lib/python3/dist-packages/timekpr/server/interface/dbus/daemon.py", line 221, in checkUsers
    self._timekprUserList[rUserName].adjustLimitsFromConfig()
  File "/usr/lib/python3/dist-packages/timekpr/server/user/userdata.py", line 279, in adjustLimitsFromConfig
    allowedHours = self._timekprUserConfig.getUserAllowedHours(rDay)
  File "/usr/lib/python3/dist-packages/timekpr/common/utils/config.py", line 920, in getUserAllowedHours
    hour, sMin, eMin, uacc = findHourStartEndMinutes(rHour)
  File "/usr/lib/python3/dist-packages/timekpr/common/utils/misc.py", line 191, in findHourStartEndMinutes
    uacc = True if pStr[0] == "!" else False
IndexError: string index out of range

2021-01-01 13:22:37.763649: ---=== ERROR working on users ===---
2021-01-01 13:22:37.763704: --- end working on users ---
2021-01-01 13:22:37.763754: --- performance: 0:00:00.005797 ---
2021-01-01 13:22:40.761062: --- start working on users ---
2021-01-01 13:22:40.761572: start checkUsers
2021-01-01 13:22:40.761872: start getUserList
2021-01-01 13:22:40.763471: USER: sunxd, UID: 1000, UNAME: sunxd, UPATH: /org/freedesktop/login1/user/_1000
2021-01-01 13:22:40.763809: USER: gdm, UID: 121, UNAME: gdm, UPATH: /org/freedesktop/login1/user/_121
2021-01-01 13:22:40.764048: finish getUserList
2021-01-01 13:22:40.764353: NOTE: system user "gdm" explicitly excluded
2021-01-01 13:22:40.764666: INFO: searching for login manager (gdm) VTNr
2021-01-01 13:22:40.780969: INFO: login manager (gdm) TTY found: 1
2021-01-01 13:22:40.781524: start adjustTimeSpentActual
2021-01-01 13:22:40.782151: ---=== start isUserActive for "sunxd" ===---
2021-01-01 13:22:40.785550: user stats, state: active, idleState: False
2021-01-01 13:22:40.786033: ---=== start cacheUserSessionList for "sunxd" ===---
2021-01-01 13:22:40.788169: adding session: 2, /org/freedesktop/login1/session/_32
2021-01-01 13:22:40.794038: ---=== finish cacheUserSessionList for "sunxd" ===---
2021-01-01 13:22:40.796935: INFO: session locked state is available and will be used for idle state detection (if it works)
2021-01-01 13:22:40.797147: got session - type: x11, VTNr: 2, state: active, idle: False, locked: False
2021-01-01 13:22:40.797270: session 2 active
2021-01-01 13:22:40.797371: ---=== finish isUserActive: True ===---
2021-01-01 13:22:40.797483: ---=== ERROR working on users ===---
2021-01-01 13:22:40.797730: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/timekpr/server/interface/dbus/daemon.py", line 135, in executeTimekprWorker
    self.checkUsers()

Revision history for this message
Eduards Bezverhijs (mjasnik) said :
#8

I tried to reproduce the error, but no success.
Will try with your exact config.

One more thing: does file /var/lib/timekpr/work/sunxd.time does not contain a section [sunxd.PLAYTIME]?

Revision history for this message
Xudong Sun (sunxd) said :
#9

no. /var/lib/timekpr/work/sunxd.time does NOT contain a section [sunxd.PLAYTIME]

maybe the users with the same problem, they should first simply replace their user specific configuration file with the example. i will try if that works.

Revision history for this message
Eduards Bezverhijs (mjasnik) said :
#10

Ahh, I see, you entered minutes with ":" as a separator, please change that to "-" as per description.
Fresh log file helped, but it was hard to spot :)

Example: 20[0:30] (wrong) change to 20[0-30] (correct).

Question, why don't you use graphical configurator? Is it not working or some other reason?

Revision history for this message
Xudong Sun (sunxd) said :
#11

ah, that was stupid of me! Sorry for the time you wasted !

I also checked if i changed the configure file by copying the timekpr.UESER.CONF it works

To your question, it seems the GUI does not allow changing of the time limit.

For example, for the "Daily Limit" tab, the button "apply" is not active, and double click or right click any of the days' time budget does not change anything.

I changed back to the previous configuration file and replaced : with -, but this time i can not stop the timekpr sevice, will restart to try again.

Revision history for this message
Best Eduards Bezverhijs (mjasnik) said :
#12

For GUI when entering the time intervals, please press "verify" and if config is ok, apply buttton will become active.
I tried to explain that in the README ;)

Ok, glad the issue is solved.

Revision history for this message
Xudong Sun (sunxd) said :
#13

for some reason, I launched the non-super-user GUI. shame on me again.

wish you a good start in the new year!

Revision history for this message
Eduards Bezverhijs (mjasnik) said :
#14

Thanks!

Best wishes to you in the new year!