Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
tweepy
Commits
5acff93d
Commit
5acff93d
authored
Aug 20, 2013
by
Aaron Hill
Browse files
Merge branch 'master' into add_update_banner
parents
c1886ad0
d355d9e1
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
.travis.yml
View file @
5acff93d
...
@@ -25,4 +25,4 @@ env:
...
@@ -25,4 +25,4 @@ env:
JjlEyFWS487IFteR87U9pt18qongJJIphaBdT9/lDVLsMWZ0Jh5ZLQfX+2jS
JjlEyFWS487IFteR87U9pt18qongJJIphaBdT9/lDVLsMWZ0Jh5ZLQfX+2jS
aF2UwsrYkzBUMrqMqYCc2+X6CuswLEZTVXDAlNh+emvhxZ5faMI=
aF2UwsrYkzBUMrqMqYCc2+X6CuswLEZTVXDAlNh+emvhxZ5faMI=
after_success
:
'
coveralls'
after_success
:
'
if
[[
"$TRAVIS_PULL_REQUEST"
==
"false"
]];
then
coveralls
;
fi
'
README.md
View file @
5acff93d
Tweepy
[](https://travis-ci.org/tweepy/tweepy)
Tweepy
: Twitter for Python!
======
======
*Twitter for Python!*
[

](https://travis-ci.org/tweepy/tweepy)
[

](https://crate.io/packages/tweepy)
[

](https://crate.io/packages/tweepy)
[

](https://coveralls.io/r/tweepy/tweepy?branch=master)
Installation
Installation
------------
------------
...
...
run_tests.sh
View file @
5acff93d
#! /usr/bin/env bash
#! /usr/bin/env bash
if
[[
$TRAVIS_SECURE_ENV_VARS
==
"false"
]]
;
then
if
[[
$TRAVIS_SECURE_ENV_VARS
==
"false"
]]
;
then
curl
"https://dl.dropboxusercontent.com/u/231242/record.json"
-o
tests/record.json
USE_REPLAY
=
1 nosetests
-v
tests.test_api tests.test_utils
USE_REPLAY
=
1 nosetests
-v
tests.test_api tests.test_utils
else
else
nosetests
-v
--with-coverage
tests.test_api tests.test_streaming tests.test_cursors tests.test_utils
nosetests
-v
--with-coverage
tests.test_api tests.test_streaming tests.test_cursors tests.test_utils
...
...
tests/record.json
deleted
100644 → 0
View file @
c1886ad0
This diff is collapsed.
Click to expand it.
tests/test_api.py
View file @
5acff93d
...
@@ -135,7 +135,7 @@ class TweepyAPITests(TweepyTestCase):
...
@@ -135,7 +135,7 @@ class TweepyAPITests(TweepyTestCase):
self
.
assertEqual
(
friend
.
screen_name
,
'twitter'
)
self
.
assertEqual
(
friend
.
screen_name
,
'twitter'
)
def
testshowfriendship
(
self
):
def
testshowfriendship
(
self
):
source
,
target
=
self
.
api
.
show_friendship
(
target_screen_name
=
'tw
t
iter'
)
source
,
target
=
self
.
api
.
show_friendship
(
target_screen_name
=
'twi
t
ter'
)
self
.
assert_
(
isinstance
(
source
,
Friendship
))
self
.
assert_
(
isinstance
(
source
,
Friendship
))
self
.
assert_
(
isinstance
(
target
,
Friendship
))
self
.
assert_
(
isinstance
(
target
,
Friendship
))
...
...
tweepy/api.py
View file @
5acff93d
...
@@ -486,16 +486,6 @@ class API(object):
...
@@ -486,16 +486,6 @@ class API(object):
require_auth
=
True
require_auth
=
True
)
)
""" help/test """
def
test
(
self
):
try
:
bind_api
(
path
=
'/help/test.json'
,
)(
self
)
except
TweepError
:
return
False
return
True
create_list
=
bind_api
(
create_list
=
bind_api
(
path
=
'/lists/create.json'
,
path
=
'/lists/create.json'
,
method
=
'POST'
,
method
=
'POST'
,
...
...
tweepy/streaming.py
View file @
5acff93d
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
# Copyright 2009-2010 Joshua Roesslein
# Copyright 2009-2010 Joshua Roesslein
# See LICENSE for details.
# See LICENSE for details.
import
logging
import
httplib
import
httplib
from
socket
import
timeout
from
socket
import
timeout
from
threading
import
Thread
from
threading
import
Thread
...
@@ -31,24 +32,30 @@ class StreamListener(object):
...
@@ -31,24 +32,30 @@ class StreamListener(object):
"""
"""
pass
pass
def
on_data
(
self
,
data
):
def
on_data
(
self
,
raw_
data
):
"""Called when raw data is received from connection.
"""Called when raw data is received from connection.
Override this method if you wish to manually handle
Override this method if you wish to manually handle
the stream data. Return False to stop stream and close connection.
the stream data. Return False to stop stream and close connection.
"""
"""
data
=
json
.
loads
(
raw_data
)
if
'in_reply_to_status_id'
in
data
:
if
'in_reply_to_status_id'
in
data
:
status
=
Status
.
parse
(
self
.
api
,
json
.
loads
(
data
)
)
status
=
Status
.
parse
(
self
.
api
,
data
)
if
self
.
on_status
(
status
)
is
False
:
if
self
.
on_status
(
status
)
is
False
:
return
False
return
False
elif
'delete'
in
data
:
elif
'delete'
in
data
:
delete
=
json
.
loads
(
data
)
[
'delete'
][
'status'
]
delete
=
data
[
'delete'
][
'status'
]
if
self
.
on_delete
(
delete
[
'id'
],
delete
[
'user_id'
])
is
False
:
if
self
.
on_delete
(
delete
[
'id'
],
delete
[
'user_id'
])
is
False
:
return
False
return
False
elif
'limit'
in
data
:
elif
'limit'
in
data
:
if
self
.
on_limit
(
json
.
loads
(
data
)
[
'limit'
][
'track'
])
is
False
:
if
self
.
on_limit
(
data
[
'limit'
][
'track'
])
is
False
:
return
False
return
False
elif
'disconnect'
in
data
:
if
self
.
on_disconnect
(
data
[
'disconnect'
])
is
False
:
return
False
else
:
logging
.
error
(
"Unknown message type: "
+
str
(
raw_data
))
def
on_status
(
self
,
status
):
def
on_status
(
self
,
status
):
"""Called when a new status arrives"""
"""Called when a new status arrives"""
...
@@ -70,6 +77,14 @@ class StreamListener(object):
...
@@ -70,6 +77,14 @@ class StreamListener(object):
"""Called when stream connection times out"""
"""Called when stream connection times out"""
return
return
def
on_disconnect
(
self
,
notice
):
"""Called when twitter sends a disconnect notice
Disconnect codes are listed here:
https://dev.twitter.com/docs/streaming-apis/messages#Disconnect_messages_disconnect
"""
return
class
Stream
(
object
):
class
Stream
(
object
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment