import base64
from datetime import datetime
import requests
-from common.utils import sync
+from common.utils import sync, unicode_to_str
from common.buildtrigger import trigger_next
import xml.etree.ElementTree as ElementTree
print '\n'
sys.stdout.flush()
- if ret_data['building_normal'] > 0 or ret_data['building_power'] > 0 \
- or ret_data['waiting'] > 0:
+ #if ret_data['building_normal'] > 0 or ret_data['building_power'] > 0 \
+ # or ret_data['waiting'] > 0:
+ if True:
sync_src = os.path.join(os.getenv('JENKINS_HOME'), '.obs_worker_trend', 'obs_worker_history.log')
sync_dest = os.path.join(os.getenv('IMG_SYNC_DEST_BASE'), 'snapshots', \
'.dashboard', 'obs_worker_trend')
- with open(sync_src, 'a') as wh:
- wh.write('%s,%s,%s,%s,%s,%s,%s\n' \
+ curr_item = '%s,%s,%s,%s,%s,%s,%s\n' \
% (curr_time,
ret_data['idle_normal'], ret_data['idle_power'],
ret_data['building_normal'], ret_data['building_power'],
- ret_data['waiting'], ret_data['blocked']))
- print sync(os.path.dirname(sync_src), sync_dest)
+ ret_data['waiting'], ret_data['blocked'])
+ last_item = ''
+ with open(sync_src, 'rb') as rh:
+ rh.seek(-1024, os.SEEK_END)
+ last_item = rh.readlines()[-1].decode()
+ # Do not log if the last is the same as current
+ if unicode_to_str(curr_item).split(',')[1:-1] != unicode_to_str(last_item).split(',')[1:-1]:
+ with open(sync_src, 'a') as wh:
+ wh.write(curr_item)
+ print sync(os.path.dirname(sync_src), sync_dest)
return ret_data
def request_workers(num_executors, worker_type=OBS_NORMAL_WORKER):