whitespace trimming, and reindentation with tabs

This commit is contained in:
2018-10-17 19:21:11 +03:00
parent 1c4237aada
commit cd28617259

View File

@@ -11,7 +11,7 @@ def aeonview(argv):
parser = optparse.OptionParser( parser = optparse.OptionParser(
usage="Usage: %prog [options]", usage="Usage: %prog [options]",
description="aeonview for timelapses", description="aeonview for timelapses",
version="%prog v"+version version="%prog v"+version
) )
basicopts = optparse.OptionGroup( basicopts = optparse.OptionGroup(
@@ -56,14 +56,15 @@ def aeonview(argv):
default="daily", default="daily",
help="Video to process: daily, monthly or yearly [default: %default]", help="Video to process: daily, monthly or yearly [default: %default]",
type="string") type="string")
videoopts.add_option('--generate',
videoopts.add_option('--generate',
help="Date to video. Format: YYYY-MM-DD. " help="Date to video. Format: YYYY-MM-DD. "
"Default is calculated yesterday, currently %default", "Default is calculated yesterday, currently %default",
type="string", type="string",
default=datetime.date.today()-datetime.timedelta(1)) default=datetime.date.today()-datetime.timedelta(1))
# TODO: mode for monthly videos # TODO: mode for monthly videos
#videoopts.add_option("--gen-month", #videoopts.add_option("--gen-month",
# help="Month to video. Format: YYYY-MM. " # help="Month to video. Format: YYYY-MM. "
# "Default is last month, currently %default", # "Default is last month, currently %default",
# type="string", # type="string",
@@ -80,9 +81,9 @@ def aeonview(argv):
parser.add_option("-q", help="Quiet", action="store_false", dest="verbose", default=True) parser.add_option("-q", help="Quiet", action="store_false", dest="verbose", default=True)
parser.add_option("-s", "--simulate", parser.add_option("-s", "--simulate",
help="Demostrates what will happen (good for checking your settings and destinations)", help="Demostrates what will happen (good for checking your settings and destinations)",
default=False, default=False,
action="store_true") action="store_true")
(options, args) = parser.parse_args(argv[1:]) (options, args) = parser.parse_args(argv[1:])
@@ -124,10 +125,10 @@ def aeonview(argv):
options.imgname = time.strftime("%H-%M-%S") options.imgname = time.strftime("%H-%M-%S")
# Let us build the destination path and filename # Let us build the destination path and filename
options.fileext = os.path.splitext(options.url)[1] options.fileext = os.path.splitext(options.url)[1]
options.destdir = options.path + "/" + options.project + options.imgpath options.destdir = options.path + "/" + options.project + options.imgpath
options.destination = options.destdir + options.imgname + options.fileext options.destination = options.destdir + options.imgname + options.fileext
getit = options.url + " -o " + options.destination getit = options.url + " -o " + options.destination
# Crude, but works. # Crude, but works.
if options.simulate == False: if options.simulate == False:
@@ -151,27 +152,27 @@ def aeonview(argv):
sys.exit(-1) sys.exit(-1)
if options.videorun == "daily": if options.videorun == "daily":
vid_date = str(options.generate).split("-") vid_date = str(options.generate).split("-")
year = vid_date[0] year = vid_date[0]
month = vid_date[1] month = vid_date[1]
day = vid_date[2] day = vid_date[2]
if check_date(int(year), int(month), int(day)): if check_date(int(year), int(month), int(day)):
proj_dir = options.path + "/" + options.project proj_dir = options.path + "/" + options.project
video_dir = proj_dir + "/img/" + year + "-" + month + "/" + day + "/*" video_dir = proj_dir + "/img/" + year + "-" + month + "/" + day + "/*"
video_out_dir = proj_dir + "/vid/" + year + "-" + month + "/" video_out_dir = proj_dir + "/vid/" + year + "-" + month + "/"
video_out_day = video_out_dir + day + vid_extension video_out_day = video_out_dir + day + vid_extension
mfdir = os.path.dirname(os.path.realpath(video_dir)) mfdir = os.path.dirname(os.path.realpath(video_dir))
command = mencoder + " -o " + video_out_day + " 'mf://" + mfdir + "/*'" command = mencoder + " -o " + video_out_day + " 'mf://" + mfdir + "/*'"
if options.simulate == False: if options.simulate == False:
mkdir_p( video_out_dir ) mkdir_p( video_out_dir )
os.system(command) os.system(command)
else: else:
print "(!) Video dir to process:", video_dir print "(!) Video dir to process:", video_dir
print "(!) Video output-file:", video_out_day print "(!) Video output-file:", video_out_day
print "(!) Made directory structure:", video_out_dir print "(!) Made directory structure:", video_out_dir
print "(!) Command to run", command print "(!) Command to run", command
else: else:
print "(!) Error: check your date. Value provided:", options.generate print "(!) Error: check your date. Value provided:", options.generate
@@ -194,12 +195,12 @@ def aeonview(argv):
# http://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python/600612#600612 # http://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python/600612#600612
def mkdir_p(path): def mkdir_p(path):
try: try:
os.makedirs(path) os.makedirs(path)
except OSError as exc: # Python >2.5 except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST: if exc.errno == errno.EEXIST:
pass pass
else: raise else: raise
# Modified http://markmail.org/message/k2pxsle2lslrmnut # Modified http://markmail.org/message/k2pxsle2lslrmnut