def perform_test(self, task, *vargs, **kwargs): from pyloco.main import perform if vargs: return perform(task, list(vargs), **kwargs) else: return perform(task, **kwargs)
def run(self, argv, subargv=None, forward=None): if not argv: raise UsageError("PlZ Task is not found." " Please check plz path.") elif not os.path.isfile(argv[0]): raise UsageError("PlZ Task '%s' is not found." " Please check plz path." % str(argv[0])) out = -1 taskpath = argv.pop(0) if zipfile.is_zipfile(taskpath): tempdir = None with TemporaryDirectory() as tempdir: plz = zipfile.ZipFile(taskpath) plz.extractall(path=tempdir) plz.close() dirnames = os.listdir(tempdir) if len(dirnames) != 1: raise UsageError("'%s' is not a plz file." % taskpath) taskname = dirnames[0] pkgdir = os.path.join(tempdir, taskname) moddir = os.path.join(pkgdir, taskname) sys.path.insert(0, pkgdir) mod = pyloco_import(taskname) taskcls = getattr(mod, "entry_task") if taskcls is PlXTask: argv.insert(0, os.path.join(moddir, getattr(mod, "plx"))) sys.path.pop(0) from pyloco.main import perform parent = self.get_proxy() out = perform(taskcls, argv=argv, subargv=subargv, parent=parent, forward=forward, shared=self.parent.shared) return out else: raise UsageError("'%s' is not a plz file format." % taskpath)
# -*- coding: utf-8 -*- #main entry for pyloco command-line interface from .matplot import MatPlot as entry_task from pyloco.main import perform if __name__ == "__main__": import sys import multiprocessing multiprocessing.freeze_support() if "--" in sys.argv: idx = sys.argv.index("--") perform(entry_task, sys.argv[1:idx], sys.argv[idx + 1:]) else: perform(entry_task, sys.argv[1:])
def perform(cls, *vargs, **kwargs): from pyloco.main import perform kwargs["manager"] = cls return perform(*vargs, **kwargs)