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:
parent
4e9e00eb77
commit
c075f0ef59
21
default.cfg
Normal file
21
default.cfg
Normal 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
|
@ -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': ''}
|
||||
|
||||
|
2
mover.py
2
mover.py
@ -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
23
run.py
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user