Added Database restore

This commit is contained in:
Tanay Karve 2019-04-14 22:44:55 +07:00 committed by GitHub
parent ed8e5d2f2b
commit 69c4ec1f2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,9 @@ GMAIL_PASSWORD = dotenv['GMAIL_PASSWORD']
KUMAR_EMAIL = 'kumar.a@example.com'
KEYWORDS_REGEX = re.compile(r'sorry|help|wrong', re.IGNORECASE)
backup="~/PATH/backup.zip"
dbname="DBNAME"
REPLY_BODY = "No problem. I've fixed it. \n\n Please be careful next time."
@ -37,7 +40,7 @@ def main():
for mail in g.inbox().mail(unread=True, sender=KUMAR_EMAIL, prefetch=True):
if KEYWORDS_REGEX.search(mail.body):
# Restore DB and send a reply.
os.system('gunzip #{backup} | psql #{dbname}')
os.system('gunzip {} | psql {}'.format(backup,dbname))
mail.add_label('Database fixes')
send_reply(mail.subject)