1
0
mirror of https://github.com/fraoustin/piwigotools.git synced 2025-06-07 16:06:27 +00:00

advance on sync

This commit is contained in:
fraoustin 2016-02-07 19:31:22 +01:00
parent b2bb209dfc
commit 61f3387008
3 changed files with 34 additions and 10 deletions

View File

@ -60,8 +60,9 @@ class Piwigo(piwigo.Piwigo):
@property
def plan(self):
return { i["name"] : i["id"] for i in self.pwg.categories.getList(recursive=True, fullname=True)['categories'] }
plan = { i["name"] : i["id"] for i in self.pwg.categories.getList(recursive=True, fullname=True)['categories'] }
plan[""] = 0
return plan
def _checkarg(fn):
def checking(self, *args, **kw):

View File

@ -70,11 +70,12 @@ class Run:
' ',
progressbar.Timer()],
maxval=self._qin.qsize()).start()
for thread in self._threads:
thread.start()
while not self._qout.full():
time.sleep(0.1) # sleep 0.1s
pbar.update(self._qout.qsize())
if self._qin.qsize():
for thread in self._threads:
thread.start()
while not self._qout.full():
time.sleep(0.1) # sleep 0.1s
pbar.update(self._qout.qsize())
pbar.finish()
return self._qerr

View File

@ -35,7 +35,7 @@ VERBS = {
"description" : "upload file in piwigo gallery",
"arg" :
{
"category" : {"type":"string", "default":"/", "help":"destination category of piwigo gallery"},
"category" : {"type":"string", "default":"", "help":"destination category of piwigo gallery"},
"source" : {"type":"string", "default":"*.jpg", "help":"path of upload picture"},
"url" : {"type":"string", "default":"", "help":"url of piwigo gallery"},
"user" : {"type":"string", "default":"", "help":"user of piwigo gallery"},
@ -49,7 +49,7 @@ VERBS = {
"description" : "download image from piwigo gallery",
"arg" :
{
"category" : {"type":"string", "default":"/", "help":"source category of piwigo gallery"},
"category" : {"type":"string", "default":"", "help":"source category of piwigo gallery"},
"dest" : {"type":"string", "default":".", "help":"path of destination"},
"url" : {"type":"string", "default":"", "help":"url of piwigo gallery"},
"user" : {"type":"string", "default":"", "help":"user of piwigo gallery"},
@ -63,7 +63,7 @@ VERBS = {
"description" : "synchronization between path and piwigo gallery",
"arg" :
{
"category" : {"type":"string", "default":"/", "help":"category of piwigo gallery"},
"category" : {"type":"string", "default":"", "help":"category of piwigo gallery"},
"source" : {"type":"string", "default":".", "help":"path of picture"},
"url" : {"type":"string", "default":"", "help":"url of piwigo gallery"},
"user" : {"type":"string", "default":"", "help":"user of piwigo gallery"},
@ -199,6 +199,28 @@ def main():
piwigo.logout()
if run.error:
parser.error(run.strerror)
if verb == "sync":
ana = Analyse('Analyze')
ana.start()
try:
piwigo = Piwigo(url=options.url)
piwigo.login(options.user, options.password)
# check
options.source = os.path.abspath(options.source)
if not os.path.isdir(options.source):
raise Exception("%s is not directory" % options.source)
piwigo.iscategory(options.category)
# treatment
run = Run(verb, options.thread)
kw = purge_kw(options.__dict__,('user','password','url','source','category','thread'))
ana.stop()
except Exception as e:
ana.stop()
raise e
run.start()
piwigo.logout()
if run.error:
parser.error(run.strerror)
except Exception as e:
parser.error(e)
sys.exit(1)