Hi Chris,
I need to add a script to Wooey. the script will use a python module that will read a log file. the log file will be uploaded by the user with wooey. but the problem is: the upload file must be a file handler object in the script, but the module only accepts a string as the filename as args. I'd like to know how to get the full path and filename of the uploaded log file? Thanks!
example code:
import somemodule
parser.add_argument("log_file", type=argparse.FileType('r'))
args = parser.parse_args()
print(args.log_file) # the args.log_file is a io.TextIOWrapper
result = somemodule.check(log_filename) # the log_filename must be a string not io.TextIOWrapper
After some trying, I got the solution, it's very easy actually: the args.log_file is an io.IOTextWrapper object, it has a 'name' attribute which is its abs path.
Hi Chris, I need to add a script to Wooey. the script will use a python module that will read a log file. the log file will be uploaded by the user with wooey. but the problem is: the upload file must be a file handler object in the script, but the module only accepts a string as the filename as args. I'd like to know how to get the full path and filename of the uploaded log file? Thanks!
example code: