ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/Development/ray/src/common/pyradlib/pyrad_proc.py
(Generate patch)

Comparing ray/src/common/pyradlib/pyrad_proc.py (file contents):
Revision 1.2 by schorsch, Wed Mar 30 18:02:06 2016 UTC vs.
Revision 1.4 by schorsch, Tue Apr 19 21:17:41 2016 UTC

# Line 22 | Line 22 | class ProcMixin():
22          '''Process and pipeline management for Python Radiance scripts
23          '''
24          def raise_on_error(self, actstr, e):
25 <                raise Error('Unable to %s - %s' % (actstr, str(e)))
25 >                if hasattr(e, 'strerror'): eb = e.strerror
26 >                elif isinstance(e, self._strtypes): eb = e
27 >                else: eb = e
28 >                if isinstance(eb, type(b'')):
29 >                        estr = eb.decode(encoding='utf-8', errors='ignore')
30 >                else: estr = eb
31 >                raise Error('Unable to %s - %s' % (actstr, estr)) #
32  
33          def __configure_subprocess(self):
34                  '''Prevent subprocess module failure in frozen scripts on Windows.
# Line 73 | Line 79 | class ProcMixin():
79                  if _in == PIPE:
80                          stdin = _in
81                  elif isinstance(_in, self._strtypes):
82 <                        stdin = open(_in, 'rb')
82 >                        if not getattr(self, 'donothing', None):
83 >                                stdin = open(_in, 'rb')
84 >                        else: stdin = None
85                          instr = ' < "%s"' % _in
86                  elif hasattr(_in, 'read'):
87                          stdin = _in
# Line 83 | Line 91 | class ProcMixin():
91                  if out == PIPE:
92                          stdout = out
93                  elif isinstance(out, self._strtypes):
94 <                        stdout = open(out, 'wb')
94 >                        if not getattr(self, 'donothing', None):
95 >                                stdout = open(out, 'wb')
96 >                        else: stdout = None
97                          outstr = ' > "%s"' % out
98                  elif hasattr(out, 'write'):
99                          stdout = out
# Line 124 | Line 134 | class ProcMixin():
134                                          stdin=stdin, stdout=stdout, stderr=self._stderr,
135                                          universal_newlines=universal_newlines, **self._pipeargs)
136                          except Exception as e:
137 <                                self.raise_on_error(actstr, str(e))
137 >                                self.raise_on_error(actstr, e)
138                          if stdin != PIPE and stdout != PIPE:
139                                  # caller needs to wait after reading or writing (else deadlock)
140                                  res = p.wait()
# Line 154 | Line 164 | class ProcMixin():
164                                          stdin=stdin, stdout=PIPE, stderr=self._stderr,
165                                          **self._pipeargs)
166                          except Exception as e:
167 <                                self.raise_on_error(actstr_1, str(e))
167 >                                self.raise_on_error(actstr_1, e)
168                  if getattr(self, 'verbose', None):
169                          sys.stderr.write(self.qjoin(cmdl_2) + outstr + '\n')
170                  if not getattr(self, 'donothing', None):
# Line 164 | Line 174 | class ProcMixin():
174                                                  universal_newlines=universal_newlines, **self._pipeargs)
175                                  p1.stdout.close()
176                          except Exception as e:
177 <                                self.raise_on_error(actstr_2, str(e))
177 >                                self.raise_on_error(actstr_2, e)
178                          if stdin != PIPE and stdout != PIPE:
179                                  # caller needs to wait after reading or writing (else deadlock)
180                                  res = p1.wait()
# Line 209 | Line 219 | class ProcMixin():
219                                                  stdout=PIPE, stderr=self._stderr, **self._pipeargs)
220                                  procs.append(prevproc)
221                          except Exception as e:
222 <                                self.raise_on_error(actstr, str(e))
222 >                                self.raise_on_error(actstr, e)
223  
224                  for cmdl in cmdlines[1:-1]:
225                          if getattr(self, 'verbose', None):
# Line 222 | Line 232 | class ProcMixin():
232                                          prevproc.stdout.close()
233                                          prevproc = nextproc
234                                  except Exception as e:
235 <                                        self.raise_on_error(actstr, str(e))
235 >                                        self.raise_on_error(actstr, e)
236  
237                  if getattr(self, 'verbose', None):
238                          sys.stderr.write(self.qjoin(cmdlines[-1]) + outstr + '\n')
# Line 235 | Line 245 | class ProcMixin():
245                                  procs.append(lastproc)
246                                  prevproc.stdout.close()
247                          except Exception as e:
248 <                                self.raise_on_error(actstr, str(e))
248 >                                self.raise_on_error(actstr, e)
249  
250                          if stdin != PIPE and stdout!= PIPE:
251                                  # caller needs to wait after reading or writing (else deadlock)

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)