mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2025-12-22 11:13:28 +00:00
Updates to scripts.
This commit is contained in:
@@ -59,6 +59,8 @@ class PseudoChannel():
|
||||
|
||||
DEBUG = config.debug_mode
|
||||
|
||||
ROTATE_LOG = config.rotateLog
|
||||
|
||||
def __init__(self):
|
||||
|
||||
logging.basicConfig(filename="pseudo-channel.log", level=logging.INFO)
|
||||
@@ -1008,6 +1010,18 @@ class PseudoChannel():
|
||||
|
||||
f.write(data)
|
||||
|
||||
def rotate_log(self):
|
||||
|
||||
try:
|
||||
os.remove('../pseudo-channel.log')
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
try:
|
||||
os.remove('./pseudo-channel.log')
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def exit_app(self):
|
||||
|
||||
print " - Exiting Pseudo TV & cleaning up."
|
||||
@@ -1175,6 +1189,9 @@ if __name__ == '__main__':
|
||||
see if it's midnight (or 23.59), if so then generate a new daily_schedule
|
||||
|
||||
"""
|
||||
"""Every <user specified day> rotate log"""
|
||||
dayToRotateLog = pseudo_channel.ROTATE_LOG.lower()
|
||||
schedule.every().friday.at("00:00").do(pseudo_channel.rotate_log)
|
||||
|
||||
logging.info("+++++ Running PseudoChannel.py -r")
|
||||
|
||||
|
||||
@@ -31,20 +31,6 @@
|
||||
|
||||
"""
|
||||
|
||||
import os, sys
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
# import ../plex_token.py
|
||||
|
||||
try:
|
||||
import plex_token as plex_token
|
||||
except ImportError as e:
|
||||
print "+++++ Cannot find plex_token file. Make sure you create a plex_token.py file with the appropriate data."
|
||||
raise e
|
||||
|
||||
baseurl = plex_token.baseurl
|
||||
token = plex_token.token
|
||||
gkey = plex_token.gkey
|
||||
|
||||
'''
|
||||
*
|
||||
* List of plex clients to use (add multiple clients to control multiple TV's)
|
||||
@@ -83,8 +69,34 @@ useDailyOverlapCache = True
|
||||
|
||||
dailyUpdateTime = "12:00 AM"
|
||||
|
||||
"""Debug mode will give you more output in your terminal to help problem solve issues.s"""
|
||||
"""Debug mode will give you more output in your terminal to help problem solve issues."""
|
||||
debug_mode = True
|
||||
|
||||
"""---"""
|
||||
useGoogleCalendar = False
|
||||
useGoogleCalendar = False
|
||||
|
||||
"""When to delete / remake the pseudo-channel.log - right at midnight, (i.e. 'friday') """
|
||||
rotateLog = "friday"
|
||||
|
||||
|
||||
"""
|
||||
##### Do not edit below this line.
|
||||
|
||||
Below is logic to grab your Plex 'token' & Plex 'baseurl'. If you are following along and have created a 'plex_token.py'
|
||||
file as instructed, you do not need to edit below this line.
|
||||
|
||||
"""
|
||||
|
||||
import os, sys
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
# import ../plex_token.py
|
||||
|
||||
try:
|
||||
import plex_token as plex_token
|
||||
except ImportError as e:
|
||||
print "+++++ Cannot find plex_token file. Make sure you create a plex_token.py file with the appropriate data."
|
||||
raise e
|
||||
|
||||
baseurl = plex_token.baseurl
|
||||
token = plex_token.token
|
||||
gkey = plex_token.gkey
|
||||
48
startstop.sh
48
startstop.sh
@@ -13,35 +13,57 @@
|
||||
|
||||
#----BEGIN EDITABLE VARS----
|
||||
|
||||
pid_file=running.pid
|
||||
SCRIPT_TO_EXECUTE_PLUS_ARGS='PseudoChannel.py -m -r'
|
||||
|
||||
output_pid_path=.
|
||||
OUTPUT_PID_FILE=running.pid
|
||||
|
||||
python_to_use="$(which python)"
|
||||
OUTPUT_PID_PATH=.
|
||||
|
||||
PYTHON_TO_USE="$(which python)"
|
||||
|
||||
# If using 'virtualenv' with python, specify the local virtualenv dir.
|
||||
VIRTUAL_ENV_DIR="env"
|
||||
|
||||
#----END EDITABLE VARS-------
|
||||
|
||||
if [ ! -e $output_pid_path/$pid_file ]; then
|
||||
if [ -d "$VIRTUAL_ENV_DIR" ]; then
|
||||
|
||||
PYTHON_TO_USE="$VIRTUAL_ENV_DIR/bin/python"
|
||||
|
||||
fi
|
||||
|
||||
if [ ! -e "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE" ]; then
|
||||
|
||||
# If the running.pid file doesn't exists, create it, start PseudoChannel.py and add the PID to it.
|
||||
nohup $python_to_use ./PseudoChannel.py -m -r > /dev/null 2>&1 & echo $! > $output_pid_path/$pid_file
|
||||
"$PYTHON_TO_USE" ./$SCRIPT_TO_EXECUTE_PLUS_ARGS > /dev/null 2>&1 & echo $! > "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE"
|
||||
|
||||
echo "Started $SCRIPT_TO_EXECUTE_PLUS_ARGS @ Process: $!"
|
||||
|
||||
echo "Started PseudoChannel.py @ Process: $!"
|
||||
sleep .7
|
||||
echo "Created $pid_file file in $output_pid_path dir"
|
||||
|
||||
echo "Created $OUTPUT_PID_FILE file in $OUTPUT_PID_PATH dir"
|
||||
|
||||
else
|
||||
|
||||
# If the running.pid exists, read it & try to kill the process if it exists, then delete it.
|
||||
the_pid=$(<$output_pid_path/$pid_file)
|
||||
rm $output_pid_path/$pid_file
|
||||
echo "Deleted $pid_file file in $output_pid_path dir"
|
||||
kill $the_pid
|
||||
the_pid=$(<$OUTPUT_PID_PATH/$OUTPUT_PID_FILE)
|
||||
|
||||
rm "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE"
|
||||
|
||||
echo "Deleted $OUTPUT_PID_FILE file in $OUTPUT_PID_PATH dir"
|
||||
|
||||
kill "$the_pid"
|
||||
|
||||
while [ -e /proc/$the_pid ]
|
||||
|
||||
do
|
||||
echo "PseudoChannel.py @: $the_pid is still running"
|
||||
|
||||
echo "$SCRIPT_TO_EXECUTE_PLUS_ARGS @: $the_pid is still running"
|
||||
|
||||
sleep .7
|
||||
|
||||
done
|
||||
echo "PseudoChannel.py @: $the_pid has finished"
|
||||
|
||||
echo "$SCRIPT_TO_EXECUTE_PLUS_ARGS @: $the_pid has finished"
|
||||
|
||||
fi
|
||||
Reference in New Issue
Block a user