Skip to main content

Python library for GNIP.

Project description

gnippy provides an easy way to access the Power Track stream provided by GNIP. You can also use gnippy to programatically add rules to your Power Track stream.

Installation:

pip install gnippy

Quickstart:

Create a .gnippy file and place it in your home directory. It should contain the following:

[Credentials]
username = user@company.com
password = mypassword

[PowerTrack]
url = https://my.gnip.powertrack/url.json

Fire up the client:

#!/usr/bin/env python
import time
from gnippy import PowerTrackClient

# Define a callback
def callback(activity):
    print activity

# Create the client
client = PowerTrackClient(callback)
client.connect()

# Wait for 2 minutes and then disconnect
time.sleep(120)
client.disconnect()

If you don’t want to create a config file or you want it put it in another location:

client = PowerTrackClient(callback, url = "http://my.gnip.powertrack/url.json", auth = ('MyUserName', 'MyPassword'))
# OR
client = PowerTrackClient(callback, config_file_path="/etc/gnippy")

If you want to add rules to your PowerTrack:

from gnippy import rules
from gnippy.errors import RuleAddFailedException

# Add a
try:
    rules.add_rule('(Hello OR World OR "this is a test") AND lang:en', tag="MyRule") # The tag is optional
except RuleAddFailedException:
    pass # uh oh

# OR ... add multiple rules at once
rule_list = []
rule_list.append(rules.build_rule("Hello World", tag="asdf"))
rule_list.append(rules.build_rule("Rule Without a Tag"))
try:
    rules.add_rules(rule_list)
except RuleAddFailedException:
    pass # uh oh

Source available on GitHub: http://github.com/abh1nav/gnippy/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gnippy-0.3.0.tar.gz (5.8 kB view details)

Uploaded Source

File details

Details for the file gnippy-0.3.0.tar.gz.

File metadata

  • Download URL: gnippy-0.3.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for gnippy-0.3.0.tar.gz
Algorithm Hash digest
SHA256 eedd904bcc5015c05695c8fbf8532634bf2f24e068eafe8887feceb3f0bd7fde
MD5 0888b693c0f366bb15009ae3b762ce4a
BLAKE2b-256 adf1f5b20f75f17b0e61ad1f4ed64e76fba0461e102b22e12cd4eb5cd7b9a1c6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page