forked from metabrainz/mb2wikidatabot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
38 lines (33 loc) · 1.16 KB
/
run.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
#!/usr/bin/env python
"""
This is a bot to automatically add MBIDs to Wikidata pages.
Usage: python run.py [options]
Command line options:
-createtable: Create the table storing the processed MBIDs
-entites: A comma-separated list of entity types for which MBIDs are to be
added to their Wikidata pages. Example: `-entities:artist,work,place`
-limit:x: Only handle x entities of *each* type
"""
import sys
import traceback
from time import sleep
import psycopg2
import pywikibot as wp
from bot.common import mainloop, SettingsReloadedException
while True:
try:
mainloop()
except psycopg2.Error as e:
# It might take a few seconds for everything to properly work after
# settings have been changed, so give Docker a few seconds to get
# everything running.
print("Trouble connecting to PostgreSQL: {}".format(e.pgerror))
traceback.print_exc()
sleep(5)
except SettingsReloadedException:
# Settings have been reloaded, just start the mainloop again.
pass
except Exception as err:
print("General exception caught: {}".format(err))
traceback.print_exc()
sleep(5)