From b20e6972a5e968dccfc034a1768e94cbc2bc5ead Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 4 May 2019 16:21:03 +0200 Subject: [PATCH] write accepted orders to database --- process/accept-orders.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/process/accept-orders.py b/process/accept-orders.py index 237184861..08f4e27de 100755 --- a/process/accept-orders.py +++ b/process/accept-orders.py @@ -57,6 +57,9 @@ sendmail = True maxfiles = 30 # write headers to file? writeheaders = True +# write received files to datrabase? +tooldir = os.path.join(rootdir, orderbase) +writedb = os.path.exists(tooldir) # reject all html email? rejecthtml = True @@ -225,16 +228,20 @@ def write_part(outfile, part): def copy_orders(message, filename, sender): # print the header first + dirname, basename = split(filename) if writeheaders: - from os.path import split - dirname, basename = split(filename) - dirname = dirname + '/headers' - if not os.path.exists(dirname): os.mkdir(dirname) - outfile = open(dirname + '/' + basename, "w") + header_dir = dirname + '/headers' + if not os.path.exists(header_dir): os.mkdir(header_dir) + outfile = open(header_dir + '/' + basename, "w") for name, value in message.items(): outfile.write(name + ": " + value + "\n") outfile.close() + if writedb: + cli = os.path.join(tooldir, 'cli.php'); + dbname = os.path.join(dirname, 'orders.db') + subprocess.call(['php', cli, '-d', dbname, 'insert', basename]) + found = False outfile = open(filename, "w") if message.is_multipart():