1
0
mirror of https://github.com/sashacmc/photo-importer.git synced 2024-11-24 08:02:14 +02:00

Defaut config added. Command line options parsing. Bugfixes.

This commit is contained in:
sashacmc 2018-05-20 14:50:02 +02:00
parent 4e9e00eb77
commit c075f0ef59
4 changed files with 38 additions and 9 deletions

21
default.cfg Normal file
View File

@ -0,0 +1,21 @@
[main]
# time source order
time_src = exif,name,attr
# Date/Time formats
out_date_format = %%Y-%%m-%%d
out_time_format = %%Y-%%m-%%d_%%H-%%M-%%S
# Output sub directorines
out_subdir_image = Foto
out_subdir_video = Video
out_subdir_audio = Audio
# Thread count
threads_count = 2
# Remove garbage files (photo config, thumbnails, etc.) 0/1
remove_garbage = 1
# Remove source files (in case of out_path specified) 0/1
move_mode = 1

View File

@ -15,6 +15,7 @@ class Importer(threading.Thread):
self.__config = config
self.__input_path = input_path
self.__output_path = output_path
self.__mov = None
self.__rot = None
self.__stat = {'stage': ''}

View File

@ -62,7 +62,7 @@ class Mover(object):
if self.__output_path:
type_subdir = \
self.__config['main'][self.OUT_SUBDIR_CFG[prop.type()]]
date_subdir = prop.time().strftime(
self.__config['main']['out_date_format'])

23
run.py
View File

@ -1,8 +1,6 @@
#!/usr/bin/python3
import sys
import log
import time
import argparse
import threading
import progressbar
@ -33,15 +31,15 @@ class ProgressBar(threading.Thread):
def run(self):
stage = ''
while True:
time.sleep(0.1)
stat = self.__imp.status()
if stage != stat['stage']:
stage = stat['stage']
if stage == 'scan':
print('Scan...')
print('Scan... ', end='', flush=True)
continue
if stage == 'move':
print('Done.')
self.__create('Import:', stat['total'])
continue
if stage == 'rotate':
@ -58,16 +56,25 @@ class ProgressBar(threading.Thread):
def args_parse():
parser = argparse.ArgumentParser()
parser.add_argument("echo", help="echo the string you use here")
parser.add_argument('in_path', help="Input path")
parser.add_argument('out_path', help="Output path", nargs='?')
parser.add_argument('-c', '--config', help="Config file")
parser.add_argument('-l', '--logfile', help="Log file", default='log.txt')
return parser.parse_args()
def main():
# args = args_parse()
args = args_parse()
log.initLogger('log.txt')
cfg = config.Config(args.config)
log.initLogger(args.logfile)
imp = importer.Importer(
cfg,
args.in_path,
args.out_path)
imp = importer.Importer(config.Config(), sys.argv[1], sys.argv[2])
pbar = ProgressBar(imp)
imp.start()
pbar.start()