Завершение работы Intel NUC HTPC на холостом ходу

Это зависит от версии wxwidgets. Вы должны установить 2.8.12 вместо 2.8.11, предоставленного в официальных репозиториях Oneiric. Найдите источник на http://wxwidgets.org/ (вам придется его самостоятельно скомпилировать) или введите в терминале следующее:

sudo add-apt-repository ppa: n-muench / program-ppa sudo apt-get update sudo apt-get upgrade

Наслаждайтесь!

2
задан 15 January 2018 в 05:27

2 ответа

Я не мог заставить события системы MythTV работать. Пытался изо всех сил играть с разрешениями все напрасно. Вот мой текущий рабочий код. Замените переменные базы данных на свои настройки. Сохраните его, скажем, /etc/cron.daily/idle_htpc.py Если какой-либо из шагов завершится неудачей, программа закроется. Просто sudo crontab -e это для каждого 5-59/15 * * * * /etc/cron.daily/idle_htpc.py /var/log/htpc_out 2> /var/log/htpc_err 15 минут

Шаг 1: Посмотрите, есть ли какие-либо SSH-соединения

Шаг 2: Проверьте, воспроизводится ли в реальном времени или записанное видео , Если вы не спите в течение 5 минут

Шаг 3: Еще раз проверьте, воспроизводится ли живое или записанное видео в данный момент

Шаг 4: Проверьте, был ли живой поток в течение последних 5 минут на всякий случай, если на этапе 2 был поток в 5 минут, а скрипт спал на этапе 2. Однако, если было зарегистрированное воспроизведение, здесь не будет никаких средств для обнаружения.

Шаг 5: Проверьте следующую предстоящую запись и если есть один, и это> 5 минут, то теперь активируется ACPI пробуждение за 3 минуты до времени начала и завершения работы, иначе очистка и отключение ACPI.

Надеюсь, это кому-то поможет.

#!/usr/bin/python3 import pymysql import pymysql.cursors from datetime import timedelta,datetime import subprocess import time import sys print ( datetime.now().strftime("%Y-%m-%d %H:%M:%S"), file=sys.stdout) def check_Logins(): #Returns the number of SSH connections #result= subprocess.run('who | grep -cv "(:"', stdout=subprocess.PIPE, shell=True) result= subprocess.run("netstat -n |grep tcp |grep ':22' |wc -l", stdout=subprocess.PIPE, shell=True) print ('Logins:'+result.stdout.decode('UTF-8'), file=sys.stdout) return (int(result.stdout.decode('UTF-8'))) def check_if_InUse(): #Checks if a live stream or a previosuly recorded program is being served at this moment. If yes, non zero value is returned InUse=1 connection = pymysql.connect(host=$host, user=$username, password=$password, db=$db, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) try: with connection.cursor() as cursor: # Read a single record sql = "select count(*) from inuseprograms where recusage !='jobqueue' and recusage !='flagger'" cursor.execute(sql) result = cursor.fetchone() InUse = result["count(*)"] finally: connection.close() print ("Count: "+str(InUse), file=sys.stdout) return InUse def check_live_5min(): #Checks if there were any live streams served in last 5 minutes RecInUse_5min=1 connection = pymysql.connect(host=$host, user=$username, password=$password, db=$db, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) try: with connection.cursor() as cursor: # Read a single record sql = "select max(starttime) from recordedseek" cursor.execute(sql) result = cursor.fetchone() print ('Recent: ', result['max(starttime)'], file=sys.stdout) print ('Current: ',datetime.utcnow(), file=sys.stdout) if datetime.utcnow()-result['max(starttime)']>=timedelta(minutes=5): RecInUse_5min =0 finally: connection.close() return RecInUse_5min def get_next_rec(): #Returns a tuple indicating if there is any scheduled recording if yes, how far into the future retdata = (True, timedelta(minutes=1)) connection = pymysql.connect(host=$host, user=$username, password=$password, db=$db, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) try: with connection.cursor() as cursor: # Read a single record sql = "select MIN(next_record) from record where recordid!=1 and next_record IS NOT NULL;" cursor.execute(sql) result = cursor.fetchone() if result['MIN(next_record)'] is None: #no scheduled recordings retdata= (False,timedelta(minutes=1)) else: retdata= (True,result['MIN(next_record)']-datetime.utcnow()) finally: connection.close() return retdata if check_Logins()==0: print ('First check passed', file=sys.stdout) if check_if_InUse() == 0: print ('Second check passed', file=sys.stdout) time.sleep(5*60) if check_if_InUse() == 0: print ('Third check passed', file=sys.stdout) if check_live_5min()==0: print ('Fourth check passed', file=sys.stdout) (valid,upcoming) = get_next_rec() # Clear any previously set wakeup time result = subprocess.run('echo 0 > /sys/class/rtc/rtc0/wakealarm',stdout=subprocess.PIPE,shell=True) print ('Clear:'+result.stdout.decode('UTF-8'), file=sys.stdout) if valid is True: # Generate wakeup time string upcoming = upcoming - timedelta(minutes=3) wakeup_string="'+"+str(upcoming.days)+" days + "+str(max([int(upcoming.seconds/60)-3,0]))+" minutes'" print ('Setting for '+wakeup_string, file=sys.stdout) wakeup_command="echo `date '+%s' -d " +wakeup_string+ "` > /sys/class/rtc/rtc0/wakealarm" #Setup wakeup time result = subprocess.run(wakeup_command,stderr=subprocess.PIPE, shell=True) print ('Set:'+result.stderr.decode('UTF-8'), file=sys.stdout) #Check if alarm is set. It should show the unix time stamp result= subprocess.run('cat /sys/class/rtc/rtc0/wakealarm', stdout=subprocess.PIPE, shell=True) print ('Check:'+result.stdout.decode('UTF-8'), file=sys.stdout) print ('Shutting down', file=sys.stdout) subprocess.Popen(['/sbin/shutdown', '-h', 'now'])
0
ответ дан 17 July 2018 в 23:03

Я не мог заставить события системы MythTV работать. Пытался изо всех сил играть с разрешениями все напрасно. Вот мой текущий рабочий код. Замените переменные базы данных на свои настройки. Сохраните его, скажем, /etc/cron.daily/idle_htpc.py Если какой-либо из шагов завершится неудачей, программа закроется. Просто sudo crontab -e это для каждого 5-59/15 * * * * /etc/cron.daily/idle_htpc.py /var/log/htpc_out 2> /var/log/htpc_err 15 минут

Шаг 1: Посмотрите, есть ли какие-либо SSH-соединения

Шаг 2: Проверьте, воспроизводится ли в реальном времени или записанное видео , Если вы не спите в течение 5 минут

Шаг 3: Еще раз проверьте, воспроизводится ли живое или записанное видео в данный момент

Шаг 4: Проверьте, был ли живой поток в течение последних 5 минут на всякий случай, если на этапе 2 был поток в 5 минут, а скрипт спал на этапе 2. Однако, если было зарегистрированное воспроизведение, здесь не будет никаких средств для обнаружения.

Шаг 5: Проверьте следующую предстоящую запись и если есть один, и это> 5 минут, то теперь активируется ACPI пробуждение за 3 минуты до времени начала и завершения работы, иначе очистка и отключение ACPI.

Надеюсь, это кому-то поможет.

#!/usr/bin/python3 import pymysql import pymysql.cursors from datetime import timedelta,datetime import subprocess import time import sys print ( datetime.now().strftime("%Y-%m-%d %H:%M:%S"), file=sys.stdout) def check_Logins(): #Returns the number of SSH connections #result= subprocess.run('who | grep -cv "(:"', stdout=subprocess.PIPE, shell=True) result= subprocess.run("netstat -n |grep tcp |grep ':22' |wc -l", stdout=subprocess.PIPE, shell=True) print ('Logins:'+result.stdout.decode('UTF-8'), file=sys.stdout) return (int(result.stdout.decode('UTF-8'))) def check_if_InUse(): #Checks if a live stream or a previosuly recorded program is being served at this moment. If yes, non zero value is returned InUse=1 connection = pymysql.connect(host=$host, user=$username, password=$password, db=$db, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) try: with connection.cursor() as cursor: # Read a single record sql = "select count(*) from inuseprograms where recusage !='jobqueue' and recusage !='flagger'" cursor.execute(sql) result = cursor.fetchone() InUse = result["count(*)"] finally: connection.close() print ("Count: "+str(InUse), file=sys.stdout) return InUse def check_live_5min(): #Checks if there were any live streams served in last 5 minutes RecInUse_5min=1 connection = pymysql.connect(host=$host, user=$username, password=$password, db=$db, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) try: with connection.cursor() as cursor: # Read a single record sql = "select max(starttime) from recordedseek" cursor.execute(sql) result = cursor.fetchone() print ('Recent: ', result['max(starttime)'], file=sys.stdout) print ('Current: ',datetime.utcnow(), file=sys.stdout) if datetime.utcnow()-result['max(starttime)']>=timedelta(minutes=5): RecInUse_5min =0 finally: connection.close() return RecInUse_5min def get_next_rec(): #Returns a tuple indicating if there is any scheduled recording if yes, how far into the future retdata = (True, timedelta(minutes=1)) connection = pymysql.connect(host=$host, user=$username, password=$password, db=$db, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) try: with connection.cursor() as cursor: # Read a single record sql = "select MIN(next_record) from record where recordid!=1 and next_record IS NOT NULL;" cursor.execute(sql) result = cursor.fetchone() if result['MIN(next_record)'] is None: #no scheduled recordings retdata= (False,timedelta(minutes=1)) else: retdata= (True,result['MIN(next_record)']-datetime.utcnow()) finally: connection.close() return retdata if check_Logins()==0: print ('First check passed', file=sys.stdout) if check_if_InUse() == 0: print ('Second check passed', file=sys.stdout) time.sleep(5*60) if check_if_InUse() == 0: print ('Third check passed', file=sys.stdout) if check_live_5min()==0: print ('Fourth check passed', file=sys.stdout) (valid,upcoming) = get_next_rec() # Clear any previously set wakeup time result = subprocess.run('echo 0 > /sys/class/rtc/rtc0/wakealarm',stdout=subprocess.PIPE,shell=True) print ('Clear:'+result.stdout.decode('UTF-8'), file=sys.stdout) if valid is True: # Generate wakeup time string upcoming = upcoming - timedelta(minutes=3) wakeup_string="'+"+str(upcoming.days)+" days + "+str(max([int(upcoming.seconds/60)-3,0]))+" minutes'" print ('Setting for '+wakeup_string, file=sys.stdout) wakeup_command="echo `date '+%s' -d " +wakeup_string+ "` > /sys/class/rtc/rtc0/wakealarm" #Setup wakeup time result = subprocess.run(wakeup_command,stderr=subprocess.PIPE, shell=True) print ('Set:'+result.stderr.decode('UTF-8'), file=sys.stdout) #Check if alarm is set. It should show the unix time stamp result= subprocess.run('cat /sys/class/rtc/rtc0/wakealarm', stdout=subprocess.PIPE, shell=True) print ('Check:'+result.stdout.decode('UTF-8'), file=sys.stdout) print ('Shutting down', file=sys.stdout) subprocess.Popen(['/sbin/shutdown', '-h', 'now'])
0
ответ дан 24 July 2018 в 13:36

Другие вопросы по тегам:

Похожие вопросы: