Eryksun: Thanks for your reply. Yes, as I mentioned in my reply to Allen, I used subprocess.check_output and it worked for me. -SM
On Sun, Jan 19, 2014 at 11:33 PM, eryksun <eryk...@gmail.com> wrote: > On Sun, Jan 19, 2014 at 6:36 PM, SM <sunith...@gmail.com> wrote: > > > > This time it probably ran for a few more iterations than before and > stopped > > with the same error message. This time it also output the following > > messages: > > > > IOError: [Errno 4] Interrupted system call > > Attribute not found in file (tsk_fs_attrlist_get: Attribute 128 not > found) > > Attribute not found in file (tsk_fs_attrlist_get: Attribute 128 not > found) > > Attribute not found in file (tsk_fs_attrlist_get: Attribute 128 not > found) > > I can't help with these (NTFS?) Attribute errors from "The Sleuth Kit" > digital forensics tools. > > In Python 3.3, `IOError` is an alias for `OSError`, and EINTR (i.e. > errno.errorcode[4]) is exposed directly as `InterruptedError`. So you > must be running a previous version. I see you're using `print` as a > function, so I'll guess you're using 3.2. > > In 3.2, `os.popen` is implemented via `subprocess.Popen`: > > http://hg.python.org/cpython/file/cef745775b65/Lib/os.py#l776 > > For example, it uses the following for 'r' mode: > > proc = subprocess.Popen(cmd, > shell=True, > stdout=subprocess.PIPE, > bufsize=buffering) > return _wrap_close(io.TextIOWrapper(proc.stdout), proc) > > If you're sticking to `os.popen`, you'll need to retry the read in > case of an interrupted system call. > > I recommend you switch to `Popen` directly and call `communicate`. > This retries reading `stdout` using the helper function > `_eintr_retry_call`: > > http://hg.python.org/cpython/file/cef745775b65/Lib/subprocess.py#l452 > > def _eintr_retry_call(func, *args): > while True: > try: > return func(*args) > except (OSError, IOError) as e: > if e.errno == errno.EINTR: > continue > raise > > More simply, use `subprocess.check_output`, which calls `communicate` > for you. You can pass `shell=True` if you really need it. >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor