forked from nanos/FediFetcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargparser.py
197 lines (193 loc) · 6.02 KB
/
argparser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
"""argparser.py - Parses command line arguments."""
import argparse
import json
def parse_arguments() -> argparse.Namespace:
"""Parse command line arguments."""
argparser = argparse.ArgumentParser()
argparser.add_argument(
"-c",
"--config",
required=False,
type=str,
help="Optionally provide a path to a JSON file containing configuration "
"options. If not provided, options must be supplied using command line flags.",
)
argparser.add_argument(
"--server",
required=False,
help="Required: The name of your server (e.g. `mstdn.thms.uk`)",
)
argparser.add_argument(
"--access-token",
action="append",
required=False,
help="Required: The access token can be generated at "
"https://<server>/settings/applications, and must have read:search, "
"read:statuses and admin:read:accounts scopes. You can supply this "
"multiple times, if you want to run it for multiple users.",
)
argparser.add_argument(
"--reply-interval-in-hours",
required=False,
type=int,
default=0,
help="Fetch remote replies to posts that have received replies from users on "
"your own instance in this period",
)
argparser.add_argument(
"--home-timeline-length",
required=False,
type=int,
default=0,
help="Look for replies to posts in the API-Key owner's home timeline, up to "
"this many posts",
)
argparser.add_argument(
"--max-followings",
required=False,
type=int,
default=0,
help="Backfill posts for new accounts followed by --user. We'll backfill at "
"most this many followings' posts",
)
argparser.add_argument(
"--max-followers",
required=False,
type=int,
default=0,
help="Backfill posts for new accounts following --user. We'll backfill at most "
"this many followers' posts",
)
argparser.add_argument(
"--max-follow-requests",
required=False,
type=int,
default=0,
help="Backfill posts of the API key owners pending follow requests. "
"We'll backfill at most this many requester's posts",
)
argparser.add_argument(
"--max-bookmarks",
required=False,
type=int,
default=0,
help="Fetch remote replies to the API key owners Bookmarks. We'll fetch "
"replies to at most this many bookmarks",
)
argparser.add_argument(
"--max-favourites",
required=False,
type=int,
default=0,
help="Fetch remote replies to the API key owners Favourites. We'll fetch "
"replies to at most this many favourites",
)
argparser.add_argument(
"--from-notifications",
required=False,
type=int,
default=0,
help="Backfill accounts of anyone appearing in your notifications, "
"during the last hours",
)
argparser.add_argument(
"--remember-users-for-hours",
required=False,
type=int,
default=24 * 7,
help="How long to remember users that you aren't following for, "
"before trying to backfill them again.",
)
argparser.add_argument(
"--http-timeout",
required=False,
type=int,
default=5,
help="The timeout for any HTTP requests to your own, or other instances.",
)
argparser.add_argument(
"--backfill-with-context",
required=False,
type=int,
default=1,
help="If enabled, we'll fetch remote replies when backfilling "
"profiles. Set to `0` to disable.",
)
argparser.add_argument(
"--backfill-mentioned-users",
required=False,
type=int,
default=1,
help="If enabled, we'll backfill any mentioned users when fetching "
"remote replies to timeline posts. Set to `0` to disable.",
)
argparser.add_argument(
"--lock-hours",
required=False,
type=int,
default=24,
help="The lock timeout in hours.",
)
argparser.add_argument(
"--lock-file",
required=False,
default=None,
help="Location of the lock file",
)
argparser.add_argument(
"--state-dir",
required=False,
default="artifacts",
help="Directory to store persistent files and possibly lock file",
)
argparser.add_argument(
"--on-done",
required=False,
default=None,
help="Provide a url that will be pinged when processing has completed. You can "
"use this for 'dead man switch' monitoring of your task",
)
argparser.add_argument(
"--on-start",
required=False,
default=None,
help="Provide a url that will be pinged when processing is starting. You can "
"use this for 'dead man switch' monitoring of your task",
)
argparser.add_argument(
"--on-fail",
required=False,
default=None,
help="Provide a url that will be pinged when processing has failed. You can "
"use this for 'dead man switch' monitoring of your task",
)
argparser.add_argument(
"--log-level",
required=False,
type=int,
default=20,
help="Set the log level. 10=DEBUG, 20=INFO, 30=WARNING, 40=ERROR, 50=CRITICAL",
)
argparser.add_argument(
"--external-tokens",
required=False,
type=json.loads,
default=None,
help="Provide a JSON-formatted dictionary of external tokens, "
"keyed by server.",
)
argparser.add_argument(
"--pgpassword",
required=False,
type=str,
default=None,
help="Provide the password for the postgres user",
)
argparser.add_argument(
"--external-feeds",
required=False,
type=str,
default=None,
help="Provide a comma-separated list of external feeds to fetch from.",
)
return argparser.parse_args()