Ejemplo n.º 1
0
def pull(dry_run, flavor, interactive, debug):
    """ Pull down tasks from forges and add them to your taskwarrior tasks.

    Relies on configuration in bugwarriorrc
    """

    try:
        main_section = _get_section_name(flavor)
        config = _try_load_config(main_section, interactive)

        lockfile_path = os.path.join(get_data_path(config, main_section),
                                     'bugwarrior.lockfile')
        lockfile = PIDLockFile(lockfile_path)
        lockfile.acquire(timeout=10)
        try:
            # Get all the issues.  This can take a while.
            issue_generator = aggregate_issues(config, main_section, debug)

            # Stuff them in the taskwarrior db as necessary
            synchronize(issue_generator, config, main_section, dry_run)
        finally:
            lockfile.release()
    except LockTimeout:
        log.critical(
            'Your taskrc repository is currently locked. '
            'Remove the file at %s if you are sure no other '
            'bugwarrior processes are currently running.' % (
                lockfile_path
            )
        )
    except RuntimeError as e:
        log.critical("Aborted (%s)" % e)
Ejemplo n.º 2
0
def pull(dry_run, flavor, interactive, debug):
    """ Pull down tasks from forges and add them to your taskwarrior tasks.

    Relies on configuration in bugwarriorrc
    """

    try:
        main_section = _get_section_name(flavor)
        config = _try_load_config(main_section, interactive)

        lockfile_path = os.path.join(get_data_path(config, main_section),
                                     'bugwarrior.lockfile')
        lockfile = PIDLockFile(lockfile_path)
        lockfile.acquire(timeout=10)
        try:
            # Get all the issues.  This can take a while.
            issue_generator = aggregate_issues(config, main_section, debug)

            # Stuff them in the taskwarrior db as necessary
            synchronize(issue_generator, config, main_section, dry_run)
        finally:
            lockfile.release()
    except LockTimeout:
        log.critical('Your taskrc repository is currently locked. '
                     'Remove the file at %s if you are sure no other '
                     'bugwarrior processes are currently running.' %
                     (lockfile_path))
    except RuntimeError as e:
        log.exception("Aborted (%s)" % e)
Ejemplo n.º 3
0
 def assertDataPath(self, expected_datapath):
     self.assertEqual(
         expected_datapath, config.get_data_path(self.config, 'general'))
Ejemplo n.º 4
0
 def assertDataPath(self, expected_datapath):
     self.assertEqual(expected_datapath,
                      config.get_data_path(self.config, 'general'))
Ejemplo n.º 5
0
import os
import json

from lockfile.pidlockfile import PIDLockFile

from bugwarrior.config import get_data_path

DATAFILE = os.path.join(get_data_path(), 'bugwarrior.data')
LOCKFILE = os.path.join(get_data_path(), 'bugwarrior-data.lockfile')


def get(key):
    try:
        with open(DATAFILE, 'r') as jsondata:
            try:
                data = json.load(jsondata)
            except ValueError:  # File does not contain JSON.
                return None
            else:
                return data[key]
    except IOError:  # File does not exist.
        return None


def set(key, value):
    with PIDLockFile(LOCKFILE):
        try:
            with open(DATAFILE, 'r+') as jsondata:
                data = json.load(jsondata)
                data[key] = value
                json.dump(data, jsondata)
Ejemplo n.º 6
0
import os
import json

from lockfile.pidlockfile import PIDLockFile

from bugwarrior.config import get_data_path


DATAFILE = os.path.join(get_data_path(), 'bugwarrior.data')
LOCKFILE = os.path.join(get_data_path(), 'bugwarrior-data.lockfile')


def get(key):
    try:
        with open(DATAFILE, 'r') as jsondata:
            try:
                data = json.load(jsondata)
            except ValueError:  # File does not contain JSON.
                return None
            else:
                return data[key]
    except IOError:  # File does not exist.
        return None


def set(key, value):
    with PIDLockFile(LOCKFILE):
        try:
            with open(DATAFILE, 'r+') as jsondata:
                data = json.load(jsondata)
                data[key] = value