101 | | infile = open(self.filename, "rb") |
102 | | try : |
103 | | for totiffcommand in self.totiffcommands : |
104 | | infile.seek(0) |
105 | | error = False |
106 | | commandline = totiffcommand % locals() |
107 | | child = popen2.Popen4(commandline) |
108 | | try : |
109 | | try : |
110 | | data = infile.read(MEGABYTE) |
111 | | while data : |
112 | | child.tochild.write(data) |
113 | | child.tochild.flush() |
114 | | data = infile.read(MEGABYTE) |
115 | | except (IOError, OSError) : |
116 | | error = True |
117 | | finally : |
118 | | child.tochild.close() |
119 | | dummy = child.fromchild.read() |
120 | | child.fromchild.close() |
121 | | |
122 | | try : |
123 | | status = child.wait() |
124 | | except OSError : |
| 101 | infname = self.filename |
| 102 | for totiffcommand in self.totiffcommands : |
| 103 | error = False |
| 104 | commandline = totiffcommand % locals() |
| 105 | # self.logdebug("Executing '%s'" % commandline) |
| 106 | status = os.system(commandline) |
| 107 | if os.WIFEXITED(status) : |
| 108 | if os.WEXITSTATUS(status) : |
126 | | else : |
127 | | if os.WIFEXITED(status) : |
128 | | if os.WEXITSTATUS(status) : |
129 | | error = True |
130 | | else : |
131 | | error = True |
132 | | |
133 | | if not os.path.exists(fname) : |
134 | | error = True |
135 | | elif not os.stat(fname).st_size : |
136 | | error = True |
137 | | else : |
138 | | break # Conversion worked fine it seems. |
139 | | self.logdebug("Command failed : %s" % repr(commandline)) |
140 | | finally : |
141 | | infile.close() |
| 110 | else : |
| 111 | error = True |
| 112 | if not os.path.exists(outfname) : |
| 113 | error = True |
| 114 | elif not os.stat(outfname).st_size : |
| 115 | error = True |
| 116 | else : |
| 117 | break # Conversion worked fine it seems. |
| 118 | sys.stderr.write("Command failed : %s\n" % repr(commandline)) |