summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/idle.py
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2014-05-14 16:48:51 (GMT)
committerBritney Fransen <brfransen@gmail.com>2014-05-14 16:48:51 (GMT)
commit9e73f8ae6c7d9800b6fc643fc143f40549fac609 (patch)
tree429909e856ecea45721599e9eab62823edb20d51 /abs/core/LinHES-system/idle.py
parent5cd1b95e1f680f549c2e11ce30e0d22a3a887678 (diff)
downloadlinhes_pkgbuild-9e73f8ae6c7d9800b6fc643fc143f40549fac609.zip
linhes_pkgbuild-9e73f8ae6c7d9800b6fc643fc143f40549fac609.tar.gz
linhes_pkgbuild-9e73f8ae6c7d9800b6fc643fc143f40549fac609.tar.bz2
LinHES-system: idle.py: add option to check user logins. closes #969
Diffstat (limited to 'abs/core/LinHES-system/idle.py')
-rwxr-xr-xabs/core/LinHES-system/idle.py45
1 files changed, 36 insertions, 9 deletions
diff --git a/abs/core/LinHES-system/idle.py b/abs/core/LinHES-system/idle.py
index 16dc873..6b813b4 100755
--- a/abs/core/LinHES-system/idle.py
+++ b/abs/core/LinHES-system/idle.py
@@ -182,6 +182,25 @@ def mythtvsetup_check(cmdargs):
msg(cmdargs," mythtv-setup is NOT running.")
return True
+def userlogins_check(cmdargs):
+ if (cmdargs.logins):
+ u=False
+ msg(cmdargs," Checking for users logged in...")
+ users=subprocess.check_output("who")
+ names=([x.split() for x in users.splitlines()])
+ for i in names:
+ if (i[0] == "mythtv" and i[4] == "(:0)"):
+ msg(cmdargs," Ignoring %s %s" %(i[0],i[4]))
+ else:
+ msg(cmdargs," User logged in: %s %s" %(i[0],i[4]))
+ u=True
+ if u:
+ return False
+ else:
+ return True
+ else:
+ return True
+
def mythfe_check(cmdargs,cursor,mythDB):
if ( cmdargs.runningfe ):
msg(cmdargs," Checking for running and playing mythfrontends...")
@@ -229,20 +248,22 @@ def usage():
idle.py checks these parts of the system in this order to
determine if it is idle:
+ - (option -g) users are logged in return busy
+ ignores mythtv (:0) for busy
- (option -l) mythshutdown is locked return busy
- - (option -d) In a daily wake period or
+ - (option -d) in a daily wake period or
about to start a daily wake period return busy
checks the next 15 minutes. -t TIME changes time
- schema is locked return busy
- - There are in use programs return busy
- - There are active jobs in the job queue return busy
+ - there are in use programs return busy
+ - there are active jobs in the job queue return busy
- mythfilldatabase is running return busy
- mythtv-setup is running return busy
- - There are upcoming recordings return busy
+ - there are upcoming recordings return busy
checks the next 15 minutes. -t TIME changes time
- - (option -r) mythfrontends running
- - mythfrontends playing back a recording or video
- - mythfrontends not in menus
+ - (option -r) mythfrontends running return busy
+ - mythfrontends playing back a recording or video return busy
+ - mythfrontends not in menus return busy
idle.py stops checking and returns false (busy) when the first busy is found.
'''
@@ -252,6 +273,7 @@ def usage():
def main(args=[False]):
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--daily', action='store_true', help='Include daily wake & about to start wake in system busy. (default: daily wake & about to start wake is system idle)')
+ parser.add_argument('-g', '--logins', action='store_true', help='Include user logins in system busy. ignores mythtv (:0) in system busy.')
parser.add_argument('-l', '--lock', action='store_true', help='Include mythshutdown lock in system busy. (default: mythshutdown lock is system idle)')
parser.add_argument('-r', '--runningfe', action='store_true', help='Include running mythfrontends in system busy. (default: running mythfrontends are system idle)')
parser.add_argument('-s', '--silent', action='store_true', help='Run without printing output. Recommended for use in cron jobs or scripts.')
@@ -267,6 +289,11 @@ def main(args=[False]):
idle=True
msg(cmdargs,"Checking system idle...")
+ if (userlogins_check(cmdargs)):
+ idle = True
+ else:
+ idle = False
+
try:
from MythTV import MythDB
mythDB = MythDB()
@@ -284,7 +311,7 @@ def main(args=[False]):
msg(cmdargs,"Couldn't connect to MythTV backend.")
be_conn=False
- if ( db_conn ):
+ if ( db_conn and idle ):
if (mythshutdownlock_check(cmdargs,cursor) and dailywake_check(cmdargs,cursor) and schemalock_check(cmdargs,cursor) and in_use(cmdargs,cursor) and job_check(cmdargs,cursor)):
idle=True
else:
@@ -297,7 +324,7 @@ def main(args=[False]):
idle=False
if ( db_conn and idle ):
- if ( mythfe_check(cmdargs,cursor,mythDB) ):
+ if (mythfe_check(cmdargs,cursor,mythDB)):
idle=True
else:
idle=False