Show raw data for alerts.
335839
def cli(obj, ids, query, filters):
    """"""
    client = obj['client']
    if ids:
        query = [('id', x) for x in ids]
    elif query:
        query = [('q', query)]
    else:
        query = build_query(filters)
    alerts = client.search(query)

    headers = {'id': 'ID', 'rawData': 'RAW DATA'}
    click.echo(
        tabulate([{'id': a.id, 'rawData': a.raw_data} for a in alerts], headers=headers, tablefmt=obj['output']))
168526
def inspect
      if alert.exists?
        format('#<%s:0x%x alert=true>', self.class, hash * 2)
      else
        format('#<%s:0x%x url=%s title=%s>', self.class, hash * 2, url.inspect, title.inspect)
      end
    rescue Errno::ECONNREFUSED
      format('#<%s:0x%x closed=true>', self.class, hash * 2)
    end
90537
def dump_rawdata(self):
        """"""
        if hasattr(self, 'transport'):
            attrs = vars(self.transport)
            return ', '.join("%s: %s" % item for item in attrs.items())
130567
public void show() {
        if (isShowing) {
            Log.w("AlertWindow", "AlertWindow is already displayed.");
        } else {
            isShowing = true;
            mWindowManager.addView(mContentView, mParams);
        }
    }
1070459
def _get_raw_data(subset):
  """"""
  raw_data = _LOADED.get(subset)
  if raw_data is not None:
    return raw_data, _LOADED["vocab"]
  else:
    train_data, valid_data, test_data, vocab = ptb_reader.ptb_raw_data(
        FLAGS.data_path)
    _LOADED.update({
        "train": np.array(train_data),
        "valid": np.array(valid_data),
        "test": np.array(test_data),
        "vocab": vocab
    })
    return _LOADED[subset], vocab
1373107
def get_alert(self, stat, header=""):
        """"""
        if not isinstance(stat['size'], numbers.Number):
            ret = 'DEFAULT'
        else:
            ret = 'OK'

            if stat['critical'] is not None and \
               stat['size'] > int(stat['critical']) * 1000000:
                ret = 'CRITICAL'
            elif stat['warning'] is not None and \
                    stat['size'] > int(stat['warning']) * 1000000:
                ret = 'WARNING'
            elif stat['careful'] is not None and \
                    stat['size'] > int(stat['careful']) * 1000000:
                ret = 'CAREFUL'

        # Get stat name
        stat_name = self.get_stat_name(header=header)

        # Manage threshold
        self.manage_threshold(stat_name, ret)

        # Manage action
        self.manage_action(stat_name,
                           ret.lower(),
                           header,
                           stat[self.get_key()])

        return ret
31655
def raw(config):  # pragma: no cover
        """"""
        client = Client()
        client.prepare_connection()
        audit_api = API(client)
        print(audit_api.raw())
1312873
def print_data(zone_id, connection):
    """"""
    result = connection.execute(
        # explicitly pass zone id before related data
        select([cast(zone_id.encode('utf-8'), BYTEA), test_table]))
    result = result.fetchall()
    ZONE_ID_INDEX = 0
    print("use zone_id: ", zone_id)
    print("{:<3} - {} - {} - {}".format("id", 'zone', "data", "raw_data"))
    for row in result:
        print(
            "{:<3} - {} - {} - {}\n".format(
            row['id'], row[ZONE_ID_INDEX].decode('utf-8'),
            row['data'].decode('utf-8', errors='ignore'), row['raw_data']))
124904
def cli(obj, ids, query, filters, display, from_date=None):
    """"""
    client = obj['client']
    timezone = obj['timezone']
    if ids:
        query = [('id', x) for x in ids]
    elif query:
        query = [('q', query)]
    else:
        query = build_query(filters)
    if from_date:
        query.append(('from-date', from_date))

    r = client.http.get('/alerts', query, page=1, page_size=1000)

    if obj['output'] == 'json':
        click.echo(json.dumps(r['alerts'], sort_keys=True, indent=4, ensure_ascii=False))
    elif obj['output'] in ['json_lines', 'jsonl', 'ndjson']:
        for alert in r['alerts']:
            click.echo(json.dumps(alert, ensure_ascii=False))
    else:
        alerts = [Alert.parse(a) for a in r['alerts']]
        last_time = r['lastTime']
        auto_refresh = r['autoRefresh']

        if display == 'tabular':
            headers = {'id': 'ID', 'lastReceiveTime': 'LAST RECEIVED', 'severity': 'SEVERITY', 'status': 'STATUS',
                       'duplicateCount': 'DUPL', 'customer': 'CUSTOMER', 'environment': 'ENVIRONMENT', 'service': 'SERVICE',
                       'resource': 'RESOURCE', 'group': 'GROUP', 'event': 'EVENT', 'value': 'VALUE', 'text': 'TEXT'}
            click.echo(tabulate([a.tabular('summary', timezone)
                                 for a in alerts], headers=headers, tablefmt=obj['output']))
        elif display in ['compact', 'details']:
            for alert in reversed(alerts):
                color = COLOR_MAP.get(alert.severity, {'fg': 'white'})
                click.secho('{}|{}|{}|{:5d}|{}|{:<5s}|{:<10s}|{:<18s}|{:12s}|{:16s}|{:12s}'.format(
                    alert.id[0:8],
                    DateTime.localtime(alert.last_receive_time, timezone),
                    alert.severity,
                    alert.duplicate_count,
                    alert.customer or '-',
                    alert.environment,
                    ','.join(alert.service),
                    alert.resource,
                    alert.group,
                    alert.event,
                    alert.value or 'n/a'), fg=color['fg'])
                click.secho('   |{}'.format(alert.text), fg=color['fg'])

                if display == 'details':
                    click.secho('    severity   | {} -> {}'.format(alert.previous_severity,
                                                                   alert.severity), fg=color['fg'])
                    click.secho('    trend      | {}'.format(alert.trend_indication), fg=color['fg'])
                    click.secho('    status     | {}'.format(alert.status), fg=color['fg'])
                    click.secho('    resource   | {}'.format(alert.resource), fg=color['fg'])
                    click.secho('    group      | {}'.format(alert.group), fg=color['fg'])
                    click.secho('    event      | {}'.format(alert.event), fg=color['fg'])
                    click.secho('    value      | {}'.format(alert.value), fg=color['fg'])
                    click.secho('    tags       | {}'.format(' '.join(alert.tags)), fg=color['fg'])

                    for key, value in alert.attributes.items():
                        click.secho('    {} | {}'.format(key.ljust(10), value), fg=color['fg'])

                    latency = alert.receive_time - alert.create_time

                    click.secho('        time created  | {}'.format(
                        DateTime.localtime(alert.create_time, timezone)), fg=color['fg'])
                    click.secho('        time received | {}'.format(
                        DateTime.localtime(alert.receive_time, timezone)), fg=color['fg'])
                    click.secho('        last received | {}'.format(
                        DateTime.localtime(alert.last_receive_time, timezone)), fg=color['fg'])
                    click.secho('        latency       | {}ms'.format((latency.microseconds / 1000)), fg=color['fg'])
                    click.secho('        timeout       | {}s'.format(alert.timeout), fg=color['fg'])

                    click.secho('            alert id     | {}'.format(alert.id), fg=color['fg'])
                    click.secho('            last recv id | {}'.format(alert.last_receive_id), fg=color['fg'])
                    click.secho('            customer     | {}'.format(alert.customer), fg=color['fg'])
                    click.secho('            environment  | {}'.format(alert.environment), fg=color['fg'])
                    click.secho('            service      | {}'.format(','.join(alert.service)), fg=color['fg'])
                    click.secho('            resource     | {}'.format(alert.resource), fg=color['fg'])
                    click.secho('            type         | {}'.format(alert.event_type), fg=color['fg'])
                    click.secho('            repeat       | {}'.format(alert.repeat), fg=color['fg'])
                    click.secho('            origin       | {}'.format(alert.origin), fg=color['fg'])
                    click.secho('            correlate    | {}'.format(','.join(alert.correlate)), fg=color['fg'])

        return auto_refresh, last_time
1029213
def plotted_data(self):
        """"""
        return InteractiveList(
            [arr for arr, val in zip(self.iter_data,
                                     cycle(slist(self.value)))
             if val is not None])
1196852
def on_tick_data(self, ticks):
        """"""
        for tick in XmlHelper.node_iter(ticks):
            names = [str(tick.getElement(_).name()) for _ in range(tick.numElements())]
            tickmap = {n: XmlHelper.get_child_value(tick, n) for n in names}
            self.response.ticks.append(tickmap)
1281041
def process_alert(file_name):
    

    processed_line = open(file_name, 'r').read()
    char_pos = processed_line.find("}")
    new_line = "{" + processed_line[char_pos + 2:]
    return new_line
237159
def data(self):
        """"""
        # add attributes
        if self._attributes:
            self._indicator_data['attribute'] = []
            for attr in self._attributes:
                if attr.valid:
                    self._indicator_data['attribute'].append(attr.data)
        # add file actions
        if self._file_actions:
            self._indicator_data.setdefault('fileAction', {})
            self._indicator_data['fileAction'].setdefault('children', [])
            for action in self._file_actions:
                self._indicator_data['fileAction']['children'].append(action.data)
        # add file occurrences
        if self._occurrences:
            self._indicator_data.setdefault('fileOccurrence', [])
            for occurrence in self._occurrences:
                self._indicator_data['fileOccurrence'].append(occurrence.data)
        # add security labels
        if self._labels:
            self._indicator_data['securityLabel'] = []
            for label in self._labels:
                self._indicator_data['securityLabel'].append(label.data)
        # add tags
        if self._tags:
            self._indicator_data['tag'] = []
            for tag in self._tags:
                if tag.valid:
                    self._indicator_data['tag'].append(tag.data)
        return self._indicator_data
1182688
def cli(obj, ids, query, filters, tags):
    """"""
    client = obj['client']
    if ids:
        total = len(ids)
    else:
        if query:
            query = [('q', query)]
        else:
            query = build_query(filters)
        total, _, _ = client.get_count(query)
        ids = [a.id for a in client.get_alerts(query)]

    with click.progressbar(ids, label='Untagging {} alerts'.format(total)) as bar:
        for id in bar:
            client.untag_alert(id, tags)
528112
def get_alerts_for(self, trigger):
        
        assert trigger is not None
        assert isinstance(trigger.id, str), "Value must be a string"
        status, data = self.http_client.get_json(
            ALERTS_URI % trigger.id,
            params={'appid': self.API_key},
            headers={'Content-Type': 'application/json'})
        return [self.alert_parser.parse_dict(item) for item in data]
1280405
def get_alert(self, alert):
        
        if alert > self.alerts_count() or self.alerts_count() is None:
            return None
        else:
            return self.get()[alert-1]
93337
def display(self):
        ''''''
        self.pretty(self._timings, 'Raw Redis Commands')
        print()
        for key, value in self._commands.items():
            self.pretty(value, 'Qless "%s" Command' % key)
            print()