X-Git-Url: http://users.mur.at/ms/git/gitweb/?a=blobdiff_plain;f=aces_1.0.0%2Fpython%2Faces_ocio%2Fprocess.py;h=76dd754389909215b44aa9d9a8810b6d34040974;hb=529f7b361204176430ea0df642e4ec00a5c54ad7;hp=db23fc37abc24b4b4d26524560102b65a5b10225;hpb=d815605e42c964ddb306e32506caaa077b3cf160;p=OpenColorIO-Configs.git diff --git a/aces_1.0.0/python/aces_ocio/process.py b/aces_1.0.0/python/aces_ocio/process.py index db23fc3..76dd754 100755 --- a/aces_1.0.0/python/aces_ocio/process.py +++ b/aces_1.0.0/python/aces_ocio/process.py @@ -6,6 +6,8 @@ A process wrapper class that maintains the text output and execution status of a process or a list of other process wrappers which carry such data. """ +from __future__ import division + import os import sys import traceback @@ -39,9 +41,13 @@ def read_text(text_file): Return value description. """ - if text_file != '': - with open(text_file, 'rb') as fp: - text = (fp.read()) + # TODO: Investigate if check is needed. + if not text_file: + return + + with open(text_file, 'rb') as fp: + text = (fp.read()) + return text @@ -60,9 +66,13 @@ def write_text(text, text_file): Return value description. """ - if text_file != '': - with open(text_file, 'wb') as fp: - fp.write(text) + # TODO: Investigate if check is needed. + if not text_file: + return + + with open(text_file, 'wb') as fp: + fp.write(text) + return text @@ -74,7 +84,7 @@ class Process: def __init__(self, description=None, cmd=None, - args=[], + args=None, cwd=None, env=None, batch_wrapper=False): @@ -92,6 +102,9 @@ class Process: Return value description. """ + if args is None: + args = [] + self.cmd = cmd if not description: self.description = cmd @@ -148,7 +161,7 @@ class Process: Return value description. """ - if key != None and (value != None or start_stop != None): + if key is not None and (value is not None or start_stop is not None): indent = '\t' * write_dict['indentationLevel'] if write_dict['format'] == 'xml': if start_stop == 'start': @@ -413,7 +426,7 @@ class Process: # Using *subprocess* if sp: - if process != None: + if process is not None: # pid = process.pid # log.logLine('process id %s\n' % pid) @@ -431,14 +444,16 @@ class Process: # This is now used to ensure that the process has finished. line = '' - while line != None and process.poll() is None: + while line is not None and process.poll() is None: try: line = process.stdout.readline() except: break # 3.1 try: - self.log_line(str(line, encoding='utf-8')) + # TODO: Investigate previous eroneous statement. + # self.log_line(str(line, encoding='utf-8')) + self.log_line(str(line)) # 2.6 except: self.log_line(line) @@ -460,6 +475,8 @@ class Process: exit_code = -1 try: stdout_lines = stdout.readlines() + # TODO: Investigate if this is the good behavior, close() does + # not return anything / None. exit_code = stdout.close() stdout.close() @@ -713,7 +730,6 @@ def main(): args_start = sys.argv.index('--') + 1 args = sys.argv[args_start:] except: - args_start = len(sys.argv) + 1 args = [] if cmd is None: