| |
@@ -14,22 +14,23 @@
|
| |
|
| |
.. code:: bash
|
| |
|
| |
- sudo yum install fedmsg
|
| |
- sudo yum install python-fedmsg-meta-fedora-infrastructure
|
| |
- sudo yum install python-fabulous
|
| |
- sudo yum install tweepy
|
| |
+ sudo dnf install fedmsg
|
| |
+ sudo dnf install python-fedmsg-meta-fedora-infrastructure
|
| |
+ sudo dnf install python3-pip
|
| |
+ pip3 install fabulous --user
|
| |
+ pip3 install tweepy --user
|
| |
|
| |
----
|
| |
|
| |
Your first fedmsg script
|
| |
~~~~~~~~~~~~~~~~~~~~~~~~
|
| |
|
| |
- .. code:: python
|
| |
+ .. code:: python3
|
| |
|
| |
import fedmsg
|
| |
import pprint
|
| |
|
| |
- print "Posting up to listen on the fedmsg bus. Waiting for a message..."
|
| |
+ print("Posting up to listen on the fedmsg bus. Waiting for a message...")
|
| |
for name, endpoint, topic, msg in fedmsg.tail_messages():
|
| |
pprint.pprint(msg)
|
| |
|
| |
@@ -40,10 +41,10 @@
|
| |
It's like a million voices cried out and then were silent
|
| |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| |
|
| |
- .. code:: python
|
| |
+ .. code:: python3
|
| |
|
| |
- #topic_filter = 'fedbadges' # We really want this, but its rare
|
| |
- topic_filter = 'fedoratagger' # This is much easier to test with
|
| |
+ #topic_filter = "fedbadges" # We really want this, but its rare
|
| |
+ topic_filter = "fedoratagger" # This is much easier to test with
|
| |
|
| |
for name, endpoint, topic, msg in fedmsg.tail_messages():
|
| |
if topic_filter not in topic:
|
| |
@@ -59,7 +60,7 @@
|
| |
Some config at the top
|
| |
~~~~~~~~~~~~~~~~~~~~~~
|
| |
|
| |
- .. code:: python
|
| |
+ .. code:: python3
|
| |
|
| |
import fedmsg.config
|
| |
import logging.config
|
| |
@@ -75,7 +76,7 @@
|
| |
So meta
|
| |
~~~~~~~
|
| |
|
| |
- .. code:: python
|
| |
+ .. code:: python3
|
| |
|
| |
import fedmsg.meta
|
| |
|
| |
@@ -93,14 +94,14 @@
|
| |
# Use it to make nice text and other things
|
| |
# See also: msg2icon, msg2link, msg2usernames, msg2packages...
|
| |
subtitle = fedmsg.meta.msg2subtitle(msg, **config)
|
| |
- print subtitle
|
| |
+ print(subtitle)
|
| |
|
| |
----
|
| |
|
| |
A picture is worth a thousand words
|
| |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| |
|
| |
- .. code:: python
|
| |
+ .. code:: python3
|
| |
|
| |
import tempfile
|
| |
import urllib
|
| |
@@ -113,12 +114,12 @@
|
| |
icon = fedmsg.meta.msg2icon(msg, **config)
|
| |
|
| |
_, filename = tempfile.mkstemp(suffix='.png')
|
| |
- print "Downloading", icon, "to", filename
|
| |
+ print("Downloading", icon, "to", filename)
|
| |
urllib.urlretrieve(icon, filename)
|
| |
|
| |
- print fabulous.image.Image(filename)
|
| |
+ print(fabulous.image.Image(filename))
|
| |
|
| |
- print "Cleaning up %r" % filename
|
| |
+ print("Cleaning up %r" % filename)
|
| |
os.remove(filename)
|
| |
|
| |
|
| |
@@ -152,7 +153,7 @@
|
| |
|
| |
In it, put a file called ``fedmsg.d/twitter-secrets.py`` that looks like this:
|
| |
|
| |
- .. code:: python
|
| |
+ .. code:: python3
|
| |
|
| |
config = dict(
|
| |
consumer_key = "your api key goes here",
|
| |
@@ -174,7 +175,7 @@
|
| |
|
| |
Go back to ``yourwordcloudbot.py`` and add the following:
|
| |
|
| |
- .. code:: python
|
| |
+ .. code:: python3
|
| |
|
| |
import tweepy
|
| |
|
| |
@@ -192,7 +193,7 @@
|
| |
And further down
|
| |
~~~~~~~~~~~~~~~~
|
| |
|
| |
- .. code:: python
|
| |
+ .. code:: python3
|
| |
|
| |
for name, endpoint, topic, msg in fedmsg.tail_messages():
|
| |
|
| |
@@ -201,16 +202,16 @@
|
| |
icon = fedmsg.meta.msg2icon(msg, **config)
|
| |
|
| |
_, filename = tempfile.mkstemp(suffix='.png')
|
| |
- print "Downloading", icon, "to", filename
|
| |
+ print("Downloading", icon, "to", filename)
|
| |
urllib.urlretrieve(icon, filename)
|
| |
|
| |
# Construct and post our tweet.
|
| |
- #print fabulous.image.Image(filename)
|
| |
+ #print(fabulous.image.Image(filename))
|
| |
content = subtitle + " " + link
|
| |
- print "Tweeting %r" % content
|
| |
+ print("Tweeting %r" % content)
|
| |
twitter_api.update_with_media(filename, content)
|
| |
|
| |
- print "Cleaning up %r" % filename
|
| |
+ print("Cleaning up %r" % filename)
|
| |
os.remove(filename)
|
| |
|
| |
----
|
| |
@@ -390,7 +391,7 @@
|
| |
|
| |
fedmsg-tail --really-pretty
|
| |
|
| |
- .. code:: python
|
| |
+ .. code:: python3
|
| |
|
| |
{
|
| |
"i": 1,
|
| |
@@ -413,12 +414,12 @@
|
| |
consuming messages from python
|
| |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| |
|
| |
- .. code:: python
|
| |
+ .. code:: python3
|
| |
|
| |
import fedmsg
|
| |
|
| |
for name, endpoint, topic, msg in fedmsg.tail_messages():
|
| |
- print topic, msg
|
| |
+ print(topic, msg)
|
| |
|
| |
|
| |
consuming messages with a daemon
|
| |
@@ -429,7 +430,7 @@
|
| |
<http://www.fedmsg.com/en/latest/consuming/#the-hub-consumer-approach>`_
|
| |
for writing plugins, but they look like this:
|
| |
|
| |
- .. code:: python
|
| |
+ .. code:: python3
|
| |
|
| |
import pprint
|
| |
import fedmsg.consumers
|
| |
Check the commit logs. :)