mirror of
https://github.com/fraoustin/piwigotools.git
synced 2025-06-08 08:26:19 +00:00
advance on sync
This commit is contained in:
parent
b2bb209dfc
commit
61f3387008
@ -60,8 +60,9 @@ class Piwigo(piwigo.Piwigo):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def plan(self):
|
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 _checkarg(fn):
|
||||||
def checking(self, *args, **kw):
|
def checking(self, *args, **kw):
|
||||||
|
@ -70,6 +70,7 @@ class Run:
|
|||||||
' ',
|
' ',
|
||||||
progressbar.Timer()],
|
progressbar.Timer()],
|
||||||
maxval=self._qin.qsize()).start()
|
maxval=self._qin.qsize()).start()
|
||||||
|
if self._qin.qsize():
|
||||||
for thread in self._threads:
|
for thread in self._threads:
|
||||||
thread.start()
|
thread.start()
|
||||||
while not self._qout.full():
|
while not self._qout.full():
|
||||||
|
@ -35,7 +35,7 @@ VERBS = {
|
|||||||
"description" : "upload file in piwigo gallery",
|
"description" : "upload file in piwigo gallery",
|
||||||
"arg" :
|
"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"},
|
"source" : {"type":"string", "default":"*.jpg", "help":"path of upload picture"},
|
||||||
"url" : {"type":"string", "default":"", "help":"url of piwigo gallery"},
|
"url" : {"type":"string", "default":"", "help":"url of piwigo gallery"},
|
||||||
"user" : {"type":"string", "default":"", "help":"user of piwigo gallery"},
|
"user" : {"type":"string", "default":"", "help":"user of piwigo gallery"},
|
||||||
@ -49,7 +49,7 @@ VERBS = {
|
|||||||
"description" : "download image from piwigo gallery",
|
"description" : "download image from piwigo gallery",
|
||||||
"arg" :
|
"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"},
|
"dest" : {"type":"string", "default":".", "help":"path of destination"},
|
||||||
"url" : {"type":"string", "default":"", "help":"url of piwigo gallery"},
|
"url" : {"type":"string", "default":"", "help":"url of piwigo gallery"},
|
||||||
"user" : {"type":"string", "default":"", "help":"user of piwigo gallery"},
|
"user" : {"type":"string", "default":"", "help":"user of piwigo gallery"},
|
||||||
@ -63,7 +63,7 @@ VERBS = {
|
|||||||
"description" : "synchronization between path and piwigo gallery",
|
"description" : "synchronization between path and piwigo gallery",
|
||||||
"arg" :
|
"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"},
|
"source" : {"type":"string", "default":".", "help":"path of picture"},
|
||||||
"url" : {"type":"string", "default":"", "help":"url of piwigo gallery"},
|
"url" : {"type":"string", "default":"", "help":"url of piwigo gallery"},
|
||||||
"user" : {"type":"string", "default":"", "help":"user of piwigo gallery"},
|
"user" : {"type":"string", "default":"", "help":"user of piwigo gallery"},
|
||||||
@ -199,6 +199,28 @@ def main():
|
|||||||
piwigo.logout()
|
piwigo.logout()
|
||||||
if run.error:
|
if run.error:
|
||||||
parser.error(run.strerror)
|
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:
|
except Exception as e:
|
||||||
parser.error(e)
|
parser.error(e)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user