Changeset f81af4dc1c0580cb43338e46aeb2cedfb88827c3

Show
Ignore:
Timestamp:
11/25/06 04:07:28 (2 years ago)
Author:
Jason Michalski <armooo@armooo.net>
git-committer:
Jason Michalski <armooo@armooo.net> 1164449248 +0000
git-parent:

[f73eb991e35c522085b02fbaea125347f26e41b6]

git-author:
Jason Michalski <armooo@armooo.net> 1164449248 +0000
Message:

pyTivo
- BAD HACK to get subprocess to work without a console
- pyTivoService.py now works

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pyTivoService.py

    rf73eb99 rf81af4d  
    33import win32service  
    44import win32event 
    5 import select 
     5import select, sys 
    66 
    77class PyTivoService(win32serviceutil.ServiceFramework): 
     
    1818 
    1919        p = os.path.dirname(__file__) 
    20         open(os.path.join(p, 'pyTivo.conf')) 
    21        
     20     
     21        f = open(os.path.join(p, 'log.txt'), 'w') 
     22        sys.stdout = f 
     23        sys.stderr = f 
     24        print 'test' 
     25     
    2226        config = ConfigParser.ConfigParser() 
    2327        config.read( os.path.join(p, 'pyTivo.conf') ) 
     
    3640         
    3741        while 1: 
     42            sys.stdout.flush() 
    3843            (rx, tx, er) = select.select((httpd,), (), (), 5) 
    3944            for sck in rx: 
  • transcode.py

    rf838e68 rf81af4d  
    1 import subprocess, shutil, os, re 
     1import subprocess, shutil, os, re, sys 
    22 
    33SCRIPTDIR = os.path.dirname(__file__) 
    44 
     5# subprocess is broken for me on windows so super hack 
     6def patchSubprocess(): 
     7    o = subprocess.Popen._make_inheritable 
     8 
     9    def _make_inheritable(self, handle): 
     10        print 'MY _make_inheritable' 
     11        if not handle: return subprocess.GetCurrentProcess() 
     12        return o(self, handle) 
     13 
     14    subprocess.Popen._make_inheritable = _make_inheritable 
     15 
     16mswindows = (sys.platform == "win32") 
     17 
     18if mswindows: 
     19    patchSubprocess() 
     20         
    521def output_video(inFile, outFile): 
    622    if tivo_compatable(inFile): 
    723        f = file(inFile, 'rb') 
    824        shutil.copyfileobj(f, outFile) 
    9         f.close() 
     25        f.close()  
    1026    else: 
    1127        transcode(inFile, outFile) 
     
    1430 
    1531    cmd = SCRIPTDIR + "\\ffmpeg_mp2.exe -i \"%s\" -vcodec mpeg2video -r 29.97 -b 4096 %s -ac 2 -ab 192 -f vob -" % (inFile, select_aspect(inFile)) 
     32    # subprocess is busted in my python 2.5 when run without a console. Setting all to PIPE fixes it. 
     33    # but now we get this nice select loop to dump the stderr data 
    1634    ffmpeg = subprocess.Popen(cmd, stdout=subprocess.PIPE) 
    1735    try: 
     
    6886def video_info(inFile): 
    6987    cmd = SCRIPTDIR + "\\ffmpeg_mp2.exe -i \"%s\"" % inFile 
    70     ffmpeg = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE
     88    ffmpeg = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE
    7189    output = ffmpeg.stderr.read() 
    7290