summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Reports/importscript.py
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2010-07-05 23:44:23 +0000
committerSol Jerome <sol.jerome@gmail.com>2010-07-08 23:26:49 -0500
commit2b514771564024df2fb89e5b4351eef903f9947d (patch)
tree9b9e362d62479eb8782e0b794c2007c96ac5554b /src/lib/Server/Reports/importscript.py
parent1245c432c2b3a5b3854efa17ca45504492328c41 (diff)
downloadbcfg2-2b514771564024df2fb89e5b4351eef903f9947d.tar.gz
bcfg2-2b514771564024df2fb89e5b4351eef903f9947d.tar.bz2
bcfg2-2b514771564024df2fb89e5b4351eef903f9947d.zip
DBStats: Improved handling of binary objects in the database
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5962 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Reports/importscript.py')
-rwxr-xr-xsrc/lib/Server/Reports/importscript.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/Server/Reports/importscript.py b/src/lib/Server/Reports/importscript.py
index 69147abbb..0c061d65b 100755
--- a/src/lib/Server/Reports/importscript.py
+++ b/src/lib/Server/Reports/importscript.py
@@ -25,15 +25,20 @@ from time import strptime
from django.db import connection
from Bcfg2.Server.Reports.updatefix import update_database
import ConfigParser
-import difflib
import logging
import Bcfg2.Logger
import platform
def build_reason_kwargs(r_ent):
+ binary_file=False
if r_ent.get('current_bfile', False):
- contents = binascii.a2b_base64(r_ent.get('current_bfile'))
- rc_diff = '\n'.join(difflib.ndiff([], contents.split('\n')))
+ binary_file=True
+ rc_diff = r_ent.get('current_bfile')
+ if len(rc_diff) > 1024*1024:
+ rc_diff = ''
+ elif len(rc_diff) == 0:
+ # No point in flagging binary if we have no data
+ binary_file=False
elif r_ent.get('current_bdiff', False):
rc_diff = binascii.a2b_base64(r_ent.get('current_bdiff'))
elif r_ent.get('current_diff', False):
@@ -53,7 +58,8 @@ def build_reason_kwargs(r_ent):
version=r_ent.get('version', default=""),
current_version=r_ent.get('current_version', default=""),
current_exists=r_ent.get('current_exists', default="True").capitalize()=="True",
- current_diff=rc_diff)
+ current_diff=rc_diff,
+ is_binary=binary_file)
def load_stats(cdata, sdata, vlevel, logger, quick=False, location=''):