How to use the aj.plugins.core.api.tasks.Task function in aj

To help you get started, we’ve selected a few aj examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ajenti / ajenti / plugins / filesystem / tasks.py View on Github external
'mv', item['item']['path'], '-t', self.destination
                ])
                if r != 0:
                    logging.warn('mv exited with code %i', r)
            if item['mode'] == 'copy':
                logging.info('Copying %s', item['item']['path'])
                r = subprocess.call([
                    'cp', '-a', item['item']['path'], '-t', self.destination
                ])
                if r != 0:
                    logging.warn('cp exited with code %i', r)

        self.push('filesystem', 'refresh')


class Delete(Task):
    name = _('Deleting')

    def __init__(self, context, items=None):
        Task.__init__(self, context)
        self.items = items

    def run(self):
        logging.info('Deleting %s items', len(self.items))

        for idx, item in enumerate(self.items):
            self.report_progress(message=item['name'], done=idx, total=len(self.items))
            logging.info('Deleting %s', item['path'])
            r = subprocess.call([
                'rm', '-r', '-f', item['path'],
            ])
            if r != 0:
github ajenti / ajenti / plugins / filesystem / tasks.py View on Github external
def __init__(self, context, items=None):
        Task.__init__(self, context)
        self.items = items
github ajenti / ajenti / plugins / packages / tasks.py View on Github external
def __init__(self, context, manager_id=None):
        Task.__init__(self, context)
        for mgr in PackageManager.all(self.context):
            if mgr.id == manager_id:
                self.manager = mgr
                break
        else:
            logging.error('Package manager %s not found', manager_id)
github ajenti / ajenti / plugins / filesystem / tasks.py View on Github external
import logging
import subprocess

from aj.plugins.core.api.tasks import Task


class Transfer(Task):
    name = _('File transfer')

    def __init__(self, context, destination=None, items=None):
        Task.__init__(self, context)
        self.destination = destination
        self.items = items

    def run(self):
        logging.info('Transferring %s items into %s', len(self.items), self.destination)
        self.destination = self.destination.rstrip('/') + '/'

        for idx, item in enumerate(self.items):
            self.report_progress(message=item['item']['name'], done=idx, total=len(self.items))
            if item['mode'] == 'move':
                logging.info('Moving %s', item['item']['path'])
                r = subprocess.call([
github ajenti / ajenti / plugins / filesystem / tasks.py View on Github external
def __init__(self, context, destination=None, items=None):
        Task.__init__(self, context)
        self.destination = destination
        self.items = items
github ajenti / ajenti / plugins / plugins / tasks.py View on Github external
from aj.plugins.core.api.tasks import Task


class InstallPlugin (Task):
    name = 'Installing plugin'

    def __init__(self, context, name=None, version=None):
        Task.__init__(self, context)
        self.spec = 'ajenti.plugin.%s==%s' % (name, version)

    def run(self):
        subprocess.check_output(['pip', 'install', self.spec])


class UpgradeAll (Task):
    name = 'Upgrading Ajenti'

    def run(self):
        try:
            subprocess.check_output(['ajenti-upgrade'])
        except:
            subprocess.check_output(['/usr/local/bin/ajenti-upgrade'])
github ajenti / ajenti / plugins / plugins / tasks.py View on Github external
import subprocess

from aj.plugins.core.api.tasks import Task


class InstallPlugin (Task):
    name = 'Installing plugin'

    def __init__(self, context, name=None, version=None):
        Task.__init__(self, context)
        self.spec = 'ajenti.plugin.%s==%s' % (name, version)

    def run(self):
        subprocess.check_output(['pip', 'install', self.spec])


class UpgradeAll (Task):
    name = 'Upgrading Ajenti'

    def run(self):
        try:
            subprocess.check_output(['ajenti-upgrade'])
github ajenti / ajenti / plugins / packages / tasks.py View on Github external
import logging

from aj.plugins.core.api.tasks import Task
from aj.plugins.packages.api import PackageManager


class UpdateLists(Task):
    name = 'Update package lists'

    def __init__(self, context, manager_id=None):
        Task.__init__(self, context)
        for mgr in PackageManager.all(self.context):
            if mgr.id == manager_id:
                self.manager = mgr
                break
        else:
            logging.error('Package manager %s not found', manager_id)

    def run(self):
        self.manager.update_lists(self.report_progress)
        self.push('packages', 'refresh')
github ajenti / ajenti / plugins / plugins / tasks.py View on Github external
def __init__(self, context, name=None, version=None):
        Task.__init__(self, context)
        self.spec = 'ajenti.plugin.%s==%s' % (name, version)