ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/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.3 by schorsch, Sat Apr 2 15:52:48 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 self.donothing: stdin = None
83 >                        else: stdin = open(_in, 'rb')
84                          instr = ' < "%s"' % _in
85                  elif hasattr(_in, 'read'):
86                          stdin = _in
# Line 83 | Line 90 | class ProcMixin():
90                  if out == PIPE:
91                          stdout = out
92                  elif isinstance(out, self._strtypes):
93 <                        stdout = open(out, 'wb')
93 >                        if self.donothing: stdout = None
94 >                        else: stdout = open(out, 'wb')
95                          outstr = ' > "%s"' % out
96                  elif hasattr(out, 'write'):
97                          stdout = out
# Line 124 | Line 132 | class ProcMixin():
132                                          stdin=stdin, stdout=stdout, stderr=self._stderr,
133                                          universal_newlines=universal_newlines, **self._pipeargs)
134                          except Exception as e:
135 <                                self.raise_on_error(actstr, str(e))
135 >                                self.raise_on_error(actstr, e)
136                          if stdin != PIPE and stdout != PIPE:
137                                  # caller needs to wait after reading or writing (else deadlock)
138                                  res = p.wait()
# Line 154 | Line 162 | class ProcMixin():
162                                          stdin=stdin, stdout=PIPE, stderr=self._stderr,
163                                          **self._pipeargs)
164                          except Exception as e:
165 <                                self.raise_on_error(actstr_1, str(e))
165 >                                self.raise_on_error(actstr_1, e)
166                  if getattr(self, 'verbose', None):
167                          sys.stderr.write(self.qjoin(cmdl_2) + outstr + '\n')
168                  if not getattr(self, 'donothing', None):
# Line 164 | Line 172 | class ProcMixin():
172                                                  universal_newlines=universal_newlines, **self._pipeargs)
173                                  p1.stdout.close()
174                          except Exception as e:
175 <                                self.raise_on_error(actstr_2, str(e))
175 >                                self.raise_on_error(actstr_2, e)
176                          if stdin != PIPE and stdout != PIPE:
177                                  # caller needs to wait after reading or writing (else deadlock)
178                                  res = p1.wait()
# Line 209 | Line 217 | class ProcMixin():
217                                                  stdout=PIPE, stderr=self._stderr, **self._pipeargs)
218                                  procs.append(prevproc)
219                          except Exception as e:
220 <                                self.raise_on_error(actstr, str(e))
220 >                                self.raise_on_error(actstr, e)
221  
222                  for cmdl in cmdlines[1:-1]:
223                          if getattr(self, 'verbose', None):
# Line 222 | Line 230 | class ProcMixin():
230                                          prevproc.stdout.close()
231                                          prevproc = nextproc
232                                  except Exception as e:
233 <                                        self.raise_on_error(actstr, str(e))
233 >                                        self.raise_on_error(actstr, e)
234  
235                  if getattr(self, 'verbose', None):
236                          sys.stderr.write(self.qjoin(cmdlines[-1]) + outstr + '\n')
# Line 235 | Line 243 | class ProcMixin():
243                                  procs.append(lastproc)
244                                  prevproc.stdout.close()
245                          except Exception as e:
246 <                                self.raise_on_error(actstr, str(e))
246 >                                self.raise_on_error(actstr, e)
247  
248                          if stdin != PIPE and stdout!= PIPE:
249                                  # caller needs to wait after reading or writing (else deadlock)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines