Proper configuration file
This commit is contained in:
parent
7273d3a079
commit
f6bff1b998
|
@ -2,6 +2,7 @@ __pycache__/
|
||||||
test/
|
test/
|
||||||
input/
|
input/
|
||||||
images/
|
images/
|
||||||
|
conf/*custom.ini
|
||||||
.directory
|
.directory
|
||||||
*.swp
|
*.swp
|
||||||
*~
|
*~
|
||||||
|
|
|
@ -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
|
9
main.py
9
main.py
|
@ -25,10 +25,10 @@ import zipfile
|
||||||
import shutil as sh
|
import shutil as sh
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import configparser
|
||||||
|
|
||||||
# Our custom library (again no pun intended)
|
# Our custom library (again no pun intended)
|
||||||
import tcparser
|
import tcparser
|
||||||
import settings
|
|
||||||
|
|
||||||
# Start CGI handling for webserver
|
# Start CGI handling for webserver
|
||||||
cgitb.enable()
|
cgitb.enable()
|
||||||
|
@ -49,18 +49,21 @@ print()
|
||||||
|
|
||||||
### End of HTTP headers: it is now safe to output things
|
### 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')
|
luh = open('./output/lastupdate.txt', 'r')
|
||||||
lu = int(float(luh.read()))
|
lu = int(float(luh.read()))
|
||||||
luh.close()
|
luh.close()
|
||||||
|
|
||||||
mtime = os.path.getmtime(settings.path)
|
mtime = os.path.getmtime(conf['default']['path'])
|
||||||
|
|
||||||
outdir = './output'
|
outdir = './output'
|
||||||
|
|
||||||
if int(lu) < int(mtime):
|
if int(lu) < int(mtime):
|
||||||
# Unzip Tellico .tc database
|
# Unzip Tellico .tc database
|
||||||
zipHandler = zipfile.ZipFile(settings.path, 'r')
|
zipHandler = zipfile.ZipFile(conf['default']['path'], 'r')
|
||||||
zipHandler.extractall(outdir)
|
zipHandler.extractall(outdir)
|
||||||
zipHandler.close()
|
zipHandler.close()
|
||||||
luh = open('./output/lastupdate.txt', 'w')
|
luh = open('./output/lastupdate.txt', 'w')
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
# TPDF - Tellico Parser anD Finder -- MAIN CONFIGURATION FILE
|
|
||||||
|
|
||||||
# Path to Tellico .tc database to use
|
|
||||||
path = 'input/tellico.tc'
|
|
Loading…
Reference in New Issue