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
18dad6f8
Unverified
Commit
18dad6f8
authored
Jun 02, 2018
by
Joshua Roesslein
Committed by
GitHub
Jun 02, 2018
Browse files
Merge pull request #1042 from nyanye/master
Fix Python3.7 compatibility issue
parents
62eb3da8
7ae8019c
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/test_streaming.py
View file @
18dad6f8
...
...
@@ -99,7 +99,7 @@ class TweepyStreamTests(unittest.TestCase):
def
test_track_encoding
(
self
):
s
=
Stream
(
None
,
None
)
s
.
_start
=
lambda
async
:
None
s
.
_start
=
lambda
is_
async
:
None
s
.
filter
(
track
=
[
u
'Caf
\xe9
'
])
# Should be UTF-8 encoded
...
...
@@ -107,7 +107,7 @@ class TweepyStreamTests(unittest.TestCase):
def
test_follow_encoding
(
self
):
s
=
Stream
(
None
,
None
)
s
.
_start
=
lambda
async
:
None
s
.
_start
=
lambda
is_
async
:
None
s
.
filter
(
follow
=
[
u
'Caf
\xe9
'
])
# Should be UTF-8 encoded
...
...
tweepy/streaming.py
View file @
18dad6f8
...
...
@@ -356,9 +356,9 @@ class Stream(object):
if
resp
.
raw
.
closed
:
self
.
on_closed
(
resp
)
def
_start
(
self
,
async
):
def
_start
(
self
,
is_
async
):
self
.
running
=
True
if
async
:
if
is_
async
:
self
.
_thread
=
Thread
(
target
=
self
.
_run
)
self
.
_thread
.
start
()
else
:
...
...
@@ -374,7 +374,7 @@ class Stream(object):
replies
=
None
,
track
=
None
,
locations
=
None
,
async
=
False
,
is_
async
=
False
,
encoding
=
'utf8'
):
self
.
session
.
params
=
{
'delimited'
:
'length'
}
if
self
.
running
:
...
...
@@ -395,25 +395,25 @@ class Stream(object):
if
track
:
self
.
session
.
params
[
'track'
]
=
u
','
.
join
(
track
).
encode
(
encoding
)
self
.
_start
(
async
)
self
.
_start
(
is_
async
)
def
firehose
(
self
,
count
=
None
,
async
=
False
):
def
firehose
(
self
,
count
=
None
,
is_
async
=
False
):
self
.
session
.
params
=
{
'delimited'
:
'length'
}
if
self
.
running
:
raise
TweepError
(
'Stream object already connected!'
)
self
.
url
=
'/%s/statuses/firehose.json'
%
STREAM_VERSION
if
count
:
self
.
url
+=
'&count=%s'
%
count
self
.
_start
(
async
)
self
.
_start
(
is_
async
)
def
retweet
(
self
,
async
=
False
):
def
retweet
(
self
,
is_
async
=
False
):
self
.
session
.
params
=
{
'delimited'
:
'length'
}
if
self
.
running
:
raise
TweepError
(
'Stream object already connected!'
)
self
.
url
=
'/%s/statuses/retweet.json'
%
STREAM_VERSION
self
.
_start
(
async
)
self
.
_start
(
is_
async
)
def
sample
(
self
,
async
=
False
,
languages
=
None
,
stall_warnings
=
False
):
def
sample
(
self
,
is_
async
=
False
,
languages
=
None
,
stall_warnings
=
False
):
self
.
session
.
params
=
{
'delimited'
:
'length'
}
if
self
.
running
:
raise
TweepError
(
'Stream object already connected!'
)
...
...
@@ -422,9 +422,9 @@ class Stream(object):
self
.
session
.
params
[
'language'
]
=
','
.
join
(
map
(
str
,
languages
))
if
stall_warnings
:
self
.
session
.
params
[
'stall_warnings'
]
=
'true'
self
.
_start
(
async
)
self
.
_start
(
is_
async
)
def
filter
(
self
,
follow
=
None
,
track
=
None
,
async
=
False
,
locations
=
None
,
def
filter
(
self
,
follow
=
None
,
track
=
None
,
is_
async
=
False
,
locations
=
None
,
stall_warnings
=
False
,
languages
=
None
,
encoding
=
'utf8'
,
filter_level
=
None
):
self
.
body
=
{}
self
.
session
.
headers
[
'Content-type'
]
=
"application/x-www-form-urlencoded"
...
...
@@ -448,10 +448,10 @@ class Stream(object):
self
.
body
[
'filter_level'
]
=
filter_level
.
encode
(
encoding
)
self
.
session
.
params
=
{
'delimited'
:
'length'
}
self
.
host
=
'stream.twitter.com'
self
.
_start
(
async
)
self
.
_start
(
is_
async
)
def
sitestream
(
self
,
follow
,
stall_warnings
=
False
,
with_
=
'user'
,
replies
=
False
,
async
=
False
):
with_
=
'user'
,
replies
=
False
,
is_
async
=
False
):
self
.
body
=
{}
if
self
.
running
:
raise
TweepError
(
'Stream object already connected!'
)
...
...
@@ -464,7 +464,7 @@ class Stream(object):
self
.
body
[
'with'
]
=
with_
if
replies
:
self
.
body
[
'replies'
]
=
replies
self
.
_start
(
async
)
self
.
_start
(
is_
async
)
def
disconnect
(
self
):
if
self
.
running
is
False
:
...
...
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