Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
c8f35d8d
Commit
c8f35d8d
authored
5 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Use set_defaults(func=) style
parent
fdefb9e2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/app/admin_cmd.py
+8
-11
8 additions, 11 deletions
synapse/app/admin_cmd.py
with
8 additions
and
11 deletions
synapse/app/admin_cmd.py
+
8
−
11
View file @
c8f35d8d
...
...
@@ -90,15 +90,17 @@ class AdminCmdReplicationHandler(ReplicationClientHandler):
@defer.inlineCallbacks
def
export_data_command
(
hs
,
user_id
,
directory
):
def
export_data_command
(
hs
,
args
):
"""
Export data for a user.
Args:
user_id (str)
directory (str|None): Directory to write output to. Will create a temp
directory if not specified.
hs (HomeServer)
args (argparse.Namespace)
"""
user_id
=
args
.
user_id
directory
=
args
.
output_directory
res
=
yield
hs
.
get_handlers
().
admin_handler
.
exfiltrate_user_data
(
user_id
,
FileExfiltrationWriter
(
user_id
,
directory
=
directory
)
)
...
...
@@ -129,6 +131,7 @@ def start(config_options):
help
=
"
The directory to store the exported data in. Must be emtpy. Defaults
"
"
to creating a temp directory.
"
,
)
export_data_parser
.
set_defaults
(
func
=
export_data_command
)
try
:
config
,
args
=
HomeServerConfig
.
load_config_with_parser
(
parser
,
config_options
)
...
...
@@ -173,12 +176,6 @@ def start(config_options):
ss
.
setup
()
if
args
.
command
==
"
export-data
"
:
command
=
lambda
:
export_data_command
(
ss
,
args
.
user_id
,
args
.
output_directory
)
else
:
# This shouldn't happen.
raise
ConfigError
(
"
Unknown admin command %s
"
%
(
args
.
command
,))
# We use task.react as the basic run command as it correctly handles tearing
# down the reactor when the deferreds resolve and setting the return value.
# We also make sure that `_base.start` gets run before we actually run the
...
...
@@ -188,7 +185,7 @@ def start(config_options):
def
run
(
_reactor
):
with
LoggingContext
(
"
command
"
):
yield
_base
.
start
(
ss
,
[])
yield
command
(
)
yield
args
.
func
(
ss
,
args
)
_base
.
start_worker_reactor
(
"
synapse-admin-cmd
"
,
config
,
run_command
=
lambda
:
task
.
react
(
run
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment