summaryrefslogtreecommitdiff
blob: ca1b022a1ce1cc8c19d42ace2d3faac48ecba38b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
diff -urN hplip-1.7.4a.orig/hpssd.py hplip-1.7.4a/hpssd.py
--- hplip-1.7.4a.orig/hpssd.py	2007-10-18 15:20:16.000000000 +0200
+++ hplip-1.7.4a/hpssd.py	2007-10-18 15:54:34.000000000 +0200
@@ -53,7 +53,7 @@
 
 # Std Lib
 import sys, socket, os, os.path, signal, getopt, glob, time, select
-import popen2, threading, re, fcntl, pwd, tempfile
+import subprocess, threading, re, fcntl, pwd, tempfile
 #from asyncore import dispatcher, loop
 
 from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \
@@ -562,21 +562,23 @@
 
         if sendmail:
             sendmail = os.path.join(sendmail, 'sendmail')
-            sendmail += ' -t -r %s' % self.from_address
+            cmd = [sendmail,'-t','-r',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
+            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.")