From e690fdfa6f1eebac5a4790668ab946e82f947eaf Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Sun, 16 Apr 2017 16:59:02 -0400 Subject: take webroot as a command line argument --- main.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index a109d2f..f1c3317 100755 --- a/main.py +++ b/main.py @@ -1,5 +1,8 @@ #!/usr/bin/env python3 +import argparse +import os + from unbiasedObjects import * from unbiasedFunctions import * from parser import * @@ -7,13 +10,17 @@ import time def main(): + parser = argparse.ArgumentParser() + parser.add_argument('-w', '--webroot', default='/var/www/ubiased', help='location to write the output html') + args = parser.parse_args() + while True: print('-----------------------') - run() + run(args.webroot) print('-----------------------') time.sleep(600) -def run(): +def run(webroot): sourceList=[] ''' @@ -25,6 +32,8 @@ def run(): ''' + print('running with webroot="{}"'.format(webroot)) + ### These values have to be the second half of the function name ### E.g. Guardian calls buildGuardian(), etc. @@ -54,7 +63,7 @@ def run(): outputHTML=buildOutput(newsSourceArr) #print the output file HTML - printOutputHTML(outputHTML, '/var/www/html/index.html') + printOutputHTML(outputHTML, os.path.join(webroot, 'index.html')) if __name__=="__main__": -- cgit v1.2.3