106 lines
3.7 KiB
Diff
106 lines
3.7 KiB
Diff
diff -up hplip-2.7.9/hpssd.py.subprocess-replacement hplip-2.7.9/hpssd.py
|
|
--- hplip-2.7.9/hpssd.py.subprocess-replacement 2007-10-12 09:34:06.000000000 +0100
|
|
+++ hplip-2.7.9/hpssd.py 2007-10-12 09:36:28.000000000 +0100
|
|
@@ -53,7 +53,7 @@ __doc__ = "Provides persistent data and
|
|
|
|
# Std Lib
|
|
import sys, socket, os, os.path, signal, getopt, time, select
|
|
-import popen2, threading, tempfile
|
|
+import subprocess, threading, tempfile
|
|
|
|
from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \
|
|
ENOTCONN, ESHUTDOWN, EINTR, EISCONN
|
|
@@ -560,21 +560,23 @@ class MailThread(threading.Thread):
|
|
|
|
if sendmail:
|
|
sendmail = os.path.join(sendmail, 'sendmail')
|
|
- sendmail += ' -t -r %s' % self.from_address
|
|
-
|
|
- log.debug(sendmail)
|
|
- std_out, std_in, std_err = popen2.popen3(sendmail)
|
|
- log.debug(repr(self.message))
|
|
- std_in.write(self.message)
|
|
- std_in.close()
|
|
-
|
|
- r, w, e = select.select([std_err], [], [], 2.0)
|
|
-
|
|
- if r:
|
|
- err = std_err.read()
|
|
- if err:
|
|
- log.error(repr(err))
|
|
- self.result = ERROR_TEST_EMAIL_FAILED
|
|
+ cmd = [sendmail,'-t','-r',self.from_address]
|
|
+
|
|
+ log.debug(repr(cmd))
|
|
+ err = None
|
|
+ try:
|
|
+ sp = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
+ std_out, std_err = sp.communicate(self.message)
|
|
+ log.debug(repr(self.message))
|
|
+ if std_err != '':
|
|
+ err = std_err
|
|
+
|
|
+ except OSError, e:
|
|
+ err = str(e)
|
|
+
|
|
+ if err:
|
|
+ log.error(repr(err))
|
|
+ self.result = ERROR_TEST_EMAIL_FAILED
|
|
|
|
else:
|
|
log.error("Mail send failed. sendmail not found.")
|
|
diff -up hplip-2.7.9/scan.py.subprocess-replacement hplip-2.7.9/scan.py
|
|
--- hplip-2.7.9/scan.py.subprocess-replacement 2007-10-12 09:36:36.000000000 +0100
|
|
+++ hplip-2.7.9/scan.py 2007-10-12 09:40:45.000000000 +0100
|
|
@@ -829,7 +829,7 @@ else: # NON_INTERACTIVE_MODE
|
|
from scan import sane
|
|
import scanext
|
|
import cStringIO
|
|
- import popen2
|
|
+ import subprocess
|
|
|
|
try:
|
|
import Image
|
|
@@ -1311,26 +1311,25 @@ else: # NON_INTERACTIVE_MODE
|
|
|
|
if sendmail:
|
|
sendmail = os.path.join(sendmail, 'sendmail')
|
|
- sendmail += ' -t -r %s' % email_from
|
|
+ cmd = [sendmail,'-t','-r',email_from]
|
|
|
|
- log.debug(sendmail)
|
|
- std_out, std_in, std_err = popen2.popen3(sendmail)
|
|
- std_in.write(msg.as_string())
|
|
- std_in.close()
|
|
-
|
|
- while True:
|
|
- update_spinner()
|
|
- r, w, e = select.select([std_err], [], [], 1.0)
|
|
-
|
|
- if r:
|
|
- break
|
|
+ log.debug(repr(cmd))
|
|
+ err = None
|
|
+ try:
|
|
+ sp = subprocess.Popen(cmd, stdin=subprocess.PIPE,
|
|
+ stdout=subprocess.PIPE,
|
|
+ stderr=subprocess.PIPE)
|
|
+ std_out, std_err = sp.communicate(msg.as_string())
|
|
+ if std_err != '':
|
|
+ err = std_err
|
|
+ except OSError, e:
|
|
+ err = str(e)
|
|
|
|
+ update_spinner()
|
|
cleanup_spinner()
|
|
|
|
- if r:
|
|
- err = std_err.read()
|
|
- if err:
|
|
- log.error(repr(err))
|
|
+ if err:
|
|
+ log.error(repr(err))
|
|
|
|
else:
|
|
log.error("Mail send failed. 'sendmail' not found.")
|