def __init__(self,hist): self.mysite = Piwigo(url='http://qmul.piwigo.com/') self.mysite.login(username="******", password="******") self.webfdlist = self.mysite.plan self.webparent = u'CRLM_V2 / ' ## " " space is necessary self.hist = hist self.finame = hist.finame if self.webfdlist.has_key(self.webparent+self.finame) == False: self.mysite.mkdir(self.webparent+self.finame)
def __init__(self, fdname, finame): self.fdname = fdname self.finame = finame self.im = ops.OpenSlide(self.fdname + self.finame + '.ndpi') self.root = self.ExtractRoot() self.an_num = self.root.__len__() self.mysite = Piwigo(url='http://qmul.piwigo.com/') self.login = self.Login() self.webimlist = self.mysite.images(self.mysite.plan.keys()[0]) self.webfdlist = self.mysite.plan self.update = self.CheckMysite() #Update or
# -*- coding: utf-8 -*- """ Created on Sun Feb 21 22:18:47 2016 @author: john """ from piwigotools import Piwigo from piwigo.ws import Ws from piwigotools.interface import * import os mysite = Piwigo(url='http://qmul.piwigo.com/') mysite.login(username="******", password="******") #mysite.mkdir(r'/Test1/2016-1-1/T') #print mysite.plan #print mysite.idcategory(mysite.plan.keys()[0]) #print mysite.images(mysite.plan.keys()[-1]) #mysite.removedirs('/Test3') flist = os.listdir('../Samples') ''' for tmp in flist: if tmp[-3:] != 'png': flist.remove(tmp) for im in flist: mysite.upload(im,mysite.plan.keys()[0])
def __init__(self, webparent=u'LYMPH_NODE_METASTASES_V2 / '): self.mysite = Piwigo(url='http://qmul.piwigo.com/') self.mysite.login(username="******", password="******") self.webfdlist = self.mysite.plan self.webparent = webparent # u'LYMPH_NODE_METASTASES_V2 / ' ## " " space is necessary
def setUp(self): self.url = "http://mygallery.piwigo.com/" self.usertest = 'USERTEST' self.passwordtest = 'xxxxxx' self.piwigo = Piwigo(self.url)
def main(): usage = USAGE parser = OptionParser(version="%s %s" % (PROG, VERSION), usage=usage) parser.description = DESCRIPTION parser.epilog = AUTHOR try: add_dynamic_option(parser) (options, args) = parser.parse_args() verb = args[0] if verb == 'ws': piwigo = Piwigo(url=options.url) if 'user' and 'password' in options.__dict__: piwigo.login(options.user, options.password) kw = purge_kw(options.__dict__, ('user', 'password', 'url')) pp = pprint.PrettyPrinter(indent=4) pp.pprint(Ws(piwigo, options.method)(**kw)) if piwigo.islogged: piwigo.logout() if verb == "download": ana = Analyse('Analyze') ana.start() try: piwigo = Piwigo(url=options.url) piwigo.login(options.user, options.password) # check if not os.path.isdir(options.dest): os.makedirs(options.dest) options.dest = os.path.abspath(options.dest) piwigo.iscategory(options.category) if options.category[-2:] == ' /': options.category = options.category[:-2] # treatment run = Run(verb, options.thread) kw = purge_kw( options.__dict__, ('user', 'password', 'url', 'dest', 'category', 'thread')) for img in piwigo.images(options.category, **kw): run.add(piwigo.download, [ "%s / %s" % (options.category, str(img)), "%s%s%s" % (options.dest, os.path.sep, str(img)) ], kw) except Exception as e: ana.stop() raise e ana.stop() run.start() piwigo.logout() if run.error: parser.error(run.strerror) if verb == "upload": ana = Analyse('Analyze') ana.start() try: piwigo = Piwigo(url=options.url) piwigo.login(options.user, options.password) # check piwigo.makedirs(options.category) # treatment run = Run(verb, options.thread) kw = purge_kw(options.__dict__, ('user', 'password', 'url', 'source', 'category', 'thread')) for img in glob.glob(options.source): run.add(piwigo.upload, [os.path.abspath(img), options.category], kw) ana.stop() except Exception as e: ana.stop() raise e run.start() piwigo.logout() if run.error: parser.error(run.strerror) if verb == "sync-up": 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) if len(options.category) and options.category[ -1] != '/' and options.category[:-3] != ' / ': options.category = options.category + ' / ' # treatment run = Run(verb, options.thread) kw = purge_kw(options.__dict__, ('user', 'password', 'url', 'source', 'category', 'thread')) # local -> piwigo for root, dirnames, filenames in os.walk(options.source): filtering = fnmatch.filter(filenames, options.extension.split(',')[0]) for ext in options.extension.split(',')[1:]: filtering = filtering + fnmatch.filter(filenames, ext) for filename in filtering: pathrel = os.path.abspath(os.path.join( root, filename))[len(options.source) + 1:] pathabs = os.path.abspath(os.path.join(root, filename)) category = options.category + ' / '.join( pathrel.split(os.sep)[:-1]) if not piwigo.isimage(category + ' / ' + filename): run.add(piwigo.makedirs, [ category, ], kw) run.add(piwigo.upload, [pathabs, category], kw) ana.stop() except Exception as e: ana.stop() raise e run.start() piwigo.logout() if run.error: parser.error(run.strerror) if verb == "sync-down": 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) if len(options.category) and options.category[ -1] != '/' and options.category[:-3] != ' / ': options.category = options.category + ' / ' # treatment run = Run(verb, options.thread) kw = purge_kw(options.__dict__, ('user', 'password', 'url', 'source', 'category', 'thread')) # piwigo -> local for category, item in piwigo.plan.iteritems(): if options.category == category[0:len(options.category)]: path = os.path.join( options.source, *category[len(options.category):].split(' / ')) if not os.path.exists(path): os.makedirs(path) for img in piwigo.images(category): pathimg = os.path.join(path, img) if not os.path.exists(pathimg): run.add(piwigo.download, [ "%s / %s" % (category, str(img)), pathimg ], kw) 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)