# HG changeset patch # User Marcin Kuzminski # Date 1341594350 -7200 # Node ID 9a99b574bb485e2b3abda2393b1d8977e113ccc1 # Parent 9382e88eae22014bb0f70d2e57a239ef1834875f py25 compatibility for subprocession module diff -r 9382e88eae22 -r 9a99b574bb48 rhodecode/lib/subprocessio.py --- a/rhodecode/lib/subprocessio.py Fri Jul 06 18:28:13 2012 +0200 +++ b/rhodecode/lib/subprocessio.py Fri Jul 06 19:05:50 2012 +0200 @@ -22,6 +22,7 @@ along with git_http_backend.py Project. If not, see . ''' +from __future__ import unicode_literals import os import subprocess import threading @@ -40,22 +41,23 @@ self.daemon = True filelike = False self.bytes = b'' - if type(source) in (type(''), bytes, bytearray): # string-like + if type(source) in (type(''), bytes, bytearray): # string-like self.bytes = bytes(source) - else: # can be either file pointer or file-like - if type(source) in (int, long): # file pointer it is + else: # can be either file pointer or file-like + if type(source) in (int, long): # file pointer it is ## converting file descriptor (int) stdin into file-like try: source = os.fdopen(source, 'rb', 16384) - except: + except Exception: pass # let's see if source is file-like by now try: filelike = source.read - except: + except Exception: pass if not filelike and not self.bytes: - raise TypeError("StreamFeeder's source object must be a readable file-like, a file descriptor, or a string-like.") + raise TypeError("StreamFeeder's source object must be a readable " + "file-like, a file descriptor, or a string-like.") self.source = source self.readiface, self.writeiface = os.pipe() @@ -325,11 +327,11 @@ ''' Initializes SubprocessIOChunker - @param cmd A Subprocess.Popen style "cmd". Can be string or array of strings - @param inputstream (Default: None) A file-like, string, or file pointer. - @param buffer_size (Default: 65536) A size of total buffer per stream in bytes. - @param chunk_size (Default: 4096) A max size of a chunk. Actual chunk may be smaller. - @param starting_values (Default: []) An array of strings to put in front of output que. + :param cmd: A Subprocess.Popen style "cmd". Can be string or array of strings + :param inputstream: (Default: None) A file-like, string, or file pointer. + :param buffer_size: (Default: 65536) A size of total buffer per stream in bytes. + :param chunk_size: (Default: 4096) A max size of a chunk. Actual chunk may be smaller. + :param starting_values: (Default: []) An array of strings to put in front of output que. ''' if inputstream: