forked from crowdani/RulesBasedDcoumentExtraction
/
start.py
60 lines (49 loc) · 2.4 KB
/
start.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'''
DISCLAIMER OF WARRANTIES.
This code is sample code created by IBM Corporation. IBM grants you a
nonexclusive copyright license to use this sample code example. This
sample code is not part of any standard IBM product and is provided to you
solely for the purpose of assisting you in the development of your
applications. This example has not been thoroughly tested under all
conditions. IBM, therefore cannot guarantee nor may you imply reliability,
serviceability, or function of these programs. The code is provided "AS IS",
without warranty of any kind. IBM shall not be liable for any damages
arising out of your or any other parties use of the sample code, even if IBM
has been advised of the possibility of such damages. If you do not agree with
these terms, do not use the sample code.
Copyright IBM Corp. 2019 All Rights Reserved.
To run, see README.md
'''
import datetime as dt
from loggingHandler import logger
from downloadFiles import downloadFiles
from uploadFiles import uploadFiles
from deleteFiles import deleteFiles
from updateReport import updateReport
from executeRules import executeRules
from oauth import oauth
starttime = dt.datetime.now()
if __name__ == '__main__':
logger.info("**************************************")
logger.info("Content Analyzer API Sample tool starting...")
logger.info("Logs can be found in the current directory, processing.log")
uploadSuccess = oauth()
bearerToken = "Bearer " + uploadSuccess
logger.info("Uploading files")
uploadSuccess = uploadFiles(bearerToken)
if (uploadSuccess):
logger.info("Ready to download output files...")
complete = downloadFiles(bearerToken)
if(complete):
logger.info("Deleting files on the server")
deleteFiles()
uploadSuccess = executeRules()
if(uploadSuccess):
logger.info("All done")
else:
logger.info("Could not delete at this time because download has not been completed yet, please run deleteFiles.py at a later time")
logger.info("Updating report")
updateReport()
endtime = dt.datetime.now()
seconds = (endtime - starttime).total_seconds()
logger.info("Content Analyzer API Sample tool ended. Processing time took {0} seconds, Disclaimer: This includes time to upload, download and delete and has nothing to do with BACA's actual processing time.".format(int(seconds)))