Commit 27745a19 authored by Pawel Szostek's avatar Pawel Szostek

svn,git: prevent error messages from being printed

parent 69b2e933
......@@ -3,6 +3,7 @@
import os
from util import path
import logging
from tempfile import TemporaryFile
from subprocess import Popen, PIPE
......@@ -67,14 +68,20 @@ class Git(object):
def check_commit_id(path):
cur_dir = os.getcwd()
commit = None
stderr = TemporaryFile()
try:
os.chdir(path)
git_cmd = 'git log -1 --format="%H" | cut -c1-32'
git_out = Popen(git_cmd, shell=True, stdin=PIPE, stdout=PIPE, close_fds=True)
git_out = Popen(git_cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=stderr, close_fds=True)
errmsg = stderr.readlines()
if errmsg:
logging.debug("git error message (in %s): %s" % (path, '\n'.join(errmsg)))
try:
commit = git_out.stdout.readlines()[0].strip()
except IndexError:
pass
finally:
os.chdir(cur_dir)
stderr.close()
return commit
......@@ -2,6 +2,7 @@
import os
import logging
from tempfile import TemporaryFile
from util import path
from subprocess import Popen, PIPE
......@@ -42,14 +43,21 @@ class Svn(object):
def check_revision_number(path):
cur_dir = os.getcwd()
revision = None
stderr = TemporaryFile()
try:
os.chdir(path)
svn_cmd = "svn info 2>/dev/null | awk '{if(NR == 5) {print $2}}'"
svn_out = Popen(svn_cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=None, close_fds=True)
svn_out = Popen(svn_cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=stderr, close_fds=True)
errmsg = stderr.readlines()
if errmsg:
logging.debug("svn error message (in %s): %s" % (path, '\n'.join(errmsg)))
try:
revision = svn_out.stdout.readlines()[0].strip()
except IndexError:
pass
finally:
os.chdir(cur_dir)
stderr.close()
return revision
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment