extras-buildsys/server Repo.py,1.16.2.3.4.6,1.16.2.3.4.7
Michael Schwendt
mschwendt at fedoraproject.org
Tue Dec 9 23:28:29 UTC 2008
Author: mschwendt
Update of /cvs/fedora/extras-buildsys/server
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv17459/server
Modified Files:
Tag: Plague-0_4_5
Repo.py
Log Message:
With Python >= 2.6 use "subprocess" not "popen2" to avoid the ugly deprecation warning.
Index: Repo.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/Repo.py,v
retrieving revision 1.16.2.3.4.6
retrieving revision 1.16.2.3.4.7
diff -u -r1.16.2.3.4.6 -r1.16.2.3.4.7
--- Repo.py 29 Sep 2008 16:05:54 -0000 1.16.2.3.4.6
+++ Repo.py 9 Dec 2008 23:28:27 -0000 1.16.2.3.4.7
@@ -14,12 +14,19 @@
#
# Copyright 2005 Dan Williams <dcbw at redhat.com> and Red Hat, Inc.
+import sys
+if sys.version_info[0:2] < (2,6):
+ import popen2
+ use_subprocess = False
+else: # available since Python 2.4
+ import subprocess
+ use_subprocess = True
+
import os
import threading
import shutil
import time
import commands
-import popen2
import fcntl
import stat
import EmailUtils
@@ -150,9 +157,16 @@
def _run_repo_script(self):
target_str = self._target_cfg.target_string()
cmd = "%s %s" % (self._repo_script, target_str)
- print "Repo '%s': executing repository script %s" % (target_str, self._repo_script)
- self._pobj = popen2.Popen4(cmd=cmd)
- fcntl.fcntl(self._pobj.fromchild.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
+ print "Repo '%s': executing repository script: %s" % (target_str, cmd)
+ if use_subprocess:
+ try:
+ self._pobj = subprocess.Popen(args=cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
+ fcntl.fcntl(self._pobj.stdout.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
+ except OSError, e:
+ print "Repo Error (%s): repo_script failed: %s" % (target_str, e)
+ else:
+ self._pobj = popen2.Popen4(cmd=cmd)
+ fcntl.fcntl(self._pobj.fromchild.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
self._repo_script_start = time.time()
def _email_repo_script_failure(self, subject):
@@ -167,7 +181,10 @@
output = ""
while True:
try:
- string = os.read(self._pobj.fromchild.fileno(), 1024)
+ if use_subprocess:
+ string = os.read(self._pobj.stdout.fileno(), 1024)
+ else:
+ string = os.read(self._pobj.fromchild.fileno(), 1024)
if not len(string):
break
except OSError, e:
More information about the fedora-extras-commits
mailing list