If you have a bunch of logfiles in a directory and you only want a range of them, another option is to write a small Python script that takes in a range and a base, and just calls import logs for each one (or, if you want to get particularly fancy, you could actually import import_logs
directly).
You can run any shell command with Popen
in Python. So if you wanted to run import_logs log_base_str01123.txt
, you could just run the following:
from subprocess import Popen, PIPE
print Popen("import_logs.py log_base_str01123.txt", stdout=PIPE, shell=True).stdout.read()
and if you wanted to do that for a bunch of strings:
from subprocess import Popen, PIPE
import os
base_prefix = "u_ex"
base_suffix = ".log"
logs=["my", "list", "of", "log#s"]
for log in logs:
path = "import_logs.py {prefix}{log_name}{suffix}".format(
prefix=prefix, log_name=log, suffix=base_suffix)
if not os.path.exists(log):
print Popen(,
stdout=PIPE, shell=True).stdout.read())
This could be a more general purpose solution/let you have more finegrained control.
If you want to go through a list of consecutive values, you can just use:
logs = map(str, range(start_number, end_number + 1))