def bulk_add(self, payload, series, user_id, user_secret): total = 0 for item in payload.split('\n'): total += 1 time_seconds, value = item.split(' ') timestamp = util.from_seconds(time_seconds) value = float(value) data.add(name=series, value=value, timestamp=timestamp, user_id=user_id, secret=user_secret) return 'Added %d items to %s' % (total, series)
def single_add(self, timestamp_str, timems, series, value, user_id, user_secret): if not util.has_value(timestamp_str): if util.has_value(timems): time_seconds = float(timems) / 1000 timestamp = util.from_seconds(time_seconds) else: timestamp = datetime.datetime.now() else: timestamp = util.parse_time(timestamp_str) data.add(name=series, value=value, timestamp=timestamp, user_id=user_id, secret=user_secret) return 'Added: %s, %s, %s\n' % (series, value, timestamp)