Proper configuration file

This commit is contained in:
giomba 2018-11-03 14:13:18 +01:00
parent 7273d3a079
commit f6bff1b998
4 changed files with 18 additions and 7 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@ __pycache__/
test/
input/
images/
conf/*custom.ini
.directory
*.swp
*~

11
conf/conf.ini Normal file
View File

@ -0,0 +1,11 @@
# TPDF - Tellico Parser anD Finder
# Main configuration file
#
# Do not edit this file directly if you want to keep your git repository clean.
# Copy/Rename it as `conf.custom.ini` and edit it.
# It will override this file's values, and it will not be tracked.
################################################################################
[default]
# Path to Tellico .tc database to use
path = /some/path/to/tellico.tc

View File

@ -25,10 +25,10 @@ import zipfile
import shutil as sh
import os
import time
import configparser
# Our custom library (again no pun intended)
import tcparser
import settings
# Start CGI handling for webserver
cgitb.enable()
@ -49,18 +49,21 @@ print()
### End of HTTP headers: it is now safe to output things
##########################################################
# Read configuration files (latest files in list override previous settings)
conf = configparser.ConfigParser()
conf.read(['conf/conf.ini', 'conf/conf.custom.ini'])
luh = open('./output/lastupdate.txt', 'r')
lu = int(float(luh.read()))
luh.close()
mtime = os.path.getmtime(settings.path)
mtime = os.path.getmtime(conf['default']['path'])
outdir = './output'
if int(lu) < int(mtime):
# Unzip Tellico .tc database
zipHandler = zipfile.ZipFile(settings.path, 'r')
zipHandler = zipfile.ZipFile(conf['default']['path'], 'r')
zipHandler.extractall(outdir)
zipHandler.close()
luh = open('./output/lastupdate.txt', 'w')

View File

@ -1,4 +0,0 @@
# TPDF - Tellico Parser anD Finder -- MAIN CONFIGURATION FILE
# Path to Tellico .tc database to use
path = 'input/tellico.tc'