~mjasnik/timekpr-revived/stable

« back to all changes in this revision

Viewing changes to src/common/timekprpam.py

  • Committer: Eduards Bezverhijs
  • Date: 2018-08-10 06:48:59 UTC
  • mfrom: (1.1.27 development)
  • Revision ID: edzis@inbox.lv-20180810064859-7l6dhe2tzef1vx3o
* Improve notification handling (DBUS lazy init)
  * New notification limits:
  * time left > 2hrs = notifications every hour
  * time left < 2hrs = notifications every half an hour
  * time left < 30mins = notifications every 10 minutes
  * time left < 10mins = notifications every 5 minutes
  * time left < 3mins = notifications every minute
  * notifications are critical starting when time left < 10 minutes (critial means notifications try to stay on top of all they can)
  * Added debugging options (in case there are problems with client)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
    """
21
21
    s = open(conffile).read()
22
22
    check = re.compile('## TIMEKPR START|## TIMEKPR END').findall(s)
23
 
    
 
23
 
24
24
    # If the timekpr section lines '## TIMEKPR START' or '## TIMEKPR END' are not
25
25
    # found, exit with an error.
26
26
    if not len(check):
124
124
    #return Al0700-2400
125
125
    if mfrom and mto:
126
126
        return 'Al' + hourize(mfrom.group(1)) + '-' + hourize(mto.group(1))
127
 
    
 
127
 
128
128
    #or if all days separate
129
129
    su = 'Su' + hourize(hfrom[0]) + '-' + hourize(hto[0])
130
130
    mo = 'Mo' + hourize(hfrom[1]) + '-' + hourize(hto[1])
264
264
def converttconf(tfrom, tto, mode=0):
265
265
    """Removes the unnecessary 0 and multiplies from and to lists if necessary
266
266
 
267
 
    If mode = 0 (default), it converts tfrom = ['08','08','13','14','15','01','09'], 
 
267
    If mode = 0 (default), it converts tfrom = ['08','08','13','14','15','01','09'],
268
268
    tto = ['22','14','19','20','21','23','25'] into ['8','8','13','14','15','1','9']
269
269
    and ['22','14','19','20','21','23','25'] respectively
270
270
    If mode = 1, it converts tfrom = '08', tto = '22' into ['8','8','8','8','8','8','8']
333
333
                                [su[1], mo[1],tu[1],we[1],th[1],fr[1],sa[1]])
334
334
        retlist.append([u, final])
335
335
        # Internal example - retlist.append appends like so:
336
 
        # user: [niania,(['0', '0', '0', '0', '0', '0', '0'], 
 
336
        # user: [niania,(['0', '0', '0', '0', '0', '0', '0'],
337
337
        #       ['24', '24', '24', '24', '24', '24', '24'])]
338
 
        # user: [wawa,(['7', '7', '7', '7', '7', '7', '9'], 
 
338
        # user: [wawa,(['7', '7', '7', '7', '7', '7', '9'],
339
339
        #        ['22', '22', '22', '22', '22', '22', '22'])]
340
 
    
 
340
 
341
341
    return retlist
342
342
 
343
343
def getuserlimits(u):