client/tools/spacewalk-abrt/src/spacewalk_abrt/abrt.py | 35 ++++++++++-------
1 file changed, 21 insertions(+), 14 deletions(-)
New commits:
commit 910486c5a1563b6e6f911532c985ebbc229d148d
Author: Matej Kollar <mkollar(a)redhat.com>
Date: Mon Sep 23 13:10:26 2013 +0200
Reading only one line
and changed the way we detect nonexistence of file
diff --git a/client/tools/spacewalk-abrt/src/spacewalk_abrt/abrt.py
b/client/tools/spacewalk-abrt/src/spacewalk_abrt/abrt.py
index 6f14ec7..6d8316b 100644
--- a/client/tools/spacewalk-abrt/src/spacewalk_abrt/abrt.py
+++ b/client/tools/spacewalk-abrt/src/spacewalk_abrt/abrt.py
@@ -17,6 +17,7 @@
import base64
import os
import sys
+import errno
RHNROOT = '/usr/share/rhn'
if RHNROOT not in sys.path:
@@ -31,16 +32,20 @@ from up2date_client import up2dateAuth
from up2date_client import rhnserver
from up2date_client import up2dateLog
+
def _readline(filepath):
- if os.path.exists(filepath):
- filecontent = None
+ firstline = None
+ try:
f = open(filepath, 'r')
- filecontent = f.readlines()[0].strip()
+ firstline = f.readline().strip()
f.close()
+ except IOError, e:
+ if e.errno == errno.ENOENT:
+ pass
+ else:
+ raise
+ return firstline
- return filecontent
- else:
- return None
def _get_abrt_dir():
abrt_dir = '/var/tmp/abrt'
commit 3e7bc878aed77e04f92ff91875ffa436b2c2a907
Author: Matej Kollar <mkollar(a)redhat.com>
Date: Mon Sep 23 13:05:38 2013 +0200
1002041 - File content is loaded only when needed
diff --git a/client/tools/spacewalk-abrt/src/spacewalk_abrt/abrt.py
b/client/tools/spacewalk-abrt/src/spacewalk_abrt/abrt.py
index fc109d3..6f14ec7 100644
--- a/client/tools/spacewalk-abrt/src/spacewalk_abrt/abrt.py
+++ b/client/tools/spacewalk-abrt/src/spacewalk_abrt/abrt.py
@@ -106,10 +106,7 @@ def report(problem_dir):
if not os.path.isfile(path):
continue
- filecontent = None
- with open(path, 'r') as f:
- filecontent = f.read()
- filesize = os.stat(path)[6]
+ filesize = os.stat(path).st_size
crash_file_data = {'filename': os.path.basename(i),
'path': path,
@@ -117,7 +114,11 @@ def report(problem_dir):
'filecontent': base64.encodestring(""),
'content-encoding': 'base64'}
if server.abrt.is_crashfile_upload_enabled(systemid) and filesize <=
server.abrt.get_crashfile_uploadlimit(systemid):
- crash_file_data['filecontent'] = base64.encodestring(filecontent)
+ f = open(path, 'r')
+ try:
+ crash_file_data['filecontent'] = base64.encodestring(f.read())
+ finally:
+ f.close()
server.abrt.upload_crash_file(systemid, basename, crash_file_data)
commit 219e0f4336de55814974ff37048ddf857c0b2027
Author: Matej Kollar <mkollar(a)redhat.com>
Date: Mon Sep 23 12:55:24 2013 +0200
Small whitespace changes
diff --git a/client/tools/spacewalk-abrt/src/spacewalk_abrt/abrt.py
b/client/tools/spacewalk-abrt/src/spacewalk_abrt/abrt.py
index 26b3c78..fc109d3 100644
--- a/client/tools/spacewalk-abrt/src/spacewalk_abrt/abrt.py
+++ b/client/tools/spacewalk-abrt/src/spacewalk_abrt/abrt.py
@@ -51,11 +51,12 @@ def _get_abrt_dir():
cf = config.ConfigFile('/etc/abrt/abrt.conf')
return cf['DumpLocation'] or abrt_dir
+
def report(problem_dir):
problem_dir = os.path.normpath(os.path.abspath(problem_dir))
basename = os.path.basename(problem_dir)
log = up2dateLog.initLog()
- if not (os.path.exists(problem_dir) and os.path.isdir(problem_dir)):
+ if not (os.path.exists(problem_dir) and os.path.isdir(problem_dir)):
log.log_me("The specified path [%s] is not a valid directory." %
problem_dir)
return -1
@@ -95,7 +96,7 @@ def report(problem_dir):
# Create record about the crash
r = server.abrt.create_crash(systemid, crash_data, pkg_data)
- if (r < 0): # Error creating new crash report
+ if (r < 0): # Error creating new crash report
log.log_me("Error creating new crash report.")
return -1
@@ -127,7 +128,7 @@ def update_count(problem_dir):
problem_dir = os.path.normpath(os.path.abspath(problem_dir))
basename = os.path.basename(problem_dir)
log = up2dateLog.initLog()
- if not (os.path.exists(problem_dir) and os.path.isdir(problem_dir)):
+ if not (os.path.exists(problem_dir) and os.path.isdir(problem_dir)):
log.log_me("The specified path [%s] is not a valid directory." %
problem_dir)
return -1
Show replies by date