Compare commits
No commits in common. "3a8032b7875718177dc92c76965d908dff5f9131" and "73a989e4a4998e7bf4930a254afd6a262af92fd1" have entirely different histories.
3a8032b787
...
73a989e4a4
1
afu/.gitattributes
vendored
1
afu/.gitattributes
vendored
@ -1 +0,0 @@
|
|||||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
|
5
afu/.gitignore
vendored
5
afu/.gitignore
vendored
@ -1,5 +0,0 @@
|
|||||||
# Ignore the following files
|
|
||||||
# Configuration File of callbook, config.ini is created automatically after starting the script
|
|
||||||
config.ini
|
|
||||||
# For testing purposes, store this PDF as lfs (large file storage), pls install git-lfs.
|
|
||||||
!Rufzeichenliste_AT_Stand_20240601.pdf
|
|
BIN
afu/Rufzeichenliste_AT_Stand_20240601.pdf
(Stored with Git LFS)
BIN
afu/Rufzeichenliste_AT_Stand_20240601.pdf
(Stored with Git LFS)
Binary file not shown.
@ -23,34 +23,15 @@ def call_description():
|
|||||||
|
|
||||||
def call_configparser():
|
def call_configparser():
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
try:
|
config['MARIADB'] = {
|
||||||
configfile = get_active_path('config.ini')
|
'db_user': 'om',
|
||||||
ret = config.read(configfile)
|
'db_password': 'oe3tkt',
|
||||||
if not ret:
|
'db_host': '127.0.0.1',
|
||||||
print(f'The file {configfile} was not found. We create a new config file.')
|
'db_port': 3306,
|
||||||
config['Common']={
|
'db_database': 'callbook'
|
||||||
'description': 'Download and Parse the Austrian Callbook',
|
|
||||||
'author': 'Thomas Kuschel, OE3TKT (OExTKT)',
|
|
||||||
'version': __version__,
|
|
||||||
'created': datetime.datetime.now()
|
|
||||||
}
|
}
|
||||||
config['MariaDB'] = {
|
|
||||||
'user': 'om',
|
|
||||||
'password': 'oe3tkt',
|
|
||||||
'host': '127.0.0.1',
|
|
||||||
'port': 3306,
|
|
||||||
'database': 'callbook'}
|
|
||||||
with open(get_active_path('config.ini'), 'w') as configfile:
|
with open(get_active_path('config.ini'), 'w') as configfile:
|
||||||
config.write(configfile, False)
|
config.write(configfile)
|
||||||
print(f'Configuration file "config.ini" created.')
|
|
||||||
|
|
||||||
except FileNotFoundError:
|
|
||||||
sys.exit(8)
|
|
||||||
except Exception as e:
|
|
||||||
print('Error: {}'.format(e), file=sys.stderr)
|
|
||||||
sys.exit(9)
|
|
||||||
# print(config.sections()) ## ['Common', 'MariaDB']
|
|
||||||
return config
|
|
||||||
|
|
||||||
def call_parser():
|
def call_parser():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
@ -73,8 +54,12 @@ def call_parser():
|
|||||||
|
|
||||||
opt = parser.parse_args()
|
opt = parser.parse_args()
|
||||||
opt.verbose = 0 if opt.verbose is None else sum(opt.verbose)
|
opt.verbose = 0 if opt.verbose is None else sum(opt.verbose)
|
||||||
|
ask = opt.path != ''
|
||||||
|
base = os.path.basename(opt.path)
|
||||||
|
dir = os.path.dirname(opt.path)
|
||||||
if opt.path != '' and os.path.dirname(opt.path) == '':
|
if opt.path != '' and os.path.dirname(opt.path) == '':
|
||||||
opt.path = get_active_path(opt.path)
|
opt.path = os.path.join(os.path.dirname(os.path.abspath(__file__)), opt.path)
|
||||||
|
|
||||||
return opt
|
return opt
|
||||||
|
|
||||||
def call_website(url,verbose,path='',interactive=False,output='',mariadb=''):
|
def call_website(url,verbose,path='',interactive=False,output='',mariadb=''):
|
||||||
@ -183,7 +168,7 @@ def gender_substring(path, search_substring, verbose=0):
|
|||||||
|
|
||||||
gender_substring.lines = None
|
gender_substring.lines = None
|
||||||
|
|
||||||
def get_active_path(file):
|
def get_active_path(file)
|
||||||
return os.path.join(os.path.dirname(os.path.abspath(__file__)), file)
|
return os.path.join(os.path.dirname(os.path.abspath(__file__)), file)
|
||||||
|
|
||||||
def get_gender(firstnames, surname, call, verbose=0):
|
def get_gender(firstnames, surname, call, verbose=0):
|
||||||
@ -465,25 +450,20 @@ if __name__ == '__main__':
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
configdb = config['MariaDB'] # fetch from config file, then do with fallbacks:
|
|
||||||
conn = mariadb.connect(
|
conn = mariadb.connect(
|
||||||
user = configdb.get('user', 'om'),
|
user = 'om',
|
||||||
password = configdb.get('password','oe3tkt'),
|
password = 'oe3tkt',
|
||||||
host = configdb.get('host','127.0.0.1'),
|
host='127.0.0.1',
|
||||||
port = configdb.getint('port',3306),
|
port=3306,
|
||||||
database = configdb.get('database','callbook')
|
database='callbook'
|
||||||
)
|
)
|
||||||
except mariadb.Error as e:
|
except mariadb.Error as e:
|
||||||
print(f'Error connectiong to MariaDB platform: {e}')
|
print(f'Error connectiong to MariaDB platform: {e}')
|
||||||
sys.exit(5)
|
sys.exit(5)
|
||||||
print(f'Connected to MariaDB API Version {mariadb.mariadbapi_version}.')
|
|
||||||
|
|
||||||
print(datetime.datetime.now(datetime.UTC))
|
print(datetime.datetime.now(datetime.UTC))
|
||||||
# Get Cursor
|
# Get Cursor
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
cur.execute('SELECT VERSION()')
|
|
||||||
print(cur.fetchone()[0])
|
|
||||||
|
|
||||||
sql_file = '.sql_init'
|
sql_file = '.sql_init'
|
||||||
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), sql_file)
|
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), sql_file)
|
||||||
exec_sql_file(cur, path)
|
exec_sql_file(cur, path)
|
||||||
|
Loading…
Reference in New Issue
Block a user