Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
shadowban-eu-backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
shadowban-eu-backend
Commits
01daa105
Commit
01daa105
authored
Jan 27, 2021
by
Netzdenunziant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt code for faster testing
parent
2c01dbc8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
+20
-8
backend.py
backend.py
+20
-8
No files found.
backend.py
View file @
01daa105
...
...
@@ -239,11 +239,12 @@ class TwitterSession:
# rate limit reset
if
last_remaining
<
self
.
remaining
and
self
.
overshot
>
0
and
self
.
username
is
not
None
:
log
(
'[rate-limit] Reset detected for '
+
self
.
username
+
'. Saving overshoot count...'
)
if
db
is
not
None
:
db
.
write_rate_limit
({
'screen_name'
:
self
.
username
,
'overshot'
:
self
.
overshot
})
self
.
overshot
=
0
# count the requests that failed because of rate limiting
if
self
.
remaining
is
0
:
if
self
.
remaining
==
0
:
log
(
'[rate-limit] Limit hit by '
+
str
(
self
.
username
)
+
'.'
)
self
.
overshot
+=
1
...
...
@@ -459,6 +460,7 @@ class TwitterSession:
result
[
"tests"
][
"more_replies"
]
=
{
"error"
:
"EISGHOSTED"
}
debug
(
'['
+
profile
[
'screen_name'
]
+
'] Writing result to DB'
)
if
db
is
not
None
:
db
.
write_result
(
result
)
return
result
...
...
@@ -527,6 +529,8 @@ async def api(request):
return
web
.
json_response
(
result
)
async
def
login_accounts
(
accounts
,
cookie_dir
=
None
):
if
accounts
is
None
or
len
(
accounts
)
==
0
:
return
if
cookie_dir
is
not
None
and
not
os
.
path
.
isdir
(
cookie_dir
):
os
.
mkdir
(
cookie_dir
,
0o700
)
coroutines
=
[]
...
...
@@ -556,7 +560,7 @@ parser.add_argument('--daemon', action='store_true', help='run in background')
parser
.
add_argument
(
'--debug'
,
type
=
str
,
default
=
None
,
help
=
'debug log file'
)
parser
.
add_argument
(
'--port'
,
type
=
int
,
default
=
8080
,
help
=
'port which to listen on'
)
parser
.
add_argument
(
'--host'
,
type
=
str
,
default
=
'127.0.0.1'
,
help
=
'hostname/ip which to listen on'
)
parser
.
add_argument
(
'--mongo-host'
,
type
=
str
,
default
=
'localhost'
,
help
=
'hostname or IP of mongoDB service to connect to'
)
parser
.
add_argument
(
'--mongo-host'
,
type
=
str
,
default
=
None
,
help
=
'hostname or IP of mongoDB service to connect to'
)
parser
.
add_argument
(
'--mongo-port'
,
type
=
int
,
default
=
27017
,
help
=
'port of mongoDB service to connect to'
)
parser
.
add_argument
(
'--mongo-db'
,
type
=
str
,
default
=
'tester'
,
help
=
'name of mongo database to use'
)
parser
.
add_argument
(
'--twitter-auth-key'
,
type
=
str
,
default
=
TWITTER_AUTH_KEY
,
help
=
'auth key for twitter guest session'
)
...
...
@@ -570,9 +574,15 @@ if (args.cors_allow is None):
else
:
debug
(
'[CORS] Allowing requests from: '
+
args
.
cors_allow
)
ensure_dir
(
args
.
cookie_dir
)
with
open
(
args
.
account_file
,
"r"
)
as
f
:
accounts
=
[]
if
args
.
account_file
is
None
:
debug
(
'No account file specified.'
)
elif
not
os
.
path
.
exists
(
args
.
account_file
):
debug
(
'Account file does not exist'
)
else
:
ensure_dir
(
args
.
cookie_dir
)
with
open
(
args
.
account_file
,
"r"
)
as
f
:
accounts
=
json
.
loads
(
f
.
read
())
if
args
.
log
is
not
None
:
...
...
@@ -589,6 +599,8 @@ if args.debug is not None:
def
run
():
global
db
db
=
None
if
args
.
mongo_host
is
not
None
:
db
=
connect
(
host
=
args
.
mongo_host
,
port
=
args
.
mongo_port
)
loop
=
asyncio
.
get_event_loop
()
loop
.
run_until_complete
(
login_accounts
(
accounts
,
args
.
cookie_dir
))
...
...
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