reduced code clutter
This commit is contained in:
parent
797042b97a
commit
a3b20cbb17
@ -5,10 +5,7 @@ import mysql.connector as mysql
|
||||
from os import getenv
|
||||
import time, sys
|
||||
|
||||
code_name = 'INVITES_MANAGER'
|
||||
|
||||
def remove_old(config):
|
||||
global code_name
|
||||
'''
|
||||
Removes invites that are out of date
|
||||
'''
|
||||
@ -22,11 +19,10 @@ def remove_old(config):
|
||||
|
||||
cursor.close()
|
||||
conn.close()
|
||||
print(f'[ {code_name} ] : Removed old invites with no errors')
|
||||
print(f'[ {__file__} ] : Removed old invites with no errors')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
fail = False
|
||||
config = {
|
||||
'database': getenv('DATABASE_NAME'),
|
||||
'password': getenv('DATABASE_PASS'),
|
||||
@ -36,11 +32,7 @@ if __name__ == '__main__':
|
||||
}
|
||||
for k in config:
|
||||
if config[k] is None:
|
||||
print(f'[ {code_name} ] : {k} not set', file=sys.stderr)
|
||||
fail = True
|
||||
|
||||
|
||||
if not fail:
|
||||
remove_old(config)
|
||||
print(f'[ {__file__} ] : {k} not set', file=sys.stderr)
|
||||
else:
|
||||
exit(1)
|
||||
remove_old(config)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user