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():
|
||||
config = configparser.ConfigParser()
|
||||
try:
|
||||
configfile = get_active_path('config.ini')
|
||||
ret = config.read(configfile)
|
||||
if not ret:
|
||||
print(f'The file {configfile} was not found. We create a new config file.')
|
||||
config['Common']={
|
||||
'description': 'Download and Parse the Austrian Callbook',
|
||||
'author': 'Thomas Kuschel, OE3TKT (OExTKT)',
|
||||
'version': __version__,
|
||||
'created': datetime.datetime.now()
|
||||
config['MARIADB'] = {
|
||||
'db_user': 'om',
|
||||
'db_password': 'oe3tkt',
|
||||
'db_host': '127.0.0.1',
|
||||
'db_port': 3306,
|
||||
'db_database': 'callbook'
|
||||
}
|
||||
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:
|
||||
config.write(configfile, False)
|
||||
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
|
||||
config.write(configfile)
|
||||
|
||||
def call_parser():
|
||||
parser = argparse.ArgumentParser(
|
||||
@ -73,8 +54,12 @@ def call_parser():
|
||||
|
||||
opt = parser.parse_args()
|
||||
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) == '':
|
||||
opt.path = get_active_path(opt.path)
|
||||
opt.path = os.path.join(os.path.dirname(os.path.abspath(__file__)), opt.path)
|
||||
|
||||
return opt
|
||||
|
||||
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
|
||||
|
||||
def get_active_path(file):
|
||||
def get_active_path(file)
|
||||
return os.path.join(os.path.dirname(os.path.abspath(__file__)), file)
|
||||
|
||||
def get_gender(firstnames, surname, call, verbose=0):
|
||||
@ -465,25 +450,20 @@ if __name__ == '__main__':
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
configdb = config['MariaDB'] # fetch from config file, then do with fallbacks:
|
||||
conn = mariadb.connect(
|
||||
user = configdb.get('user', 'om'),
|
||||
password = configdb.get('password','oe3tkt'),
|
||||
host = configdb.get('host','127.0.0.1'),
|
||||
port = configdb.getint('port',3306),
|
||||
database = configdb.get('database','callbook')
|
||||
user = 'om',
|
||||
password = 'oe3tkt',
|
||||
host='127.0.0.1',
|
||||
port=3306,
|
||||
database='callbook'
|
||||
)
|
||||
except mariadb.Error as e:
|
||||
print(f'Error connectiong to MariaDB platform: {e}')
|
||||
sys.exit(5)
|
||||
print(f'Connected to MariaDB API Version {mariadb.mariadbapi_version}.')
|
||||
|
||||
print(datetime.datetime.now(datetime.UTC))
|
||||
# Get Cursor
|
||||
cur = conn.cursor()
|
||||
cur.execute('SELECT VERSION()')
|
||||
print(cur.fetchone()[0])
|
||||
|
||||
sql_file = '.sql_init'
|
||||
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), sql_file)
|
||||
exec_sql_file(cur, path)
|
||||
|
Loading…
Reference in New Issue
Block a user