From 32e2d9d563d64b046553036f3c0e2aecdd027765 Mon Sep 17 00:00:00 2001 From: Jason Michalski Date: Thu, 1 Mar 2007 05:02:43 +0000 Subject: [PATCH] pyTivo - Added the Config.py to fix files path when running as a windows service. --- Config.py | 5 +++++ plugins/video/transcode.py | 4 ++-- pyTivo.py | 6 ++---- pyTivoService.py | 5 ++--- 4 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 Config.py diff --git a/Config.py b/Config.py new file mode 100644 index 0000000..dfaecf7 --- /dev/null +++ b/Config.py @@ -0,0 +1,5 @@ +import ConfigParser, os + +config = ConfigParser.ConfigParser() +p = os.path.dirname(__file__) +config.read(os.path.join(p, 'pyTivo.conf')) diff --git a/plugins/video/transcode.py b/plugins/video/transcode.py index 8c26fc8..0ed2c71 100644 --- a/plugins/video/transcode.py +++ b/plugins/video/transcode.py @@ -1,7 +1,7 @@ import subprocess, shutil, os, re, sys, ConfigParser -config = ConfigParser.ConfigParser() -config.read(os.path.join(os.getcwd(), 'pyTivo.conf')) +from Config import config + FFMPEG = config.get('Server', 'ffmpeg') #SCRIPTDIR = os.path.dirname(__file__) #FFMPEG = os.path.join(SCRIPTDIR, 'ffmpeg_mp2.exe') diff --git a/pyTivo.py b/pyTivo.py index 0e441f4..f04a162 100644 --- a/pyTivo.py +++ b/pyTivo.py @@ -1,11 +1,9 @@ #!/usr/bin/env python2.4 -import beacon, httpserver, ConfigParser, os, sys +import beacon, httpserver, os, sys -config = ConfigParser.ConfigParser() -p = os.path.dirname(__file__) -config.read(os.path.join(p, 'pyTivo.conf')) +from Config import config port = config.get('Server', 'Port') diff --git a/pyTivoService.py b/pyTivoService.py index 0c4b25a..9522b65 100644 --- a/pyTivoService.py +++ b/pyTivoService.py @@ -16,15 +16,14 @@ class PyTivoService(win32serviceutil.ServiceFramework): import sys, os + from Config import config + p = os.path.dirname(__file__) f = open(os.path.join(p, 'log.txt'), 'w') sys.stdout = f sys.stderr = f - print 'test' - config = ConfigParser.ConfigParser() - config.read( os.path.join(p, 'pyTivo.conf') ) port = config.get('Server', 'Port') -- 2.11.4.GIT