From 704e96f6b6ffcbb856ce4610853c75e59f115cbd Mon Sep 17 00:00:00 2001 From: Justin Emter Date: Fri, 4 Aug 2017 20:01:54 -0700 Subject: [PATCH] Fixed the -xml chdir issue (I think). --- PseudoChannel.py | 16 ++++++++++++---- src/PseudoDailyScheduleController.py | 21 ++++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/PseudoChannel.py b/PseudoChannel.py index 893e876..76a5d54 100644 --- a/PseudoChannel.py +++ b/PseudoChannel.py @@ -20,6 +20,7 @@ import calendar import itertools import argparse import textwrap +import os, sys from xml.dom import minidom import xml.etree.ElementTree as ET @@ -314,6 +315,11 @@ class PseudoChannel(): def update_schedule(self): + """Changing dir to the schedules dir.""" + abspath = os.path.abspath(__file__) + dname = os.path.dirname(abspath) + os.chdir(dname) + self.db.create_tables() self.db.remove_all_scheduled_items() @@ -352,7 +358,7 @@ class PseudoChannel(): if time.attrib['type'] == key or time.attrib['type'] in value: - title = time.attrib['title'] + title = time.attrib['title'] if 'title' in time.attrib else '' natural_start_time = self.translate_time(time.text) @@ -362,11 +368,13 @@ class PseudoChannel(): day_of_week = child.tag - strict_time = time.attrib['strict-time'] + strict_time = time.attrib['strict-time'] if 'strict-time' in time.attrib else '' - time_shift = time.attrib['time-shift'] + time_shift = time.attrib['time-shift'] if 'time-shift' in time.attrib else '' - overlap_max = time.attrib['overlap-max'] + overlap_max = time.attrib['overlap-max'] if 'overlap-max' in time.attrib else '' + + seriesOffset = time.attrib['series-offset'] if 'series-offset' in time.attrib else '' start_time_unix = self.translate_time(time.text) diff --git a/src/PseudoDailyScheduleController.py b/src/PseudoDailyScheduleController.py index fd95b77..75eea1a 100644 --- a/src/PseudoDailyScheduleController.py +++ b/src/PseudoDailyScheduleController.py @@ -47,10 +47,6 @@ class PseudoDailyScheduleController(): self.my_logger.addHandler(self.handler) - """Changing dir to the schedules dir.""" - web_dir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'schedules')) - os.chdir(web_dir) - ''' * * Get the full image url (including plex token) from the local db. @@ -82,6 +78,10 @@ class PseudoDailyScheduleController(): if self.webserverStarted == False: + """Changing dir to the schedules dir.""" + web_dir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'schedules')) + os.chdir(web_dir) + PORT = int(self.CONTROLLER_SERVER_PORT) class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): @@ -91,7 +91,7 @@ class PseudoDailyScheduleController(): global httpd try: - print "Starting webserver at port: ", PORT + #print "Starting webserver at port: ", PORT # create the httpd handler for the simplehttpserver # we set the allow_reuse_address incase something hangs can still bind to port class ReusableTCPServer(SocketServer.TCPServer): allow_reuse_address=True @@ -365,6 +365,10 @@ class PseudoDailyScheduleController(): ''' def write_schedule_to_file(self, data): + """Changing dir to the schedules dir.""" + web_dir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'schedules')) + os.chdir(web_dir) + now = datetime.now() fileName = "index.html" @@ -396,6 +400,10 @@ class PseudoDailyScheduleController(): ''' def write_xml_to_file(self, data): + """Changing dir to the schedules dir.""" + web_dir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'schedules')) + os.chdir(web_dir) + now = datetime.now() fileName = "pseudo_schedule.xml" @@ -425,6 +433,9 @@ class PseudoDailyScheduleController(): * ''' def write_refresh_bool_to_file(self): + """Changing dir to the schedules dir.""" + web_dir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'schedules')) + os.chdir(web_dir) fileName = "pseudo_refresh.txt"