 |
pyTivo Discussion Forum Answers and the development of pyTivo a TiVo transcoding server
|
|
| Author |
Message |
rjmitche
Joined: 04 Jan 2008 Posts: 33
|
Posted: Sun Mar 02, 2008 8:08 pm Post subject: pyTivo as a service - observations |
|
|
I've been running pyTivo on XP as a service for a while now and been keeping up with all the recent developments. I'm currently running the most recent version from wgw's branch which includes the new debug code/module. I've noticed a few things about running as a service that appear to differ from running it via the command window and was wondering if it is expected behavior or if there is something unique with the way I'm doing things.
1. debug.txt location - when running as a service, debug.txt is created in C:\Python25\Lib\site-packages\win32\debug.txt rather than C:\Program Files\pyTivo\debug.txt (where it is when running via command window). I managed to change this behavior by changing the following line in debug.py:
| Code: | old: fdebug = open('debug.txt', 'a')
new: fdebug = open(os.path.join(p, 'debug.txt'), 'a') |
2. log.txt - when running as a service, a log.txt file is created in the pyTivo directory from pyTivoService.py (see code snippet blow). Some of the things that appear in the command window when running manually are written to log.txt (NameMapper warning, http requests, etc.) but, certainly not everything. It would be great if this really did contain all of the things that would normally be written to the console but, I'm not sure how feasible that is.
Code from pyTivoService.py:
| Code: | f = open(os.path.join(p, 'log.txt'), 'w')
sys.stdout = f
sys.stderr = f |
3. precache functionality - I could certainly be wrong here (my shares don't contain huge amounts of files) but, I'm not sure that the precache functionality is working when running as a service. Is there a way to tell for sure? I know that it is working when run via the command window (I see the print statements as it caches each share) but, I see different menu behavior when running as a service (more delays going into a share as well as paging within a share). Looking at the debug.txt, I see the ffmpeg output as it precaches each video file when running via the command window but, I don't see the same output when running as a service:
debug.txt running via command window:
| Code: | debug.38 [<module>] ----- begin pyTivo.conf -----
debug.38 [<module>] [Server]
debug.38 [<module>] debug = true
debug.38 [<module>] guid = 111111
debug.38 [<module>] port = 9032
debug.38 [<module>] ffmpeg = c:\Program Files\pyTivo\plugins\video\ffmpeg_mp2.exe
debug.38 [<module>] max_audio_br = 448K
debug.38 [<module>] [Admin]
debug.38 [<module>] type = admin
debug.38 [<module>] [_tivo_6490001xxxxxxxx]
debug.38 [<module>] aspect169 = true
debug.38 [<module>] [_tivo_5400001xxxxxxxx]
debug.38 [<module>] aspect169 = false
debug.38 [<module>] [_tivo_5400001xxxxxxxx]
debug.38 [<module>] aspect169 = false
debug.38 [<module>] [TV]
debug.38 [<module>] type = video
debug.38 [<module>] path = G:\TVShows\CSI-NY
debug.38 [<module>] precache=true
debug.38 [<module>] ------- end pyTivo.conf -----
transcode.311 [video_info] ffmpeg output= FFmpeg version SVN-r11870, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --enable-liba52 --enable-avisynth --enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --cpu=i686 --enable-memalign-hack --extra-ldflags=-static
libavutil version: 49.6.0
libavcodec version: 51.50.0
libavformat version: 52.7.0
libavdevice version: 52.0.0
built on Feb 5 2008 23:46:38, gcc: 4.2.3
Input #0, mpeg, from 'G:\TVShows\CSI-NY\CSI-NY 4x04 'Times Up'.mpg':
Duration: 00:42:14.4, start: 0.200000, bitrate: 2292 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x480 [PAR 32:27 DAR 16:9], 104857 kb/s, 29.97 tb(r)
Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, stereo, 192 kb/s
Must supply at least one output file
<ffmpeg output repeated for each video file> |
debug.txt running as a service:
| Code: | debug.38 [<module>] ----- begin pyTivo.conf -----
debug.38 [<module>] [Server]
debug.38 [<module>] debug = true
debug.38 [<module>] guid = 111111
debug.38 [<module>] port = 9032
debug.38 [<module>] ffmpeg = c:\Program Files\pyTivo\plugins\video\ffmpeg_mp2.exe
debug.38 [<module>] max_audio_br = 448K
debug.38 [<module>] [Admin]
debug.38 [<module>] type = admin
debug.38 [<module>] [_tivo_6490001xxxxxxxx]
debug.38 [<module>] aspect169 = true
debug.38 [<module>] [_tivo_5400001xxxxxxxx]
debug.38 [<module>] aspect169 = false
debug.38 [<module>] [_tivo_5400001xxxxxxxx]
debug.38 [<module>] aspect169 = false
debug.38 [<module>] [TV]
debug.38 [<module>] type = video
debug.38 [<module>] path = G:\TVShows\CSI-NY
debug.38 [<module>] precache=true
debug.38 [<module>] ------- end pyTivo.conf ----- |
side comment: I like the fact that pyTivo.conf is listed at the beginning of each new startup in debug.txt.... it might be nice to have a date/time stamp at the top as well just so, it's easier to tell exactly when a particular instance of pyTivo was started. I added the following to my debug.py:
| Code: | import datetime
...
debug_write(srcMod, fnAttr, [''])
debug_write(srcMod, fnAttr, ['********************************************************'])
debug_write(srcMod, fnAttr, ['** Begin pyTivo Session:', datetime.datetime.today(), ' **'])
debug_write(srcMod, fnAttr, ['********************************************************'])
debug_write(srcMod, fnAttr, ['----- begin pyTivo.conf -----']) |
which, as you might guess, adds the following to debug.txt:
| Code: | debug.38 [<module>]
debug.38 [<module>] ********************************************************
debug.38 [<module>] ** Begin pyTivo Session: 2008-03-02 21:54:15.921000 **
debug.38 [<module>] ********************************************************
debug.38 [<module>] ----- begin pyTivo.conf -----
...
|
4. upgrading - is it necessary to unistall/re-install the service every time I apply a new version of pyTivo? I typically just stop the service, update the pyTivo code, then restart the service. |
|
| Back to top |
|
 |
krkeegan Site Admin

Joined: 04 Jan 2008 Posts: 412 Location: Los Angeles, CA
|
Posted: Sun Mar 02, 2008 9:10 pm Post subject: Re: pyTivo as a service - observations |
|
|
| rjmitche wrote: | 1. debug.txt location - when running as a service, debug.txt is created in C:\Python25\Lib\site-packages\win32\debug.txt |
Interesting it looks like you are running the pywin32 version of the TiVo service. The newer service uses the correct working directory. But that should be an easy fix.
| Quote: | 2. log.txt - when running as a service, a log.txt file is created in the pyTivo directory from pyTivoService.py (see code snippet blow). |
Again this is a hold over from the pywin32 way of installing a service. This file is no longer created with the newer pytivoservice.exe. Instead a smaller file with start and stop times along with error codes is created as pytivoservice.txt.
I would rather not include all the output from the console as it would become a rather unwieldy large file if left running.
| Quote: | 3. precache functionality - I could certainly be wrong here (my shares don't contain huge amounts of files) but, I'm not sure that the precache functionality is working when running as a service. Is there a way to tell for sure? |
It isn't if you are using the pywin32 service method. Also there is no reason to continue to use precache setting. pyTivo is actually faster without it now on large shares. But using precache and the pywin32 service is actually slowing you down right now because of how the two older functions work with each other.
| Quote: | side comment: I like the fact that pyTivo.conf is listed at the beginning of each new startup in debug.txt.... it might be nice to have a date/time stamp at the top as well just so |
Agree we can add this.
| Quote: | 4. upgrading - is it necessary to unistall/re-install the service every time I apply a new version of pyTivo? I typically just stop the service, update the pyTivo code, then restart the service. |
It would be easier if you used the newer service method. Unfortunately because they share the same name 'pytivo' the pywin32 method is removed too. I force a complete uninstall because pyTivo evolves at a fast pace. As such I always want the installer to start with a clean slate. |
|
| Back to top |
|
 |
wgw
Joined: 06 Jan 2008 Posts: 262
|
Posted: Sun Mar 02, 2008 9:21 pm Post subject: |
|
|
Yeah, pyTivo was writing debug.txt to the launch directory even before I moved it. I'll add your patches shortly. Adding date time sounds like a good idea as well. _________________ Download pyTivo
my pyTivo branch |
|
| Back to top |
|
 |
rjmitche
Joined: 04 Jan 2008 Posts: 33
|
Posted: Sun Mar 02, 2008 10:00 pm Post subject: |
|
|
Thanks for the quick responses. I have to admit that I haven't really been following the Windows installer conversation too closely since I've gotten fairly comfortable replacing/upgrading to newer code manually. As such, I've been sticking with the pyWin32 version of the service simply because that is all I've known.
Having said that, I'm more than willing to give the installer a try, especially if it provides an extra benefit for those of us running pyTivo as a service. So, for someone that likes to know exactly what's being modified, is it documented somewhere exactly what steps the installer is taking? Would it be wise to start out with a cleared out c:\program files\pytivo directory but, leave pytivo.conf in place (I assume it won't try to recreate an already existing config file)?
Also, I'm a little surprised to hear that precache is no longer necessary... is that only when running as a service or across the board for all (relatively recent) instances of pyTivo? |
|
| Back to top |
|
 |
krkeegan Site Admin

Joined: 04 Jan 2008 Posts: 412 Location: Los Angeles, CA
|
Posted: Sun Mar 02, 2008 11:16 pm Post subject: |
|
|
you can clear out c:\program files\pytivo except for pytivo.conf.
As for a list of what is done. The installer is part of my git repository, the most recent version of it can be seen here. It is unfortunately not immediately understandable if you have never seen a NSIS script before. The summary of what it does is as follows:
1. It checks your registry for a valid installation of python
2. It asks if you want to install pyTivo as Console + Service or Console only
3. It asks what directory pytivo should be installed in
4. It asks where the shortcuts to pyTivo should be placed
5. It checks to see if there is a prior pytivo.conf
6. If not it helps you build a very basic one
7. It copies all the files to the directory you choose.
8. If you selected to install the service it registers and starts the service.
9. It writes the location of the uninstaller to the registry. This allows you to uninstall pyTivo from the control panel
10. It copies the shortcuts to the location chosen in the menu
Thats it.
As for precache. It kinda became obsolete as soon as it was born. Within 2 days of releasing it wmcbrine created a method to skip ffmpeg on the initial folder loading. ffmpeg was what was causing the delay.
Precache is still around because a few users still prefered to use that method. The only downside to not using precache now is that a file appears to be a video file but is otherwise corrupt and not playable by ffmpeg will appear in the video list. However once you select the detailed few of this file you will see a Red X informing you that the file is copyright and cannot be transfered. This is our way of saying that ffmpeg is incapable of playing that file. These instances are extremely rare and the solution is sufficient for most users.
Thanks again for your efforts in tracking down bugs. Kevin |
|
| Back to top |
|
 |
rjmitche
Joined: 04 Jan 2008 Posts: 33
|
Posted: Mon Mar 03, 2008 10:19 pm Post subject: |
|
|
Thanks for the info. I must have tried to use the installer once before on my machine because when I ran it this time, it told me I needed to uninstall the old version completely before continuing. I couldn't really uninstall since I had (apparently) removed all the files related to the installer. Thanks to the list in the previous response, I was able to nuke the entry in the registry related to uninstaller and was able to continue with the install.
I'm happy to say that it worked great and things are working well.
Thanks again for the detailed responses and everyone's outstanding work on this project. |
|
| Back to top |
|
 |
krkeegan Site Admin

Joined: 04 Jan 2008 Posts: 412 Location: Los Angeles, CA
|
Posted: Mon Mar 03, 2008 10:25 pm Post subject: |
|
|
| rjmitche wrote: | I must have tried to use the installer once before on my machine because when I ran it this time, it told me I needed to uninstall the old version completely before continuing. | Hmm, interesting I should figure out a more glamorous solution to that. |
|
| Back to top |
|
 |
wgw
Joined: 06 Jan 2008 Posts: 262
|
Posted: Wed Mar 05, 2008 6:03 pm Post subject: |
|
|
Since I was using the debug.txt location bug, umm feature, to my advantage, I've added an option for a user definable debug output path to my branch. It includes additional features, but would probably not be of interest to most users unless you regularly use debug. See branch for details. _________________ Download pyTivo
my pyTivo branch |
|
| Back to top |
|
 |
krkeegan Site Admin

Joined: 04 Jan 2008 Posts: 412 Location: Los Angeles, CA
|
Posted: Wed Mar 05, 2008 11:45 pm Post subject: |
|
|
| I agree that most users will not immediately find it useful I do plan on merging that in. You never really know when someone is going to have problems and being able to quickly enable a meaningful debug file is extremely helpful. |
|
| Back to top |
|
 |
rjmitche
Joined: 04 Jan 2008 Posts: 33
|
Posted: Sat Mar 08, 2008 5:59 am Post subject: |
|
|
krkeegan - I see you have merged all the latest patches into your branch. Now that I have switched to using the windows installer (and installing as a service), what is the best way to update to your latest package?
Can I just stop the service, unzip into the pyTivo directory, and restart the service or should I wait until the installer has been updated? |
|
| Back to top |
|
 |
krkeegan Site Admin

Joined: 04 Jan 2008 Posts: 412 Location: Los Angeles, CA
|
Posted: Sat Mar 08, 2008 1:07 pm Post subject: |
|
|
Umm right now you can just unzip if you like. Sorry I didn't repackage a windows installer yet, mostly because the updates I merged were relatively minor. I will run it when I get a chance, but if you unzip over the top of your current directory it should work just fine.
Kevin |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|